Skip to content

Commit

Permalink
👕 #1795 - black.
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed Nov 23, 2023
1 parent 3af4ae0 commit d0bf625
Showing 1 changed file with 35 additions and 23 deletions.
58 changes: 35 additions & 23 deletions src/open_inwoner/cms/cases/tests/test_htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,17 +504,21 @@ def mock_list(request, context):
Mock GET "zaakinformatieobjecten" endpoint (schemas/ZaakInformatieObject array).
Creates schemas/ZaakInformatieObject dict for each item in uploads.
"""
items = [generate_oas_component(
"zrc",
"schemas/ZaakInformatieObject",
url=f"{ZAKEN_ROOT}zaakinformatieobjecten/e55153aa-ad2c-4a07-ae75-15add57d6",
informatieobject=upload["url"],
zaak=self.zaak["url"],
) for upload in uploads]
items = [
generate_oas_component(
"zrc",
"schemas/ZaakInformatieObject",
url=f"{ZAKEN_ROOT}zaakinformatieobjecten/e55153aa-ad2c-4a07-ae75-15add57d6",
informatieobject=upload["url"],
zaak=self.zaak["url"],
)
for upload in uploads
]
return json.dumps(items)

m.get(
f"{ZAKEN_ROOT}zaakinformatieobjecten?zaak={self.zaak['url']}", text=mock_list
f"{ZAKEN_ROOT}zaakinformatieobjecten?zaak={self.zaak['url']}",
text=mock_list,
),

# Upload mock.
Expand All @@ -529,7 +533,7 @@ def mock_upload(request, context):

# Create a UUID based on a seed derived from the file name.
# This makes sure the two test cases have unique entries.
seed = file_name.ljust(16, '0').encode("utf-8")
seed = file_name.ljust(16, "0").encode("utf-8")
uuid = UUID(bytes=seed)

uploaded_informatie_object = generate_oas_component(
Expand All @@ -552,18 +556,22 @@ def mock_upload(request, context):
m.post(
f"{DOCUMENTEN_ROOT}enkelvoudiginformatieobjecten",
status_code=201,
text=mock_upload
text=mock_upload,
),

# Setup.
context = self.browser.new_context(storage_state=self.user_login_state)
page = context.new_page()
page.goto(self.live_reverse("cases:case_detail", kwargs={"object_id": self.zaak["uuid"]}))
page.goto(
self.live_reverse(
"cases:case_detail", kwargs={"object_id": self.zaak["uuid"]}
)
)

upload_form = page.locator("#document-upload")
file_input = upload_form.get_by_label('Sleep of selecteer bestanden')
file_input = upload_form.get_by_label("Sleep of selecteer bestanden")
submit_button = upload_form.get_by_role("button", name=_("Upload documenten"))
notification_list = page.get_by_role('alert').get_by_role("list")
notification_list = page.get_by_role("alert").get_by_role("list")
notification_list_items = notification_list.get_by_role("listitem")
file_list = page.get_by_role("list").last
file_list_items = file_list.get_by_role("listitem")
Expand All @@ -578,24 +586,28 @@ def mock_upload(request, context):
{
"name": "document_1.txt",
"mimeType": "text/plain",
"buffer": "test12345".encode("utf8")
"buffer": "test12345".encode("utf8"),
},
{
"name": "document_two.pdf",
"mimeType": "application/pdf",
"buffer": "test67890".encode("utf8")
}
"buffer": "test67890".encode("utf8"),
},
],
)
submit_button.click()
page.wait_for_url(self.live_reverse("cases:case_detail", kwargs={"object_id": self.zaak["uuid"]}))
page.wait_for_url(
self.live_reverse(
"cases:case_detail", kwargs={"object_id": self.zaak["uuid"]}
)
)

# Check that the case does now have two uploaded documents.
expect(notification_list_items).to_have_count(2)
expect(notification_list_items.first).to_contain_text('document_1.txt')
expect(notification_list_items.last).to_contain_text('document_two.pdf')
expect(notification_list_items.first).to_contain_text("document_1.txt")
expect(notification_list_items.last).to_contain_text("document_two.pdf")
expect(file_list_items).to_have_count(2)
expect(file_list_items.first).to_contain_text('document_1')
expect(file_list_items.first).to_contain_text('(txt, 9 bytes)')
expect(file_list_items.last).to_contain_text('document_two')
expect(file_list_items.last).to_contain_text('(pdf, 9 bytes)')
expect(file_list_items.first).to_contain_text("document_1")
expect(file_list_items.first).to_contain_text("(txt, 9 bytes)")
expect(file_list_items.last).to_contain_text("document_two")
expect(file_list_items.last).to_contain_text("(pdf, 9 bytes)")

0 comments on commit d0bf625

Please sign in to comment.