From 378648a96cf3008edea6b24d560064eec6e86c97 Mon Sep 17 00:00:00 2001 From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de> Date: Thu, 21 Feb 2019 17:13:03 +0100 Subject: [PATCH] Increased timeouts for frontend tests --- functional_tests/test_auto_logout.py | 10 ++++------ functional_tests/test_export_modal.py | 2 +- functional_tests/test_feedback_creation.py | 20 ++++++++++---------- functional_tests/test_front_pages.py | 2 +- functional_tests/test_login_page.py | 4 ++-- functional_tests/util.py | 2 +- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/functional_tests/test_auto_logout.py b/functional_tests/test_auto_logout.py index ecdfa41f..ec268c73 100644 --- a/functional_tests/test_auto_logout.py +++ b/functional_tests/test_auto_logout.py @@ -1,5 +1,4 @@ import datetime -import time import logging from django.test import LiveServerTestCase from selenium import webdriver @@ -45,7 +44,7 @@ class TestAutoLogout(LiveServerTestCase): def test_auto_logout_can_continue(self): with self.settings(JWT_AUTH={ - 'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=5), + 'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=15), 'JWT_ALLOW_REFRESH': True, } ): @@ -54,12 +53,11 @@ class TestAutoLogout(LiveServerTestCase): 'return sessionStorage["token"]' ) logout_dialog = self.browser.find_element_by_id('logout-dialog') - WebDriverWait(self.browser, 5).until( + WebDriverWait(self.browser, 15).until( ec.visibility_of_element_located((By.ID, 'logout-dialog'))) logout_dialog.find_element_by_id('continue-btn').click() - # explicit sleep is unfortunately necessary here, since we need to wait - # for the initial token to expire and the site to be the same - time.sleep(2) + WebDriverWait(self.browser, 10).until( + ec.invisibility_of_element_located((By.ID, 'logout-dialog'))) self.assertNotIn('login', self.browser.current_url) new_token = self.browser.execute_script( 'return sessionStorage["token"]' diff --git a/functional_tests/test_export_modal.py b/functional_tests/test_export_modal.py index fbc3b130..5c4da4fe 100644 --- a/functional_tests/test_export_modal.py +++ b/functional_tests/test_export_modal.py @@ -47,7 +47,7 @@ class ExportTestModal(LiveServerTestCase): fact.SubmissionFactory() self._login() - WebDriverWait(self.browser, 3).until(export_btn_is_red) + WebDriverWait(self.browser, 10).until(export_btn_is_red) def test_export_warning_tooltip_uncorrected_submissions(self): fact.SubmissionFactory() diff --git a/functional_tests/test_feedback_creation.py b/functional_tests/test_feedback_creation.py index 74486392..f34e2e5f 100644 --- a/functional_tests/test_feedback_creation.py +++ b/functional_tests/test_feedback_creation.py @@ -55,20 +55,20 @@ class UntestedParent: # stage can be 'initial', 'validate', or 'conflict' def _go_to_subscription(self, stage='initial', sub_type=None): tasks = self.browser.find_element_by_name('subscription-list') - WebDriverWait(self.browser, 3).until(subscriptions_loaded_cond(tasks)) + WebDriverWait(self.browser, 10).until(subscriptions_loaded_cond(tasks)) tab = tasks.find_element_by_xpath(f'//*[contains(text(), "{stage}")]') tab.click() sub_type = sub_type if sub_type is not None else self.sub_type sub_type_xpath = f'//*[contains(text(), "{sub_type.name}") ' \ f'and not(contains(@class, "inactive"))]' - WebDriverWait(self.browser, 3).until( + WebDriverWait(self.browser, 10).until( ec.element_to_be_clickable((By.XPATH, sub_type_xpath)), message="SubmissionType not clickable" ) sub_type_el = tasks.find_element_by_xpath(sub_type_xpath) sub_type_el.click() - WebDriverWait(self.browser, 3).until(ec.url_contains('subscription')) + WebDriverWait(self.browser, 10).until(ec.url_contains('subscription')) def write_comments_on_lines(self, line_comment_tuples): """ line_comment_tuples is an iterable containing tuples of @@ -120,7 +120,7 @@ class UntestedParent: self.assertIn(test.name, name_label.text) self.assertIn(test.label, name_label.text) test_output = tests.find_element_by_name('test-output') - WebDriverWait(self.browser, 3).until(ec.visibility_of(test_output)) + WebDriverWait(self.browser, 10).until(ec.visibility_of(test_output)) self.assertEqual(test.annotation, test_output.text) def wait_until_code_changes(self, code): @@ -140,7 +140,7 @@ class UntestedParent: self.browser.find_element_by_id('score-full').click() submit_btn = self.browser.find_element_by_id('submit-feedback') submit_btn.click() - WebDriverWait(self.browser, 3).until( + WebDriverWait(self.browser, 10).until( self.wait_until_code_changes(code) ) submission_for_code = Submission.objects.get(text=code) @@ -162,7 +162,7 @@ class UntestedParent: self.browser.find_element_by_id('score-zero').click() self.write_comments_on_lines([(0, 'A comment')]) self.browser.find_element_by_id('submit-feedback').click() - WebDriverWait(self.browser, 3).until(self.wait_until_code_changes(code)) + WebDriverWait(self.browser, 10).until(self.wait_until_code_changes(code)) submission_for_code = Submission.objects.get(text=code) self.assertEqual(0, submission_for_code.feedback.score) @@ -183,7 +183,7 @@ class UntestedParent: submit_btn = self.browser.find_element_by_id('submit-feedback') submit_btn.click() - WebDriverWait(self.browser, 3).until( + WebDriverWait(self.browser, 10).until( self.wait_until_code_changes(code) ) submission_for_code = Submission.objects.get(text=code) @@ -206,7 +206,7 @@ class UntestedParent: self._go_to_subscription() code = self._reconstruct_submission_code() self.browser.find_element_by_id('skip-submission').click() - WebDriverWait(self.browser, 3).until(self.wait_until_code_changes(code)) + WebDriverWait(self.browser, 10).until(self.wait_until_code_changes(code)) def test_can_validate_submission(self): self._login() @@ -215,7 +215,7 @@ class UntestedParent: self.write_comments_on_lines([(0, 'A comment by me')]) self.browser.find_element_by_id('score-zero').click() self.browser.find_element_by_id('submit-feedback').click() - WebDriverWait(self.browser, 3).until(self.wait_until_code_changes(code)) + WebDriverWait(self.browser, 10).until(self.wait_until_code_changes(code)) reset_browser_after_test(self.browser, self.live_server_url) # logs out user user_snd = 'tutor_snd' @@ -227,7 +227,7 @@ class UntestedParent: self.write_comments_on_lines([(0, 'I disagree'), (1, 'Full points!')]) self.browser.find_element_by_id('score-full').click() self.browser.find_element_by_id('submit-feedback').click() - WebDriverWait(self.browser, 5).until(ec.url_contains('subscription/ended')) + WebDriverWait(self.browser, 10).until(ec.url_contains('subscription/ended')) submission_for_code = Submission.objects.get(text=code) self.assertEqual(self.sub_type.full_score, submission_for_code.feedback.score) self.assertEqual(3, submission_for_code.feedback.feedback_lines.count()) diff --git a/functional_tests/test_front_pages.py b/functional_tests/test_front_pages.py index ff2254a4..c24400e2 100644 --- a/functional_tests/test_front_pages.py +++ b/functional_tests/test_front_pages.py @@ -50,7 +50,7 @@ class UntestedParent: tasks = self.browser.find_element_by_name('subscription-list') title = tasks.find_element_by_class_name('v-toolbar__title') self.assertEqual('Tasks', title.text) - WebDriverWait(self.browser, 6).until(subscriptions_loaded_cond(tasks)) + WebDriverWait(self.browser, 10).until(subscriptions_loaded_cond(tasks)) subscription_links = extract_hrefs_hashes( tasks.find_elements_by_tag_name('a') ) diff --git a/functional_tests/test_login_page.py b/functional_tests/test_login_page.py index 23d5fb5d..ede4aee7 100644 --- a/functional_tests/test_login_page.py +++ b/functional_tests/test_login_page.py @@ -102,7 +102,7 @@ class LoginPageTest(LiveServerTestCase): password_input = self.browser.find_element_by_xpath('//input[@aria-label="Password"]') password_input.send_keys('p') self.browser.find_element_by_xpath('//button[@type="submit"]').send_keys(Keys.ENTER) - WebDriverWait(self.browser, 3).until(ec.url_contains('/home')) + WebDriverWait(self.browser, 10).until(ec.url_contains('/home')) def test_tutor_can_login(self): tutor = self.test_data['tutors'][0] @@ -132,7 +132,7 @@ class LoginPageTest(LiveServerTestCase): password_input.send_keys(password) register_submit_el = self.browser.find_element_by_id('register-submit') register_submit_el.click() - WebDriverWait(self.browser, 3).until_not(ec.visibility_of(register_submit_el)) + WebDriverWait(self.browser, 10).until_not(ec.visibility_of(register_submit_el)) tutor = UserAccount.objects.get(username=username) self.assertEqual(UserAccount.TUTOR, tutor.role) self.assertFalse(tutor.is_active, "Tutors should be inactive after registered") diff --git a/functional_tests/util.py b/functional_tests/util.py index d6ca5434..7a45ec5a 100644 --- a/functional_tests/util.py +++ b/functional_tests/util.py @@ -26,7 +26,7 @@ def login(browser, live_server_url, username, password='p'): password_input = browser.find_element_by_xpath('//input[@aria-label="Password"]') password_input.send_keys(password) browser.find_element_by_xpath('//button[@type="submit"]').send_keys(Keys.ENTER) - WebDriverWait(browser, 3).until(ec.url_contains('/home')) + WebDriverWait(browser, 10).until(ec.url_contains('/home')) def reset_browser_after_test(browser: webdriver.Firefox, live_server_url): -- GitLab