Skip to content

Feature/api form component tests - #10213

Open
BacLuc wants to merge 2 commits into
ecamp:develfrom
BacLuc:feature/api-form-component-tests
Open

Feature/api form component tests#10213
BacLuc wants to merge 2 commits into
ecamp:develfrom
BacLuc:feature/api-form-component-tests

Conversation

@BacLuc

@BacLuc BacLuc commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Look at the second commit.

BacLuc 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>
@BacLuc
BacLuc requested a review from manuelmeister July 2, 2026 15:14
@BacLuc
BacLuc requested review from a team and removed request for manuelmeister July 2, 2026 15:14
@BacLuc

BacLuc commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant