Repository navigation
feat: request restore - #7948
feat: request restore #7948
Conversation
WalkthroughThis PR implements tab UID synchronization in the RequestTab component to handle cases where a tab's pathname resolves to a collection item with a different UID, followed by comprehensive snapshot tests that verify request-pane tab interactivity is preserved across Electron app restarts for multiple request types. ChangesTab UID Synchronization & Snapshot Testing
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 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.
🧹 Nitpick comments (2)
tests/snapshots/basic.spec.ts (1)
820-821: ⚡ Quick winAvoid hardcoded 2s waits before restart in snapshot tests.
These sleeps can still race debounce timing and slow the suite. Use a condition-based wait (polling persisted snapshot/readiness) before
closeElectronApp.As 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”.Also applies to: 870-871
🤖 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/snapshots/basic.spec.ts` around lines 820 - 821, The test uses fixed 2s sleeps (page.waitForTimeout(2000)) before calling closeElectronApp which can cause flakiness and slow the suite; replace those hardcoded waits with a condition-based poll that waits for a deterministic snapshot/readiness signal (e.g., wait until persisted snapshot file exists, a specific DOM/state marker is present, or a readiness API returns true) before invoking closeElectronApp; update the two occurrences around lines referenced to use a polling loop with timeout that checks the snapshot/readiness condition instead of page.waitForTimeout, and reuse existing helpers or add a small helper (e.g., waitForSnapshotPersisted or waitForAppReady) to keep tests deterministic.tests/snapshots/request-pane-interactivity.spec.ts (1)
37-38: ⚡ Quick winReplace fixed sleeps with deterministic persistence checks.
page.waitForTimeout(2000)will be flaky under slower/faster CI. Prefer an explicit condition (e.g., polling for snapshot state/file update) before closing the app.As 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”.Also applies to: 86-87
🤖 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/snapshots/request-pane-interactivity.spec.ts` around lines 37 - 38, The test currently uses page.waitForTimeout(2000) before calling closeElectronApp(app), which is flaky; replace these fixed sleeps (both the occurrence around page.waitForTimeout and the similar occurrences at lines 86-87) with a deterministic persistence check — e.g., poll for the snapshot state or file update that the test expects (using page.waitForSelector, expect.poll, or a custom waitForFunction that checks the snapshot file/DB/state) and only call closeElectronApp(app) after that condition is satisfied; update the test code around the page.waitForTimeout calls and the closeElectronApp invocation to await that explicit condition instead of a fixed timeout.
🤖 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.
Nitpick comments:
In `@tests/snapshots/basic.spec.ts`:
- Around line 820-821: The test uses fixed 2s sleeps (page.waitForTimeout(2000))
before calling closeElectronApp which can cause flakiness and slow the suite;
replace those hardcoded waits with a condition-based poll that waits for a
deterministic snapshot/readiness signal (e.g., wait until persisted snapshot
file exists, a specific DOM/state marker is present, or a readiness API returns
true) before invoking closeElectronApp; update the two occurrences around lines
referenced to use a polling loop with timeout that checks the snapshot/readiness
condition instead of page.waitForTimeout, and reuse existing helpers or add a
small helper (e.g., waitForSnapshotPersisted or waitForAppReady) to keep tests
deterministic.
In `@tests/snapshots/request-pane-interactivity.spec.ts`:
- Around line 37-38: The test currently uses page.waitForTimeout(2000) before
calling closeElectronApp(app), which is flaky; replace these fixed sleeps (both
the occurrence around page.waitForTimeout and the similar occurrences at lines
86-87) with a deterministic persistence check — e.g., poll for the snapshot
state or file update that the test expects (using page.waitForSelector,
expect.poll, or a custom waitForFunction that checks the snapshot file/DB/state)
and only call closeElectronApp(app) after that condition is satisfied; update
the test code around the page.waitForTimeout calls and the closeElectronApp
invocation to await that explicit condition instead of a fixed timeout.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4e90e3be-3004-49f5-b74c-4299b5e8ef31
📒 Files selected for processing (3)
packages/bruno-app/src/components/RequestTabs/RequestTab/index.jstests/snapshots/basic.spec.tstests/snapshots/request-pane-interactivity.spec.ts
There was a problem hiding this comment.
Pull request overview
Adds a safeguard to keep restored request tabs correctly wired to their underlying request items after app restart, and introduces Playwright snapshot tests to prevent regressions where request-pane tabs become non-interactive after restore.
Changes:
- Sync restored request tab
uidto the resolved collection itemuidwhen a restored tab was created with a pathname fallback. - Add snapshot e2e coverage for request-pane tab interactivity after restart (HTTP/GraphQL/gRPC/WebSocket).
- Extend existing snapshot suite with additional restore/interactivity scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/bruno-app/src/components/RequestTabs/RequestTab/index.js |
Synces restored request tab UID to the real request UID once the item is resolvable, fixing post-restore interactivity issues. |
tests/snapshots/request-pane-interactivity.spec.ts |
New snapshot e2e tests for gRPC and WebSocket request-pane tab interactivity after restart. |
tests/snapshots/basic.spec.ts |
Adds snapshot e2e coverage for basic HTTP and GraphQL request-pane tab interactivity after restart. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
JIRA
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
Release Notes
Bug Fixes
Tests