Repository navigation
improve: tests - #6321
improve: tests#6321
Conversation
WalkthroughConsolidates repeated UI test interactions into shared helpers and locators (importCollection, environment helpers, sendRequest, createRequest, locators, runner helpers), replaces brittle visibility booleans with explicit locator waits/races, and updates many tests to use the new utilities and extended timeouts. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/preferences/autosave/autosave.spec.ts (1)
108-113: Test no longer verifies “no autosave within ~2s” semantics
await expect(requestTab.locator('.has-changes-icon')).toBeVisible({ timeout: 2000 });will typically return immediately because the icon is already visible; it doesn’t assert that the icon stays visible for 2 seconds like a previouswaitForTimeout(2000) + expect(...).toBeVisible()would.If you still want to guard against unintended autosave while minimizing arbitrary waits, consider keeping a small, explicit delay around the assertion:
- // Verify draft indicator appears - const requestTab = page.locator('.request-tab').filter({ has: page.locator('.tab-label', { hasText: 'Test Request' }) }); - await expect(requestTab.locator('.has-changes-icon')).toBeVisible(); - - await expect(requestTab.locator('.has-changes-icon')).toBeVisible({ timeout: 2000 }); + // Verify draft indicator appears and remains visible (no autosave) + const requestTab = page.locator('.request-tab').filter({ has: page.locator('.tab-label', { hasText: 'Test Request' }) }); + await expect(requestTab.locator('.has-changes-icon')).toBeVisible(); + await page.waitForTimeout(2000); + await expect(requestTab.locator('.has-changes-icon')).toBeVisible();This reintroduces a minimal, intentional timeout specifically where it’s needed to assert “no autosave”.
🧹 Nitpick comments (13)
tests/utils/page/runner.ts (2)
1-16: Runner locator builder + counts helper are clean and aligned with shared-utils patternCentralizing runner controls in
buildRunnerLocatorsand reusing them ingetRunnerResultCountsis a good move; it keeps selectors in one place and makes the helper easier to evolve.Also applies to: 23-32
81-93: Sandbox helpers look solid; consider slightly more resilient selectorsThe new
buildSandboxLocators+setSandboxModehelper provides a nice, reusable path to flip between safe/developer modes with clear steps and timeouts.Two optional resilience tweaks you might consider later:
- Use the existing
jsSandboxHeadinglocator to derivesecurityForminstead of hard-codingpage.locator('div').filter({ hasText: 'JavaScript Sandbox' }), so heading semantics stay in one place.- Relax the
developerModeRadiolabel string slightly (e.g. use a regex that only anchors on"Developer Mode") to decouple tests from future copy changes around the explanatory text.Not blockers, just potential hardening.
Also applies to: 102-155
tests/environments/api-setEnvVar/api-setEnvVar-without-persist.spec.ts (1)
1-3: Good use ofsendRequesthelper to de-duplicate request flowSwitching to
await sendRequest(page, 200);removes boilerplate request-dispatch logic from the test and keeps the behavior consistent with other suites using the same helper.Also applies to: 18-20
tests/import/openapi/missing-info.spec.ts (1)
16-20: Direct error message assertion improves clarityAsserting
getByText('Unsupported collection format').first()is visible with a timeout is clearer and less brittle than a separate boolean flag.If you see flakiness later, you might tighten this further by scoping the locator to
importModal, but the current change is already an improvement.tests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.ts (1)
1-5: Consistent use ofsendRequesthelper in persist test keeps flows alignedReusing
sendRequest(page, 200);here brings this test in line with the non-persist variant and centralizes the send/200-assertion behavior in the shared helper.Also applies to: 24-26
tests/import/bruno/import-bruno-missing-required-schema.spec.ts (1)
16-20: Explicit error text assertion is clearer and more robust than a boolean flagCapturing
errorMessageviagetByText('Unsupported collection format').first()and asserting visibility with a timeout is a straightforward way to validate the failure condition.As with the OpenAPI test, you could optionally scope this locator to the import dialog for extra resilience, but the current form is already an improvement.
tests/variable-tooltip/variable-tooltip.spec.ts (1)
44-48: Consider using locators frombuildCommonLocatorsfor consistency.Lines 44-46 use inline locators while other parts of the test use
buildCommonLocators. For consistency, consider:- await page.locator('.collection-item-name').filter({ hasText: 'Test Request' }).click(); - const urlEditor = page.locator('#request-url .CodeMirror'); - await urlEditor.click(); + const locators = buildCommonLocators(page); + await locators.sidebar.request('Test Request').click(); + await locators.request.urlInput().click();This pattern is already used in lines 246-248.
tests/utils/page/locators.ts (1)
69-93: New request, response, plusMenu, and import locators.Well-organized additions. Consider scoping the
fileInputlocator if multiple file inputs could exist on the page.- fileInput: () => page.locator('input[type="file"]') + fileInput: () => page.locator('[data-testid="import-collection-modal"] input[type="file"]')This prevents matching unintended file inputs.
tests/environments/create-environment/global-env-create.spec.ts (2)
46-50: Consider using locators for the collection item click.Line 47 uses an inline locator with
.first(). For clarity, consider using a more specific selector or the locators utility.- await page.locator('.collection-item-name').first().click(); + await locators.sidebar.request('test_request_name').click();If the request name is dynamic, using
.first()is acceptable but less explicit.
61-63: Cleanup in step vs afterEach.The cleanup is in a test step. If the test fails before this step, the collection remains. Consider adding an
afterEachhook for robust cleanup, similar to other tests in this PR.tests/environments/create-environment/collection-env-create.spec.ts (1)
61-63: Same cleanup pattern note as global-env-create.Consider moving
removeCollectionto anafterEachfor resilience against mid-test failures.tests/utils/page/actions.ts (2)
79-84: Use strict equality for undefined check.Line 81 uses
!=instead of!==for the undefined comparison.- if (options.openWithSandboxMode != undefined) { + if (options.openWithSandboxMode !== undefined) {
440-444: Fragile selector for closing environment panel.
getByText('×')is locale/character-sensitive and could match multiple elements.Consider using a more robust selector:
const closeEnvironmentPanel = async (page: Page) => { await test.step('Close environment panel', async () => { - await page.getByText('×').click(); + const locators = buildCommonLocators(page); + await locators.modal.closeButton().click(); }); };If the modal close button has a different structure, consider adding a dedicated test ID.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (24)
tests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.ts(2 hunks)tests/environments/api-setEnvVar/api-setEnvVar-without-persist.spec.ts(2 hunks)tests/environments/create-environment/collection-env-create.spec.ts(1 hunks)tests/environments/create-environment/global-env-create.spec.ts(1 hunks)tests/global-environments/non-string-values.spec.ts(2 hunks)tests/import/bruno/import-bruno-missing-required-schema.spec.ts(1 hunks)tests/import/bruno/import-bruno-testbench.spec.ts(2 hunks)tests/import/insomnia/import-insomnia-v4.spec.ts(1 hunks)tests/import/insomnia/import-insomnia-v5.spec.ts(1 hunks)tests/import/openapi/import-openapi-json.spec.ts(1 hunks)tests/import/openapi/import-openapi-yaml.spec.ts(1 hunks)tests/import/openapi/malformed-yaml.spec.ts(1 hunks)tests/import/openapi/missing-info.spec.ts(1 hunks)tests/import/postman/import-postman-v20.spec.ts(1 hunks)tests/import/postman/import-postman-v21.spec.ts(1 hunks)tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts(1 hunks)tests/interpolation/interpolate-request-url.spec.ts(1 hunks)tests/preferences/autosave/autosave.spec.ts(4 hunks)tests/response/response-actions.spec.ts(1 hunks)tests/utils/page/actions.ts(2 hunks)tests/utils/page/index.ts(1 hunks)tests/utils/page/locators.ts(3 hunks)tests/utils/page/runner.ts(3 hunks)tests/variable-tooltip/variable-tooltip.spec.ts(4 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation, never tabs
Use single quotes for strings instead of double quotes
Always add semicolons at the end of statements
No trailing commas in code
Always use parentheses around parameters in arrow functions, even for single parameters
For multiline constructs, put opening braces on the same line with a minimum of 2 elements for multiline formatting
No newlines inside function parentheses
Space before and after the arrow in arrow functions:() => {}
No space between function name and parentheses:func()notfunc ()
Semicolons should go at the end of the line, not on a new line
Function names should be concise and descriptive
Add JSDoc comments to provide details to abstractions
Avoid single-line abstractions where all that is being done is increasing the call stack with one additional function
Add meaningful comments to explain complex code flow instead of obvious comments
Files:
tests/preferences/autosave/autosave.spec.tstests/import/openapi/malformed-yaml.spec.tstests/import/bruno/import-bruno-missing-required-schema.spec.tstests/utils/page/index.tstests/environments/api-setEnvVar/api-setEnvVar-without-persist.spec.tstests/response/response-actions.spec.tstests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.tstests/import/postman/import-postman-v21.spec.tstests/global-environments/non-string-values.spec.tstests/import/insomnia/import-insomnia-v4.spec.tstests/import/openapi/missing-info.spec.tstests/variable-tooltip/variable-tooltip.spec.tstests/utils/page/runner.tstests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.tstests/import/bruno/import-bruno-testbench.spec.tstests/environments/create-environment/collection-env-create.spec.tstests/import/openapi/import-openapi-yaml.spec.tstests/environments/create-environment/global-env-create.spec.tstests/interpolation/interpolate-request-url.spec.tstests/import/postman/import-postman-v20.spec.tstests/utils/page/locators.tstests/import/openapi/import-openapi-json.spec.tstests/import/insomnia/import-insomnia-v5.spec.tstests/utils/page/actions.ts
**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
Add tests for any new functionality or meaningful changes; update corresponding tests when code is added, removed, or significantly modified
Files:
tests/preferences/autosave/autosave.spec.tstests/import/openapi/malformed-yaml.spec.tstests/import/bruno/import-bruno-missing-required-schema.spec.tstests/environments/api-setEnvVar/api-setEnvVar-without-persist.spec.tstests/response/response-actions.spec.tstests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.tstests/import/postman/import-postman-v21.spec.tstests/global-environments/non-string-values.spec.tstests/import/insomnia/import-insomnia-v4.spec.tstests/import/openapi/missing-info.spec.tstests/variable-tooltip/variable-tooltip.spec.tstests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.tstests/import/bruno/import-bruno-testbench.spec.tstests/environments/create-environment/collection-env-create.spec.tstests/import/openapi/import-openapi-yaml.spec.tstests/environments/create-environment/global-env-create.spec.tstests/interpolation/interpolate-request-url.spec.tstests/import/postman/import-postman-v20.spec.tstests/import/openapi/import-openapi-json.spec.tstests/import/insomnia/import-insomnia-v5.spec.ts
tests/**/**.*
⚙️ CodeRabbit configuration file
tests/**/**.*: Review the following e2e test code written using the Playwright test library. Ensure that:
Follow best practices for Playwright code and e2e automation
Try to reduce usage of
page.waitForTimeout();in code unless absolutely necessary and the locator cannot be found using existingexpect()playwright callsAvoid using
page.pause()in codeUse locator variables for locators
Avoid using test.only
Use multiple assertions
Promote the use of
test.stepas much as possible so the generated reports are easier to readEnsure that the
fixtureslike the collections are nested inside thefixturesfolderFixture Example*: Here's an example of possible fixture and test pair
. ├── fixtures │ └── collection │ ├── base.bru │ ├── bruno.json │ ├── collection.bru │ ├── ws-test-request-with-headers.bru │ ├── ws-test-request-with-subproto.bru │ └── ws-test-request.bru ├── connection.spec.ts # <- Depends on the collection in ./fixtures/collection ├── headers.spec.ts ├── persistence.spec.ts ├── variable-interpolation │ ├── fixtures │ │ └── collection │ │ ├── environments │ │ ├── bruno.json │ │ └── ws-interpolation-test.bru │ ├── init-user-data │ └── variable-interpolation.spec.ts # <- Depends on the collection in ./variable-interpolation/fixtures/collection └── subproto.spec.ts
Files:
tests/preferences/autosave/autosave.spec.tstests/import/openapi/malformed-yaml.spec.tstests/import/bruno/import-bruno-missing-required-schema.spec.tstests/utils/page/index.tstests/environments/api-setEnvVar/api-setEnvVar-without-persist.spec.tstests/response/response-actions.spec.tstests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.tstests/import/postman/import-postman-v21.spec.tstests/global-environments/non-string-values.spec.tstests/import/insomnia/import-insomnia-v4.spec.tstests/import/openapi/missing-info.spec.tstests/variable-tooltip/variable-tooltip.spec.tstests/utils/page/runner.tstests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.tstests/import/bruno/import-bruno-testbench.spec.tstests/environments/create-environment/collection-env-create.spec.tstests/import/openapi/import-openapi-yaml.spec.tstests/environments/create-environment/global-env-create.spec.tstests/interpolation/interpolate-request-url.spec.tstests/import/postman/import-postman-v20.spec.tstests/utils/page/locators.tstests/import/openapi/import-openapi-json.spec.tstests/import/insomnia/import-insomnia-v5.spec.tstests/utils/page/actions.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-03T08:09:57.124Z
Learning: Applies to **/*.{test,spec}.{js,jsx,ts,tsx} : Add tests for any new functionality or meaningful changes; update corresponding tests when code is added, removed, or significantly modified
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-03T08:09:57.124Z
Learning: Use consistent patterns and helper utilities where they improve clarity; prefer shared test utilities over copy-pasted setup code only when it reduces complexity
📚 Learning: 2025-12-03T08:09:57.124Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-03T08:09:57.124Z
Learning: Applies to **/*.{test,spec}.{js,jsx,ts,tsx} : Add tests for any new functionality or meaningful changes; update corresponding tests when code is added, removed, or significantly modified
Applied to files:
tests/preferences/autosave/autosave.spec.tstests/variable-tooltip/variable-tooltip.spec.tstests/utils/page/runner.tstests/environments/create-environment/collection-env-create.spec.tstests/environments/create-environment/global-env-create.spec.tstests/utils/page/locators.tstests/import/openapi/import-openapi-json.spec.tstests/import/insomnia/import-insomnia-v5.spec.ts
📚 Learning: 2025-12-03T08:09:57.124Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-03T08:09:57.124Z
Learning: Use consistent patterns and helper utilities where they improve clarity; prefer shared test utilities over copy-pasted setup code only when it reduces complexity
Applied to files:
tests/variable-tooltip/variable-tooltip.spec.tstests/utils/page/runner.tstests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.tstests/environments/create-environment/collection-env-create.spec.tstests/environments/create-environment/global-env-create.spec.tstests/interpolation/interpolate-request-url.spec.tstests/import/openapi/import-openapi-json.spec.ts
🧬 Code graph analysis (13)
tests/preferences/autosave/autosave.spec.ts (1)
tests/utils/page/actions.ts (1)
closeAllCollections(553-553)
tests/environments/api-setEnvVar/api-setEnvVar-without-persist.spec.ts (1)
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (2)
sendRequest(506-622)sendRequest(506-622)
tests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.ts (2)
tests/utils/page/actions.ts (1)
sendRequest(570-570)packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (2)
sendRequest(506-622)sendRequest(506-622)
tests/import/insomnia/import-insomnia-v4.spec.ts (1)
tests/utils/page/actions.ts (2)
closeAllCollections(553-553)importCollection(558-558)
tests/variable-tooltip/variable-tooltip.spec.ts (2)
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (2)
saveEnvironment(1758-1796)saveEnvironment(1758-1796)tests/utils/page/locators.ts (1)
buildCommonLocators(3-94)
tests/utils/page/runner.ts (2)
packages/bruno-app/src/components/RunnerResults/index.jsx (1)
failed(22-22)packages/bruno-app/src/components/ResponsePane/QueryResult/index.js (1)
mode(29-29)
tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts (2)
tests/utils/page/actions.ts (3)
closeAllCollections(553-553)openCollectionAndAcceptSandbox(554-554)sendRequest(570-570)tests/utils/page/locators.ts (1)
buildCommonLocators(3-94)
tests/import/bruno/import-bruno-testbench.spec.ts (1)
tests/utils/page/actions.ts (1)
importCollection(558-558)
tests/environments/create-environment/collection-env-create.spec.ts (2)
tests/utils/page/locators.ts (1)
buildCommonLocators(3-94)tests/utils/page/actions.ts (8)
importCollection(558-558)createEnvironment(564-564)addEnvironmentVariables(566-566)saveEnvironment(567-567)closeEnvironmentPanel(568-568)sendRequest(570-570)expectResponseContains(574-574)removeCollection(559-559)
tests/environments/create-environment/global-env-create.spec.ts (3)
playwright/index.ts (1)
test(28-246)tests/utils/page/locators.ts (1)
buildCommonLocators(3-94)tests/utils/page/actions.ts (8)
importCollection(558-558)createEnvironment(564-564)addEnvironmentVariables(566-566)saveEnvironment(567-567)closeEnvironmentPanel(568-568)sendRequest(570-570)expectResponseContains(574-574)closeAllCollections(553-553)
tests/interpolation/interpolate-request-url.spec.ts (2)
tests/utils/page/actions.ts (2)
closeAllCollections(553-553)sendRequest(570-570)tests/utils/page/locators.ts (1)
buildCommonLocators(3-94)
tests/import/postman/import-postman-v20.spec.ts (1)
tests/utils/page/actions.ts (2)
closeAllCollections(553-553)importCollection(558-558)
tests/utils/page/actions.ts (2)
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (10)
importCollection(2403-2427)importCollection(2403-2427)removeCollection(2131-2185)removeCollection(2131-2185)saveEnvironment(1758-1796)saveEnvironment(1758-1796)selectEnvironment(2104-2129)selectEnvironment(2104-2129)sendRequest(506-622)sendRequest(506-622)tests/utils/page/locators.ts (1)
buildCommonLocators(3-94)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Playwright E2E Tests
- GitHub Check: Unit Tests
- GitHub Check: SSL Tests - Windows
- GitHub Check: CLI Tests
- GitHub Check: SSL Tests - Linux
- GitHub Check: SSL Tests - macOS
🔇 Additional comments (34)
tests/preferences/autosave/autosave.spec.ts (3)
5-10: Guarding cleanup onpage.isClosed()is a solid stability improvementThe conditional
closeAllCollectionsinafterEachavoids acting on a closed page and should reduce noisy teardown failures.
60-66: Autosave enabled: expectation-based wait is appropriateSwapping a fixed delay for
not.toBeVisible({ timeout: 5000 })correctly encodes “eventually auto-saves” without hard sleeps and should reduce flakiness.
172-175: Autosave existing drafts: assertion-based wait looks goodUsing
not.toBeVisible({ timeout: 5000 })here is a clear, state-driven way to verify that existing drafts are auto-saved without a blind sleep.tests/utils/page/runner.ts (1)
42-78:runCollectionflow is much clearer and more deterministic nowWrapping the entire run sequence in
test.step, scoping the collection selector togetByTestId('collections'), and explicitly handling the reset vs fresh-run cases should make these runner-driven tests more robust.tests/utils/page/index.ts (1)
1-3: Re-exporting locators from the page utils index keeps the public surface cohesiveAdding
export * from './locators';matches the existing barrel pattern and simplifies imports across tests.tests/import/openapi/malformed-yaml.spec.ts (1)
16-23: OR-based error assertion correctly models multiple valid failure modesUsing separate locators for the parse error and generic import error, then
await expect(parseError.or(importError)).toBeVisible({ timeout: 10000 });, neatly captures “any expected error is fine” without duplicating wait logic.tests/interpolation/interpolate-request-url.spec.ts (1)
2-3: Helper-based navigation and send flow looks solidUsing
buildCommonLocatorsfor sidebar interactions andsendRequest(page, 200)to encapsulate send + status assertion makes these tests more readable and less brittle without changing behavior. This is well-aligned with the shared test utility pattern. Based on learnings, this aligns with preferring shared helpers over ad-hoc DOM queries.Also applies to: 11-14, 21-23
tests/global-environments/non-string-values.spec.ts (1)
2-3: Good use of common locators and send helper in seeding stepSwitching the “Run the request” step to
buildCommonLocators(page).sidebar.request('set-global-nonstring')plussendRequest(page, 200)tightens the flow and avoids duplicating low-level interactions, while preserving the surrounding assertions on environment behavior.Also applies to: 44-46
tests/import/postman/import-postman-v20.spec.ts (1)
1-3: Import flow abstraction reads cleanlyDelegating the Postman v2.0 import to
importCollection(page, postmanFile, tmpDir, { expectedCollectionName })keeps this spec minimal and consistent with other import tests; the helper can own the detailed UI steps and assertions.Also applies to: 13-15
tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts (1)
2-3: Dynamic-variable request flow nicely aligned with shared helpersUsing
buildCommonLocators(page)forsidebar.request('set-var-dynamic-variable')andsendRequest(page, 200)simplifies the setup while keeping the downstream response parsing/assertions intact, and matches the helper-based approach used in related interpolation specs. As per coding guidelines, this improves clarity without adding complexity.Also applies to: 11-12, 17-17, 20-20
tests/import/postman/import-postman-v21.spec.ts (1)
1-3: Consistent helper usage for Postman v2.1 importMirroring the v2.0 spec with
importCollection(page, postmanFile, tmpDir, { expectedCollectionName })keeps these tests uniform and focused on what differs between versions (fixtures and expected names), which is exactly what we want.Also applies to: 13-15
tests/import/openapi/import-openapi-yaml.spec.ts (1)
1-3: OpenAPI YAML import test is clean and consistentThe switch to
importCollection(page, openApiFile, tmpDir, { expectedCollectionName })brings this spec in line with the other import tests and removes duplicated UI choreography while still validating the resulting collection name.Also applies to: 13-15
tests/response/response-actions.spec.ts (1)
2-8: Response actions test now uses well-structured helpers and locatorsCreating the collection/request with
createCollection+createRequestWithUrl, sending viasendRequest(page, 200), and usingbuildCommonLocators(page).response.copyButton()insidetest.stepblocks makes this e2e much easier to follow and less brittle than the prior hand-written UI sequence, while keeping clear assertions on visibility and the toast message.Also applies to: 17-17, 21-21, 25-25, 28-30
tests/import/insomnia/import-insomnia-v4.spec.ts (1)
1-3: Insomnia v4 import spec is aligned with shared import helper patternRefactoring to
importCollection(page, insomniaFile, tmpDir, { expectedCollectionName })keeps this test minimal and consistent with the Postman/OpenAPI specs, centralizing all the UI steps and primary assertion in the helper.Also applies to: 13-15
tests/import/bruno/import-bruno-testbench.spec.ts (1)
1-16: LGTM! Clean migration to helper-based import flow.The refactor replaces verbose UI interactions with the
importCollectionhelper, improving readability and maintainability. Based on learnings, shared test utilities are preferred over copy-pasted setup code.tests/import/insomnia/import-insomnia-v5.spec.ts (1)
1-16: LGTM! Consistent with the new import helper pattern.Clean refactor aligns with other import tests. Good use of
afterEachfor cleanup.tests/import/openapi/import-openapi-json.spec.ts (1)
1-16: LGTM! Follows the established helper pattern.The test is concise and delegates import flow to the shared utility.
tests/variable-tooltip/variable-tooltip.spec.ts (4)
2-11: Good adoption of environment management helpers.The imports consolidate environment setup logic. This aligns with the PR's goal of reducing inline UI interactions.
14-17: Defensive page check is appropriate.The
page.isClosed()guard prevents errors when the page is already closed during cleanup.
27-36: Clean environment setup using helpers.Replaces verbose UI steps with declarative helper calls. Well-structured with
test.step.
246-252: Good use ofbuildCommonLocatorsfor consistent element access.This demonstrates the intended usage pattern for the locator utilities.
tests/utils/page/locators.ts (2)
20-23: LGTM! Useful sidebar locators added.
closeAllCollectionsButtonuses a test ID (robust), whilecollectionRowuses a structured filter approach.
56-68: Comprehensive environment locators.Good coverage for environment management flows. The index-based approach for
variableNameInput,variableSecretCheckbox, andvariableRowis practical for form interactions.tests/environments/create-environment/global-env-create.spec.ts (2)
3-13: Good import of modular helpers and locators.Clean separation of concerns with helpers for environment management and locators for element access.
30-44: Well-structured environment creation step.Uses
createEnvironment,addEnvironmentVariables,saveEnvironment, andcloseEnvironmentPanelhelpers effectively. The assertion oncurrentEnvironmentconfirms the environment was created.tests/environments/create-environment/collection-env-create.spec.ts (2)
3-13: Good import structure matching the global-env-create test.Consistent with the pattern established across the test suite.
30-44: Clean environment setup with variable addition.Follows the helper-based pattern. The
isSecret: trueflag forsecretApiTokendemonstrates the secret variable handling.tests/utils/page/actions.ts (7)
1-5: Good type imports and SandboxMode definition.Clean type setup for the module.
135-194: Well-structured importCollection helper.Good use of:
test.stepfor report clarity- Explicit waits with
waitFor- Optional
expectedCollectionNameandopenWithSandboxModeparametersThe 10000ms timeout on line 170 is reasonable for import operations.
196-223: Clean removeCollection implementation.Properly waits for modal visibility/invisibility and verifies removal.
320-365: Environment creation helpers look good.The
openEnvironmentSelectorandcreateEnvironmentfunctions are well-structured with appropriate assertions.
380-408: addEnvironmentVariable: Wait for CodeMirror before typing.The implementation waits for the CodeMirror editor visibility before clicking and typing, which is correct. The sequential approach for adding variables is appropriate.
474-497: sendRequest helper with optional status validation.Good implementation with configurable timeout. The
expectedStatusCodeaccepts both number and string for flexibility.
552-577: Comprehensive exports.All helpers and types are properly exported for test consumption.
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/import/insomnia/invalid-missing-collection.spec.ts (1)
5-24: Add test.step for better test reporting.As per coding guidelines, use
test.stepto structure the test into logical steps for improved readability in test reports.Apply this diff to add test.step:
test('Handle Insomnia v5 collection missing collection array', async ({ page }) => { const insomniaFile = path.resolve(__dirname, 'fixtures', 'insomnia-v5-invalid-missing-collection.yaml'); - await page.locator('.plus-icon-button').click(); - await page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Import collection' }).click(); - - // Wait for import collection modal to be ready - const importModal = page.getByRole('dialog'); - await importModal.waitFor({ state: 'visible' }); - await expect(importModal.locator('.bruno-modal-header-title')).toContainText('Import Collection'); - - await page.setInputFiles('input[type="file"]', insomniaFile); - - const errorLocator = page.getByText(/Unsupported collection format|Failed to parse|Invalid|Error/).first(); - await expect(errorLocator).toBeVisible({ timeout: 10000 }); - - // Cleanup: close any open modals - await page.getByTestId('modal-close-button').click(); + await test.step('Open import collection modal', async () => { + await page.locator('.plus-icon-button').click(); + await page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Import collection' }).click(); + + const importModal = page.getByRole('dialog'); + await importModal.waitFor({ state: 'visible' }); + await expect(importModal.locator('.bruno-modal-header-title')).toContainText('Import Collection'); + }); + + await test.step('Attempt to import invalid collection file', async () => { + await page.setInputFiles('input[type="file"]', insomniaFile); + }); + + await test.step('Verify error message is displayed', async () => { + const errorLocator = page.getByText(/Unsupported collection format|Failed to parse|Invalid|Error/).first(); + await expect(errorLocator).toBeVisible({ timeout: 10000 }); + }); + + await test.step('Close modal', async () => { + await page.getByTestId('modal-close-button').click(); + }); });Based on learnings, consistent patterns and helper utilities improve clarity.
🧹 Nitpick comments (15)
tests/interpolation/interpolate-request-url.spec.ts (2)
11-15: Navigation + send helper look good; consider test.step for reportingUsing
buildCommonLocatorsandsendRequest(page, 200)makes this flow concise and consistent with other specs, while still exercising the full UI path. As an optional improvement, consider wrapping the navigation and send intest.stepblocks so the Playwright report shows clearer phases (e.g. “open interpolation collection”, “send request”). Based on learnings, this keeps tests both DRY and readable.
21-23: Verify collection selection independence in second testHere you build locators but only click
locators.sidebar.request('echo-request-odata')without selecting theinterpolationcollection first. Ifrequest()depends on the active collection, this test may rely on state from the previous test and could fail when run in isolation or under filtering. Ifrequest()is globally scoped, you’re fine, but it’s worth double‑checking and potentially adding the explicitcollection('interpolation').click()for isolation and clarity.tests/environments/import-environment/bruno-env-import/collection-env-import/collection-env-import.spec.ts (1)
1-139: Consider extracting repeated locators to variables.Several locators are used multiple times across both tests. Per coding guidelines, extracting them to variables improves maintainability:
test.describe.serial('Collection Environment Import Tests', () => { const getEnvironmentSelectorTrigger = (page) => page.getByTestId('environment-selector-trigger'); const getCollectionEnvTab = (page) => page.getByTestId('env-tab-collection'); const getEnvironmentsModal = (page) => page.locator('.bruno-modal').filter({ hasText: 'Environments' }); test('should import single collection environment', async ({ pageWithUserData: page }) => { // Use: await getEnvironmentSelectorTrigger(page).click(); // ... }); });tests/import/insomnia/invalid-missing-collection.spec.ts (1)
8-9: Use locator variables consistently.As per coding guidelines, store locators in variables for better readability and reusability. Lines 12 and 18 correctly use variables, but lines 8, 9, and 16 use locators directly.
Apply this diff:
+ const plusIconButton = page.locator('.plus-icon-button'); + const importMenuItem = page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Import collection' }); + await plusIconButton.click(); + await importMenuItem.click(); - await page.locator('.plus-icon-button').click(); - await page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Import collection' }).click(); // Wait for import collection modal to be ready const importModal = page.getByRole('dialog'); await importModal.waitFor({ state: 'visible' }); await expect(importModal.locator('.bruno-modal-header-title')).toContainText('Import Collection'); + const fileInput = page.locator('input[type="file"]'); + await fileInput.setInputFiles(insomniaFile); - await page.setInputFiles('input[type="file"]', insomniaFile);Also applies to: 16-16
tests/preferences/autosave/autosave.spec.ts (2)
114-114: This pattern doesn’t actually assert “stays visible for 2s”The second
toBeVisible({ timeout: 2000 })will usually pass immediately because the condition is already true, so it doesn’t prove the draft icon remains visible over time; it’s effectively a duplicate of the first check. If you need to guarantee “no autosave for ~2s while disabled”, consider re-introducing a small delay or a helper that explicitly re-checks visibility after a delay.
177-177: You can likely drop the precedingwaitForTimeoutnowWith
await expect(...).not.toBeVisible({ timeout: 10000 }), the explicitpage.waitForTimeout(1000)above is probably redundant; letting the expect poll for up to 10s keeps the intent while aligning better with the guideline to avoid fixed sleeps.As per coding guidelines, reducing
page.waitForTimeoutusage in favor of assertion-driven waits is preferred.tests/import/postman/malformed-structure.spec.ts (1)
18-22: Broadened error matcher looks good; consider scoping the genericErrortextThe composite error locator and longer timeout should make this test more resilient, but the
|Errorbranch is very broad and could match unrelated UI text in future screens. If you start seeing flakiness, consider either:
- scoping the locator to the import modal/toast container, or
- dropping the plain
Erroralternative in favor of more specific phrases.tests/import/bruno/import-bruno-corrupted-fails.spec.ts (1)
18-19: Align error locator pattern and avoid over-broadErrormatchUsing a composite locator for multiple error messages is a good improvement here. To keep things maintainable and less flaky long-term, consider:
- aligning this regex with the one in
malformed-structure.spec.ts, and- extracting a small helper (e.g.
getImportErrorLocator(page)) so all import tests share the same set of expected messages and scoping, instead of each re-defining/...|Error/.tests/import/bruno/import-bruno-with-examples.spec.ts (1)
24-40: Race-based success/error handling looks solid; consider broadening error detection and step namingThe
Promise.racebetween the location modal and the error message is a nice way to avoid hanging on failures, and the expliciterror/timeoutbranches make the outcome clear.Two small improvements to consider:
- Other import tests now accept multiple possible error strings; here you only match
'Failed to parse the file'. Using the same composite pattern (or a shared helper) would keep behavior consistent and avoid false “timeout” when a different error text is shown.- The step label says “verify location modal appears”, but this block also handles error and timeout paths. Either tweak the step name to reflect that, or move the error/timeout handling into a dedicated step for clearer reporting.
tests/response/response-actions.spec.ts (1)
2-31: Nice refactor to helper-based flow and locators for response copySwitching to
createCollection,createRequest,sendRequest, andbuildCommonLocatorsmakes this test much leaner and easier to maintain, while still asserting both the button visibility and the “Response copied to clipboard” feedback.If you ever need stronger guarantees, a follow-up could assert some aspect of the response body via
getResponseBody, but for a copy-action test this level of coverage is appropriate.tests/environments/create-environment/global-env-create.spec.ts (1)
3-65: Good use of helpers; avoid relying on the first collection itemThe test is nicely decomposed into steps and makes good use of the new helpers (
importCollection, environment helpers,sendRequest,expectResponseContains).One place that could become brittle is:
await page.locator('.collection-item-name').first().click();If the fixture ever changes ordering, this may stop targeting the intended request. Prefer an explicit sidebar locator instead, e.g. via
locators.sidebar.request('<request name>'), so the test remains stable even if additional items are added.tests/utils/page/actions.ts (4)
1-5: ReuseSandboxModealias where possible for consistencyYou’ve introduced
type SandboxMode = 'safe' | 'developer';butCreateCollectionOptionsandopenCollectionAndAcceptSandboxstill spell out the union type inline:type CreateCollectionOptions = { openWithSandboxMode?: 'safe' | 'developer'; }; ... const openCollectionAndAcceptSandbox = async (page, collectionName: string, sandboxMode: 'safe' | 'developer' = 'safe') => {Switching these to
SandboxModewill keep the allowed values in one place and reduce drift if you ever add more modes.Also applies to: 52-54
173-224: Import/remove/create folder helpers look solid; minor locator reuse opportunityThe new
importCollection,removeCollection, andcreateFolderhelpers give tests a much cleaner, high-level API for collection lifecycle.A couple of small polish points to consider:
- In
importCollection, you already havebuildCommonLocators(page)but still use raw selectors forinput[type="file"], the import modal, and#collection-location. Using theimportandmodallocators frombuildCommonLocatorswould keep selectors in one place.removeCollectionandcreateFolderare already usingbuildCommonLocatorseffectively and have clear assertions on final state; no issues there.These are purely maintainability tweaks; behavior looks correct.
Also applies to: 232-285
287-400: Environment helpers are a good abstraction; tighten selectors and reuse locatorsThe environment helpers (
openEnvironmentSelector,createEnvironment,addEnvironmentVariable(s),saveEnvironment,closeEnvironmentPanel,selectEnvironment) make env flows much easier to script and assert.Two improvement areas:
Selector reuse:
addEnvironmentVariablemanually wires selectors for the add button, name input, row, and secret checkbox, even thoughbuildCommonLocatorsalready exposesenvironment.addVariableButton,variableNameInput,variableRow,variableSecretCheckbox. Using those would remove duplication and keep selectors aligned with other tests.Close button targeting:
closeEnvironmentPanelusespage.getByText('×'), which is quite generic and could click the wrong close icon if multiple modals/panels are open. If there’s a more specific test id or container for the environment panel, consider scoping the locator to that instead.Functionally this all looks fine; these suggestions are mainly about robustness and DRY.
Also applies to: 407-439
448-517: Request/response helpers match UI well; small optional locator abstraction
sendRequest,openRequest,openFolderRequest,getResponseBody, andexpectResponseContainsnicely encapsulate common flows and encourage multiple assertions on response content.If you want to be fully consistent with the rest of this module, you could:
- use
buildCommonLocators(page).request.sendButton()and.response.statusCode()insidesendRequest, and- use a response locator helper in
getResponseBody/expectResponseContains,so that all selectors live in
locators.ts. Not required, but it would make future UI changes easier to absorb.Behavior-wise, these helpers look correct and align with how specs are using them.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
tests/environments/create-environment/global-env-create.spec.ts(1 hunks)tests/environments/import-environment/bruno-env-import/collection-env-import/collection-env-import.spec.ts(1 hunks)tests/import/bruno/import-bruno-corrupted-fails.spec.ts(1 hunks)tests/import/bruno/import-bruno-with-examples.spec.ts(1 hunks)tests/import/insomnia/invalid-missing-collection.spec.ts(1 hunks)tests/import/postman/malformed-structure.spec.ts(1 hunks)tests/interpolation/interpolate-request-url.spec.ts(1 hunks)tests/preferences/autosave/autosave.spec.ts(4 hunks)tests/response/response-actions.spec.ts(1 hunks)tests/utils/page/actions.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions.() => {}is good
No space between function name and parentheses.func()notfunc ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly
Files:
tests/import/bruno/import-bruno-corrupted-fails.spec.tstests/environments/import-environment/bruno-env-import/collection-env-import/collection-env-import.spec.tstests/interpolation/interpolate-request-url.spec.tstests/import/postman/malformed-structure.spec.tstests/preferences/autosave/autosave.spec.tstests/import/insomnia/invalid-missing-collection.spec.tstests/import/bruno/import-bruno-with-examples.spec.tstests/response/response-actions.spec.tstests/environments/create-environment/global-env-create.spec.tstests/utils/page/actions.ts
tests/**/**.*
⚙️ CodeRabbit configuration file
tests/**/**.*: Review the following e2e test code written using the Playwright test library. Ensure that:
Follow best practices for Playwright code and e2e automation
Try to reduce usage of
page.waitForTimeout();in code unless absolutely necessary and the locator cannot be found using existingexpect()playwright callsAvoid using
page.pause()in codeUse locator variables for locators
Avoid using test.only
Use multiple assertions
Promote the use of
test.stepas much as possible so the generated reports are easier to readEnsure that the
fixtureslike the collections are nested inside thefixturesfolderFixture Example*: Here's an example of possible fixture and test pair
. ├── fixtures │ └── collection │ ├── base.bru │ ├── bruno.json │ ├── collection.bru │ ├── ws-test-request-with-headers.bru │ ├── ws-test-request-with-subproto.bru │ └── ws-test-request.bru ├── connection.spec.ts # <- Depends on the collection in ./fixtures/collection ├── headers.spec.ts ├── persistence.spec.ts ├── variable-interpolation │ ├── fixtures │ │ └── collection │ │ ├── environments │ │ ├── bruno.json │ │ └── ws-interpolation-test.bru │ ├── init-user-data │ └── variable-interpolation.spec.ts # <- Depends on the collection in ./variable-interpolation/fixtures/collection └── subproto.spec.ts
Files:
tests/import/bruno/import-bruno-corrupted-fails.spec.tstests/environments/import-environment/bruno-env-import/collection-env-import/collection-env-import.spec.tstests/interpolation/interpolate-request-url.spec.tstests/import/postman/malformed-structure.spec.tstests/preferences/autosave/autosave.spec.tstests/import/insomnia/invalid-missing-collection.spec.tstests/import/bruno/import-bruno-with-examples.spec.tstests/response/response-actions.spec.tstests/environments/create-environment/global-env-create.spec.tstests/utils/page/actions.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:32.975Z
Learning: Applies to **/*.test.{js,jsx,ts,tsx} : Add tests for any new functionality or meaningful changes. If code is added, removed, or significantly modified, corresponding tests should be updated or created
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:32.975Z
Learning: Use consistent patterns and helper utilities where they improve clarity. Prefer shared test utilities over copy-pasted setup code, but only when it actually reduces complexity
📚 Learning: 2025-12-05T20:31:32.975Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:32.975Z
Learning: Use consistent patterns and helper utilities where they improve clarity. Prefer shared test utilities over copy-pasted setup code, but only when it actually reduces complexity
Applied to files:
tests/interpolation/interpolate-request-url.spec.tstests/environments/create-environment/global-env-create.spec.ts
📚 Learning: 2025-12-05T20:31:32.975Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:32.975Z
Learning: Applies to **/*.test.{js,jsx,ts,tsx} : Add tests for any new functionality or meaningful changes. If code is added, removed, or significantly modified, corresponding tests should be updated or created
Applied to files:
tests/preferences/autosave/autosave.spec.tstests/utils/page/actions.ts
🧬 Code graph analysis (1)
tests/utils/page/actions.ts (2)
tests/utils/page/locators.ts (1)
buildCommonLocators(3-94)packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (10)
importCollection(2403-2427)importCollection(2403-2427)removeCollection(2131-2185)removeCollection(2131-2185)saveEnvironment(1758-1796)saveEnvironment(1758-1796)selectEnvironment(2104-2129)selectEnvironment(2104-2129)sendRequest(506-622)sendRequest(506-622)
🔇 Additional comments (7)
tests/interpolation/interpolate-request-url.spec.ts (1)
2-3: Good use of shared test helpers and locators importsImporting
closeAllCollections,sendRequest, andbuildCommonLocatorscentralizes common UI actions and keeps specs lean, matching the repo’s preference for shared test utilities over copy‑paste setup. Based on learnings, this is the right direction.tests/import/insomnia/invalid-missing-collection.spec.ts (1)
22-22: Good change to use getByTestId.The switch from a data-test-id selector to
getByTestId('modal-close-button')follows Playwright best practices and improves consistency.tests/preferences/autosave/autosave.spec.ts (3)
5-5: Suite-level timeout increase looks reasonableGiven multiple autosave-related waits (5–10s expectations), a 60s suite timeout is a sensible upper bound; just watch that future additions don’t silently normalize very slow tests.
9-11: Good defensivepage.isClosed()guard in cleanupThis avoids noisy
Target closed/page closederrors when a test intentionally closes the page beforeafterEachruns, while still ensuring collections are cleaned up when the page is alive.
67-67: Nice switch from fixed sleep to timeout-based assertionUsing
await expect(...).not.toBeVisible({ timeout: 5000 })is a solid improvement over a hardwaitForTimeout, and keeps the test robust to autosave timing as long as it settles within 5s.tests/utils/page/actions.ts (2)
87-135:createRequesthelper nicely unifies collection/folder flowsThe new
CreateRequestOptions+createRequestabstraction reads well and centralizes:
- entry point (collection vs folder via
inFolder)- menu navigation
- optional URL typing into CodeMirror
- postcondition checks on the sidebar
This should reduce a lot of duplicated setup across specs. No functional issues stand out here.
519-542: Export surface is cohesive and test-facingThe final export block cleanly exposes all the new helpers and types needed by specs, without leaking internal details. Grouping functions and their supporting types here will make it easy for tests to adopt the new APIs incrementally.
No changes requested.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/import/insomnia/invalid-missing-collection.spec.ts (1)
5-23: Add test.step for improved report readability.The test has clear logical sections but doesn't use
test.step, which is explicitly required by the coding guidelines to improve generated reports.As per coding guidelines, promote the use of
test.stepas much as possible.Apply this diff to structure the test with steps:
test('Handle Insomnia v5 collection missing collection array', async ({ page }) => { const insomniaFile = path.resolve(__dirname, 'fixtures', 'insomnia-v5-invalid-missing-collection.yaml'); - await page.locator('.plus-icon-button').click(); - await page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Import collection' }).click(); - - // Wait for import collection modal to be ready - const importModal = page.getByRole('dialog'); - await importModal.waitFor({ state: 'visible' }); - await expect(importModal.locator('.bruno-modal-header-title')).toContainText('Import Collection'); - - await page.setInputFiles('input[type="file"]', insomniaFile); - - const errorLocator = page.getByText('Unsupported collection format').first(); - await expect(errorLocator).toBeVisible({ timeout: 10000 }); - - // Cleanup: close any open modals - await page.getByTestId('modal-close-button').click(); + await test.step('Open import collection modal', async () => { + await page.locator('.plus-icon-button').click(); + await page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Import collection' }).click(); + + const importModal = page.getByRole('dialog'); + await importModal.waitFor({ state: 'visible' }); + await expect(importModal.locator('.bruno-modal-header-title')).toContainText('Import Collection'); + }); + + await test.step('Select invalid collection file', async () => { + await page.setInputFiles('input[type="file"]', insomniaFile); + }); + + await test.step('Verify error message is displayed', async () => { + const errorLocator = page.getByText('Unsupported collection format').first(); + await expect(errorLocator).toBeVisible({ timeout: 10000 }); + }); + + await test.step('Close modal', async () => { + await page.getByTestId('modal-close-button').click(); + }); });
🧹 Nitpick comments (3)
tests/utils/page/runner.ts (3)
8-16: Runner locators abstraction looks good; consider making count parsing failures more explicitCentralizing the runner buttons in
buildRunnerLocatorsis a solid improvement and keepsgetRunnerResultCountsreadable, aligning nicely with the guidance to use shared utilities where they genuinely reduce duplication. Based on learnings, this is a good direction.One small robustness tweak: if any of the underlying
<span>texts ever change format,parseIntwill quietly returnNaNand later assertions will fail with less helpful messages. You could fail fast with a clearer error if parsing breaks, e.g.:+const parseCount = async (locator: ReturnType<Page['locator']>) => { + const text = await locator.innerText(); + const value = parseInt(text, 10); + if (Number.isNaN(value)) { + throw new Error(`Unexpected runner count text: "${text}"`); + } + return value; +}; + export const getRunnerResultCounts = async (page: Page) => { const locators = buildRunnerLocators(page); - const totalRequests = parseInt(await locators.allButton().locator('span').innerText()); - const passed = parseInt(await locators.passedButton().locator('span').innerText()); - const failed = parseInt(await locators.failedButton().locator('span').innerText()); - const skipped = parseInt(await locators.skippedButton().locator('span').innerText()); + const totalRequests = await parseCount(locators.allButton().locator('span')); + const passed = await parseCount(locators.passedButton().locator('span')); + const failed = await parseCount(locators.failedButton().locator('span')); + const skipped = await parseCount(locators.skippedButton().locator('span'));This keeps the helper readable while making DOM regressions easier to debug.
Also applies to: 24-29
42-79: runCollection flow is much clearer; consider scoping the "Run" menu item more tightlyWrapping the collection run in a
test.step, scoping interactions throughcollectionContainer/actionsContainer, and reusingbuildRunnerLocatorsis a good cleanup for both readability and flakiness.One thing to watch:
page.getByText('Run', { exact: true })is global. If additional “Run” labels appear elsewhere (toolbar, other menus), this could occasionally pick the wrong element. If you have a stable container for the context/menu, you might scope the locator, e.g.:const menu = page.locator('[data-testid="collection-menu"]'); // or actual menu container const runMenuItem = menu.getByText('Run', { exact: true });or, if applicable, prefer a role-based locator like
getByRole('menuitem', { name: 'Run' })scoped to the menu.This is optional, but it can reduce future flakiness as the UI grows.
81-94: Sandbox helpers look good; tighten badge visibility probes and reuse existing locatorsThe new
buildSandboxLocators+setSandboxModeflow is a nice abstraction: it keeps the steps readable, usestest.step, and avoids arbitrary timeouts, which lines up well with the project’s guidance on clear and maintainable test utilities.A few targeted improvements to further harden this:
- Bound
isVisible()calls on badges to avoid unnecessary waiting when no badge existsRight now:
const developerBadgeVisible = await sandboxLocators.developerModeBadge().isVisible().catch(() => false); const safeBadgeVisible = await sandboxLocators.safeModeBadge().isVisible().catch(() => false);
isVisible()can wait up to the default Playwright timeout when nothing ever appears. Mirroring what you did for the runner reset button, you can bound these checks with a short timeout so the “first‑time selection” path doesn’t pay a large latency cost:-const developerBadgeVisible = await sandboxLocators.developerModeBadge().isVisible().catch(() => false); -const safeBadgeVisible = await sandboxLocators.safeModeBadge().isVisible().catch(() => false); +const developerBadgeVisible = await sandboxLocators + .developerModeBadge() + .isVisible({ timeout: 1000 }) + .catch(() => false); +const safeBadgeVisible = await sandboxLocators + .safeModeBadge() + .isVisible({ timeout: 1000 }) + .catch(() => false);
- Reuse existing heading locator instead of re-finding the sandbox container
Later you do:
const securityForm = page.locator('div').filter({ hasText: 'JavaScript Sandbox' }).locator('..').first();Since you already have
jsSandboxHeading, you could reduce duplication and make this more intention‑revealing by deriving from that locator instead, e.g.:const securityForm = sandboxLocators.jsSandboxHeading().locator('..');(Adjust the parent traversal as needed for the actual DOM.)
- Consider slightly more resilient label text for
developerModeRadio
getByLabel('Developer Mode(use only if')hard-codes a fairly long fragment; a minor copy tweak in the UI might break this. If feasible, shortening to'Developer Mode'or using a regex like/^Developer Mode/would keep the intent but be less fragile, while still keeping selectors readable.None of these are blockers, but they should make the sandbox utilities faster and a bit more future‑proof.
Also applies to: 103-155
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
tests/import/insomnia/invalid-missing-collection.spec.ts(1 hunks)tests/utils/page/runner.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions.() => {}is good
No space between function name and parentheses.func()notfunc ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly
Files:
tests/import/insomnia/invalid-missing-collection.spec.tstests/utils/page/runner.ts
tests/**/**.*
⚙️ CodeRabbit configuration file
tests/**/**.*: Review the following e2e test code written using the Playwright test library. Ensure that:
Follow best practices for Playwright code and e2e automation
Try to reduce usage of
page.waitForTimeout();in code unless absolutely necessary and the locator cannot be found using existingexpect()playwright callsAvoid using
page.pause()in codeUse locator variables for locators
Avoid using test.only
Use multiple assertions
Promote the use of
test.stepas much as possible so the generated reports are easier to readEnsure that the
fixtureslike the collections are nested inside thefixturesfolderFixture Example*: Here's an example of possible fixture and test pair
. ├── fixtures │ └── collection │ ├── base.bru │ ├── bruno.json │ ├── collection.bru │ ├── ws-test-request-with-headers.bru │ ├── ws-test-request-with-subproto.bru │ └── ws-test-request.bru ├── connection.spec.ts # <- Depends on the collection in ./fixtures/collection ├── headers.spec.ts ├── persistence.spec.ts ├── variable-interpolation │ ├── fixtures │ │ └── collection │ │ ├── environments │ │ ├── bruno.json │ │ └── ws-interpolation-test.bru │ ├── init-user-data │ └── variable-interpolation.spec.ts # <- Depends on the collection in ./variable-interpolation/fixtures/collection └── subproto.spec.ts
Files:
tests/import/insomnia/invalid-missing-collection.spec.tstests/utils/page/runner.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:32.975Z
Learning: Applies to **/*.test.{js,jsx,ts,tsx} : Add tests for any new functionality or meaningful changes. If code is added, removed, or significantly modified, corresponding tests should be updated or created
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:32.975Z
Learning: Use consistent patterns and helper utilities where they improve clarity. Prefer shared test utilities over copy-pasted setup code, but only when it actually reduces complexity
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:32.975Z
Learning: Keep tests readable and maintainable. Optimise for clarity over cleverness. Name tests descriptively, keep setup minimal, and avoid unnecessary abstraction
📚 Learning: 2025-12-05T20:31:32.975Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:32.975Z
Learning: Applies to **/*.test.{js,jsx,ts,tsx} : Add tests for any new functionality or meaningful changes. If code is added, removed, or significantly modified, corresponding tests should be updated or created
Applied to files:
tests/utils/page/runner.ts
📚 Learning: 2025-12-05T20:31:32.975Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:32.975Z
Learning: Use consistent patterns and helper utilities where they improve clarity. Prefer shared test utilities over copy-pasted setup code, but only when it actually reduces complexity
Applied to files:
tests/utils/page/runner.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Unit Tests
- GitHub Check: Playwright E2E Tests
- GitHub Check: CLI Tests
- GitHub Check: SSL Tests - Windows
- GitHub Check: SSL Tests - macOS
- GitHub Check: SSL Tests - Linux
🔇 Additional comments (1)
tests/import/insomnia/invalid-missing-collection.spec.ts (1)
22-22: Good improvement using TestId.Switching to
getByTestIdprovides a more stable and explicit selector for the modal close button.
* improve: tests * fixes * fixes
Description
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
✏️ Tip: You can customize this high-level summary in your review settings.