diff --git a/backend/src/openarchiefbeheer/destruction/tests/e2e/issues/test_459_update_reviewer.py b/backend/src/openarchiefbeheer/destruction/tests/e2e/issues/test_459_update_reviewer.py new file mode 100644 index 000000000..a441e6b37 --- /dev/null +++ b/backend/src/openarchiefbeheer/destruction/tests/e2e/issues/test_459_update_reviewer.py @@ -0,0 +1,59 @@ +# fmt: off +from django.test import tag + +from openarchiefbeheer.utils.tests.e2e import browser_page +from openarchiefbeheer.utils.tests.gherkin import GherkinLikeTestCase + +from ....constants import ListStatus + + +@tag("e2e") +@tag("gh-459") +class Issue459UpdateReviewer(GherkinLikeTestCase): + async def test_scenario_record_manager_updates_reviewer(self): + async with browser_page() as page: + record_manger = await self.given.record_manager_exists() + reviewer1 = await self.given.reviewer_exists(username="reviewer1", first_name="John", last_name="Doe") + reviewer2 = await self.given.reviewer_exists(username="reviewer2", first_name="Jane", last_name="Doe") + + await self.given.assignee_exists(user=record_manger) + assignee_reviewer1 = await self.given.assignee_exists(user=reviewer1) + + destruction_list = await self.given.list_exists(name="Destruction list to update", assignees=[assignee_reviewer1], assignee=assignee_reviewer1.user, status=ListStatus.ready_to_review) + + await self.when.record_manager_logs_in(page) + await self.then.path_should_be(page, "/destruction-lists") + await self.then.list_should_have_assignee(page, destruction_list, reviewer1) + + await self.when.user_clicks_button(page, "Destruction list to update") + await self.when.user_clicks_button(page, "Beoordelaar bewerken") + await self.when.user_fills_form_field(page, "Beoordelaar", "Jane Doe (reviewer2)") + await self.when.user_fills_form_field(page, "Reden", "gh-459") + await self.when.user_clicks_button(page, "Toewijzen") + + await self.then.page_should_contain_text(page, "Destruction list to update") + await self.then.list_should_have_assignee(page, destruction_list, reviewer2) + + async def test_scenario_reviewer_updates_reviewer(self): + async with browser_page() as page: + record_manger = await self.given.record_manager_exists() + reviewer1 = await self.given.reviewer_exists(username="reviewer1", first_name="John", last_name="Doe", post__can_start_destruction=True) + reviewer2 = await self.given.reviewer_exists(username="reviewer2", first_name="Jane", last_name="Doe") + + await self.given.assignee_exists(user=record_manger) + assignee_reviewer1 = await self.given.assignee_exists(user=reviewer1) + + destruction_list = await self.given.list_exists(name="Destruction list to update", assignees=[assignee_reviewer1], assignee=assignee_reviewer1.user, status=ListStatus.ready_to_review) + + await self.when.reviewer_logs_in(page, username="reviewer1") + await self.then.path_should_be(page, "/destruction-lists") + await self.then.list_should_have_assignee(page, destruction_list, reviewer1) + + await self.when.user_clicks_button(page, "Destruction list to update") + await self.when.user_clicks_button(page, "Beoordelaar bewerken") + await self.when.user_fills_form_field(page, "Beoordelaar", "Jane Doe (reviewer2)") + await self.when.user_fills_form_field(page, "Reden", "gh-459") + await self.when.user_clicks_button(page, "Toewijzen") + + await self.then.page_should_contain_text(page, "Destruction list to update") + await self.then.list_should_have_assignee(page, destruction_list, reviewer2) diff --git a/backend/src/openarchiefbeheer/utils/tests/gherkin.py b/backend/src/openarchiefbeheer/utils/tests/gherkin.py index d7f0ca774..d74b0d0d5 100644 --- a/backend/src/openarchiefbeheer/utils/tests/gherkin.py +++ b/backend/src/openarchiefbeheer/utils/tests/gherkin.py @@ -319,34 +319,49 @@ async def user_logs_in(self, page, user): await page.get_by_label("Wachtwoord").fill("ANic3Password") await page.get_by_role("button", name="Inloggen").click() - async def record_manager_logs_in(self, page): + async def record_manager_logs_in(self, page, **kwargs): + base_kwargs = { + "username": "Record Manager", + "password": "ANic3Password", + } + merged_kwargs = {**base_kwargs, **kwargs} await page.goto(self.testcase.live_server_url) await page.wait_for_url( f"{self.testcase.live_server_url}/login?next=/destruction-lists" ) - await page.get_by_label("Gebruikersnaam").fill("Record Manager") - await page.get_by_label("Wachtwoord").fill("ANic3Password") + await page.get_by_label("Gebruikersnaam").fill(merged_kwargs["username"]) + await page.get_by_label("Wachtwoord").fill(merged_kwargs["password"]) await page.get_by_role("button", name="Inloggen").click() - async def reviewer_logs_in(self, page): + async def reviewer_logs_in(self, page, **kwargs): + base_kwargs = { + "username": "Beoordelaar", + "password": "ANic3Password", + } + merged_kwargs = {**base_kwargs, **kwargs} await page.goto(self.testcase.live_server_url) await page.wait_for_url( f"{self.testcase.live_server_url}/login?next=/destruction-lists" ) - await page.get_by_label("Gebruikersnaam").fill("Beoordelaar") - await page.get_by_label("Wachtwoord").fill("ANic3Password") + await page.get_by_label("Gebruikersnaam").fill(merged_kwargs["username"]) + await page.get_by_label("Wachtwoord").fill(merged_kwargs["password"]) await page.get_by_role("button", name="Inloggen").click() - async def archivist_logs_in(self, page): + async def archivist_logs_in(self, page, **kwargs): + base_kwargs = { + "username": "Achivaris", + "password": "ANic3Password", + } + merged_kwargs = {**base_kwargs, **kwargs} await page.goto(self.testcase.live_server_url) await page.wait_for_url( f"{self.testcase.live_server_url}/login?next=/destruction-lists" ) - await page.get_by_label("Gebruikersnaam").fill("Achivaris") - await page.get_by_label("Wachtwoord").fill("ANic3Password") + await page.get_by_label("Gebruikersnaam").fill(merged_kwargs["username"]) + await page.get_by_label("Wachtwoord").fill(merged_kwargs["password"]) await page.get_by_role("button", name="Inloggen").click() async def user_clicks_button(self, page, name, index=0):