Skip to content

test: Add playwright coverage for open multiple nested collections in bruno. - #9696

Closed
ved-bruno wants to merge 4 commits into
usebruno:tests/open-collection-internalfrom
ved-bruno:open-collection-tests
Closed

ved-bruno wants to merge 4 commits into
usebruno:tests/open-collection-internalfrom
ved-bruno:open-collection-tests

Conversation

@ved-bruno

@ved-bruno ved-bruno commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds Playwright coverage for opening collections that live in nested folders, and tags the existing multiple-collection open flow as a sanity test.

  • TC-4448 — a parent folder that itself is a collection, with two sibling collections inside it, lists all three in the Open Collection modal. Selecting all of them opens all three in the sidebar.
  • TC-4449 — collections several folders deep are discovered from the chosen root and open in the sidebar after they are selected.
  • TC-777 — Added TC id for opening multiple collections is now part of the @sanity run.

Fix

  • For TC-777 Save and restore showOpenDialog on global inside the Electron process in open-multiple-collections.spec.ts, matching the other open-collection specs.

Screenshots

Attaching screen records for reference:

Screen.Recording.2026-10-29.at.4.02.55.PM.mov
Screen.Recording.2026-10-29.at.4.08.09.PM.mov

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have tested these changes locally and confirmed they work as expected.
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.
  • I've run the claude code review skill locally.

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

  • Tests
    • Expanded automated coverage for opening collections nested across multiple folder levels, including sibling collections and collections at greater depths.
    • Added checks that collections appear in the picker and sidebar after selection, including when opening multiple collections.
    • Improved test isolation by restoring dialog behavior and closing opened collections after each test.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review: 2

  • main
  • release/*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The change adds Playwright coverage for opening collections nested at multiple folder depths. It also updates dialog restoration and adds named steps and test metadata to the existing multiple-collections tests.

Changes

Collection Picker Tests

Layer / File(s) Summary
Nested collection picker coverage
tests/collection/open/open-nested-collections.spec.ts, tests/collection/open/open-deeplynested-collections.spec.ts
New tests create nested collections, open their parent or common root, check that collections appear in the picker, and verify that selected collections appear in the sidebar.
Multiple-collection test steps
tests/collection/open/open-multiple-collections.spec.ts
The tests group existing actions and checks into named steps. The first test saves and restores the dialog handler through global and adds a TC-777 prefix and @sanity tag.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: Minimal · up to 917ab

The change adds collection-picker coverage without an identified merge-blocking issue.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: adding Playwright coverage for opening multiple nested collections in Bruno.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 3 files.

Finishing Touches

Fix failing CI checks

  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Three folders wait beneath the root,
The picker lists each nested route.
Select, and see them in the side,
Test steps mark the checks inside.
The dialog returns to its place.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a69ee32 and 917ab36.

Files selected for processing: 3

  • tests/collection/open/open-deeplynested-collections.spec.ts
  • tests/collection/open/open-multiple-collections.spec.ts
  • tests/collection/open/open-nested-collections.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔇 Additional comments: 1
tests/collection/open/open-deeplynested-collections.spec.ts-20-20: 1

20-20: Minor · Functional Correctness · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Remove the saved dialog global after restoration.

This hook restores dialog.showOpenDialog but leaves global.__origShowOpenDialog in the worker-scoped Electron process. Delete the saved property after restoration. Apply the same cleanup in open-nested-collections.spec.ts and open-multiple-collections.spec.ts; both use this key. Bruno’s coding standards prohibit shared global app state, and the retrieved test guidance requires cleanup of globals created by tests. (raw.githubusercontent.com)

Sources: Coding guidelines, Learnings


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 049335a and 02fb8c4.

Files selected for processing: 3
  • tests/collection/open/open-deeplynested-collections.spec.ts
  • tests/collection/open/open-multiple-collections.spec.ts
  • tests/collection/open/open-nested-collections.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@sahana-bruno sahana-bruno left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@sanish-bruno
sanish-bruno changed the base branch from main to tests/open-collection-internal November 5, 2026 11:30
Comment on lines +106 to +109
await test.step('Wait for error toasts to appear', async () => {
// Wait for error toasts to appear
await page.waitForTimeout(1000);
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The invalid-path test sleeps for a fixed second before asserting on the error toast, so it flakes when toasts render slower or faster than the timeout while the following expect already retries.

Suggested change
await test.step('Wait for error toasts to appear', async () => {
// Wait for error toasts to appear
await page.waitForTimeout(1000);
});

});

test('Should open multiple collections using Open Collection feature', async ({
test('TC-777 Should open multiple collections using Open Collection feature', { tag: '@sanity' }, async ({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TC-777 only calls closeAllCollections on the success path, so a failed assertion leaves opened collections on the worker for later specs.

Suggested change
test('TC-777 Should open multiple collections using Open Collection feature', { tag: '@sanity' }, async ({
test.afterEach(async ({ page }) => {
await closeAllCollections(page);
});
test('TC-777 Should open multiple collections using Open Collection feature', { tag: '@sanity' }, async ({

Comment on lines +59 to +61
for (const { name } of collections) {
await expect(openCollectionPicker.item(name)).toBeVisible();
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TC-4449 checks nested collection names only, so a regression that shows wrong relative paths in the picker still passes while users cannot tell deep collections apart.

Suggested change
for (const { name } of collections) {
await expect(openCollectionPicker.item(name)).toBeVisible();
}
for (const { dir, name } of collections) {
await expect(openCollectionPicker.item(name)).toBeVisible();
await expect(openCollectionPicker.descriptions()).toContainText(path.relative(rootDir, dir));
}

@@ -4,23 +4,19 @@ import * as fs from 'fs';
import { closeAllCollections } from '../../utils/page';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file imports only closeAllCollections while it still uses raw page.locator and getByTestId calls that buildCommonLocators in tests/utils/page already centralizes.

Suggested change
import { closeAllCollections } from '../../utils/page';
import { buildCommonLocators, closeAllCollections } from '../../utils/page';

});

await test.step('Collection is not in the sidebar yet', async () => {
await expect(page.locator('#sidebar-collection-name').getByText('Test Collection 1')).not.toBeVisible();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pre-open sidebar check uses inline #sidebar-collection-name selectors instead of the shared sidebar.collection locator used in the new nested open specs.

Suggested change
await expect(page.locator('#sidebar-collection-name').getByText('Test Collection 1')).not.toBeVisible();
const { sidebar } = buildCommonLocators(page);
await expect(sidebar.collection('Test Collection 1')).not.toBeVisible();

});

await test.step('Click on plus icon button and then "Open collection" in the dropdown', async () => {
await page.getByTestId('collections-header-add-menu').click();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TC-777 opens collections through hand-rolled add-menu selectors even though buildCommonLocators(page).plusMenu already wraps the same elements.

Suggested change
await page.getByTestId('collections-header-add-menu').click();
const { plusMenu } = buildCommonLocators(page);
await plusMenu.button().click();
await plusMenu.openCollection().click();

Comment on lines +66 to +67
const collection1Element = page.locator('#sidebar-collection-name').getByText('Test Collection 1');
const collection2Element = page.locator('#sidebar-collection-name').getByText('Test Collection 2');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post-open assertions still target #sidebar-collection-name directly, so a sidebar DOM change would not fail consistently with the helper-based nested specs.

Suggested change
const collection1Element = page.locator('#sidebar-collection-name').getByText('Test Collection 1');
const collection2Element = page.locator('#sidebar-collection-name').getByText('Test Collection 2');
const { sidebar } = buildCommonLocators(page);
await expect(sidebar.collection('Test Collection 1')).toBeVisible();
await expect(sidebar.collection('Test Collection 2')).toBeVisible();

@@ -83,26 +87,36 @@ test.describe('Open Multiple Collections', () => {
// Count collections before attempting to open invalid ones
const collectionCountBefore = await page.locator('#sidebar-collection-name').count();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The invalid-path test snapshots open collection count with a raw #sidebar-collection-name locator instead of sidebar.collection() from tests/utils/page.

Suggested change
const collectionCountBefore = await page.locator('#sidebar-collection-name').count();
const { sidebar, plusMenu } = buildCommonLocators(page);
const collectionCountBefore = await sidebar.collection().count();

await page.getByTestId('collections-header-add-menu').click();
await page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Open collection' }).click();
await test.step('Click on plus icon button and then "Open collection" in the dropdown', async () => {
await page.getByTestId('collections-header-add-menu').click();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The invalid-path flow repeats inline add-menu clicks instead of the shared plusMenu helper already used elsewhere in open-collection tests.

Suggested change
await page.getByTestId('collections-header-add-menu').click();
await plusMenu.button().click();
await plusMenu.openCollection().click();

await expect(page.locator('#sidebar-collection-name')).toHaveCount(collectionCountBefore);
await test.step('Verify no collections were opened', async () => {
// Verify no collections were opened
await expect(page.locator('#sidebar-collection-name')).toHaveCount(collectionCountBefore);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The post-error collection count assertion still queries #sidebar-collection-name inline rather than the shared sidebar locator builder.

Suggested change
await expect(page.locator('#sidebar-collection-name')).toHaveCount(collectionCountBefore);
await expect(sidebar.collection()).toHaveCount(collectionCountBefore);

@sanish-bruno

Copy link
Copy Markdown
Collaborator

closing this as this is already handled on #9758

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants