Skip to content

Commit

Permalink
✅ [#4795] Add e2e test for msg file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmolen committed Dec 23, 2024
1 parent b7b268c commit 4908172
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
Binary file added src/openforms/tests/e2e/data/test.msg
Binary file not shown.
61 changes: 61 additions & 0 deletions src/openforms/tests/e2e/test_file_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,64 @@ def setUpTestData():
await expect(
page.get_by_text("Een moment geduld", exact=False)
).to_be_visible()

async def test_form_with_msg_file_upload(self):
# If using the ci.py settings locally, the SDK_RELEASE variable should be set to 'latest', otherwise the
# JS/CSS for the SDK will not be found (since they will be expected to be in the folder
# openforms/static/sdk/<SDK version tag> instead of openforms/static/sdk
@sync_to_async
def setUpTestData():
# set up a form
form = FormFactory.create(
name="Form with file upload",
slug="form-with-file-upload",
generate_minimal_setup=True,
formstep__form_definition__name="First step",
formstep__form_definition__slug="first-step",
formstep__form_definition__configuration={
"components": [
{
"type": "file",
"key": "fileUpload",
"label": "File Upload",
"storage": "url",
"validate": {
"required": True,
},
}
]
},
translation_enabled=False, # force Dutch
ask_privacy_consent=False,
ask_statement_of_truth=False,
)
return form

form = await setUpTestData()
form_url = str(
furl(self.live_server_url)
/ reverse("forms:form-detail", kwargs={"slug": form.slug})
)

with patch("openforms.utils.validators.allow_redirect_url", return_value=True):
async with browser_page() as page:
await page.goto(form_url)

await page.get_by_role("button", name="Formulier starten").click()

async with page.expect_file_chooser() as fc_info:
await page.get_by_text("blader").click()

file_chooser = await fc_info.value
await file_chooser.set_files(TEST_FILES / "test.msg")

await page.wait_for_load_state("networkidle")

uploaded_file = page.get_by_role("link", name="test.msg")
await expect(uploaded_file).to_be_visible()

await page.get_by_role("button", name="Volgende").click()
await page.get_by_role("button", name="Verzenden").click()
await expect(
page.get_by_text("Een moment geduld", exact=False)
).to_be_visible()

0 comments on commit 4908172

Please sign in to comment.