Fixed flaky bookmark and call-to-action tests#26834
Conversation
WalkthroughAdds an internal helper 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/admin-x-settings/test/acceptance/membership/member-welcome-emails.test.ts (1)
420-423: Consider adding a wait for consistency with other GIF test.This test checks that the GIF option is not visible, but it doesn't first wait for the slash menu to render. If the menu hasn't appeared yet, the assertion could pass vacuously. The other GIF test (line 464-466) does wait for the menu before checking.
For robustness, consider adding a wait or a brief delay here as well:
💡 Suggested improvement
await editor.type('/gif'); const slashMenu = page.locator('[data-kg-slash-menu]'); +// Wait briefly to ensure menu has had time to render (if it will) +await page.waitForTimeout(100); await expect(slashMenu.getByText('GIF', {exact: true})).not.toBeVisible();Alternatively, you could wait for some menu content to appear before asserting the GIF option is absent. This is a minor observation outside the PR's immediate scope.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/admin-x-settings/test/acceptance/membership/member-welcome-emails.test.ts` around lines 420 - 423, The assertion that the GIF option is not visible runs before ensuring the slash menu has rendered; update the test around editor.type('/gif') to first wait for the slash menu to appear (e.g., await slashMenu.waitFor or waitForSelector on '[data-kg-slash-menu]' or wait for some menu item text) and then assert that slashMenu.getByText('GIF', {exact: true}) is not visible, using the existing slashMenu locator to target the menu.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@apps/admin-x-settings/test/acceptance/membership/member-welcome-emails.test.ts`:
- Around line 420-423: The assertion that the GIF option is not visible runs
before ensuring the slash menu has rendered; update the test around
editor.type('/gif') to first wait for the slash menu to appear (e.g., await
slashMenu.waitFor or waitForSelector on '[data-kg-slash-menu]' or wait for some
menu item text) and then assert that slashMenu.getByText('GIF', {exact: true})
is not visible, using the existing slashMenu locator to target the menu.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 454f1fa2-5c0e-4380-8a8e-1095c4969961
📒 Files selected for processing (1)
apps/admin-x-settings/test/acceptance/membership/member-welcome-emails.test.ts
Consolidates the delay + wait pattern into a reusable helper across all 6 slash menu test sites. Also fixes the GIF-not-configured test which previously passed vacuously by not waiting for the menu to render.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/admin-x-settings/test/acceptance/membership/member-welcome-emails.test.ts (1)
428-430: Make the GIF-not-configured assertion non-vacuous and reuse the helper.At Line 430,
not.toBeVisible()can still pass when the menu content is missing unexpectedly. Add one positive menu-item assertion first, and reuseopenSlashMenufor consistency.♻️ Proposed refinement
- await page.keyboard.type('/', {delay: 50}); - await expect(page.locator('[data-kg-slash-menu]')).toBeVisible({timeout: 5000}); - await expect(page.locator('[data-kg-slash-menu]').getByText('GIF', {exact: true})).not.toBeVisible(); + await openSlashMenu(page, ''); + await expect(page.locator('[data-kg-slash-menu]').getByText('Bookmark', {exact: true})).toBeVisible(); + await expect(page.locator('[data-kg-slash-menu]').getByText('GIF', {exact: true})).not.toBeVisible();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/admin-x-settings/test/acceptance/membership/member-welcome-emails.test.ts` around lines 428 - 430, The current negative assertion for the GIF menu item is vacuous; replace the manual slash typing with the shared helper openSlashMenu() to open the slash menu, then first assert a known positive menu item is visible (e.g., expect(page.locator('[data-kg-slash-menu]').getByText('Image', {exact: true})).toBeVisible()) to ensure the menu rendered, and only then assert the GIF entry is not visible (expect(...getByText('GIF', {exact: true})).not.toBeVisible()); use the openSlashMenu helper and the '[data-kg-slash-menu]' locator to locate the menu and items.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@apps/admin-x-settings/test/acceptance/membership/member-welcome-emails.test.ts`:
- Around line 428-430: The current negative assertion for the GIF menu item is
vacuous; replace the manual slash typing with the shared helper openSlashMenu()
to open the slash menu, then first assert a known positive menu item is visible
(e.g., expect(page.locator('[data-kg-slash-menu]').getByText('Image', {exact:
true})).toBeVisible()) to ensure the menu rendered, and only then assert the GIF
entry is not visible (expect(...getByText('GIF', {exact:
true})).not.toBeVisible()); use the openSlashMenu helper and the
'[data-kg-slash-menu]' locator to locate the menu and items.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9264d26d-0ccc-467a-81e3-7bd72edafa03
📒 Files selected for processing (1)
apps/admin-x-settings/test/acceptance/membership/member-welcome-emails.test.ts
Ensures the slash menu items have populated before asserting GIF is not present, preventing a vacuous negative assertion.
refs https://github.com/TryGhost/Ghost/actions/runs/23157241597/job/67275778166 This is a test only change; no user-facing changes. ## Summary - Extracted an `openSlashMenu(page, command)` helper that types the slash command with a delay and waits for the menu to render before continuing - Applied the helper to all 5 slash menu selection tests (bookmark, call-to-action, product, GIF) - Fixed the GIF-not-configured test which previously passed vacuously — it now waits for the slash menu to appear before asserting GIF is absent
refs https://github.com/TryGhost/Ghost/actions/runs/23157241597/job/67275778166
This is a test only change; no user-facing changes.
Summary
openSlashMenu(page, command)helper that types the slash command with a delay and waits for the menu to render before continuing