From d18e92af80ec3e6b4d099885aa068bfc1794ba09 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 18 Aug 2022 22:19:04 -0700 Subject: [PATCH] tests: functional: Add install/uninstall test for all apps Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/tests/functional/__init__.py | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/plinth/tests/functional/__init__.py b/plinth/tests/functional/__init__.py index 49f8ddf6e..5760617f2 100644 --- a/plinth/tests/functional/__init__.py +++ b/plinth/tests/functional/__init__.py @@ -364,6 +364,34 @@ def install(browser, app_name): break +def uninstall(browser, app_name): + """Uninstall the app if possible.""" + nav_to_module(browser, app_name) + actions_button = browser.find_by_id('id_extra_actions_button') + if not actions_button: + pytest.skip('App cannot be uninstalled') + + actions_button.click() + uninstall_item = browser.find_by_css('.uninstall-item') + if not uninstall_item: + pytest.skip('App cannot be uninstalled') + + uninstall_item[0].click() + submit(browser, form_class='form-uninstall') + + while True: + script = 'return (document.readyState == "complete") && ' \ + '(!Boolean(document.querySelector(".app-operation")));' + if not browser.execute_script(script): + time.sleep(0.1) + elif browser.is_element_present_by_css('.neterror'): + browser.visit(browser.url) + elif browser.is_element_present_by_css('.alert-danger'): + raise RuntimeError('Uninstall failed') + else: + break + + ################################ # App enable/disable utilities # ################################ @@ -678,3 +706,8 @@ class BaseAppTests: backup_create(session_browser, self.app_name, 'test_' + self.app_name) backup_restore(session_browser, self.app_name, 'test_' + self.app_name) self.assert_app_running(session_browser) + + def test_uninstall(self, session_browser): + """Test that app can be uninstalled and installed back again.""" + uninstall(session_browser, self.app_name) + install(session_browser, self.app_name)