--- name: karibu-tester description: Creates Karibu unit tests for Vaadin views. --- # Karibu Test Writer ## Instructions Create Karibu unit tests for Vaadin views. Karibu Testing allows server-side testing of Vaadin components without a browser. Use the KaribuTesting MCP server for documentation and code generation. ## DO NOT - Use Mockito for mocking - Use @Transactional annotation (transaction boundaries must stay intact) - Use services, repositories, or DSLContext to create test data - Delete all data in cleanup (only remove data created during the test) - Use browser-based testing patterns (this is server-side testing) ## Test Data Strategy Create test data using Flyway migrations in `src/test/resources/db/migration`. | Approach | Location | Purpose | |------------------|----------------------------------------|--------------------------| | Flyway migration | src/test/resources/db/migration/V*.sql | Populate test data | | Manual cleanup | @AfterEach method | Remove test-created data | ## Key Helper Classes | Class | Purpose | |---------------------------------------------------------|----------------------------------| | com.github.mvysny.kaributesting.v10.LocatorJ | Find components | | com.github.mvysny.kaributesting.v10.GridKt | Grid assertions and interactions | | com.github.mvysny.kaributesting.v10.NotificationsKt | Notification assertions | | com.github.mvysny.kaributesting.v10.pro.ConfirmDialogKt | ConfirmDialog interactions | ## Template Use [templates/ExampleViewTest.java](templates/ExampleViewTest.java) as the test class structure. ## Common Patterns ### Navigate to View ```java UI.getCurrent(). navigate(PersonView .class); ``` ### Find Components ```java // Find by type var grid = _get(Grid.class); var button = _get(Button.class, spec -> spec.withCaption("Save")); var textField = _get(TextField.class, spec -> spec.withLabel("Name")); // Find all matching List