2021-09-02 16:01:34 +02:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
# lint: pylint
|
|
|
|
# pylint: disable=missing-module-docstring,missing-function-docstring
|
|
|
|
|
|
|
|
from time import sleep
|
|
|
|
|
|
|
|
url = "http://localhost:11111/"
|
|
|
|
|
|
|
|
|
|
|
|
def test_index(browser):
|
|
|
|
# Visit URL
|
|
|
|
browser.visit(url)
|
2022-04-30 08:01:53 +02:00
|
|
|
assert browser.is_text_present('searxng')
|
2021-09-02 16:01:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_404(browser):
|
|
|
|
# Visit URL
|
|
|
|
browser.visit(url + 'missing_link')
|
|
|
|
assert browser.is_text_present('Page not found')
|
|
|
|
|
|
|
|
|
|
|
|
def test_about(browser):
|
|
|
|
browser.visit(url)
|
2022-06-17 09:19:07 +02:00
|
|
|
browser.links.find_by_text('searxng').click()
|
2021-09-02 16:01:34 +02:00
|
|
|
assert browser.is_text_present('Why use it?')
|
|
|
|
|
|
|
|
|
|
|
|
def test_preferences(browser):
|
|
|
|
browser.visit(url)
|
2022-06-17 09:19:07 +02:00
|
|
|
browser.links.find_by_href('/preferences').click()
|
2021-09-02 16:01:34 +02:00
|
|
|
assert browser.is_text_present('Preferences')
|
2022-04-30 08:01:53 +02:00
|
|
|
assert browser.is_text_present('COOKIES')
|
2021-09-02 16:01:34 +02:00
|
|
|
|
|
|
|
assert browser.is_element_present_by_xpath('//label[@for="checkbox_dummy"]')
|
|
|
|
|
|
|
|
|
|
|
|
def test_preferences_engine_select(browser):
|
|
|
|
browser.visit(url)
|
2022-06-17 09:19:07 +02:00
|
|
|
browser.links.find_by_href('/preferences').click()
|
2021-09-02 16:01:34 +02:00
|
|
|
|
2022-04-30 08:01:53 +02:00
|
|
|
assert browser.is_element_present_by_xpath('//label[@for="tab-engines"]')
|
|
|
|
browser.find_by_xpath('//label[@for="tab-engines"]').first.click()
|
2021-09-02 16:01:34 +02:00
|
|
|
|
|
|
|
assert not browser.find_by_xpath('//input[@id="engine_general_dummy__general"]').first.checked
|
|
|
|
browser.find_by_xpath('//label[@for="engine_general_dummy__general"]').first.check()
|
2022-04-30 08:01:53 +02:00
|
|
|
browser.find_by_xpath('//input[@type="submit"]').first.click()
|
2021-09-02 16:01:34 +02:00
|
|
|
|
|
|
|
# waiting for the redirect - without this the test is flaky..
|
|
|
|
sleep(1)
|
|
|
|
|
|
|
|
browser.visit(url)
|
2022-06-17 09:19:07 +02:00
|
|
|
browser.links.find_by_href('/preferences').click()
|
2022-04-30 08:01:53 +02:00
|
|
|
browser.find_by_xpath('//label[@for="tab-engines"]').first.click()
|
2021-09-02 16:01:34 +02:00
|
|
|
|
|
|
|
assert browser.find_by_xpath('//input[@id="engine_general_dummy__general"]').first.checked
|
|
|
|
|
|
|
|
|
|
|
|
def test_preferences_locale(browser):
|
|
|
|
browser.visit(url)
|
2022-06-17 09:19:07 +02:00
|
|
|
browser.links.find_by_href('/preferences').click()
|
2021-09-02 16:01:34 +02:00
|
|
|
|
2022-04-30 08:01:53 +02:00
|
|
|
browser.find_by_xpath('//label[@for="tab-ui"]').first.click()
|
|
|
|
browser.select('locale', 'fr')
|
|
|
|
browser.find_by_xpath('//input[@type="submit"]').first.click()
|
2021-09-02 16:01:34 +02:00
|
|
|
|
|
|
|
# waiting for the redirect - without this the test is flaky..
|
|
|
|
sleep(1)
|
|
|
|
|
|
|
|
browser.visit(url)
|
2022-06-17 09:19:07 +02:00
|
|
|
browser.links.find_by_href('/preferences').click()
|
2022-04-30 08:01:53 +02:00
|
|
|
browser.is_text_present('Préférences')
|
2021-09-02 16:01:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_search(browser):
|
|
|
|
browser.visit(url)
|
|
|
|
browser.fill('q', 'test search query')
|
|
|
|
browser.find_by_xpath('//button[@type="submit"]').first.click()
|
|
|
|
assert browser.is_text_present('didn\'t find any results')
|