Skip to content

Commit

Permalink
✅ - test: more intergration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed Aug 1, 2024
1 parent f6c8ee6 commit 1002608
Show file tree
Hide file tree
Showing 11 changed files with 468 additions and 106 deletions.
Binary file added backend/playwright-trace.zip
Binary file not shown.
25 changes: 14 additions & 11 deletions backend/src/openarchiefbeheer/destruction/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,20 @@ def assign_next(self) -> None:
self.set_status(status)
return

# Archivist has approved the (now final) list.
current_assignee = self.assignees.get(user=self.assignee)
if current_assignee.role == ListRole.archivist:
self.get_author().assign()
self.set_status(ListStatus.ready_to_delete)
return

# Assign (next) reviewer
current_assignee = self.assignees.get(user=self.assignee)
next_reviewer = current_assignee.next()
next_reviewer.assign()
try:
current_assignee = self.assignees.get(user=self.assignee)

# Archivist has approved the (now final) list.
if current_assignee.role == ListRole.archivist:
self.get_author().assign()
self.set_status(ListStatus.ready_to_delete)
return

# Assign (next) reviewer
next_reviewer = current_assignee.next()
next_reviewer.assign()
except DestructionListAssignee.DoesNotExist:
pass # No more assignees

def has_short_review_process(self) -> bool:
zaken_urls = self.items.all().values_list("zaak", flat=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# fmt: off
from django.test import tag

from openarchiefbeheer.utils.tests.e2e import browser_page
Expand All @@ -14,50 +15,39 @@ async def test_scenario_record_manager_creates_list(self):
await self.given.zaken_are_indexed(100)

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

await self.when.user_clicks_button(page, "Vernietigingslijst opstellen")
await self.then.path_should_be(page, "/destruction-lists/create")

await self.when.user_clicks_checkbox(page, "(de)selecteer rij", index=0)
await self.when.user_clicks_button(
page, "Vernietigingslijst opstellen", index=1
)
await self.when.user_fills_form_field(
page, "Naam", "Mijn Eerste Vernietigingslijst"
)
await self.when.user_fills_form_field(
page, "Eerste reviewer", "Beoordelaar 1"
)
await self.when.user_fills_form_field(
page, "Tweede reviewer", "Beoordelaar 2"
)
await self.when.user_clicks_button(page, "Vernietigingslijst opstellen", index=1)
await self.when.user_fills_form_field(page, "Naam", "Destruction list to create")
await self.when.user_fills_form_field(page, "Eerste reviewer", "Beoordelaar 1")
await self.when.user_fills_form_field(page, "Tweede reviewer", "Beoordelaar 2")
await self.when.user_clicks_button(page, "Verzenden")

await self.then.path_should_be(page, "/destruction-lists")
await self.then.page_should_contain_text(
page, "Mijn Eerste Vernietigingslijst"
)
await self.then.page_should_contain_text(page, "Destruction list to create")

async def test_scenario_reviewer_cannot_create_list(self):
async with browser_page() as page:
await self.given.reviewer_exists()
await self.given.zaken_are_indexed(100)

await self.when.reviewer_logs_in(page)
await self.when.user_clicks_button(page, "Vernietigingslijst opstellen")
await self.then.path_should_be(page, "/destruction-lists")

await self.then.path_should_be(
page, "/login?next=/destruction-lists/create"
)
await self.when.user_clicks_button(page, "Vernietigingslijst opstellen")
await self.then.path_should_be(page, "/login?next=/destruction-lists/create")

async def test_scenario_archivist_cannot_create_list(self):
async with browser_page() as page:
await self.given.archivist_exists()
await self.given.zaken_are_indexed(100)

await self.when.archivist_logs_in(page)
await self.when.user_clicks_button(page, "Vernietigingslijst opstellen")
await self.then.path_should_be(page, "/destruction-lists")

await self.then.path_should_be(
page, "/login?next=/destruction-lists/create"
)
await self.when.user_clicks_button(page, "Vernietigingslijst opstellen")
await self.then.path_should_be(page, "/login?next=/destruction-lists/create")
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# fmt: off
from django.test import tag

from openarchiefbeheer.utils.tests.e2e import browser_page
Expand All @@ -10,17 +11,23 @@
class FeatureListCreateTests(GherkinLikeTestCase):
async def test_scenario_record_manager_destroys_list(self):
async with browser_page() as page:
# fmt: off
await self.given.record_manager_exists()
destruction_list = await self.given.list_exists(status=ListStatus.ready_to_delete)
destruction_list = await self.given.list_exists(
name="Destruction list to destroy",
status=ListStatus.ready_to_delete,
uuid="00000000-0000-0000-0000-000000000000",
)

await self.when.record_manager_logs_in(page)
await self.when.user_clicks_button(page, "My First Destruction List")
await self.then.path_should_be(page, "/destruction-lists")

await self.when.user_clicks_button(page, "Destruction list to destroy")
await self.then.path_should_be(page, f"/destruction-lists/{destruction_list.uuid}")

await self.when.user_clicks_button(page, "Zaken op lijst definitief vernietigen")
await self.when.user_fills_form_field(page, "Type naam van de lijst ter bevestiging", "My First Destruction List")
await self.when.user_fills_form_field(page, "Type naam van de lijst ter bevestiging", "Destruction list to destroy")
await self.when.user_clicks_button(page, "100 zaken vernietigen")

await self.then.path_should_be(page, "/destruction-lists")
# TODO: Seems to rely on open zaak (mock?)
# await self.then.list_should_have_status(page, destruction_list, ListStatus.deleted)
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# fmt: off
from django.test import tag

from openarchiefbeheer.destruction.constants import (
ListRole,
ListStatus,
ReviewDecisionChoices,
)
from openarchiefbeheer.utils.tests.e2e import browser_page
from openarchiefbeheer.utils.tests.gherkin import GherkinLikeTestCase


@tag("e2e")
class FeatureListCreateTests(GherkinLikeTestCase):
async def test_scenario_record_manager_finalizes_list(self):
async with browser_page() as page:
record_manager = await self.given.record_manager_exists()
reviewer1 = await self.given.reviewer_exists(username="Beoordelaar 1")
reviewer2 = await self.given.reviewer_exists(username="Beoordelaar 2")
await self.given.archivist_exists(username="Archivaris")

assignees = [
await self.given.assignee_exists(user=record_manager, role=ListRole.author),
await self.given.assignee_exists(user=reviewer1, role=ListRole.reviewer),
await self.given.assignee_exists(user=reviewer2, role=ListRole.reviewer),
]

list = await self.given.list_exists(
assignee=record_manager,
assignees=assignees,
uuid="00000000-0000-0000-0000-000000000000",
name="Destruction list to finalize",
status=ListStatus.internally_reviewed,
)

# Both reviewers provided a review.
await self.given.review_exists(author=reviewer1, destruction_list=list, decision=ReviewDecisionChoices.accepted)
await self.given.review_exists(author=reviewer2, destruction_list=list, decision=ReviewDecisionChoices.accepted)

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 finalize")
await self.then.path_should_be(page, "/destruction-lists/00000000-0000-0000-0000-000000000000")

await self.when.user_clicks_button(page, "Markeren als definitief")
await self.when.user_fills_form_field(page, "Archivaris", "Archivaris")
await self.when.user_clicks_button(page, "Markeer als definitief")

await self.then.path_should_be(page, "/destruction-lists")
await self.then.page_should_contain_text(page, "Destruction list to finalize")
await self.then.list_should_have_status(page, list, ListStatus.ready_for_archivist)
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# fmt: off
from django.test import tag

from openarchiefbeheer.destruction.constants import (
ListRole,
ListStatus,
ReviewDecisionChoices,
)
from openarchiefbeheer.utils.tests.e2e import browser_page
from openarchiefbeheer.utils.tests.gherkin import GherkinLikeTestCase


@tag("e2e")
class FeatureListCreateTests(GherkinLikeTestCase):
async def test_scenario_record_manager_process_review(self):
async with browser_page() as page:
await self.given.selectielijstklasse_choices_are_available(page)
record_manager = await self.given.record_manager_exists()
reviewer1 = await self.given.reviewer_exists(username="Beoordelaar 1")
reviewer2 = await self.given.reviewer_exists(username="Beoordelaar 2")

assignees = [
await self.given.assignee_exists(user=record_manager, role=ListRole.author),
await self.given.assignee_exists(user=reviewer1, role=ListRole.reviewer),
await self.given.assignee_exists(user=reviewer2, role=ListRole.reviewer),
]

destruction_list = await self.given.list_exists(
assignee=record_manager,
assignees=assignees,
uuid="00000000-0000-0000-0000-000000000000",
name="Destruction list to process",
status=ListStatus.changes_requested,
)

# Both reviewers provided a review.
await self.given.review_exists(author=reviewer1, destruction_list=destruction_list, decision=ReviewDecisionChoices.accepted)
await self.given.review_exists(author=reviewer2, destruction_list=destruction_list, decision=ReviewDecisionChoices.rejected)

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 process")
await self.then.path_should_be(page, "/destruction-lists/00000000-0000-0000-0000-000000000000")

# TODO
await self.when.user_clicks_checkbox(page, "(de)selecteer rij")

# Fill selectielijstklasse as it's probably missing.
await self.when.user_clicks_radio(page, "Aanpassen van selectielijstklasse")
await self.when.user_fills_form_field(page, "Selectielijstklasse", "11.1 - Verleend - vernietigen - P1Y")

# Fill archive date
await self.when.user_clicks_radio(page, "Verlengen bewaartermijn")
await self.when.user_fills_form_field(page, "Archief datum", "09/15/2023")
await page.keyboard.press("Enter")

await self.when.user_fills_form_field(page, "Reden", "Andere datum")
await self.when.user_clicks_button(page, "muteren")
await self.when.user_clicks_button(page, "Opnieuw indienen")
await self.when.user_fills_form_field(page, "Opmerking", "Datum aangepast")
await self.when.user_clicks_button(page, "Opnieuw indienen")
await self.then.path_should_be(page, "/destruction-lists")
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# fmt: off
from django.test import tag

from openarchiefbeheer.destruction.constants import (
ListRole,
ListStatus,
ReviewDecisionChoices,
)
from openarchiefbeheer.utils.tests.e2e import browser_page
from openarchiefbeheer.utils.tests.gherkin import GherkinLikeTestCase


@tag("e2e")
class FeatureListCreateTests(GherkinLikeTestCase):
async def test_scenario_reviewer_approves_list(self):
async with browser_page() as page:
record_manager = await self.given.record_manager_exists()
reviewer1 = await self.given.reviewer_exists(username="peer_reviewer", first_name="Peer", last_name="Reviewer")
reviewer2 = await self.given.reviewer_exists()
archivist = await self.given.archivist_exists()

assignees = [
await self.given.assignee_exists(user=record_manager, role=ListRole.author),
await self.given.assignee_exists(user=reviewer1, role=ListRole.reviewer),
await self.given.assignee_exists(user=reviewer2, role=ListRole.reviewer),
await self.given.assignee_exists(user=archivist, role=ListRole.archivist),
]

list = await self.given.list_exists(
assignee=reviewer2,
assignees=assignees,
uuid="00000000-0000-0000-0000-000000000000",
name="Destruction list to review",
status=ListStatus.ready_to_review,
)

# Reviewer 1 already provided a review.
await self.given.review_exists(author=reviewer1, destruction_list=list, decision=ReviewDecisionChoices.accepted)

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

await self.when.user_clicks_button(page, "Destruction list to review")
await self.then.path_should_be(page, "/destruction-lists/00000000-0000-0000-0000-000000000000/review")

await self.when.user_clicks_button(page, "Accorderen")
await self.when.user_fills_form_field(page, "Opmerking", "Looks good to me👍🏻")
await self.when.user_clicks_button(page, "Accorderen")

await self.then.path_should_be(page, "/destruction-lists")
await self.then.page_should_contain_text(page, "Destruction list to review")
await self.then.list_should_have_status(page, list, ListStatus.internally_reviewed)

async def test_scenario_reviewer_rejects_list(self):
async with browser_page() as page:
record_manager = await self.given.record_manager_exists()
reviewer1 = await self.given.reviewer_exists(username="peer_reviewer", first_name="Peer", last_name="Reviewer")
reviewer2 = await self.given.reviewer_exists()
archivist = await self.given.archivist_exists()

assignees = [
await self.given.assignee_exists(user=record_manager, role=ListRole.author),
await self.given.assignee_exists(user=reviewer1, role=ListRole.reviewer),
await self.given.assignee_exists(user=reviewer2, role=ListRole.reviewer),
await self.given.assignee_exists(user=archivist, role=ListRole.archivist),
]

list = await self.given.list_exists(
assignee=reviewer2,
assignees=assignees,
uuid="00000000-0000-0000-0000-000000000000",
name="Destruction list to review",
status=ListStatus.ready_to_review,
)

# Reviewer 1 already provided a review.
await self.given.review_exists(author=reviewer1, destruction_list=list, decision=ReviewDecisionChoices.accepted)

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

await self.when.user_clicks_button(page, "Destruction list to review")
await self.then.path_should_be(page, "/destruction-lists/00000000-0000-0000-0000-000000000000/review")
await self.when.user_clicks_checkbox(page, "(de)selecteer rij")
await self.when.user_fills_form_field(page, "Reden van uitzondering", "Please reconsider this zaak")
await self.when.user_clicks_button(page, "Uitzonderen")
await self.when.user_clicks_button(page, "Beoordelen")
await self.when.user_fills_form_field(page, "Opmerking", "Please reconsider the zaak on this list")
await self.when.user_clicks_button(page, "Beoordelen")

await self.then.path_should_be(page, "/destruction-lists")
await self.then.page_should_contain_text(page, "Destruction list to review")
await self.then.list_should_have_status(page, list, ListStatus.changes_requested)
Loading

0 comments on commit 1002608

Please sign in to comment.