From a94ebc567d10a126adfb73d38685e22fbfcef917 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sun, 29 Jan 2023 11:16:26 -0800 Subject: [PATCH] tests: functional: Fix submitting forms with notifications present Closes: #2194. In the four cases fixed, if a notification is present with a 'btn-primary' in it, then instead of submitting the intended form, the button on the notification is clicked. This will result in an indefinite wait for the form to perform an action. Fix this by specifying which form exactly we want to submit. Tests: - Run functional tests for config app and updates app. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/config/tests/test_functional.py | 4 ++-- plinth/modules/upgrades/tests/test_functional.py | 4 ++-- plinth/tests/functional/__init__.py | 9 +++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/plinth/modules/config/tests/test_functional.py b/plinth/modules/config/tests/test_functional.py index 0b3ee1a37..aabebdf2b 100644 --- a/plinth/modules/config/tests/test_functional.py +++ b/plinth/modules/config/tests/test_functional.py @@ -4,6 +4,7 @@ Functional, browser based tests for config app. """ import pytest + from plinth.tests import functional pytestmark = [ @@ -61,8 +62,7 @@ def _set_home_page(browser, home_page): functional.nav_to_module(browser, 'config') drop_down = browser.find_by_id('id_homepage') drop_down.select(home_page) - update_setup = browser.find_by_css('.btn-primary') - functional.submit(browser, element=update_setup) + functional.submit(browser, form_class='form-configuration') def _check_home_page_redirect(browser, app_name): diff --git a/plinth/modules/upgrades/tests/test_functional.py b/plinth/modules/upgrades/tests/test_functional.py index 61c68cc63..61a64375d 100644 --- a/plinth/modules/upgrades/tests/test_functional.py +++ b/plinth/modules/upgrades/tests/test_functional.py @@ -4,6 +4,7 @@ Functional, browser based tests for upgrades app. """ import pytest + from plinth.tests import functional pytestmark = [pytest.mark.system, pytest.mark.essential, pytest.mark.upgrades] @@ -51,8 +52,7 @@ def _enable_automatic(browser, should_enable): else: checkbox_element.uncheck() - update_setup = browser.find_by_css('.btn-primary') - functional.submit(browser, element=update_setup) + functional.submit(browser, form_class='form-configuration') def _get_automatic(browser): diff --git a/plinth/tests/functional/__init__.py b/plinth/tests/functional/__init__.py index 508c4980d..002132d26 100644 --- a/plinth/tests/functional/__init__.py +++ b/plinth/tests/functional/__init__.py @@ -441,8 +441,7 @@ def app_can_be_disabled(browser, app_name): def set_domain_name(browser, domain_name): nav_to_module(browser, 'config') browser.find_by_id('id_domainname').fill(domain_name) - update_setup = browser.find_by_css('.btn-primary[type="submit"]') - submit(browser, element=update_setup) + submit(browser, form_class='form-configuration') ######################## @@ -493,8 +492,7 @@ def running_inside_container(): def set_hostname(browser, hostname): nav_to_module(browser, 'config') browser.find_by_id('id_hostname').fill(hostname) - update_setup = browser.find_by_css('.btn-primary') - submit(browser, element=update_setup) + submit(browser, form_class='form-configuration') def set_advanced_mode(browser, mode): @@ -505,8 +503,7 @@ def set_advanced_mode(browser, mode): else: advanced_mode.uncheck() - update_setup = browser.find_by_css('.btn-primary') - submit(browser, element=update_setup) + submit(browser, form_class='form-configuration') ####################