Skip to content

improve: tests - #6321

Merged
bijin-bruno merged 4 commits into
usebruno:mainfrom
naman-bruno:improve/tests
Dec 6, 2025
Merged

bijin-bruno merged 4 commits into
usebruno:mainfrom
naman-bruno:improve/tests

Conversation

@naman-bruno

@naman-bruno naman-bruno commented Dec 5, 2025 •

Copy link
Copy Markdown
Collaborator

Description

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

  • Tests
    • Refactored test suites to use shared helpers, reducing duplication and simplifying import/environment/request flows.
    • Improved reliability by replacing fixed waits with explicit timeouts and stronger locator-based assertions.
    • Made import/error checks more flexible to handle varied failure messages.
    • Expanded locator and helper coverage to stabilize UI interactions and validate responses more robustly.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 5, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Consolidates 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

Cohort / File(s) Summary
Import helpers & tests
tests/import/bruno/import-bruno-testbench.spec.ts, tests/import/insomnia/import-insomnia-v4.spec.ts, tests/import/insomnia/import-insomnia-v5.spec.ts, tests/import/openapi/import-openapi-json.spec.ts, tests/import/openapi/import-openapi-yaml.spec.ts, tests/import/postman/import-postman-v20.spec.ts, tests/import/postman/import-postman-v21.spec.ts
Replaced multi-step UI import flows with single importCollection(...) helper calls; removed inline expect imports and delegated import assertions to the helper; preserved cleanup via closeAllCollections.
Import error handling & resilience
tests/import/bruno/import-bruno-missing-required-schema.spec.ts, tests/import/openapi/missing-info.spec.ts, tests/import/openapi/malformed-yaml.spec.ts, tests/import/bruno/import-bruno-corrupted-fails.spec.ts, tests/import/bruno/import-bruno-with-examples.spec.ts, tests/import/insomnia/invalid-missing-collection.spec.ts, tests/import/postman/malformed-structure.spec.ts
Replaced boolean isVisible checks with explicit locator visibility assertions or combined/regex locators; introduced race-based waits and extended timeouts; simplified error matching to be more resilient.
Environment & API tests
tests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.ts, tests/environments/api-setEnvVar/api-setEnvVar-without-persist.spec.ts, tests/environments/create-environment/collection-env-create.spec.ts, tests/environments/create-environment/global-env-create.spec.ts, tests/environments/import-environment/.../collection-env-import.spec.ts
Added environment helpers (createEnvironment, addEnvironmentVariables, saveEnvironment, closeEnvironmentPanel, selectEnvironment), replaced manual send flows with sendRequest(page, expectedStatus), and increased some timeouts/delays in import-related flows.
Global & variable tests
tests/global-environments/non-string-values.spec.ts, tests/variable-tooltip/variable-tooltip.spec.ts, tests/interpolation/interpolate-request-url.spec.ts, tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts
Introduced buildCommonLocators() for stable selectors; replaced manual send-clicks with sendRequest(...); moved repeated environment setup into helpers and adjusted locators usage.
Response/request actions & creation
tests/response/response-actions.spec.ts
Added createRequest(...) and sendRequest(...) usage; replaced manual UI request creation and send flows with helpers; updated response assertions to use new response locators (e.g., copy button).
Preferences / autosave
tests/preferences/autosave/autosave.spec.ts
Replaced fixed sleeps with explicit assertions and timeouts for draft/autosave states; added page-closed guard in cleanup and extended test timeout.
Utility surface & locators
tests/utils/page/actions.ts, tests/utils/page/index.ts, tests/utils/page/locators.ts, tests/utils/page/runner.ts
Large expansion of test utilities: new exported helpers (importCollection, removeCollection, createRequest, createFolder, environment helpers, sendRequest, response helpers, runner/sandbox helpers), new types (SandboxMode, ImportCollectionOptions, EnvironmentType, EnvironmentVariable, CreateRequestOptions), re-exported locators, and many new locator builders for sidebar, modal, request, response, import, plusMenu, runner, and sandbox.
Misc small test adjustments
tests/import/bruno/import-bruno-corrupted-fails.spec.ts, tests/environments/import-environment/.../collection-env-import.spec.ts, others across tests
Increased timeouts, added deliberate delays for stability, switched some selectors to test-id-based locators, and removed redundant comments/inline waits in favor of deterministic waits.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

  • Attention areas:
    • tests/utils/page/actions.ts — validate new helper implementations, type annotations, and edge-case timeouts.
    • tests/utils/page/locators.ts — confirm selector correctness and robustness against UI changes.
    • tests/utils/page/runner.ts — verify runner/sandbox flows and race conditions.
    • Cross-check call sites in many tests to ensure helper semantics match previous per-test behavior (especially error paths and expectedStatus handling).

Possibly related PRs

Suggested reviewers

  • lohit-bruno
  • bijin-bruno
  • helloanoop

Poem

🧪 Clicks condensed to helpers' art,
Locators drawn to play their part.
Tests now call where steps once sprawled,
Small helpers keep the suite installed—
Cleaner lines and fewer hearts appalled. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'improve: tests' is vague and generic, using non-descriptive language that doesn't clearly convey the scope or nature of the changes. Replace with a specific description of the main refactoring effort, such as 'refactor: consolidate test utilities and use helper functions' or 'refactor: extract test helper functions for improved maintainability'.
✅ Passed checks (2 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.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@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: 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 previous waitForTimeout(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 pattern

Centralizing runner controls in buildRunnerLocators and reusing them in getRunnerResultCounts is 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 selectors

The new buildSandboxLocators + setSandboxMode helper 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 jsSandboxHeading locator to derive securityForm instead of hard-coding page.locator('div').filter({ hasText: 'JavaScript Sandbox' }), so heading semantics stay in one place.
  • Relax the developerModeRadio label 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 of sendRequest helper to de-duplicate request flow

Switching 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 clarity

Asserting 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 of sendRequest helper in persist test keeps flows aligned

Reusing 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 flag

Capturing errorMessage via getByText('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 from buildCommonLocators for 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 fileInput locator 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 afterEach hook 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 removeCollection to an afterEach for 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

📥 Commits

Reviewing files that changed from the base of the PR and between 80b017f and d24b12b.

📒 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() not func ()
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.ts
  • tests/import/openapi/malformed-yaml.spec.ts
  • tests/import/bruno/import-bruno-missing-required-schema.spec.ts
  • tests/utils/page/index.ts
  • tests/environments/api-setEnvVar/api-setEnvVar-without-persist.spec.ts
  • tests/response/response-actions.spec.ts
  • tests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.ts
  • tests/import/postman/import-postman-v21.spec.ts
  • tests/global-environments/non-string-values.spec.ts
  • tests/import/insomnia/import-insomnia-v4.spec.ts
  • tests/import/openapi/missing-info.spec.ts
  • tests/variable-tooltip/variable-tooltip.spec.ts
  • tests/utils/page/runner.ts
  • tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts
  • tests/import/bruno/import-bruno-testbench.spec.ts
  • tests/environments/create-environment/collection-env-create.spec.ts
  • tests/import/openapi/import-openapi-yaml.spec.ts
  • tests/environments/create-environment/global-env-create.spec.ts
  • tests/interpolation/interpolate-request-url.spec.ts
  • tests/import/postman/import-postman-v20.spec.ts
  • tests/utils/page/locators.ts
  • tests/import/openapi/import-openapi-json.spec.ts
  • tests/import/insomnia/import-insomnia-v5.spec.ts
  • tests/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.ts
  • tests/import/openapi/malformed-yaml.spec.ts
  • tests/import/bruno/import-bruno-missing-required-schema.spec.ts
  • tests/environments/api-setEnvVar/api-setEnvVar-without-persist.spec.ts
  • tests/response/response-actions.spec.ts
  • tests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.ts
  • tests/import/postman/import-postman-v21.spec.ts
  • tests/global-environments/non-string-values.spec.ts
  • tests/import/insomnia/import-insomnia-v4.spec.ts
  • tests/import/openapi/missing-info.spec.ts
  • tests/variable-tooltip/variable-tooltip.spec.ts
  • tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts
  • tests/import/bruno/import-bruno-testbench.spec.ts
  • tests/environments/create-environment/collection-env-create.spec.ts
  • tests/import/openapi/import-openapi-yaml.spec.ts
  • tests/environments/create-environment/global-env-create.spec.ts
  • tests/interpolation/interpolate-request-url.spec.ts
  • tests/import/postman/import-postman-v20.spec.ts
  • tests/import/openapi/import-openapi-json.spec.ts
  • tests/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 existing expect() playwright calls

  • Avoid using page.pause() in code

  • Use locator variables for locators

  • Avoid using test.only

  • Use multiple assertions

  • Promote the use of test.step as much as possible so the generated reports are easier to read

  • Ensure that the fixtures like the collections are nested inside the fixtures folder

    Fixture 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.ts
  • tests/import/openapi/malformed-yaml.spec.ts
  • tests/import/bruno/import-bruno-missing-required-schema.spec.ts
  • tests/utils/page/index.ts
  • tests/environments/api-setEnvVar/api-setEnvVar-without-persist.spec.ts
  • tests/response/response-actions.spec.ts
  • tests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.ts
  • tests/import/postman/import-postman-v21.spec.ts
  • tests/global-environments/non-string-values.spec.ts
  • tests/import/insomnia/import-insomnia-v4.spec.ts
  • tests/import/openapi/missing-info.spec.ts
  • tests/variable-tooltip/variable-tooltip.spec.ts
  • tests/utils/page/runner.ts
  • tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts
  • tests/import/bruno/import-bruno-testbench.spec.ts
  • tests/environments/create-environment/collection-env-create.spec.ts
  • tests/import/openapi/import-openapi-yaml.spec.ts
  • tests/environments/create-environment/global-env-create.spec.ts
  • tests/interpolation/interpolate-request-url.spec.ts
  • tests/import/postman/import-postman-v20.spec.ts
  • tests/utils/page/locators.ts
  • tests/import/openapi/import-openapi-json.spec.ts
  • tests/import/insomnia/import-insomnia-v5.spec.ts
  • tests/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.ts
  • tests/variable-tooltip/variable-tooltip.spec.ts
  • tests/utils/page/runner.ts
  • tests/environments/create-environment/collection-env-create.spec.ts
  • tests/environments/create-environment/global-env-create.spec.ts
  • tests/utils/page/locators.ts
  • tests/import/openapi/import-openapi-json.spec.ts
  • tests/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.ts
  • tests/utils/page/runner.ts
  • tests/interpolation/dynamic-variable/set-var-dynamic-variable.spec.ts
  • tests/environments/create-environment/collection-env-create.spec.ts
  • tests/environments/create-environment/global-env-create.spec.ts
  • tests/interpolation/interpolate-request-url.spec.ts
  • tests/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 on page.isClosed() is a solid stability improvement

The conditional closeAllCollections in afterEach avoids acting on a closed page and should reduce noisy teardown failures.


60-66: Autosave enabled: expectation-based wait is appropriate

Swapping 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 good

Using 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: runCollection flow is much clearer and more deterministic now

Wrapping the entire run sequence in test.step, scoping the collection selector to getByTestId('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 cohesive

Adding 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 modes

Using 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 solid

Using buildCommonLocators for sidebar interactions and sendRequest(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 step

Switching the “Run the request” step to buildCommonLocators(page).sidebar.request('set-global-nonstring') plus sendRequest(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 cleanly

Delegating 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 helpers

Using buildCommonLocators(page) for sidebar.request('set-var-dynamic-variable') and sendRequest(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 import

Mirroring 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 consistent

The 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 locators

Creating the collection/request with createCollection + createRequestWithUrl, sending via sendRequest(page, 200), and using buildCommonLocators(page).response.copyButton() inside test.step blocks 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 pattern

Refactoring 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 importCollection helper, 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 afterEach for 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 of buildCommonLocators for 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.

closeAllCollectionsButton uses a test ID (robust), while collectionRow uses a structured filter approach.


56-68: Comprehensive environment locators.

Good coverage for environment management flows. The index-based approach for variableNameInput, variableSecretCheckbox, and variableRow is 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, and closeEnvironmentPanel helpers effectively. The assertion on currentEnvironment confirms 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: true flag for secretApiToken demonstrates 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.step for report clarity
  • Explicit waits with waitFor
  • Optional expectedCollectionName and openWithSandboxMode parameters

The 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 openEnvironmentSelector and createEnvironment functions 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 expectedStatusCode accepts both number and string for flexibility.


552-577: Comprehensive exports.

All helpers and types are properly exported for test consumption.

Comment thread tests/utils/page/runner.ts Resolved

@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: 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.step to 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 reporting

Using buildCommonLocators and sendRequest(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 in test.step blocks 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 test

Here you build locators but only click locators.sidebar.request('echo-request-odata') without selecting the interpolation collection first. If request() 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. If request() is globally scoped, you’re fine, but it’s worth double‑checking and potentially adding the explicit collection('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 preceding waitForTimeout now

With await expect(...).not.toBeVisible({ timeout: 10000 }), the explicit page.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.waitForTimeout usage 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 generic Error text

The composite error locator and longer timeout should make this test more resilient, but the |Error branch 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 Error alternative 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-broad Error match

Using 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 naming

The Promise.race between the location modal and the error message is a nice way to avoid hanging on failures, and the explicit error/timeout branches 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 copy

Switching to createCollection, createRequest, sendRequest, and buildCommonLocators makes 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 item

The 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: Reuse SandboxMode alias where possible for consistency

You’ve introduced type SandboxMode = 'safe' | 'developer'; but CreateCollectionOptions and openCollectionAndAcceptSandbox still spell out the union type inline:

type CreateCollectionOptions = {
  openWithSandboxMode?: 'safe' | 'developer';
};
...
const openCollectionAndAcceptSandbox = async (page, collectionName: string, sandboxMode: 'safe' | 'developer' = 'safe') => {

Switching these to SandboxMode will 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 opportunity

The new importCollection, removeCollection, and createFolder helpers give tests a much cleaner, high-level API for collection lifecycle.

A couple of small polish points to consider:

  • In importCollection, you already have buildCommonLocators(page) but still use raw selectors for input[type="file"], the import modal, and #collection-location. Using the import and modal locators from buildCommonLocators would keep selectors in one place.
  • removeCollection and createFolder are already using buildCommonLocators effectively 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 locators

The environment helpers (openEnvironmentSelector, createEnvironment, addEnvironmentVariable(s), saveEnvironment, closeEnvironmentPanel, selectEnvironment) make env flows much easier to script and assert.

Two improvement areas:

  • Selector reuse: addEnvironmentVariable manually wires selectors for the add button, name input, row, and secret checkbox, even though buildCommonLocators already exposes environment.addVariableButton, variableNameInput, variableRow, variableSecretCheckbox. Using those would remove duplication and keep selectors aligned with other tests.

  • Close button targeting: closeEnvironmentPanel uses page.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, and expectResponseContains nicely 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() inside sendRequest, 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

📥 Commits

Reviewing files that changed from the base of the PR and between d24b12b and e7e202a.

📒 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() not func ()
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.ts
  • tests/environments/import-environment/bruno-env-import/collection-env-import/collection-env-import.spec.ts
  • tests/interpolation/interpolate-request-url.spec.ts
  • tests/import/postman/malformed-structure.spec.ts
  • tests/preferences/autosave/autosave.spec.ts
  • tests/import/insomnia/invalid-missing-collection.spec.ts
  • tests/import/bruno/import-bruno-with-examples.spec.ts
  • tests/response/response-actions.spec.ts
  • tests/environments/create-environment/global-env-create.spec.ts
  • tests/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 existing expect() playwright calls

  • Avoid using page.pause() in code

  • Use locator variables for locators

  • Avoid using test.only

  • Use multiple assertions

  • Promote the use of test.step as much as possible so the generated reports are easier to read

  • Ensure that the fixtures like the collections are nested inside the fixtures folder

    Fixture 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.ts
  • tests/environments/import-environment/bruno-env-import/collection-env-import/collection-env-import.spec.ts
  • tests/interpolation/interpolate-request-url.spec.ts
  • tests/import/postman/malformed-structure.spec.ts
  • tests/preferences/autosave/autosave.spec.ts
  • tests/import/insomnia/invalid-missing-collection.spec.ts
  • tests/import/bruno/import-bruno-with-examples.spec.ts
  • tests/response/response-actions.spec.ts
  • tests/environments/create-environment/global-env-create.spec.ts
  • tests/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.ts
  • tests/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.ts
  • tests/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 imports

Importing closeAllCollections, sendRequest, and buildCommonLocators centralizes 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 reasonable

Given 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 defensive page.isClosed() guard in cleanup

This avoids noisy Target closed/page closed errors when a test intentionally closes the page before afterEach runs, while still ensuring collections are cleaned up when the page is alive.


67-67: Nice switch from fixed sleep to timeout-based assertion

Using await expect(...).not.toBeVisible({ timeout: 5000 }) is a solid improvement over a hard waitForTimeout, and keeps the test robust to autosave timing as long as it settles within 5s.

tests/utils/page/actions.ts (2)

87-135: createRequest helper nicely unifies collection/folder flows

The new CreateRequestOptions + createRequest abstraction 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-facing

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

@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: 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.step as 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 explicit

Centralizing the runner buttons in buildRunnerLocators is a solid improvement and keeps getRunnerResultCounts readable, 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, parseInt will quietly return NaN and 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 tightly

Wrapping the collection run in a test.step, scoping interactions through collectionContainer/actionsContainer, and reusing buildRunnerLocators is 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 locators

The new buildSandboxLocators + setSandboxMode flow is a nice abstraction: it keeps the steps readable, uses test.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:

  1. Bound isVisible() calls on badges to avoid unnecessary waiting when no badge exists

Right 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);
  1. 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.)

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

📥 Commits

Reviewing files that changed from the base of the PR and between e7e202a and d315a1e.

📒 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() not func ()
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.ts
  • tests/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 existing expect() playwright calls

  • Avoid using page.pause() in code

  • Use locator variables for locators

  • Avoid using test.only

  • Use multiple assertions

  • Promote the use of test.step as much as possible so the generated reports are easier to read

  • Ensure that the fixtures like the collections are nested inside the fixtures folder

    Fixture 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.ts
  • tests/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 getByTestId provides a more stable and explicit selector for the modal close button.

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.

2 participants