Repository navigation
fix(migration): remaped snapshot tab paths and preserve uids on bru-t… - #8450
Conversation
WalkthroughThis PR records migrated request paths during .bru to .yml conversion, remaps stored collection tab pathnames and active tab values, and adds unit and end-to-end tests covering the migration. ChangesSnapshot tab remapping during YML migration
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant collection.js
participant FileSystem
participant SnapshotManager
participant electron-store
collection.js->>FileSystem: Convert .bru files to .yml
collection.js->>collection.js: Record old path -> new path in tabPathMap
collection.js->>FileSystem: Delete old .bru files and bruno.json
collection.js->>SnapshotManager: remapCollectionTabPaths(collectionPathname, tabPathMap)
SnapshotManager->>SnapshotManager: Normalize and apply pathname remaps
SnapshotManager->>electron-store: Persist updated snapshot
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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
🧹 Nitpick comments (3)
tests/collection/migrate-to-yml/migrate-to-yml.spec.ts (2)
154-154: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueExtract the repeated
pingitem locator into a variable.The
.item-namelocator filtered on "ping" is duplicated at Line 154 and Line 195.🩹 Proposed fix
+ const pingItem = page.locator('.item-name').filter({ hasText: 'ping' }); + await test.step('Open the ping request as a permanent tab', async () => { await openCollection(page, 'migration-test'); - await page.locator('.item-name').filter({ hasText: 'ping' }).dblclick(); + await pingItem.dblclick();await test.step('The migrated request opens against the yml file and is runnable', async () => { - await page.locator('.item-name').filter({ hasText: 'ping' }).click(); + await pingItem.click();As per path instructions, "Use locator variables for locators."
Also applies to: 195-195
🤖 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/collection/migrate-to-yml/migrate-to-yml.spec.ts` at line 154, The repeated ping item locator should be extracted into a shared variable in the migration spec so the same .item-name filter is not duplicated. Update the relevant test flow in migrate-to-yml.spec.ts by creating a locator variable for the ping item and reuse it in both places where the current page.locator('.item-name').filter({ hasText: 'ping' }) is used, keeping the test readable and consistent with the locator-variable pattern.Source: Path instructions
207-207: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueWrap the final page-error assertion in a
test.step.Every other assertion group in this test is wrapped in
test.stepfor readable reports; this trailing check isn't.🩹 Proposed fix
- expect(pageErrors).toHaveLength(0); + await test.step('No uncaught page errors occurred during migration', async () => { + expect(pageErrors).toHaveLength(0); + });As per path instructions, "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/collection/migrate-to-yml/migrate-to-yml.spec.ts` at line 207, The trailing page-error check in migrate-to-yml.spec.ts is not wrapped in a test.step like the other assertion groups. Update the final expect(pageErrors).toHaveLength(0) assertion to run inside a test.step in the same style used elsewhere in this test so the report remains consistent and readable.Source: Path instructions
packages/bruno-electron/src/services/snapshot/index.js (1)
207-283: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winImplementation looks correct.
Normalization, validation, and remap logic (pathname +
pathname::exampleName/pathname::exampleIndexsuffix preservation) match the unit test expectations insnapshot-remap.spec.js.Given this is a new cross-file public API consumed by
collection.js, a short JSDoc onremapCollectionTabPathsdocumenting thepathMapcontract (old→new absolute paths) and whichactiveTabaccessors are handled would help future maintainers.As per coding guidelines, "Add JSDoc comments to add more details to abstractions if needed."
🤖 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 `@packages/bruno-electron/src/services/snapshot/index.js` around lines 207 - 283, Add a short JSDoc for remapCollectionTabPaths in the snapshot service to document the pathMap contract (old absolute path to new absolute path) and clarify which activeTab accessors are remapped. Place it near the remapCollectionTabPaths method in the Snapshot service so consumers like collection.js can understand the API without inspecting the implementation. Keep the description concise and focused on the supported pathname, pathname::exampleName, and pathname::exampleIndex behavior.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 `@packages/bruno-electron/src/ipc/collection.js`:
- Around line 2738-2742: The try/catch around
snapshotManager.remapCollectionTabPaths in the collection IPC migration handler
is swallowing errors completely. Keep the best-effort behavior, but in the catch
block log the caught error with console.error so failures are observable,
matching the other error handling in this handler while still allowing migration
to continue.
---
Nitpick comments:
In `@packages/bruno-electron/src/services/snapshot/index.js`:
- Around line 207-283: Add a short JSDoc for remapCollectionTabPaths in the
snapshot service to document the pathMap contract (old absolute path to new
absolute path) and clarify which activeTab accessors are remapped. Place it near
the remapCollectionTabPaths method in the Snapshot service so consumers like
collection.js can understand the API without inspecting the implementation. Keep
the description concise and focused on the supported pathname,
pathname::exampleName, and pathname::exampleIndex behavior.
In `@tests/collection/migrate-to-yml/migrate-to-yml.spec.ts`:
- Line 154: The repeated ping item locator should be extracted into a shared
variable in the migration spec so the same .item-name filter is not duplicated.
Update the relevant test flow in migrate-to-yml.spec.ts by creating a locator
variable for the ping item and reuse it in both places where the current
page.locator('.item-name').filter({ hasText: 'ping' }) is used, keeping the test
readable and consistent with the locator-variable pattern.
- Line 207: The trailing page-error check in migrate-to-yml.spec.ts is not
wrapped in a test.step like the other assertion groups. Update the final
expect(pageErrors).toHaveLength(0) assertion to run inside a test.step in the
same style used elsewhere in this test so the report remains consistent and
readable.
🪄 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: 5bd59d33-ea7c-44b5-88fa-3ecc27940551
📒 Files selected for processing (4)
packages/bruno-electron/src/ipc/collection.jspackages/bruno-electron/src/services/snapshot/index.jspackages/bruno-electron/tests/services/snapshot-remap.spec.jstests/collection/migrate-to-yml/migrate-to-yml.spec.ts
utkarsh-bruno
left a comment
There was a problem hiding this comment.
Looks good to me.
BRU-3683
Description
Issue: When migrating a Bruno collection from the Bru format to YAML, any requests that are currently kept open during the conversion process break, displaying a "Request No Longer Exists" error. This affects both transient and normal requests.
Cause & Resolution: The issue occurs because the open tab/snapshot paths are broken and unique identifiers (UIDs) are lost during the migration. Added fix which remaps the snapshot tab paths and preserves the UIDs during the bru-to-yaml conversion.
Contribution Checklist:
Summary by CodeRabbit