test: add Playwright end-to-end example for FormView (#16) #18

Merged
pitfriedrich merged 1 commits from ai/issue-16-playwright-formview into main 2026-07-26 18:50:22 +00:00
Collaborator

Closes #16

Adds the first browser-driven test to the project, using the FormView as the example the issue asked for.

What's in it

  • e2e/PlaywrightTestBase@SpringBootTest(webEnvironment = RANDOM_PORT) starts the app, Playwright launches a headless Chromium against it. One fresh BrowserContext per test, so each test also gets a fresh Vaadin session. Provides navigate("<route>") and the page.
  • e2e/FormViewPlaywrightTest — 5 tests:
    • form renders its fields, Age is prefilled with 37 and read-only
    • saving with empty required fields shows the error notification
    • saving with an invalid email shows the error notification
    • saving valid input shows Saved: Max Mustermann
    • reset clears the entered values

Notes

  • Assertions match the English captions. German is the unsuffixed fallback bundle (translations.properties), so de is not a provided locale and Vaadin serves translations_en.properties even for a German browser. The base class pins the context locale to en-US to make that explicit rather than implicit.
  • Skips instead of failing when no browser is available. Playwright downloads its browsers into ~/.cache/ms-playwright on first use; if that is not possible (offline runner, missing system libs), the tests abort via a JUnit assumption so CI stays green rather than going red on infrastructure.
  • CLAUDE.md updated: the "no test sources exist yet" note was already stale (GridStackViewTest exists), and the autofix rules' <dein Testkommando> placeholder is now ./mvnw test.

Test run

Tests run: 5, Failures: 0, Errors: 0, Skipped: 0 -- com.example.e2e.FormViewPlaywrightTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0 -- com.example.views.GridStackViewTest
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ue9ZtWUBQF4SuSHpzZ3zwq

Closes #16 Adds the first browser-driven test to the project, using the `FormView` as the example the issue asked for. ## What's in it - **`e2e/PlaywrightTestBase`** — `@SpringBootTest(webEnvironment = RANDOM_PORT)` starts the app, Playwright launches a headless Chromium against it. One fresh `BrowserContext` per test, so each test also gets a fresh Vaadin session. Provides `navigate("<route>")` and the `page`. - **`e2e/FormViewPlaywrightTest`** — 5 tests: - form renders its fields, `Age` is prefilled with `37` and read-only - saving with empty required fields shows the error notification - saving with an invalid email shows the error notification - saving valid input shows `Saved: Max Mustermann` - reset clears the entered values ## Notes - **Assertions match the English captions.** German is the unsuffixed fallback bundle (`translations.properties`), so `de` is not a *provided* locale and Vaadin serves `translations_en.properties` even for a German browser. The base class pins the context locale to `en-US` to make that explicit rather than implicit. - **Skips instead of failing when no browser is available.** Playwright downloads its browsers into `~/.cache/ms-playwright` on first use; if that is not possible (offline runner, missing system libs), the tests abort via a JUnit assumption so CI stays green rather than going red on infrastructure. - `CLAUDE.md` updated: the "no test sources exist yet" note was already stale (`GridStackViewTest` exists), and the autofix rules' `<dein Testkommando>` placeholder is now `./mvnw test`. ## Test run ``` Tests run: 5, Failures: 0, Errors: 0, Skipped: 0 -- com.example.e2e.FormViewPlaywrightTest Tests run: 5, Failures: 0, Errors: 0, Skipped: 0 -- com.example.views.GridStackViewTest Tests run: 10, Failures: 0, Errors: 0, Skipped: 0 BUILD SUCCESS ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Ue9ZtWUBQF4SuSHpzZ3zwq
claude-bot added 1 commit 2026-07-26 18:38:47 +00:00
test: add Playwright end-to-end example for FormView (#16)
CI / build-and-test (pull_request) Successful in 2m16s
a996269aff
Adds the first browser-driven test to the project: PlaywrightTestBase starts
the app on a random port and drives a headless Chromium against it, and
FormViewPlaywrightTest covers the form's rendering, binder validation and the
save/reset buttons.

The tests skip themselves via a JUnit assumption when no browser can be
launched, so runners without Playwright browsers stay green.

Closes #16

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9ZtWUBQF4SuSHpzZ3zwq
pitfriedrich merged commit 7aff9fee4f into main 2026-07-26 18:50:22 +00:00
pitfriedrich deleted branch ai/issue-16-playwright-formview 2026-07-26 18:50:22 +00:00
Sign in to join this conversation.