added create collection testcase and few import testcases#8402
added create collection testcase and few import testcases#8402aman-bruno wants to merge 1 commit into
Conversation
WalkthroughExtends E2E Test Locator and Spec Refactors
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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: 3
🧹 Nitpick comments (1)
tests/import/url-import/insomnia-url-import.spec.ts (1)
56-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse 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. Preferlocators.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
📒 Files selected for processing (4)
tests/collection/create/create-collection.spec.tstests/import/url-import/github-repository-import.spec.tstests/import/url-import/insomnia-url-import.spec.tstests/utils/page/locators.ts
| 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(); |
There was a problem hiding this comment.
🩺 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
| await electronApp.evaluate(({ dialog }, dir) => { | ||
| dialog.showOpenDialog = async () => ({ | ||
| canceled: false, | ||
| filePaths: [dir] | ||
| }); | ||
| }, cloneLocation); |
There was a problem hiding this comment.
🩺 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
| 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"]') |
There was a problem hiding this comment.
🩺 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.
| 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
| // 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 () => { |
There was a problem hiding this comment.
please remove step numbers
|
@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: { |
There was a problem hiding this comment.
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();
Description
3578 -> create and import collection testcases
Edited the current testcases to be more robust and match the actual browserstack cases.
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
Bug Fixes