Feature/api form component tests - #10213
Open
BacLuc wants to merge 2 commits into
Open
Conversation
added 2 commits
July 1, 2026 06:03
…e2e tests
Add a dev-only route that renders a single ecamp base form component
selected via the URL, so the base (E*) form components can be driven and
asserted on with Playwright (or by hand) in isolation - without needing a
camp, login or API data.
/form-test/:component e.g. /form-test/ETextField
?props=<json> props passed to the component
?value=<json> initial v-model value
The view auto-discovers all form base components (E*.vue) via
import.meta.glob, renders the chosen one wrapped in EForm, and exposes
the live v-model value in [data-testid="form-test-model"] (the component
itself is under [data-testid="form-test-subject"]). Visiting /form-test
without a component lists the available ones. The route is gated behind
FEATURE_DEVELOPER like /controls but needs no auth, since the base
components work standalone.
Includes Playwright specs (in e2e/9-behavior-tests/components/form/base/)
that assert on a component's v-model after interacting with it: ETextField,
ECheckbox, and ETimePicker (the latter keeps the date part and only
replaces the time of day).
Add a shared, authenticated singleton entity plus a dev route so the API-backed form components (ApiTextField, ApiCheckbox, ApiTimePicker, ...) can be driven and asserted on with Playwright - including the two-tab "change here, reload there" flow and end-to-end persistence through the database. api: - FormTestDatum entity exposed via API Platform with Get / GetCollection / Patch, each secured with is_authenticated(). No create/delete, so the single row cannot be multiplied or removed; every authenticated user reads and writes that same row. Fields cover each form component type (text, multilineText, html, number, flag, color, date, time, language, languageMultiselect). Every property carries an ApiProperty example so the OpenAPI spec documents a representative value for each field. - The `time` field is stored as a datetime (in UTC) and exchanged as an ISO 8601 string (e.g. "2024-01-15T09:30:00+00:00") via an explicit serializer context (DateTimeNormalizer::FORMAT_KEY), which the ApiTimePicker / ETimePicker read and write with their default valueFormat "YYYY-MM-DDTHH:mm:ssZ". This makes the time field updateable and persisted, with a clean API <-> DB round-trip. - The single row is seeded in the schema migration (not via fixtures) so it exists in every environment, including production. Its id is fixed (0123456789ab). The migration is the newest schema migration, so its INSERT runs after the dev-data seeding (which truncates) and survives. frontend: - /api-form-test/:component (dev only, auth required) renders the named API component bound to the singleton (?path= chooses the field), shows the persisted value in [data-testid="api-form-test-value"], and offers a reload button to re-fetch the entity from the API. e2e (in e2e/9-behavior-tests/components/form/api/): - apiFormComponentTest: opens two tabs sharing one session, edits the field in tab A (auto-saved via PATCH), confirms tab B still shows the stale value, and that reloading tab B surfaces tab A's change. - apiFormMultiselectTest: selecting multiple languages auto-saves the array and survives reload. - apiFormTimePickerTest: editing the time picker auto-saves the datetime and survives reload - proving the time field round-trips through the database end to end. Verified: authenticated GET/PATCH round-trip works (incl. the time field); the OpenAPI spec snapshot is updated; psalm, phpstan, eslint, the frontend build and the e2e tests are green. Signed-off-by: BacLuc <lucius.bachmann@clubpage.ch>
Contributor
Author
|
trace.zip trace.zip trace.zip [trace.zip](https://github.com/user-attachments/files/29604413/t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Look at the second commit.