-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
14 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
class StaffLiveTests(LiveServerTest): | ||
def test_changes_form_data(self): | ||
"""Regression test for #1769""" | ||
manager = make_manager() | ||
responsible = baker.make(UserProfile) | ||
editor = baker.make(UserProfile) | ||
|
@@ -36,16 +37,16 @@ def test_changes_form_data(self): | |
evaluation=evaluation, | ||
contributor=responsible, | ||
order=0, | ||
role=Contribution.Role.EDITOR, | ||
textanswer_visibility=Contribution.TextAnswerVisibility.GENERAL_TEXTANSWERS, | ||
role=Contribution.Role.CONTRIBUTOR, | ||
textanswer_visibility=Contribution.TextAnswerVisibility.OWN_TEXTANSWERS, | ||
) | ||
contribution2 = baker.make( | ||
Contribution, | ||
evaluation=evaluation, | ||
contributor=editor, | ||
order=1, | ||
role=Contribution.Role.EDITOR, | ||
) | ||
) # contribution without interaction | ||
contribution1.questionnaires.set([contributor_questionnaire]) | ||
contribution2.questionnaires.set([contributor_questionnaire]) | ||
|
||
|
@@ -55,34 +56,20 @@ def test_changes_form_data(self): | |
|
||
self.selenium.get(self.live_server_url + reverse("staff:evaluation_edit", args=[evaluation.pk])) | ||
|
||
self.wait.until( | ||
expected_conditions.visibility_of_element_located((By.XPATH, "//label[contains(text(), 'Editor')]")) | ||
) | ||
|
||
manager_id = self.selenium.execute_script( | ||
""" | ||
const tomselect = document.getElementById("id_contributions-0-contributor").tomselect; | ||
const options = tomselect.options; | ||
const managerOption = Object.keys(options).find( | ||
key => options[key].text == "manager ([email protected])", | ||
); | ||
tomselect.setValue(managerOption); | ||
return managerOption; | ||
""" | ||
submit_btn = self.wait.until( | ||
expected_conditions.element_to_be_clickable((By.XPATH, "//button[@name='operation' and @value='save']")) | ||
) | ||
|
||
editor_labels = self.selenium.find_elements(By.XPATH, "//label[contains(text(), 'Editor')]") | ||
own_and_general_labels = self.selenium.find_elements(By.XPATH, "//label[contains(text(), 'Own and general')]") | ||
|
||
editor_labels[0].click() | ||
own_and_general_labels[0].click() | ||
|
||
form_data = self.selenium.execute_script( | ||
""" | ||
return Object.fromEntries(new FormData(document.getElementById("evaluation-form"))); | ||
""" | ||
) | ||
self.assertEqual(form_data["contributions-0-contributor"], manager_id) | ||
self.assertEqual(form_data["contributions-0-order"], "0") | ||
self.assertEqual(form_data["contributions-0-role"], "1") | ||
self.assertEqual(form_data["contributions-0-textanswer_visibility"], "GENERAL") | ||
submit_btn.click() | ||
|
||
contribution1.refresh_from_db() | ||
|
||
self.assertEqual(contribution1.contributor_id, responsible.id) | ||
self.assertEqual(contribution1.order, 0) | ||
self.assertEqual(contribution1.role, Contribution.Role.EDITOR) | ||
self.assertEqual(contribution1.textanswer_visibility, Contribution.TextAnswerVisibility.GENERAL_TEXTANSWERS) |