Skip to content

fix(test): flaky bookmark cypress test - #1273

Open
spaenleh wants to merge 1 commit into
mainfrom
fix-flaky-bookmark-cypress-test
Open

spaenleh wants to merge 1 commit into
mainfrom
fix-flaky-bookmark-cypress-test

Conversation

@spaenleh

Copy link
Copy Markdown
Member

Summary

UNBOOKMARK_ICON_SELECTOR and BOOKMARK_ICON_SELECTOR were both .lucide-bookmark, so Cypress could click the icon before the bookmarks query resolved. The button was still in "add" mode, so it sent bookmarkItem and unbookmarkItem never fired.

The icon now exposes its state and the selectors match on it, so Cypress retries until the button is in the expected state:

 <BookmarkIcon
   fill={isFavorite ? BOOKMARK_COLOR : 'none'}
   fontSize={size}
+  data-bookmarked={isFavorite}
 />

-UNBOOKMARK_ICON_SELECTOR = '.lucide-bookmark'
-BOOKMARK_ICON_SELECTOR   = '.lucide-bookmark'
+UNBOOKMARK_ICON_SELECTOR = '.lucide-bookmark[data-bookmarked="true"]'
+BOOKMARK_ICON_SELECTOR   = '.lucide-bookmark[data-bookmarked="false"]'

Evidence

  • Before: CI run: Bookmarked Item › remove item from item card failed with cy.wait() timed out waiting 8000ms for the 1st request to the route: unbookmarkItem. No request ever occurred.
    After: bookmarks.cy.ts passes locally, 6/6. One test (remove item from bookmark card) needed a retry because of a blank page while the local Vite dev server was compiling. CI tests a prebuilt preview, so this shouldn't happen there.

Merge Danger

Door: two-way

Blast Radius: minimal

Adds a data-bookmarked attribute to the bookmark icon's SVG. Nothing in the app reads it, and the selectors are only used by the bookmarks spec.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant