PHPUnit tests: Support form actions being outside of a form

Created on 21 June 2024, 3 months ago
Updated 13 August 2024, 25 days ago

Problem/Motivation

Gin has a new feature to display all form items in a sticky bar which resides outside of the actual <form>. This is natively support by HTML but will fail regular functional tests using submitForm() as this assumes the form actions being part of the <form>.

We temporarily override the submitForm() so the PHPUnit tests within the Gin theme do not fail. However if you run any functional testing on the backend it will now potentially fail.

I can think of a couple of ways how we can easily solve this.

Steps to reproduce

Approach A:
Install Gin theme
Enable sticky form actions
Run PHPUnit tests on an admin form

Approach B:
Create form where button render outside the form actions
like:

<form action="/action_page.php" method="get" id="form1">
  What is your favorite color? <input type="text" name="fav_color"><br>
  <input type="submit">
</form>

<fieldset form="form1">
  Name: <input type="text" name="username"><br>
  Email: <input type="text" name="usermail"><br>
</fieldset>

Reference link: https://www.w3schools.com/tags/att_form.asp

Now if you try to add Phpunit test case for this form , then test fails.

Proposed resolution

Alter submitForm() to support form actions being set outside of a <form>.

Remaining tasks

Update submitForm()

User interface changes

API changes

Data model changes

Release notes snippet

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
FormΒ  β†’

Last updated 1 minute ago

Created by

πŸ‡¨πŸ‡­Switzerland saschaeggi Zurich

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024