Repository navigation
fix(tests): flaky bound action tests - #8071
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe ChangesNew Request Hotkey Relocation
Playwright Shortcut Test Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js`:
- Around line 130-133: Update the stale comment above the "Folder rows" block in
CollectionItem to remove the reference to a global override in HotkeysProvider
and instead state that the migration moved keyboard handling to scoped handlers;
keep the note that when the row has keyboard focus its handler mounts the New
Request modal with `item={item}` so new requests are created inside the folder
rather than at the collection root, and reword to reflect current ownership by
scoped handlers rather than a global binding path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d22cf10e-c427-481a-9d3b-52df63a5109d
📒 Files selected for processing (3)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/index.jspackages/bruno-app/src/providers/Hotkeys/index.js
💤 Files with no reviewable changes (1)
- packages/bruno-app/src/providers/Hotkeys/index.js
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/shortcuts/collections-env.spec.ts`:
- Around line 145-147: The suite-level hook uses the test-scoped page fixture:
replace test.afterAll(async ({ page }) => await closeAllCollections(page)) with
an afterEach hook (or remove if cleanup is done elsewhere) so you no longer
access the per-test page in a suite-level hook; also change reopenClosedTab to
remove static waits (replace page.waitForTimeout(150/200) with
locator.waitFor()/page.waitForEvent()/expect(locator).toBeVisible() style waits)
to avoid flakiness, and deduplicate the duplicated "Edit Environment" scenario
by removing or consolidating the duplicate under the “customized Alt+E” describe
so each scenario appears only once (references: closeAllCollections,
reopenClosedTab, the two Describe blocks containing the Cmd/Ctrl+E and
customized Alt+E tests).
In `@tests/shortcuts/sidebar-actions.spec.ts`:
- Around line 257-266: The assertion mismatches the renamed value: after filling
requestNameInput with 'req-1-renamed' and clicking
getByTestId('rename-item-button'), update the
locator('.collection-item-name').filter({ hasText: ... }) check to look for
'req-1-renamed' (match the exact string used in requestNameInput) so the test
verifies the correct renamed label.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1a44e4ab-7096-43df-9f8d-7fdce21dca11
📒 Files selected for processing (8)
tests/shortcuts/bound-actions.spec.tstests/shortcuts/collections-env.spec.tstests/shortcuts/developer-tool.spec.tstests/shortcuts/other-actions.spec.tstests/shortcuts/reqeust-actions.spec.tstests/shortcuts/search-actions.spec.tstests/shortcuts/sidebar-actions.spec.tstests/shortcuts/tabs-actions.spec.ts
💤 Files with no reviewable changes (1)
- tests/shortcuts/bound-actions.spec.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (8)
tests/shortcuts/search-actions.spec.ts (1)
32-34:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAssert that global search closes after
Escapein both tests.
Escapeis triggered, but the close behavior is not verified. This can let dismissal regressions pass.Suggested patch
- await page.keyboard.down('Escape'); - await page.keyboard.up('Escape'); + await page.keyboard.press('Escape'); + await expect(page.getByTestId('global-search-input')).toBeHidden({ timeout: 2000 }); ... - await page.keyboard.down('Escape'); - await page.keyboard.up('Escape'); + await page.keyboard.press('Escape'); + await expect(page.getByTestId('global-search-input')).toBeHidden({ timeout: 2000 });As per coding guidelines, "Use multiple assertions" and "E2E tests must verify user-visible behaviour, not implementation details."
Also applies to: 59-60
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/search-actions.spec.ts` around lines 32 - 34, The tests call page.keyboard.down('Escape') / page.keyboard.up('Escape') but never assert the global search actually closed; after each Escape press (the occurrences around page.keyboard.down('Escape') / page.keyboard.up('Escape')), add an assertion that the global search UI is dismissed — e.g. verify the search dialog/overlay locator used elsewhere in the spec is not visible or not present (use the same locator/role the test suite uses for global search) so both instances (the one at the first Escape and the second at lines ~59-60) explicitly assert the closed state.tests/shortcuts/other-actions.spec.ts (2)
41-55:⚠️ Potential issue | 🟠 Major | ⚡ Quick winCustomized shortcut test currently allows a false positive.
Line 41 opens Keybindings/Preferences first, then Line 54 asserts “Preferences” is visible, so this can pass even if the remapped shortcut never works. Validate from a non-Preferences context and assert before/after state around the shortcut trigger.
Suggested test-shape fix
- await openKeybindingsTab(page); + await openKeybindingsTab(page); const row = page.getByTestId('keybinding-row-openPreferences'); await row.hover(); await page.getByTestId('keybinding-edit-openPreferences').click(); await expect(page.getByTestId('keybinding-input-openPreferences')).toBeVisible({ timeout: 2000 }); - await page.keyboard.down('Backspace'); + await page.keyboard.press('Backspace'); await page.keyboard.down(modifier); await page.keyboard.down('KeyP'); await page.keyboard.up('KeyP'); await page.keyboard.up(modifier); - await expect(page.locator('.request-tab').filter({ hasText: 'Preferences' })).toBeVisible({ timeout: 3000 }); + // Move focus to a non-Preferences context, then verify shortcut opens Preferences. + await page.getByTestId('sidebar-collections').click(); + await expect(page.getByTestId('tab-preferences')).not.toBeVisible(); + await page.keyboard.press(`${modifier}+KeyP`); + await expect(page.getByTestId('tab-preferences')).toBeVisible({ timeout: 3000 });As per coding guidelines, "Every E2E test should follow the Arrange-Act-Assert-Cleanup shape" and "Use multiple assertions".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/other-actions.spec.ts` around lines 41 - 55, The test currently opens the Keybindings UI then triggers the remapped shortcut and asserts that the Preferences tab is visible, which can give a false positive; modify the test around openKeybindingsTab, keybinding-row-openPreferences, keybinding-edit-openPreferences and keybinding-input-openPreferences so it first navigates to a different context (e.g., ensure page.locator('.request-tab').filter({ hasText: 'Preferences' }) is not visible), then close the Keybindings panel or navigate away, trigger the shortcut via page.keyboard.down/up (using modifier + KeyP) and finally assert the Preferences tab is visible—also add an assertion that the tab was absent before the shortcut to validate before/after state and optionally reset the keybinding as cleanup.
47-53:⚠️ Potential issue | 🟠 Major | ⚡ Quick winFix stuck Backspace key simulation in shortcut test
tests/shortcuts/other-actions.spec.tsline 47 usesawait page.keyboard.down('Backspace');without any matchingkeyboard.up('Backspace')/keyboard.press('Backspace'), so Backspace can remain held and make later key chords flaky. Replace withawait page.keyboard.press('Backspace');.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/other-actions.spec.ts` around lines 47 - 53, Replace the unmatched key-down call that can leave Backspace held: change the usage of page.keyboard.down('Backspace') in the test (the call to page.keyboard.down('Backspace')) to a one-shot key action by using page.keyboard.press('Backspace') so the Backspace key is released immediately and downstream modifier chords (the subsequent page.keyboard.down(modifier) / page.keyboard.down('KeyP') sequence) won’t be affected.tests/shortcuts/reqeust-actions.spec.ts (2)
148-148:⚠️ Potential issue | 🟠 Major | ⚡ Quick winFix sticky Backspace key handling in Playwright shortcut tests
tests/shortcuts/reqeust-actions.spec.tspressesBackspacewithpage.keyboard.down('Backspace')at lines 148, 197, 253, and 333, but never releases it (keyboard.up('Backspace')isn’t present), which can make shortcut-capture flaky. Replace withkeyboard.press('Backspace').✅ Suggested fix
- await page.keyboard.down('Backspace'); + await page.keyboard.press('Backspace');🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/reqeust-actions.spec.ts` at line 148, In the Playwright shortcut tests in reqeust-actions.spec.ts, replace each await page.keyboard.down('Backspace') (found in the test cases around the occurrences at lines where Backspace is used) with await page.keyboard.press('Backspace') so the key is both pressed and released; this removes the missing keyboard.up('Backspace') problem that can leave Backspace "stuck" and makes the shortcut-capture deterministic.
18-20:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winFix Playwright hook fixture misuse: don’t use test-scoped
pageintest.afterAll.
tests/shortcuts/reqeust-actions.spec.ts(lines 18-20) usestest.afterAll(async ({ page }) => ...), butpageis a test-scoped fixture; suite-level hooks should useafterEach(or a worker-scoped fixture) for cleanup.Suggested fix
- test.afterAll(async ({ page }) => { + test.afterEach(async ({ page }) => { await closeAllCollections(page); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/reqeust-actions.spec.ts` around lines 18 - 20, Replace the suite-level hook that incorrectly uses the test-scoped page fixture: change test.afterAll(async ({ page }) => { await closeAllCollections(page); }); to a test-scoped cleanup such as test.afterEach(async ({ page }) => { await closeAllCollections(page); }); (or, alternatively, convert closeAllCollections to use a worker-scoped fixture and call it from test.afterAll without the page argument); update the hook name to test.afterEach and keep the call to closeAllCollections(page) so the test-scoped page fixture is used correctly.tests/shortcuts/developer-tool.spec.ts (2)
54-56:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winReplace fixed sleeps with event-driven assertions in shortcut tests
tests/shortcuts/developer-tool.spec.tslines 54-56 and 110-113: remove thepage.waitForTimeout(1000)after clickingsession-close-1; wait on the concrete UI transition (e.g.,await expect(page.getByTestId('session-list-1')).not.toBeVisible({ timeout: 3000 });) before proceeding to clicksession-close-0.- lines 85-86: remove
page.waitForTimeout(500); the followingexpect(page.getByTestId('session-list-0')).toBeVisible(...)already provides the event-driven wait.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/developer-tool.spec.ts` around lines 54 - 56, Replace hard-coded sleep waits with event-driven assertions: remove the page.waitForTimeout(1000) after clicking the 'session-close-1' button and instead await the concrete UI transition by asserting that getByTestId('session-list-1') is not visible (e.g., await expect(page.getByTestId('session-list-1')).not.toBeVisible({ timeout: 3000 })) before proceeding to click getByTestId('session-close-0'); likewise remove the page.waitForTimeout(500) before checking getByTestId('session-list-0') since the subsequent expect(page.getByTestId('session-list-0')).toBeVisible(...) already performs the event-driven wait.
17-19:⚠️ Potential issue | 🟠 MajorFix
pagefixture usage intests/shortcuts/developer-tool.spec.tstest.afterAll
pagecomes from the default (test-scoped) fixture inplaywright/index.ts(no{ scope: 'worker' }), so using{ page }intest.afterAllforcloseAllCollections(page)risks lifecycle/teardown ordering issues; move this cleanup totest.afterEachor introduce a worker-scoped fixture for the shared app/page if you truly needafterAllsemantics.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/developer-tool.spec.ts` around lines 17 - 19, The teardown uses the test-scoped Playwright page in test.afterAll which can cause lifecycle issues; move the call to closeAllCollections(page) into test.afterEach so it receives the default test-scoped page fixture, or alternatively create a worker-scoped fixture in playwright/index.ts (e.g., a shared app/page) and use that worker-scoped fixture in test.afterAll; update references to closeAllCollections, test.afterAll, and test.afterEach accordingly so the cleanup runs with the correct fixture scope.tests/shortcuts/tabs-actions.spec.ts (1)
370-373:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove unrelated
Alt+Ykeypress at test endLine 370-Line 373 dispatches
Alt+Yin a save-all-tabs test without asserting its outcome. This introduces hidden state coupling and can create flaky behavior.Suggested patch
- await page.keyboard.down('Alt'); - await page.keyboard.down('KeyY'); - await page.keyboard.up('KeyY'); - await page.keyboard.up('Alt');As per coding guidelines, “Every E2E test should follow the Arrange-Act-Assert-Cleanup shape”.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/tabs-actions.spec.ts` around lines 370 - 373, In the save-all-tabs test remove the stray Alt+Y keypress sequence (page.keyboard.down/up for 'Alt' and 'KeyY') or replace it with an explicit Arrange/Act/Assert/Cleanup action: either delete the four lines dispatching 'Alt'+'KeyY' or, if that key combo is required, assert its expected effect (e.g., check UI/state) immediately after invoking it; locate the sequence by searching for the page.keyboard.down('Alt') / page.keyboard.down('KeyY') / page.keyboard.up('KeyY') / page.keyboard.up('Alt') calls and update accordingly to eliminate hidden state coupling and flakiness.
♻️ Duplicate comments (2)
tests/shortcuts/collections-env.spec.ts (1)
19-21:⚠️ Potential issue | 🟠 Major | ⚡ Quick winUse
afterEach(or remove this hook) instead ofafterAllwithpage.
pageis test-scoped; this suite-level teardown can fail or behave inconsistently.Proposed fix
- test.afterAll(async ({ page }) => { + test.afterEach(async ({ page }) => { await closeAllCollections(page); });#!/bin/bash rg -n "test\\.afterAll\\(async \\(\\{ page \\}\\)" tests/shortcuts/*.spec.tsAs per coding guidelines, "Follow best practices for Playwright code and e2e automation".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/collections-env.spec.ts` around lines 19 - 21, The teardown is using test.afterAll with the test-scoped fixture page, which can be unstable; change the suite-level hook to a per-test hook by replacing test.afterAll(async ({ page }) => closeAllCollections(page)); with test.afterEach(async ({ page }) => closeAllCollections(page)); or remove the hook entirely if per-test cleanup is not needed; ensure you update the hook name where test.afterAll is used and keep the closeAllCollections(page) call intact so it runs with the page fixture.tests/shortcuts/helpers.ts (1)
78-89:⚠️ Potential issue | 🟠 Major | ⚡ Quick winReplace fixed sleeps in
reopenClosedTabwith event-driven waits.The retry path uses hardcoded delays, which makes the shared helper flaky under variable CI timing.
Proposed fix
export const reopenClosedTab = async (page: Page, shortcut: () => Promise<void>, expectedTabName: string | RegExp) => { for (let attempt = 0; attempt < 3; attempt++) { await page.locator('.request-tab').first().click(); - await page.waitForTimeout(150); await shortcut(); const reopenedTab = page.locator('.request-tab').filter({ hasText: expectedTabName }); - if ((await reopenedTab.count()) > 0) { - await expect(reopenedTab).toBeVisible({ timeout: 3000 }); + if (await reopenedTab.isVisible({ timeout: 1000 }).catch(() => false)) { return; } - await page.waitForTimeout(200); } await expect(page.locator('.request-tab').filter({ hasText: expectedTabName })).toBeVisible({ timeout: 5000 }); };#!/bin/bash rg -n "waitForTimeout\\(" tests/shortcuts/helpers.tsAs per coding guidelines, "Try to reduce usage of
page.waitForTimeout();in code unless absolutely necessary and the locator cannot be found using existingexpect()playwright calls".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/helpers.ts` around lines 78 - 89, The helper reopenClosedTab currently relies on fixed waits (page.waitForTimeout) causing flakiness; replace those sleeps with event-driven waits by waiting for the expected tab locator to appear after triggering the shortcut. Specifically, in reopenClosedTab keep the retry loop and calls to page.locator('.request-tab').first().click() and await shortcut(), then replace the fixed delays with an explicit wait for the reopenedTab (the locator filtered by hasText(expectedTabName)) using an event-driven API such as reopenedTab.waitFor({ state: 'visible', timeout: 3000 }) or await expect(reopenedTab).toBeVisible({ timeout: 3000 }); remove the page.waitForTimeout(150) and page.waitForTimeout(200) calls so the function relies on the locator readiness instead of hardcoded sleeps.
🧹 Nitpick comments (5)
tests/shortcuts/search-actions.spec.ts (1)
23-61: ⚡ Quick winUse
test.stepblocks and a shared locator variable per test flow.Both tests are readable, but wrapping Arrange/Act/Assert in
test.stepand reusing aglobalSearchInputlocator will make reports clearer and reduce selector duplication as this suite grows.Suggested pattern
test('default Cmd/Ctrl+K Global Search Modal', async ({ page, createTmpDir }) => { + const globalSearchInput = page.getByTestId('global-search-input'); + + await test.step('Act: trigger global search shortcut', async () => { + await page.keyboard.down(modifier); + await page.keyboard.down('KeyK'); + await page.keyboard.up('KeyK'); + await page.keyboard.up(modifier); + }); - await page.keyboard.down(modifier); - await page.keyboard.down('KeyK'); - await page.keyboard.up('KeyK'); - await page.keyboard.up(modifier); - - await page.getByTestId('global-search-input').click(); - await expect(page.getByTestId('global-search-input')).toBeVisible({ timeout: 2000 }); + await test.step('Assert: search opens', async () => { + await globalSearchInput.click(); + await expect(globalSearchInput).toBeVisible({ timeout: 2000 }); + }); - await page.keyboard.down('Escape'); - await page.keyboard.up('Escape'); + await test.step('Assert: search closes', async () => { + await page.keyboard.press('Escape'); + await expect(globalSearchInput).toBeHidden({ timeout: 2000 }); + }); });As per coding guidelines, "Promote the use of
test.stepas much as possible so the generated reports are easier to read", "Use locator variables for locators", and "Every E2E test should follow the Arrange-Act-Assert-Cleanup shape."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/search-actions.spec.ts` around lines 23 - 61, The two tests ("default Cmd/Ctrl+K Global Search Modal" and "customized Alt+K Global Search Modal") should be refactored to use test.step blocks and a shared locator variable to improve readability and reporting: declare a locator (e.g., globalSearchInput = page.getByTestId('global-search-input')) at the start of each test, then wrap the Arrange, Act, Assert, and Cleanup portions in separate test.step(...) calls (for example steps named "Arrange", "Act", "Assert", "Cleanup") and replace direct page.getByTestId usages with the shared globalSearchInput locator; also apply the same pattern when interacting with keybinding elements (e.g., row, keybinding-edit-globalSearch, keybinding-input-globalSearch) to reduce selector duplication and follow the required AAA shape and reporting guidelines.tests/shortcuts/other-actions.spec.ts (1)
1-58: ⚡ Quick winAdd semicolons to satisfy repository TS/JS style rules.
Statements in this file consistently omit semicolons, which violates the project style requirement.
As per coding guidelines, "Always add semicolons at the end of statements".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/other-actions.spec.ts` around lines 1 - 58, Add missing semicolons across this test file to satisfy the TS/JS style rules: terminate all import lines (import { test, expect } ..., import { closeAllCollections } ..., import { modifier, setupBoundActionsData, openKeybindingsTab } ...), end standalone await statements and expression statements with semicolons (e.g., await page.locator(...).waitFor(...);, await setupBoundActionsData(page, createTmpDir);, await closeAllCollections(page);, all await page.keyboard.* calls;), and ensure any other statement lines inside the test blocks (expect assertions and variable declarations like const row = ...) also end with semicolons so functions/identifiers such as setupBoundActionsData, openKeybindingsTab, closeAllCollections, modifier, and row are all used in semicolon-terminated statements.tests/shortcuts/developer-tool.spec.ts (1)
25-26: ⚡ Quick winPrefer stable selectors and locator variables for sidebar interactions.
Class+text selectors here are brittle for UI evolution. Please switch these actions to stable test-id/role-based locators and keep them in local locator variables.
As per coding guidelines, "Use locator variables for locators" and "Replace brittle text/index selectors with role, label, test id, or stable user-facing selectors."
Also applies to: 41-43, 77-79, 95-96
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/developer-tool.spec.ts` around lines 25 - 26, Replace brittle class+text selectors with stable role/test-id locators and store them in local locator variables: create variables like collectionNameLocator = page.getByTestId('collection-name') or page.getByRole('link', { name: /kb-collection/i }) and requestTabLocator = page.getByTestId('request-tab') or page.getByRole('tab', { name: /collection/i }); then use collectionNameLocator.click() and await expect(requestTabLocator).toBeVisible({ timeout: 2000 }). Apply the same pattern for the other occurrences mentioned (lines ~41-43, ~77-79, ~95-96) so all sidebar interactions use stable test-id/role-based locators stored in local variables.tests/shortcuts/tabs-actions.spec.ts (2)
1-729: ⚡ Quick winApply required semicolon style consistently
This file omits semicolons across statements, which violates repository TS/JS formatting rules. Please run the configured formatter/linter autofix for this file.
As per coding guidelines, “Always add semicolons at the end of statements”.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/tabs-actions.spec.ts` around lines 1 - 729, The file is missing semicolons across many statements (imports and async calls) violating the project's semicolon style; run the repository's formatter/linter autofix (e.g., eslint --fix / Prettier) on the file and ensure semicolons are added consistently at the end of statements such as the import lines, all const/let declarations, and standalone awaits/expressions in functions like setupBoundActionsData, openKeybindingsTab, remapKeybinding, openRequest, closeTabByName, and reopenClosedTab; after autofix, run tests/lint to verify no remaining style errors.
285-374: ⚡ Quick winUse
test.stepfor multi-phase shortcut flowsThis scenario has distinct phases (remap, edit tabs, save, verify). Wrapping those phases in
test.stepwill improve trace readability and failure triage.As per coding guidelines, “Promote the use of
test.stepas much as possible so the generated reports are easier to read”.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/tabs-actions.spec.ts` around lines 285 - 374, This test ('Save all tabs customized (Alt+Shift+S)') performs multiple phases — wrap each phase in await test.step(...) to improve report clarity: 1) the "remap saveAllTabs" phase (calls using openKeybindingsTab, getByTestId edits and keyboard inputs), 2) the "edit collection tab headers" phase (locating collectionTab, clicking headers, editing nameEditor/valueEditor and asserting draft icons), 3) the "edit folder tab headers" phase (opening kb-draft-folder, editing folderNameEditor/folderValueEditor and asserting draft icons), and 4) the "save and verify" phase (sending Alt+Shift+S and assertions that has-changes-icon is gone for folderTab and collectionTab); wrap the existing blocks in descriptive test.step calls (e.g., await test.step('Remap saveAllTabs', async () => { ... })) keeping current awaits and helper calls (openKeybindingsTab, closePreferencesTab) intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@tests/shortcuts/developer-tool.spec.ts`:
- Around line 54-56: Replace hard-coded sleep waits with event-driven
assertions: remove the page.waitForTimeout(1000) after clicking the
'session-close-1' button and instead await the concrete UI transition by
asserting that getByTestId('session-list-1') is not visible (e.g., await
expect(page.getByTestId('session-list-1')).not.toBeVisible({ timeout: 3000 }))
before proceeding to click getByTestId('session-close-0'); likewise remove the
page.waitForTimeout(500) before checking getByTestId('session-list-0') since the
subsequent expect(page.getByTestId('session-list-0')).toBeVisible(...) already
performs the event-driven wait.
- Around line 17-19: The teardown uses the test-scoped Playwright page in
test.afterAll which can cause lifecycle issues; move the call to
closeAllCollections(page) into test.afterEach so it receives the default
test-scoped page fixture, or alternatively create a worker-scoped fixture in
playwright/index.ts (e.g., a shared app/page) and use that worker-scoped fixture
in test.afterAll; update references to closeAllCollections, test.afterAll, and
test.afterEach accordingly so the cleanup runs with the correct fixture scope.
In `@tests/shortcuts/other-actions.spec.ts`:
- Around line 41-55: The test currently opens the Keybindings UI then triggers
the remapped shortcut and asserts that the Preferences tab is visible, which can
give a false positive; modify the test around openKeybindingsTab,
keybinding-row-openPreferences, keybinding-edit-openPreferences and
keybinding-input-openPreferences so it first navigates to a different context
(e.g., ensure page.locator('.request-tab').filter({ hasText: 'Preferences' }) is
not visible), then close the Keybindings panel or navigate away, trigger the
shortcut via page.keyboard.down/up (using modifier + KeyP) and finally assert
the Preferences tab is visible—also add an assertion that the tab was absent
before the shortcut to validate before/after state and optionally reset the
keybinding as cleanup.
- Around line 47-53: Replace the unmatched key-down call that can leave
Backspace held: change the usage of page.keyboard.down('Backspace') in the test
(the call to page.keyboard.down('Backspace')) to a one-shot key action by using
page.keyboard.press('Backspace') so the Backspace key is released immediately
and downstream modifier chords (the subsequent page.keyboard.down(modifier) /
page.keyboard.down('KeyP') sequence) won’t be affected.
In `@tests/shortcuts/reqeust-actions.spec.ts`:
- Line 148: In the Playwright shortcut tests in reqeust-actions.spec.ts, replace
each await page.keyboard.down('Backspace') (found in the test cases around the
occurrences at lines where Backspace is used) with await
page.keyboard.press('Backspace') so the key is both pressed and released; this
removes the missing keyboard.up('Backspace') problem that can leave Backspace
"stuck" and makes the shortcut-capture deterministic.
- Around line 18-20: Replace the suite-level hook that incorrectly uses the
test-scoped page fixture: change test.afterAll(async ({ page }) => { await
closeAllCollections(page); }); to a test-scoped cleanup such as
test.afterEach(async ({ page }) => { await closeAllCollections(page); }); (or,
alternatively, convert closeAllCollections to use a worker-scoped fixture and
call it from test.afterAll without the page argument); update the hook name to
test.afterEach and keep the call to closeAllCollections(page) so the test-scoped
page fixture is used correctly.
In `@tests/shortcuts/search-actions.spec.ts`:
- Around line 32-34: The tests call page.keyboard.down('Escape') /
page.keyboard.up('Escape') but never assert the global search actually closed;
after each Escape press (the occurrences around page.keyboard.down('Escape') /
page.keyboard.up('Escape')), add an assertion that the global search UI is
dismissed — e.g. verify the search dialog/overlay locator used elsewhere in the
spec is not visible or not present (use the same locator/role the test suite
uses for global search) so both instances (the one at the first Escape and the
second at lines ~59-60) explicitly assert the closed state.
In `@tests/shortcuts/tabs-actions.spec.ts`:
- Around line 370-373: In the save-all-tabs test remove the stray Alt+Y keypress
sequence (page.keyboard.down/up for 'Alt' and 'KeyY') or replace it with an
explicit Arrange/Act/Assert/Cleanup action: either delete the four lines
dispatching 'Alt'+'KeyY' or, if that key combo is required, assert its expected
effect (e.g., check UI/state) immediately after invoking it; locate the sequence
by searching for the page.keyboard.down('Alt') / page.keyboard.down('KeyY') /
page.keyboard.up('KeyY') / page.keyboard.up('Alt') calls and update accordingly
to eliminate hidden state coupling and flakiness.
---
Duplicate comments:
In `@tests/shortcuts/collections-env.spec.ts`:
- Around line 19-21: The teardown is using test.afterAll with the test-scoped
fixture page, which can be unstable; change the suite-level hook to a per-test
hook by replacing test.afterAll(async ({ page }) => closeAllCollections(page));
with test.afterEach(async ({ page }) => closeAllCollections(page)); or remove
the hook entirely if per-test cleanup is not needed; ensure you update the hook
name where test.afterAll is used and keep the closeAllCollections(page) call
intact so it runs with the page fixture.
In `@tests/shortcuts/helpers.ts`:
- Around line 78-89: The helper reopenClosedTab currently relies on fixed waits
(page.waitForTimeout) causing flakiness; replace those sleeps with event-driven
waits by waiting for the expected tab locator to appear after triggering the
shortcut. Specifically, in reopenClosedTab keep the retry loop and calls to
page.locator('.request-tab').first().click() and await shortcut(), then replace
the fixed delays with an explicit wait for the reopenedTab (the locator filtered
by hasText(expectedTabName)) using an event-driven API such as
reopenedTab.waitFor({ state: 'visible', timeout: 3000 }) or await
expect(reopenedTab).toBeVisible({ timeout: 3000 }); remove the
page.waitForTimeout(150) and page.waitForTimeout(200) calls so the function
relies on the locator readiness instead of hardcoded sleeps.
---
Nitpick comments:
In `@tests/shortcuts/developer-tool.spec.ts`:
- Around line 25-26: Replace brittle class+text selectors with stable
role/test-id locators and store them in local locator variables: create
variables like collectionNameLocator = page.getByTestId('collection-name') or
page.getByRole('link', { name: /kb-collection/i }) and requestTabLocator =
page.getByTestId('request-tab') or page.getByRole('tab', { name: /collection/i
}); then use collectionNameLocator.click() and await
expect(requestTabLocator).toBeVisible({ timeout: 2000 }). Apply the same pattern
for the other occurrences mentioned (lines ~41-43, ~77-79, ~95-96) so all
sidebar interactions use stable test-id/role-based locators stored in local
variables.
In `@tests/shortcuts/other-actions.spec.ts`:
- Around line 1-58: Add missing semicolons across this test file to satisfy the
TS/JS style rules: terminate all import lines (import { test, expect } ...,
import { closeAllCollections } ..., import { modifier, setupBoundActionsData,
openKeybindingsTab } ...), end standalone await statements and expression
statements with semicolons (e.g., await page.locator(...).waitFor(...);, await
setupBoundActionsData(page, createTmpDir);, await closeAllCollections(page);,
all await page.keyboard.* calls;), and ensure any other statement lines inside
the test blocks (expect assertions and variable declarations like const row =
...) also end with semicolons so functions/identifiers such as
setupBoundActionsData, openKeybindingsTab, closeAllCollections, modifier, and
row are all used in semicolon-terminated statements.
In `@tests/shortcuts/search-actions.spec.ts`:
- Around line 23-61: The two tests ("default Cmd/Ctrl+K Global Search Modal" and
"customized Alt+K Global Search Modal") should be refactored to use test.step
blocks and a shared locator variable to improve readability and reporting:
declare a locator (e.g., globalSearchInput =
page.getByTestId('global-search-input')) at the start of each test, then wrap
the Arrange, Act, Assert, and Cleanup portions in separate test.step(...) calls
(for example steps named "Arrange", "Act", "Assert", "Cleanup") and replace
direct page.getByTestId usages with the shared globalSearchInput locator; also
apply the same pattern when interacting with keybinding elements (e.g., row,
keybinding-edit-globalSearch, keybinding-input-globalSearch) to reduce selector
duplication and follow the required AAA shape and reporting guidelines.
In `@tests/shortcuts/tabs-actions.spec.ts`:
- Around line 1-729: The file is missing semicolons across many statements
(imports and async calls) violating the project's semicolon style; run the
repository's formatter/linter autofix (e.g., eslint --fix / Prettier) on the
file and ensure semicolons are added consistently at the end of statements such
as the import lines, all const/let declarations, and standalone
awaits/expressions in functions like setupBoundActionsData, openKeybindingsTab,
remapKeybinding, openRequest, closeTabByName, and reopenClosedTab; after
autofix, run tests/lint to verify no remaining style errors.
- Around line 285-374: This test ('Save all tabs customized (Alt+Shift+S)')
performs multiple phases — wrap each phase in await test.step(...) to improve
report clarity: 1) the "remap saveAllTabs" phase (calls using
openKeybindingsTab, getByTestId edits and keyboard inputs), 2) the "edit
collection tab headers" phase (locating collectionTab, clicking headers, editing
nameEditor/valueEditor and asserting draft icons), 3) the "edit folder tab
headers" phase (opening kb-draft-folder, editing
folderNameEditor/folderValueEditor and asserting draft icons), and 4) the "save
and verify" phase (sending Alt+Shift+S and assertions that has-changes-icon is
gone for folderTab and collectionTab); wrap the existing blocks in descriptive
test.step calls (e.g., await test.step('Remap saveAllTabs', async () => { ...
})) keeping current awaits and helper calls (openKeybindingsTab,
closePreferencesTab) intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e4bfc688-7ad9-419a-823d-d62c1cfd2fa9
📒 Files selected for processing (8)
tests/shortcuts/collections-env.spec.tstests/shortcuts/developer-tool.spec.tstests/shortcuts/helpers.tstests/shortcuts/other-actions.spec.tstests/shortcuts/reqeust-actions.spec.tstests/shortcuts/search-actions.spec.tstests/shortcuts/sidebar-actions.spec.tstests/shortcuts/tabs-actions.spec.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/shortcuts/tabs-actions.spec.ts (1)
35-35: ⚡ Quick winRemove placeholder
// ;comments across the spec.These markers add non-functional noise and make this already large test file harder to review/maintain. Please remove them (or replace only with meaningful comments where context is actually needed).
As per coding guidelines, “No diffs unless an actual change is made…” and “Add in meaningful comments instead of obvious ones where complex code flow is explained properly.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/shortcuts/tabs-actions.spec.ts` at line 35, Remove all placeholder `// ;` comments from the tabs-actions.spec.ts file as they add non-functional noise and violate coding guidelines that require meaningful comments only. Search through the entire spec file and delete these empty comment markers wherever they appear, keeping only comments that provide actual context or explanation for complex code flow.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/shortcuts/search-actions.spec.ts`:
- Around line 42-52: The keyboard.down('Backspace') call on line 42 is never
paired with a corresponding keyboard.up('Backspace'), leaving the Backspace key
in a pressed state during the subsequent Shift+K keyboard sequences. Replace the
keyboard.down('Backspace') call with keyboard.press('Backspace') which
automatically handles both the down and up actions to properly release the key
state before the Shift+K sequences execute.
---
Nitpick comments:
In `@tests/shortcuts/tabs-actions.spec.ts`:
- Line 35: Remove all placeholder `// ;` comments from the tabs-actions.spec.ts
file as they add non-functional noise and violate coding guidelines that require
meaningful comments only. Search through the entire spec file and delete these
empty comment markers wherever they appear, keeping only comments that provide
actual context or explanation for complex code flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2fa64214-9f8e-4766-9950-dc7c7ccd5547
📒 Files selected for processing (8)
tests/shortcuts/collections-env.spec.tstests/shortcuts/developer-tool.spec.tstests/shortcuts/helpers.tstests/shortcuts/other-actions.spec.tstests/shortcuts/reqeust-actions.spec.tstests/shortcuts/search-actions.spec.tstests/shortcuts/sidebar-actions.spec.tstests/shortcuts/tabs-actions.spec.ts
💤 Files with no reviewable changes (4)
- tests/shortcuts/other-actions.spec.ts
- tests/shortcuts/reqeust-actions.spec.ts
- tests/shortcuts/developer-tool.spec.ts
- tests/shortcuts/collections-env.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/shortcuts/helpers.ts
- tests/shortcuts/sidebar-actions.spec.ts
Description
JIRA-1 - create new request in folder
JIRA-2 - fix flaky shortcuts tests and make them run parallel without any data dependency to previous test
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit
New Features
Behavior Changes
Tests