Skip to content

added create collection testcase and few import testcases#8402

Open
aman-bruno wants to merge 1 commit into
usebruno:mainfrom
aman-bruno:testcase/3578CreateAndImportCollection
Open

added create collection testcase and few import testcases#8402
aman-bruno wants to merge 1 commit into
usebruno:mainfrom
aman-bruno:testcase/3578CreateAndImportCollection

Conversation

@aman-bruno

@aman-bruno aman-bruno commented Jun 29, 2026

Copy link
Copy Markdown

Description

3578 -> create and import collection testcases
Edited the current testcases to be more robust and match the actual browserstack cases.

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 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.

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

    • Improved collection import and creation flows with clearer on-screen feedback and updated UI steps.
    • Added support for Git repository import flow, including cloning and opening selected collections.
  • Bug Fixes

    • Expanded verification of import and collection creation success messages to better confirm completed actions.
    • Improved reliability of the import experience with more explicit UI checks during each step.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Extends buildCommonLocators in tests/utils/page/locators.ts with toast message locators and expanded import modal locators (tabs, inputs, clone flow sub-namespace). Three Playwright specs are refactored to use these shared locators with test.step-based flows and explicit success assertions replacing prior ad-hoc selectors.

E2E Test Locator and Spec Refactors

Layer / File(s) Summary
Shared locator extensions
tests/utils/page/locators.ts
Adds toast group with three text-based toast locators; extends import locators with modal title, tab selectors, URL/Git URL inputs, clone/import buttons, loader, and nested cloneGit namespace for the clone dialog.
Create collection spec
tests/collection/create/create-collection.spec.ts
Imports buildCommonLocators; replaces the old HTTP-request-creation test with TC99 sanity test asserting collection-created toast and sidebar entry visibility.
GitHub repo import spec
tests/import/url-import/github-repository-import.spec.ts
Rewrites test as TC114 with step-driven flow: opens import modal, enters Git URL, stubs Electron's open-dialog to supply a temp clone dir, triggers clone, selects collection checkbox, clicks open, and asserts sidebar and success toast.
Insomnia URL import spec
tests/import/url-import/insomnia-url-import.spec.ts
Refactors single test to use locators/importLocators with test.step stages: modal/tab verification, URL fill and value assertion, loader wait, location modal input, import click, modal close, and sidebar visibility assertion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • usebruno/bruno#6321: Also modifies tests/utils/page/locators.ts and buildCommonLocators used by the same import/create test flows.
  • usebruno/bruno#7813: Replaced the Git clone dialog's checkbox list with a SelectionList component — directly relates to the new cloneGit selection checkbox locators added here.
  • usebruno/bruno#8121: Import modal revamp adding clone/selection behaviors and success toasts aligns with the new toast locators and cloneGit modal selectors.

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • bijin-bruno
  • naman-bruno

Poem

🧪 Locators bloom, shared and neat,
Steps now march in ordered beat.
Toast confirms the clone is done,
Sidebar shows the collections won.
TC99, TC114 — tests complete! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title matches the PR scope by describing the added create-collection test and multiple import test cases.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
tests/import/url-import/insomnia-url-import.spec.ts (1)

56-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the shared folder locators here instead of the raw CSS class.

These assertions still depend on .collection-item-name, which makes the test more DOM-structure-sensitive than the rest of this refactor. Prefer locators.sidebar.folder('API Tests') / locators.sidebar.folder('Data Management') so the check stays aligned with the shared locator layer.

As per coding guidelines, E2E tests should Replace brittle text/index selectors with role, label, test id, or stable user-facing selectors.

🤖 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/import/url-import/insomnia-url-import.spec.ts` around lines 56 - 57,
The assertions in the import URL spec still use the raw .collection-item-name
CSS selector, which makes the test brittle. Update the checks to use the shared
sidebar folder locator helpers from locators.sidebar.folder(...) for both “API
Tests” and “Data Management” so the test relies on the stable locator layer
instead of DOM structure.

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/collection/create/create-collection.spec.ts`:
- Around line 56-61: The collection name in create-collection.spec.ts is
hardcoded, which makes TC99 vulnerable to stale state and parallel test
collisions. Update the test to derive the visible collection name from per-test
isolated state instead of a fixed literal, and pass that same unique value
through createCollection and the sidebar assertion in
buildCommonLocators/collection.collectionName usage so each run uses a distinct
collection.

In `@tests/import/url-import/github-repository-import.spec.ts`:
- Around line 45-50: Restore the worker-scoped Electron dialog stub in the
github repository import spec by saving the original dialog.showOpenDialog
before overriding it inside the electronApp.evaluate block and restoring it
immediately after the location picker interaction completes. Update the test
flow around the dialog stub in github-repository-import.spec.ts so the fake
dialog is only active for the minimal scope and does not leak into later specs
that share the same electronApp worker state.

In `@tests/utils/page/locators.ts`:
- Around line 269-271: The collection-selection locators are too broad and can
match elements outside the clone modal, causing flaky imports. Update the
`collectionItemTitle` and `collectionCheckbox` helpers in `locators.ts` to scope
all queries to the `'Clone Git Repository'` modal and use exact matching for the
collection name instead of partial text. Use the existing locator helpers as the
entry point, and replace the current global `.selection-item*` selectors with
stable user-facing modal-scoped selectors.

---

Nitpick comments:
In `@tests/import/url-import/insomnia-url-import.spec.ts`:
- Around line 56-57: The assertions in the import URL spec still use the raw
.collection-item-name CSS selector, which makes the test brittle. Update the
checks to use the shared sidebar folder locator helpers from
locators.sidebar.folder(...) for both “API Tests” and “Data Management” so the
test relies on the stable locator layer instead of DOM structure.
🪄 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: 2237123e-952e-4bdc-ad58-d84561a57f73

📥 Commits

Reviewing files that changed from the base of the PR and between 87f7426 and b357d08.

📒 Files selected for processing (4)
  • tests/collection/create/create-collection.spec.ts
  • tests/import/url-import/github-repository-import.spec.ts
  • tests/import/url-import/insomnia-url-import.spec.ts
  • tests/utils/page/locators.ts

Comment on lines +56 to +61
test('TC99: Verify user able to Create a new collection', { tag: '@sanity' }, async ({ page, createTmpDir }) => {
const collectionName = 'test-collection';
const requestName = 'ping';

const locators = buildCommonLocators(page);
await createCollection(page, collectionName, await createTmpDir(collectionName));

// Create a new request using the dialog/modal flow
await createRequest(page, requestName, collectionName);

// Set the URL
await page.locator('#request-url .CodeMirror').click();
await page.locator('#request-url').locator('textarea').fill('http://localhost:8081');
await page.locator('#request-actions').getByTitle('Save Request').click();

// Send a request
await page.locator('#request-url .CodeMirror').click();
await page.locator('#request-url').locator('textarea').fill('/ping');
await page.locator('#request-actions').getByTitle('Save Request').click();
await page.getByTestId('send-arrow-icon').click();

// Verify the response
await expect(page.getByRole('main')).toContainText('200 OK');
await expect(locators.toast.collectionCreated()).toBeVisible();
await expect(locators.sidebar.collection(collectionName)).toBeVisible();

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Make the collection name unique per test instance.

Line 57 hardcodes 'test-collection', but the cleanup here only closes collections. That leaves this spec vulnerable to stale app state: an existing collection with the same name can satisfy the sidebar assertion, or reruns/workers can trip duplicate-name handling. Please derive the visible collection name from isolated per-test state instead of a fixed literal. As per coding guidelines, "E2E tests must be parallel-safe. No shared user data directories... Each test gets isolated temp paths and unique workspace/project names." As per path instructions, "Each test gets isolated temp paths and unique workspace/project names."

🤖 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/create/create-collection.spec.ts` around lines 56 - 61, The
collection name in create-collection.spec.ts is hardcoded, which makes TC99
vulnerable to stale state and parallel test collisions. Update the test to
derive the visible collection name from per-test isolated state instead of a
fixed literal, and pass that same unique value through createCollection and the
sidebar assertion in buildCommonLocators/collection.collectionName usage so each
run uses a distinct collection.

Sources: Coding guidelines, Path instructions

Comment on lines +45 to +50
await electronApp.evaluate(({ dialog }, dir) => {
dialog.showOpenDialog = async () => ({
canceled: false,
filePaths: [dir]
});
}, cloneLocation);

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.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Restore the Electron dialog stub before the test exits.

This overwrites dialog.showOpenDialog on the worker-scoped electronApp and never puts it back, so later specs in the same worker can inherit the fake dialog and become order-dependent. Save the original function and restore it after the location picker interaction completes.

As per coding guidelines, E2E tests must be parallel-safe with no shared global app state.

🤖 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/import/url-import/github-repository-import.spec.ts` around lines 45 -
50, Restore the worker-scoped Electron dialog stub in the github repository
import spec by saving the original dialog.showOpenDialog before overriding it
inside the electronApp.evaluate block and restoring it immediately after the
location picker interaction completes. Update the test flow around the dialog
stub in github-repository-import.spec.ts so the fake dialog is only active for
the minimal scope and does not leak into later specs that share the same
electronApp worker state.

Source: Coding guidelines

Comment on lines +269 to +271
collectionItemTitle: (name: string) => page.locator('.selection-item-title').filter({ hasText: name }),
collectionCheckbox: (name: string) =>
page.locator('.selection-item').filter({ hasText: name }).locator('input[type="checkbox"]')

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Scope the collection-selection locators to the clone modal.

These two locators search the whole page and use partial text matching, so another .selection-item* elsewhere with the same/subset name can satisfy them and make the import flow flaky. Anchor both to the 'Clone Git Repository' modal and match the collection name exactly. As per path instructions, replace brittle selectors with stable user-facing selectors in E2E tests.

Proposed fix
-      collectionItemTitle: (name: string) => page.locator('.selection-item-title').filter({ hasText: name }),
-      collectionCheckbox: (name: string) =>
-        page.locator('.selection-item').filter({ hasText: name }).locator('input[type="checkbox"]')
+      collectionItemTitle: (name: string) =>
+        page
+          .locator('.bruno-modal-card')
+          .filter({ hasText: 'Clone Git Repository' })
+          .locator('.selection-item-title')
+          .getByText(name, { exact: true }),
+      collectionCheckbox: (name: string) =>
+        page
+          .locator('.bruno-modal-card')
+          .filter({ hasText: 'Clone Git Repository' })
+          .locator('.selection-item')
+          .filter({ has: page.getByText(name, { exact: true }) })
+          .locator('input[type="checkbox"]')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
collectionItemTitle: (name: string) => page.locator('.selection-item-title').filter({ hasText: name }),
collectionCheckbox: (name: string) =>
page.locator('.selection-item').filter({ hasText: name }).locator('input[type="checkbox"]')
collectionItemTitle: (name: string) =>
page
.locator('.bruno-modal-card')
.filter({ hasText: 'Clone Git Repository' })
.locator('.selection-item-title')
.getByText(name, { exact: true }),
collectionCheckbox: (name: string) =>
page
.locator('.bruno-modal-card')
.filter({ hasText: 'Clone Git Repository' })
.locator('.selection-item')
.filter({ has: page.getByText(name, { exact: true }) })
.locator('input[type="checkbox"]')
🤖 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/utils/page/locators.ts` around lines 269 - 271, The
collection-selection locators are too broad and can match elements outside the
clone modal, causing flaky imports. Update the `collectionItemTitle` and
`collectionCheckbox` helpers in `locators.ts` to scope all queries to the
`'Clone Git Repository'` modal and use exact matching for the collection name
instead of partial text. Use the existing locator helpers as the entry point,
and replace the current global `.selection-item*` selectors with stable
user-facing modal-scoped selectors.

Source: Path instructions

@aman-bruno aman-bruno changed the title added open collection testcase and few import testcases added create collection testcase and few import testcases Jun 29, 2026
// Test GitHub repository import
await page.getByTestId('collections-header-add-menu').click();
await page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Import collection' }).click();
await test.step('Step 01: Go to menu click on the + icon', 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.

please remove step numbers

@pooja-bruno

Copy link
Copy Markdown
Collaborator

@bijin-bruno, is it okay to update the existing tests? Most of the changes involve improving tests that already exist.

submitButton: () => page.locator('.bruno-modal-footer .submit'),
newRequestMethodOption: (id: string) => page.getByTestId(`method-selector-${id.toLowerCase()}`)
},
toast: {

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.

Move toast locators to own file. Add generic method like for success, error, custom etc, no need to create methods for every messages.
eg: toast.success(message)

// merge with common locators
toast: buildToastLocators(page),
// usage
const { toast, sidebar, environment } = buildCommonLocators();

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.

3 participants