Skip to content

Commit

Permalink
#459 - test: add test proving issue #459 (reassigning broken on rev…
Browse files Browse the repository at this point in the history
…iew page)
  • Loading branch information
svenvandescheur committed Oct 25, 2024
1 parent dec3a0d commit 832f7c7
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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")
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)

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.page_should_contain_text(page, "John Doe") # Should be assignee

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.when.user_clicks_button(page, "Home")

await self.then.path_should_be(page, "/destruction-lists/")
await self.then.page_should_contain_text(page, "Jane Doe") # Should be assignee

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")
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)

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.page_should_contain_text(page, "John Doe") # Should be assignee

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.when.user_clicks_button(page, "Home")

await self.then.path_should_be(page, "/destruction-lists/")
await self.then.page_should_contain_text(page, "Jane Doe") # Should be assignee
33 changes: 24 additions & 9 deletions backend/src/openarchiefbeheer/utils/tests/gherkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 832f7c7

Please sign in to comment.