Skip to content

Commit

Permalink
#556 - test: add additional end-to-end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed Jan 3, 2025
1 parent b6c5ed0 commit e052720
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,37 @@

@tag("e2e")
class FeatureCoReviewTests(GherkinLikeTestCase):
async def test_assign_co_reviewers(self):
async with browser_page() as page:
reviewer = await self.given.reviewer_exists()
co_reviewer1 = await self.given.co_reviewer_exists(username="co-reviewer1", first_name="Co", last_name="Reviewer")
co_reviewer2 = await self.given.co_reviewer_exists(username="co-reviewer2", first_name="Cor", last_name="Eviewer")

destruction_list = await self.given.list_exists(
assignee=reviewer,
uuid="00000000-0000-0000-0000-000000000000",
name="Destruction list to assign co-reviewers for",
status=ListStatus.ready_to_review,
)

await self.when.reviewer_logs_in(page)
await self.when.user_clicks_button(page, "Destruction list to assign co-reviewers for")
await self.when.user_clicks_button(page, "Beoordelaar bewerken")

await self.when.user_fills_form_field(page, "Medebeoordelaar 1", "Co Reviewer (co-reviewer1)")
await self.when.user_fills_form_field(page, "Medebeoordelaar 2", "Cor Eviewer (co-reviewer2)")
await self.when.user_fills_form_field(page, "Reden", "gh-448")
await self.when.user_clicks_button(page, "Toewijzen")

await self.then.not_.page_should_contain_text(page, "Beoordelaar toewijzen")
await self.then.page_should_contain_text(page, "Co Reviewer (co-reviewer1)")
await self.then.page_should_contain_text(page, "Cor Eviewer (co-reviewer2)")

await self.then.list_should_have_assignee(page, destruction_list, reviewer)
await self.then.list_should_have_user_in_assignees(page, destruction_list, reviewer)
await self.then.list_should_have_user_in_assignees(page, destruction_list, co_reviewer1)
await self.then.list_should_have_user_in_assignees(page, destruction_list, co_reviewer2)

async def test_scenario_co_reviewer_select_zaken_visible_to_reviewer(self):
async with browser_page() as page:
reviewer = await self.given.reviewer_exists()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# fmt: off
from asyncio import sleep

from django.test import tag

from openarchiefbeheer.destruction.constants import ListStatus
from openarchiefbeheer.utils.tests.e2e import browser_page
from openarchiefbeheer.utils.tests.gherkin import GherkinLikeTestCase


@tag("e2e")
class FeatureListAbortTests(GherkinLikeTestCase):
async def test_scenario_user_aborts_process(self):
async with browser_page() as page:
record_manger = await self.given.record_manager_exists()
await self.given.assignee_exists(user=record_manger)
await self.given.archivist_exists()
destruction_list = await self.given.list_exists(
name="Destruction list to abort",
status=ListStatus.internally_reviewed,
uuid="00000000-0000-0000-0000-000000000000",)

await self.when.record_manager_logs_in(page)
await self.then.path_should_be(page, "/destruction-lists")

await self.when.user_clicks_button(page, "Destruction list to abort")
await self.when.user_clicks_button(page, "Proces afbreken")
await self.when.user_fills_form_field(page, "Opmerking", "gh-501")
await self.when.user_clicks_button(page, "Proces afbreken", 1)

await self.then.path_should_be(page, "/destruction-lists/00000000-0000-0000-0000-000000000000/edit")
await sleep(1) # arefresh_from_db seems not bo be working here.
await self.then.list_should_have_status(page, destruction_list, ListStatus.new)
7 changes: 7 additions & 0 deletions backend/src/openarchiefbeheer/utils/tests/gherkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,13 @@ def get_assignee():
list_assignee = await get_assignee()
self.testcase.assertEqual(list_assignee, assignee)

async def list_should_have_user_in_assignees(
self, page, destruction_list, assignee
):
await destruction_list.arefresh_from_db()
list_assignee = destruction_list.assignees.aget(pk=assignee.pk)
self.testcase.assertTrue(list_assignee)

async def list_should_have_status(self, page, destruction_list, status):
await destruction_list.arefresh_from_db()
self.testcase.assertEqual(destruction_list.status, status)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export function DestructionListReviewer({
user,
destructionList,
reviewers,
coReviewers,
assignedCoReviewers,
assignCoReviewersFormValuesState,
]);
Expand Down

0 comments on commit e052720

Please sign in to comment.