Skip to content
Snippets Groups Projects
Commit 9e2db1b2 authored by robinwilliam.hundt's avatar robinwilliam.hundt
Browse files

Increased timeouts for frontend tests

parent 19d8ed4d
No related branches found
No related tags found
No related merge requests found
Pipeline #90682 failed
This commit is part of merge request !145. Comments created here will be created in the context of that merge request.
...@@ -45,7 +45,7 @@ class TestAutoLogout(LiveServerTestCase): ...@@ -45,7 +45,7 @@ class TestAutoLogout(LiveServerTestCase):
def test_auto_logout_can_continue(self): def test_auto_logout_can_continue(self):
with self.settings(JWT_AUTH={ with self.settings(JWT_AUTH={
'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=5), 'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=15),
'JWT_ALLOW_REFRESH': True, 'JWT_ALLOW_REFRESH': True,
} }
): ):
...@@ -54,12 +54,11 @@ class TestAutoLogout(LiveServerTestCase): ...@@ -54,12 +54,11 @@ class TestAutoLogout(LiveServerTestCase):
'return sessionStorage["token"]' 'return sessionStorage["token"]'
) )
logout_dialog = self.browser.find_element_by_id('logout-dialog') 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'))) ec.visibility_of_element_located((By.ID, 'logout-dialog')))
logout_dialog.find_element_by_id('continue-btn').click() logout_dialog.find_element_by_id('continue-btn').click()
# explicit sleep is unfortunately necessary here, since we need to wait WebDriverWait(self.browser, 10).until(
# for the initial token to expire and the site to be the same ec.invisibility_of_element_located((By.ID, 'logout-dialog')))
time.sleep(2)
self.assertNotIn('login', self.browser.current_url) self.assertNotIn('login', self.browser.current_url)
new_token = self.browser.execute_script( new_token = self.browser.execute_script(
'return sessionStorage["token"]' 'return sessionStorage["token"]'
......
...@@ -47,7 +47,7 @@ class ExportTestModal(LiveServerTestCase): ...@@ -47,7 +47,7 @@ class ExportTestModal(LiveServerTestCase):
fact.SubmissionFactory() fact.SubmissionFactory()
self._login() 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): def test_export_warning_tooltip_uncorrected_submissions(self):
fact.SubmissionFactory() fact.SubmissionFactory()
......
...@@ -55,20 +55,20 @@ class UntestedParent: ...@@ -55,20 +55,20 @@ class UntestedParent:
# stage can be 'initial', 'validate', or 'conflict' # stage can be 'initial', 'validate', or 'conflict'
def _go_to_subscription(self, stage='initial', sub_type=None): def _go_to_subscription(self, stage='initial', sub_type=None):
tasks = self.browser.find_element_by_name('subscription-list') 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 = tasks.find_element_by_xpath(f'//*[contains(text(), "{stage}")]')
tab.click() tab.click()
sub_type = sub_type if sub_type is not None else self.sub_type sub_type = sub_type if sub_type is not None else self.sub_type
sub_type_xpath = f'//*[contains(text(), "{sub_type.name}") ' \ sub_type_xpath = f'//*[contains(text(), "{sub_type.name}") ' \
f'and not(contains(@class, "inactive"))]' 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)), ec.element_to_be_clickable((By.XPATH, sub_type_xpath)),
message="SubmissionType not clickable" message="SubmissionType not clickable"
) )
sub_type_el = tasks.find_element_by_xpath(sub_type_xpath) sub_type_el = tasks.find_element_by_xpath(sub_type_xpath)
sub_type_el.click() 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): def write_comments_on_lines(self, line_comment_tuples):
""" line_comment_tuples is an iterable containing tuples of """ line_comment_tuples is an iterable containing tuples of
...@@ -120,7 +120,7 @@ class UntestedParent: ...@@ -120,7 +120,7 @@ class UntestedParent:
self.assertIn(test.name, name_label.text) self.assertIn(test.name, name_label.text)
self.assertIn(test.label, name_label.text) self.assertIn(test.label, name_label.text)
test_output = tests.find_element_by_name('test-output') 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) self.assertEqual(test.annotation, test_output.text)
def wait_until_code_changes(self, code): def wait_until_code_changes(self, code):
...@@ -140,7 +140,7 @@ class UntestedParent: ...@@ -140,7 +140,7 @@ class UntestedParent:
self.browser.find_element_by_id('score-full').click() self.browser.find_element_by_id('score-full').click()
submit_btn = self.browser.find_element_by_id('submit-feedback') submit_btn = self.browser.find_element_by_id('submit-feedback')
submit_btn.click() submit_btn.click()
WebDriverWait(self.browser, 3).until( WebDriverWait(self.browser, 10).until(
self.wait_until_code_changes(code) self.wait_until_code_changes(code)
) )
submission_for_code = Submission.objects.get(text=code) submission_for_code = Submission.objects.get(text=code)
...@@ -162,7 +162,7 @@ class UntestedParent: ...@@ -162,7 +162,7 @@ class UntestedParent:
self.browser.find_element_by_id('score-zero').click() self.browser.find_element_by_id('score-zero').click()
self.write_comments_on_lines([(0, 'A comment')]) self.write_comments_on_lines([(0, 'A comment')])
self.browser.find_element_by_id('submit-feedback').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))
submission_for_code = Submission.objects.get(text=code) submission_for_code = Submission.objects.get(text=code)
self.assertEqual(0, submission_for_code.feedback.score) self.assertEqual(0, submission_for_code.feedback.score)
...@@ -183,7 +183,7 @@ class UntestedParent: ...@@ -183,7 +183,7 @@ class UntestedParent:
submit_btn = self.browser.find_element_by_id('submit-feedback') submit_btn = self.browser.find_element_by_id('submit-feedback')
submit_btn.click() submit_btn.click()
WebDriverWait(self.browser, 3).until( WebDriverWait(self.browser, 10).until(
self.wait_until_code_changes(code) self.wait_until_code_changes(code)
) )
submission_for_code = Submission.objects.get(text=code) submission_for_code = Submission.objects.get(text=code)
...@@ -206,7 +206,7 @@ class UntestedParent: ...@@ -206,7 +206,7 @@ class UntestedParent:
self._go_to_subscription() self._go_to_subscription()
code = self._reconstruct_submission_code() code = self._reconstruct_submission_code()
self.browser.find_element_by_id('skip-submission').click() 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): def test_can_validate_submission(self):
self._login() self._login()
...@@ -215,7 +215,7 @@ class UntestedParent: ...@@ -215,7 +215,7 @@ class UntestedParent:
self.write_comments_on_lines([(0, 'A comment by me')]) 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('score-zero').click()
self.browser.find_element_by_id('submit-feedback').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 reset_browser_after_test(self.browser, self.live_server_url) # logs out user
user_snd = 'tutor_snd' user_snd = 'tutor_snd'
...@@ -227,7 +227,7 @@ class UntestedParent: ...@@ -227,7 +227,7 @@ class UntestedParent:
self.write_comments_on_lines([(0, 'I disagree'), (1, 'Full points!')]) 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('score-full').click()
self.browser.find_element_by_id('submit-feedback').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) submission_for_code = Submission.objects.get(text=code)
self.assertEqual(self.sub_type.full_score, submission_for_code.feedback.score) self.assertEqual(self.sub_type.full_score, submission_for_code.feedback.score)
self.assertEqual(3, submission_for_code.feedback.feedback_lines.count()) self.assertEqual(3, submission_for_code.feedback.feedback_lines.count())
......
...@@ -50,7 +50,7 @@ class UntestedParent: ...@@ -50,7 +50,7 @@ class UntestedParent:
tasks = self.browser.find_element_by_name('subscription-list') tasks = self.browser.find_element_by_name('subscription-list')
title = tasks.find_element_by_class_name('v-toolbar__title') title = tasks.find_element_by_class_name('v-toolbar__title')
self.assertEqual('Tasks', title.text) 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( subscription_links = extract_hrefs_hashes(
tasks.find_elements_by_tag_name('a') tasks.find_elements_by_tag_name('a')
) )
......
...@@ -102,7 +102,7 @@ class LoginPageTest(LiveServerTestCase): ...@@ -102,7 +102,7 @@ class LoginPageTest(LiveServerTestCase):
password_input = self.browser.find_element_by_xpath('//input[@aria-label="Password"]') password_input = self.browser.find_element_by_xpath('//input[@aria-label="Password"]')
password_input.send_keys('p') password_input.send_keys('p')
self.browser.find_element_by_xpath('//button[@type="submit"]').send_keys(Keys.ENTER) 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): def test_tutor_can_login(self):
tutor = self.test_data['tutors'][0] tutor = self.test_data['tutors'][0]
...@@ -132,7 +132,7 @@ class LoginPageTest(LiveServerTestCase): ...@@ -132,7 +132,7 @@ class LoginPageTest(LiveServerTestCase):
password_input.send_keys(password) password_input.send_keys(password)
register_submit_el = self.browser.find_element_by_id('register-submit') register_submit_el = self.browser.find_element_by_id('register-submit')
register_submit_el.click() 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) tutor = UserAccount.objects.get(username=username)
self.assertEqual(UserAccount.TUTOR, tutor.role) self.assertEqual(UserAccount.TUTOR, tutor.role)
self.assertFalse(tutor.is_active, "Tutors should be inactive after registered") self.assertFalse(tutor.is_active, "Tutors should be inactive after registered")
...@@ -26,7 +26,7 @@ def login(browser, live_server_url, username, password='p'): ...@@ -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 = browser.find_element_by_xpath('//input[@aria-label="Password"]')
password_input.send_keys(password) password_input.send_keys(password)
browser.find_element_by_xpath('//button[@type="submit"]').send_keys(Keys.ENTER) 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): def reset_browser_after_test(browser: webdriver.Firefox, live_server_url):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment