Skip to content

Conversation

helenul
Copy link
Member

@helenul helenul commented Nov 22, 2026

Makes the E2E tests find elements the way a user or screen reader would, replaces the full-page snapshots, and adds an E2E test for the core feature of the app. The new test found a bug, which is fixed here too.

E2E locators

  • CSS classes and ids replaced with getByRole, getByLabel and toHaveAccessibleName
  • The names are written once, in both languages, in e2e/helpers/names.ts, so the tests work in Norwegian and English
  • New helpers: goToPage (navigation through the sidebar) and e2e/helpers/locators.ts (shared locators for plant cards)
  • data-testid added where there is no natural role: plant cards in lists, the placeholder image and the avatar buttons
  • uiAccessibility still uses CSS selectors on purpose, since it checks contrast and axe rules on specific elements

Snapshots

  • Full-page snapshots of Explore and Profile removed. What only they covered is now checked with targeted assertions (search placeholder, filter group name, active profile tab)
  • New snapshot of FilterSelect with counts and a disabled value. LanguageSwitcher snapshots kept. Snapshots are now only used for small components that seldom change

New E2E test: uiPreferences
A new user lands on Plant Match, chooses preferences on the profile and goes back. The first card must match all preferences, also after a reload and after changing the preferences. The test data has only one or two plants matching each set, so the expected plants are known.

Bug fix: Plant Match kept the old order
The deck in sessionStorage was only restarted when the preferences changed while Plant Match was open. Since preferences are changed on the profile page, users always got the old order, including every new user choosing preferences for the first time. The saved deck now remembers which preferences it was sorted by, and starts over if they no longer match. Covered by new component tests in PlantMatchPage.test.tsx.

Documentation

docs/tests.md: why the tests use roles and names, when snapshots are used, the new E2E test and the fix.

@helenul helenul requested a review from a team as a code owner November 22, 2026 15:41
@helenul helenul linked an issue Nov 22, 2026 that may be closed by this pull request
4 tasks
Copy link
Member

@alexajah alexajah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@helenul helenul merged commit 4452f59 into main Nov 22, 2026
0 of 4 checks passed
@helenul helenul deleted the 145-replace-css-class-locators-in-e2e-tests-with-role-based-locators branch November 22, 2026 16:40
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

replace CSS class locators in E2E tests with role-based locators
2 participants