feat(ui): integrate pricing overrides into provider config#1831
Draft
monotykamary wants to merge 9 commits intomaximhq:mainfrom
Draft
feat(ui): integrate pricing overrides into provider config#1831monotykamary wants to merge 9 commits intomaximhq:mainfrom
monotykamary wants to merge 9 commits intomaximhq:mainfrom
Conversation
- Import PricingOverridesFormFragment from fragments - Add 'pricing' tab to availableTabs() after debugging tab - Add TabsContent for pricing tab with PricingOverridesFormFragment - Tab appears for all providers with data-testid='provider-tab-pricing' Task: task-1
Add E2E test selectors for the pricing tab: - pricingTab: selector for the pricing tab button - pricingForm.container: container for the pricing form - pricingForm.jsonInput: JSON input for pricing overrides - pricingForm.resetBtn: reset button - pricingForm.saveBtn: save button Task: task-4
- Replace manual useState with useForm + zodResolver - Form field: pricing_overrides_json (JSON string validated as array) - Use form.formState.isDirty for dirty tracking - Use form.reset() after successful save - Use form.handleSubmit(onSubmit) for save button - Preserve all existing data-testid attributes - Preserve task-2 fix: pricing_overrides passed to updateProvider Task: task-3
Add methods for interacting with the pricing configuration tab: - selectConfigTab() now accepts 'pricing' parameter - getConfigSaveBtn() now accepts 'pricing' with 'Save Pricing Overrides' label - getPricingJsonInput() - returns locator for JSON textarea - getPricingResetBtn() - returns locator for reset button - getPricingSaveBtn() - returns locator for save button - savePricingConfig() - clicks save and waits for success toast - isPricingTabVisible() - checks if pricing tab is visible - setPricingOverridesJson() - helper to fill JSON textarea Task: task-1
Replace inline helper functions with page object methods: - Remove getPricingJsonInput(), setPricingOverridesJson(), savePricingConfig() helpers - Use providersPage.getPricingJsonInput() instead - Use providersPage.setPricingOverridesJson() instead - Use providersPage.savePricingConfig() instead - Use providersPage.getPricingSaveBtn() and getPricingResetBtn() instead Makes tests consistent with other config test patterns. Task: task-4
The pricing configuration methods were defined outside the class body, causing them to be undefined on ProvidersPage instances. Moved all pricing methods inside the class: - getPricingJsonInput() - getPricingResetBtn() - getPricingSaveBtn() - savePricingConfig() - isPricingTabVisible() - setPricingOverridesJson() Task: task-1
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ered in providers.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR integrates the existing
PricingOverridesFormFragmentinto the Provider Configuration sheet, enabling users to set custom pricing for any provider (including custom providers) through the UI. Previously, pricing overrides could only be set via API or config.json.Changes
UI Changes
react-hook-formwithzodResolverfor consistent form handlinguseStatewith proper form state managementupdateProvidermutationE2E Test Coverage
Type of change
Affected areas
How to test
UI Development
cd ui pnpm i pnpm dev[ { "model_pattern": "gpt-4o*", "match_type": "wildcard", "request_types": ["chat_completion"], "input_cost_per_token": 0.000005, "output_cost_per_token": 0.000015 } ]E2E Tests
Screenshots/Recordings
N/A - The UI follows existing design patterns from other config tabs (Network, Proxy, Performance, Governance).
The Pricing tab:
Breaking changes
Related issues
N/A - This is a feature enhancement based on user inquiry about setting custom provider costs through the UI.
Security considerations
useRbac(RbacResource.ModelProvider, RbacOperation.Update)Checklist
docs/contributing/README.mdand followed the guidelines