Skip to content

fix(playwright): interpolate request url with odata param#6428

Merged
bijin-bruno merged 1 commit intomainfrom
fix/interpolation-url-test
Dec 17, 2025
Merged

fix(playwright): interpolate request url with odata param#6428
bijin-bruno merged 1 commit intomainfrom
fix/interpolation-url-test

Conversation

@bijin-bruno
Copy link
Collaborator

@bijin-bruno bijin-bruno commented Dec 17, 2025

Description

Fixes playwright test - interpolate request url with odata param

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
    • Updated test data configuration and improved test element selection methods.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Walkthrough

Updated test preference configuration and refactored test selectors to use testid-based locators instead of CSS nth-child selectors for improved element targeting reliability.

Changes

Cohort / File(s) Summary
Test Configuration
tests/interpolation/init-user-data/preferences.json
Updated "maximized" boolean value from true to false
Test Selector Refactoring
tests/interpolation/interpolate-request-url.spec.ts
Replaced nth-child DOM selectors with getByTestId('response-preview-container') for more maintainable element targeting across test cases

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Configuration value change is straightforward
  • Selector updates follow a consistent, repetitive pattern with no logic changes

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno

Poem

🧪 Selectors swap for cleaner test,
✨ IDs now guide the quest,
Config tweaks, no complexity—
Better tests in harmony!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing a Playwright test for URL interpolation with OData parameters, which aligns with the test selector updates in interpolate-request-url.spec.ts.
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
  • Commit unit tests in branch fix/interpolation-url-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/interpolation/interpolate-request-url.spec.ts (1)

10-18: Consider using test.step for better report readability.

As per coding guidelines, promote the use of test.step to make generated reports easier to read. Both test cases would benefit from steps like "Navigate to request", "Send request", and "Verify response".

Example refactor for the first test:

test('Interpolate basic path params', async ({ pageWithUserData: page }) => {
  const locators = buildCommonLocators(page);
  
  await test.step('Navigate to echo-request-url', async () => {
    await locators.sidebar.collection('interpolation').click();
    await locators.sidebar.request('echo-request-url').click();
  });
  
  await test.step('Send request and verify response', async () => {
    await sendRequest(page, 200);
    const responsePreview = page.getByTestId('response-preview-container').locator('.CodeMirror-scroll');
    const texts = await responsePreview.allInnerTexts();
    await expect(texts.some((d) => d.includes(`"url": "/path/some-data"`))).toBe(true);
  });
});

Also applies to: 20-27

📜 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 2eb8db9 and a81a8c0.

📒 Files selected for processing (2)
  • tests/interpolation/init-user-data/preferences.json (1 hunks)
  • tests/interpolation/interpolate-request-url.spec.ts (2 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/interpolation/interpolate-request-url.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/interpolation/interpolate-request-url.spec.ts
  • tests/interpolation/init-user-data/preferences.json
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
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
⏰ 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: CLI Tests
  • GitHub Check: Unit Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - Windows
🔇 Additional comments (1)
tests/interpolation/init-user-data/preferences.json (1)

2-2: Verify the window state change is intentional.

Changing maximized from true to false may improve test stability, but this seems unrelated to the PR objective about URL interpolation. Please confirm this change is necessary and whether it addresses a specific test issue.

await sendRequest(page, 200);

const texts = await page.locator('div:nth-child(2) > .CodeMirror-scroll').allInnerTexts();
const texts = await page.getByTestId('response-preview-container').locator('.CodeMirror-scroll').allInnerTexts();
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Excellent selector improvement, but extract the repeated locator.

Replacing the brittle nth-child selector with getByTestId('response-preview-container') is a solid improvement for test stability. However, this exact locator pattern is repeated on lines 16 and 25. As per coding guidelines, extract it to a locator variable.

Apply this diff:

 test('Interpolate basic path params', async ({ pageWithUserData: page }) => {
   const locators = buildCommonLocators(page);
   await locators.sidebar.collection('interpolation').click();
   await locators.sidebar.request('echo-request-url').click();
   await sendRequest(page, 200);

-  const texts = await page.getByTestId('response-preview-container').locator('.CodeMirror-scroll').allInnerTexts();
+  const responsePreview = page.getByTestId('response-preview-container').locator('.CodeMirror-scroll');
+  const texts = await responsePreview.allInnerTexts();
   await expect(texts.some((d) => d.includes(`"url": "/path/some-data"`))).toBe(true);
 });

 test('Interpolate oData path params', async ({ pageWithUserData: page }) => {
   const locators = buildCommonLocators(page);
   await locators.sidebar.request('echo-request-odata').click();
   await sendRequest(page, 200);

-  const texts = await page.getByTestId('response-preview-container').locator('.CodeMirror-scroll').allInnerTexts();
+  const responsePreview = page.getByTestId('response-preview-container').locator('.CodeMirror-scroll');
+  const texts = await responsePreview.allInnerTexts();
   await expect(texts.some((d) => d.includes(`"url": "/path/Category('category123')/Item(item456)/foobar/Tags(%22tag%20test%22)"`))).toBe(true);
 });

Also applies to: 25-25

🤖 Prompt for AI Agents
In tests/interpolation/interpolate-request-url.spec.ts around lines 16 and 25,
the locator
getByTestId('response-preview-container').locator('.CodeMirror-scroll') is
duplicated; extract it into a single const (e.g., const responsePreview =
page.getByTestId('response-preview-container').locator('.CodeMirror-scroll')) at
the top of the test or before use and replace both occurrences on lines 16 and
25 with the new variable to avoid repetition and improve maintainability.

@github-actions
Copy link

CLI Test Results

  1 files  ±0  140 suites  ±0   1m 5s ⏱️ +21s
235 tests ±0  235 ✅ ±0  0 💤 ±0  0 ❌ ±0 
301 runs  ±0  300 ✅ ±0  1 💤 ±0  0 ❌ ±0 

Results for commit a81a8c0. ± Comparison against base commit 2eb8db9.

@bijin-bruno bijin-bruno merged commit 7d317a7 into main Dec 17, 2025
8 of 9 checks passed
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.

1 participant