Skip to content

Commit

Permalink
🧪 [DH#671] Add regression test for dynamic property changes
Browse files Browse the repository at this point in the history
The component changes properties dynamically, and the logic evaluation
seems to be missing some components.
  • Loading branch information
sergei-maertens committed Apr 3, 2024
1 parent f51704e commit dd20ce4
Showing 1 changed file with 86 additions and 1 deletion.
87 changes: 86 additions & 1 deletion src/openforms/tests/e2e/test_input_validation_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
from furl import furl
from playwright.async_api import expect

from openforms.forms.tests.factories import FormFactory, FormStepFactory
from openforms.forms.tests.factories import (
FormFactory,
FormLogicFactory,
FormStepFactory,
)

from .base import E2ETestCase, browser_page

Expand Down Expand Up @@ -226,3 +230,84 @@ def setUpTestData():
await expect(
page.get_by_text("Een moment geduld", exact=False)
).to_be_visible()

@tag("dh-671")
async def test_component_not_required_via_logic(self):
@sync_to_async
def setUpTestData():
form = FormFactory.create(
slug="validation",
generate_minimal_setup=True,
registration_backend=None,
translation_enabled=False, # force Dutch
ask_privacy_consent=False,
ask_statement_of_truth=False,
formstep__next_text="Volgende",
formstep__form_definition__configuration={
"components": [
{
"type": "textfield",
"key": "textfield",
"label": "Visible text field",
"validate": {"required": True},
},
]
},
)
# add a second step
FormStepFactory.create(
form=form,
next_text="Volgende",
is_applicable=True, # should not be validated
form_definition__configuration={
"components": [
{
"type": "textfield",
"key": "textfield2",
"label": "Textfield 2",
"validate": {"required": False},
},
]
},
)
FormLogicFactory.create(
form=form,
json_logic_trigger=True,
actions=[
{
"component": "textfield",
"formStepUuid": None,
"action": {
"type": "property",
"property": {"value": "validate.required", "type": "bool"},
"state": False,
},
}
],
)
return form

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

async with browser_page() as page:
await page.goto(form_url)
# Start the form
await page.get_by_role("button", name="Formulier starten").click()

# Confirm first step is visible
await expect(page.get_by_label("Visible text field")).to_be_visible()
await page.get_by_role("button", name="Volgende").click()

# Handle second step
await expect(page.get_by_label("Textfield 2")).to_be_visible()
await page.get_by_role("button", name="Volgende").click()

# Confirm and finish the form
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 dd20ce4

Please sign in to comment.