Skip to content

fix: e2e ui tests for model limts - #4519

Merged
akshaydeo merged 1 commit into
devfrom
06-18-fix_e2e_ui_tests_for_model_limts
Jun 19, 2026
Merged

fix: e2e ui tests for model limts#4519
akshaydeo merged 1 commit into
devfrom
06-18-fix_e2e_ui_tests_for_model_limts

Conversation

@sammaji

@sammaji sammaji commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary

Updates the model limits E2E page object to align with the current UI, where the model selector now defaults to "All Models" via a combobox rather than a searchable multiselect. Also introduces a reusable setBudget helper that handles adding a budget line, filling the amount, and optionally selecting a reset period.

Changes

  • Replaced the model multiselect search-and-select flow with a single combobox click that selects "All Models", reflecting the current UI behavior. The selected model name is now hardcoded to '*'.
  • Extracted budget configuration into a private setBudget method used by both createModelLimit and updateModelLimit, replacing the previous inline #modelBudgetMaxLimit locator usage.
  • Added a resetPeriodLabels map to translate duration shorthand keys (e.g. '1h', '1d') into their human-readable dropdown labels (e.g. 'Hourly', 'Daily') for selecting reset periods in the budget line combobox.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

Run the model limits E2E tests and verify that limit creation and update flows complete without errors, including budget lines with reset periods.

cd tests/e2e
pnpm test --grep "model-limits"

Breaking changes

  • Yes
  • No

Related issues

Security considerations

None.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fd7f253f-fadd-4822-853a-f58e75d9c8f6

📥 Commits

Reviewing files that changed from the base of the PR and between eee4550 and 2ebd0ab.

📒 Files selected for processing (1)
  • tests/e2e/features/model-limits/pages/model-limits.page.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/features/model-limits/pages/model-limits.page.ts

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Updated the model limits end-to-end test page to centralize budget handling and consistently apply reset-period selections when a reset duration is set.
    • Improved model creation by selecting the correct model from the model combobox using exact option matching.
    • Streamlined edit flows so budget updates are applied uniformly, improving reliability and maintainability of the test suite.

Walkthrough

The e2e model-limits page adds a resetPeriodLabels constant and escapeRegex utility, introduces a private setBudget helper to centralize budget-sheet interactions, and refactors createModelLimit to use combobox-based model selection with regex matching. Both createModelLimit and editModelLimit now use setBudget instead of inline budget input manipulation.

Changes

Model Limits E2E Page Helper Refactor

Layer / File(s) Summary
Helper constants and utility functions
tests/e2e/features/model-limits/pages/model-limits.page.ts
Adds resetPeriodLabels constant mapping reset-duration keys to UI option labels, and escapeRegex utility for safely escaping model names when building regex patterns for option matching.
setBudget helper method
tests/e2e/features/model-limits/pages/model-limits.page.ts
Introduces a private setBudget method that ensures a budget row exists, fills the amount field, and optionally selects a reset period option from a combobox using resetPeriodLabels.
Update createModelLimit and editModelLimit
tests/e2e/features/model-limits/pages/model-limits.page.ts
createModelLimit refactors model selection to interact with a combobox and match options using the escaped config.modelName regex, and delegates budget entry to setBudget. editModelLimit replaces conditional clear/fill logic with a setBudget call.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • maximhq/bifrost#3460: The main PR's model-limits.page.ts changes refactor budget-line filling by translating resetDuration via a label map and selecting the corresponding reset-period UI option, mirroring similar multi-budget and reset-duration UI test refactoring patterns.

Suggested reviewers

  • akshaydeo
  • danpiths

Poem

🐇 Helpers unite with resetPeriodLabels in hand,
escapeRegex guards model names so grand!
setBudget consolidates the budget-sheet dance,
Combobox selection gets its second chance.
Refactored, centralized—what a perfect array! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'fix: e2e ui tests for model limts' is partially related but contains a typo ('limts' instead of 'limits') and is misleading—the PR description and summary clearly indicate this is a refactor, not a bug fix. Correct the typo and update the title to reflect the actual change type: 'refactor: e2e ui tests for model limits' or 'refactor: align model limits page object with current UI'.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description is comprehensive and well-structured, covering summary, changes, type of change, affected areas, testing instructions, and checklist completion.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 06-18-fix_e2e_ui_tests_for_model_limts

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

sammaji commented Jun 18, 2026

Copy link
Copy Markdown
Member Author

@sammaji
sammaji marked this pull request as ready for review June 18, 2026 08:26
@greptile-apps

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Scoped to a single E2E page object with no production code changes; safe to merge.

The changes are confined to one test helper file. The logic is straightforward: combobox interaction replaces the old multiselect input flow, and the new setBudget method correctly branches between adding a fresh budget line and updating an existing one. The only finding is a dead escapeRegex function with no call sites, which has no impact on test correctness or runtime behavior.

No files require special attention beyond confirming the resetPeriodLabels keys match whatever duration values the test data passes in.

Important Files Changed

Filename Overview
tests/e2e/features/model-limits/pages/model-limits.page.ts Refactored model select from multiselect-input to combobox flow; extracted reusable setBudget helper with reset-period support; escapeRegex added but unused.

Reviews (4): Last reviewed commit: "fix: e2e ui tests for model limts" | Re-trigger Greptile

@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

🧹 Nitpick comments (1)
tests/e2e/features/model-limits/pages/model-limits.page.ts (1)

18-21: ⚡ Quick win

Align ModelLimitConfig/docs with the new “All Models only” behavior.

Line 20 still requires modelName, and Lines 110-113 still describe selecting config.modelName, but Lines 126-132 now always select “All Models” and return '*'. This contract drift will confuse callers and future test updates.

Suggested cleanup
 export interface ModelLimitConfig {
   provider: string
-  modelName: string
+  // Current UI flow only supports wildcard model limit creation.
+  modelName?: string
   budget?: { maxLimit: number; resetDuration?: string }
   rateLimit?: {
     tokenMaxLimit?: number
     requestMaxLimit?: number
   }
 }

 /**
- * Create a model limit via the sheet: selects provider, selects the requested
- * model (config.modelName) in the search dropdown, fills budget and rate
- * limit, then saves. Returns the selected model name for use in exists/edit/delete.
+ * Create a model limit via the sheet: selects provider, selects "All Models",
+ * fills budget and rate limit, then saves. Returns '*' for exists/edit/delete lookups.
  */

Also applies to: 109-113, 126-132

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/features/model-limits/pages/model-limits.page.ts` around lines 18 -
21, The ModelLimitConfig interface requires modelName as a mandatory field, but
the implementation in the function that uses this config (around lines 126-132)
always selects "All Models" and returns '*', ignoring the modelName value.
Additionally, the comments at lines 110-113 describe selecting config.modelName
which no longer matches the actual behavior. Make the modelName property
optional in the ModelLimitConfig interface by adding a question mark, and update
all documentation and comments that reference selecting config.modelName to
clarify that "All Models" is always selected regardless of the provided
modelName value.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/e2e/features/model-limits/pages/model-limits.page.ts`:
- Around line 101-106: The code in setBudget method currently uses a fallback to
the raw config.resetDuration value when it's not found in resetPeriodLabels,
which causes silent failures and timeouts during option lookup. Add an explicit
guard that throws an error with a clear message immediately after attempting to
retrieve resetPeriodLabel from resetPeriodLabels, ensuring that unsupported
resetDuration values fail fast with actionable feedback instead of timing out
during the getByRole option click.

---

Nitpick comments:
In `@tests/e2e/features/model-limits/pages/model-limits.page.ts`:
- Around line 18-21: The ModelLimitConfig interface requires modelName as a
mandatory field, but the implementation in the function that uses this config
(around lines 126-132) always selects "All Models" and returns '*', ignoring the
modelName value. Additionally, the comments at lines 110-113 describe selecting
config.modelName which no longer matches the actual behavior. Make the modelName
property optional in the ModelLimitConfig interface by adding a question mark,
and update all documentation and comments that reference selecting
config.modelName to clarify that "All Models" is always selected regardless of
the provided modelName value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cc175b80-33d1-4964-8b99-0c8906a85d53

📥 Commits

Reviewing files that changed from the base of the PR and between 64ffcd7 and c868296.

📒 Files selected for processing (1)
  • tests/e2e/features/model-limits/pages/model-limits.page.ts

Comment thread tests/e2e/features/model-limits/pages/model-limits.page.ts
@sammaji
sammaji force-pushed the 06-18-fix_e2e_ui_tests_for_model_limts branch from c868296 to d8f4dbf Compare June 18, 2026 08:54
@coderabbitai
coderabbitai Bot requested a review from akshaydeo June 18, 2026 08:55

@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

🧹 Nitpick comments (2)
tests/e2e/features/model-limits/pages/model-limits.page.ts (2)

146-149: 💤 Low value

Prefer data-testid selectors over hardcoded IDs.

Lines 146 and 149 use #modelTokenMaxLimit and #modelRequestMaxLimit ID selectors. Using data-testid attributes (like the rest of the page object) would improve resilience to UI refactoring.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/features/model-limits/pages/model-limits.page.ts` around lines 146
- 149, Replace the hardcoded ID selectors in the fill operations for model
limits with data-testid attributes to maintain consistency with the rest of the
page object and improve resilience to UI changes. Specifically, change the
locator selectors from using `#modelTokenMaxLimit` to use a data-testid
attribute format and from `#modelRequestMaxLimit` to use a data-testid attribute
format, following the same pattern used elsewhere in the model-limits.page.ts
file.

139-141: ⚡ Quick win

Consider adding verification after model selection.

After clicking the option and pressing Tab, there's no assertion that the combobox accepted the selection. Adding a brief check (e.g., verify the combobox displays the expected value) would catch selection failures earlier and reduce flakiness.

💡 Example verification
     await targetOption.click()
     await this.page.keyboard.press('Tab')
+    await expect(modelInput).toHaveValue(searchTerm, { timeout: 3000 })
     const selectedModelName = config.modelName
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/features/model-limits/pages/model-limits.page.ts` around lines 139
- 141, The code clicks on targetOption and presses Tab to select a model but
doesn't verify the selection succeeded. After the Tab press, add an assertion to
verify that the combobox element displays the expected selectedModelName value.
This will catch selection failures early and prevent flaky tests. You can use a
waitFor or expect statement to check that the combobox contains or displays the
selected model name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/e2e/features/model-limits/pages/model-limits.page.ts`:
- Around line 130-142: Add special case handling for when config.modelName is
the literal '*' character representing All Models. Before the
modelInput.pressSequentially call on line 134, check if config.modelName equals
'*' and if so, set a separate displayName variable to 'All Models' to use in the
regex search on lines 135-137, while typing a different input (such as 'All')
via pressSequentially that will properly display the All Models option in the
dropdown. This ensures the regex pattern and UI interaction match correctly when
the special All Models identifier is used.

---

Nitpick comments:
In `@tests/e2e/features/model-limits/pages/model-limits.page.ts`:
- Around line 146-149: Replace the hardcoded ID selectors in the fill operations
for model limits with data-testid attributes to maintain consistency with the
rest of the page object and improve resilience to UI changes. Specifically,
change the locator selectors from using `#modelTokenMaxLimit` to use a
data-testid attribute format and from `#modelRequestMaxLimit` to use a
data-testid attribute format, following the same pattern used elsewhere in the
model-limits.page.ts file.
- Around line 139-141: The code clicks on targetOption and presses Tab to select
a model but doesn't verify the selection succeeded. After the Tab press, add an
assertion to verify that the combobox element displays the expected
selectedModelName value. This will catch selection failures early and prevent
flaky tests. You can use a waitFor or expect statement to check that the
combobox contains or displays the selected model name.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 346e1164-51a8-4c7e-82b1-87a3427bf47a

📥 Commits

Reviewing files that changed from the base of the PR and between c868296 and d8f4dbf.

📒 Files selected for processing (1)
  • tests/e2e/features/model-limits/pages/model-limits.page.ts

Comment thread tests/e2e/features/model-limits/pages/model-limits.page.ts
@sammaji
sammaji force-pushed the 06-18-fix_e2e_ui_tests_for_model_limts branch from d8f4dbf to eee4550 Compare June 19, 2026 09:36
@sammaji
sammaji force-pushed the 06-18-fix_e2e_ui_tests_for_providers_management branch from 64ffcd7 to 79c6471 Compare June 19, 2026 09:36
@sammaji sammaji mentioned this pull request Jun 19, 2026
18 tasks
@coderabbitai
coderabbitai Bot requested a review from danpiths June 19, 2026 09:37

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/e2e/features/model-limits/pages/model-limits.page.ts`:
- Around line 138-141: The RegExp pattern for matching the model name in the
getByRole call is unanchored, which allows partial matches like "gpt-4" matching
"gpt-4o", causing the wrong option to be selected. Anchor the regex pattern with
`^` at the start and `$` at the end in the expression `new
RegExp(escapeRegex(config.modelName))` to ensure it matches the exact model name
only, preventing incorrect option selection when calling `.first()`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5f6c158d-a5a8-46ea-8498-3d8dfa18418f

📥 Commits

Reviewing files that changed from the base of the PR and between d8f4dbf and eee4550.

📒 Files selected for processing (1)
  • tests/e2e/features/model-limits/pages/model-limits.page.ts

Comment thread tests/e2e/features/model-limits/pages/model-limits.page.ts Outdated
Comment thread tests/e2e/features/model-limits/pages/model-limits.page.ts Outdated
@sammaji
sammaji force-pushed the 06-18-fix_e2e_ui_tests_for_model_limts branch from eee4550 to 2ebd0ab Compare June 19, 2026 10:48
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 19, 2026

akshaydeo commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • Jun 19, 6:09 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 19, 6:11 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo changed the base branch from 06-18-fix_e2e_ui_tests_for_providers_management to graphite-base/4519 June 19, 2026 18:10
@akshaydeo
akshaydeo changed the base branch from graphite-base/4519 to dev June 19, 2026 18:10
@akshaydeo
akshaydeo dismissed coderabbitai[bot]’s stale review June 19, 2026 18:10

The base branch was changed.

@akshaydeo
akshaydeo merged commit dc7206e into dev Jun 19, 2026
10 checks passed
@akshaydeo
akshaydeo deleted the 06-18-fix_e2e_ui_tests_for_model_limts branch June 19, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants