mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix defaultig to Credits tab
This commit is contained in:
3 files changed
+11
-13
No files matched your search
@@ -41,7 +41,6 @@ interface AIProviderConfigDialogProps {
|
||||
provider: AIProvider;
|
||||
onUpdate: (provider: AIProvider) => void;
|
||||
onRemove: () => void;
|
||||
initialTab?: 'credits' | 'edit';
|
||||
}
|
||||
|
||||
interface Payment {
|
||||
@@ -339,7 +338,6 @@ export function AIProviderConfigDialog({
|
||||
provider,
|
||||
onUpdate,
|
||||
onRemove,
|
||||
initialTab = 'credits',
|
||||
}: AIProviderConfigDialogProps) {
|
||||
const { t } = useTranslation();
|
||||
const { user } = useCurrentUser();
|
||||
@@ -378,12 +376,12 @@ export function AIProviderConfigDialog({
|
||||
if (open && !isLoadingCredits) {
|
||||
// Default to 'credits' tab if credits are supported, otherwise 'edit'
|
||||
if (supportsCredits) {
|
||||
setActiveTab(initialTab || 'credits');
|
||||
setActiveTab('credits');
|
||||
} else {
|
||||
setActiveTab('edit');
|
||||
}
|
||||
}
|
||||
}, [open, supportsCredits, isLoadingCredits, initialTab]);
|
||||
}, [open, supportsCredits, isLoadingCredits]);
|
||||
|
||||
// Query for payment preview (to get fee information)
|
||||
const { data: paymentPreview, isLoading: isLoadingPreview } = useQuery({
|
||||
|
||||
@@ -30,7 +30,8 @@ describe('CreditsBadge', () => {
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
expect(screen.getByText('$10.50')).toBeInTheDocument();
|
||||
// Credits are formatted as whole dollars (10.50 rounds to $11)
|
||||
expect(screen.getByText('$11')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('calls onOpenDialog when badge is clicked', () => {
|
||||
@@ -45,7 +46,7 @@ describe('CreditsBadge', () => {
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
const badge = screen.getByText('$10.50');
|
||||
const badge = screen.getByText('$11');
|
||||
fireEvent.click(badge);
|
||||
|
||||
expect(mockCallback).toHaveBeenCalled();
|
||||
@@ -58,7 +59,7 @@ describe('CreditsBadge', () => {
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
const badge = screen.getByText('$10.50');
|
||||
const badge = screen.getByText('$11');
|
||||
expect(badge).toHaveClass('cursor-pointer');
|
||||
expect(badge).toHaveClass('hover:bg-secondary/80');
|
||||
});
|
||||
|
||||
@@ -38,7 +38,6 @@ describe('AIProviderConfigDialog - Credits Tab', () => {
|
||||
provider={mockProvider}
|
||||
onUpdate={() => {}}
|
||||
onRemove={() => {}}
|
||||
initialTab="credits"
|
||||
/>
|
||||
</TestApp>
|
||||
);
|
||||
@@ -77,7 +76,6 @@ describe('AIProviderConfigDialog - Credits Tab', () => {
|
||||
provider={mockProvider}
|
||||
onUpdate={() => {}}
|
||||
onRemove={() => {}}
|
||||
initialTab="credits"
|
||||
/>
|
||||
</TestApp>
|
||||
);
|
||||
@@ -101,18 +99,20 @@ describe('AIProviderConfigDialog - Credits Tab', () => {
|
||||
provider={mockProvider}
|
||||
onUpdate={() => {}}
|
||||
onRemove={() => {}}
|
||||
initialTab="credits"
|
||||
/>
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
// Wait for the Buy Credits accordion to be visible
|
||||
// The "add" accordion defaults to being open
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Buy Credits')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// The preset buttons should be visible since the accordion defaults to open
|
||||
// Click the accordion to expand it (accordions default to closed)
|
||||
const buyCreditsButton = screen.getByText('Buy Credits');
|
||||
buyCreditsButton.click();
|
||||
|
||||
// Now the preset buttons should be visible
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('$5')).toBeInTheDocument();
|
||||
expect(screen.getByText('$10')).toBeInTheDocument();
|
||||
@@ -145,7 +145,6 @@ describe('AIProviderConfigDialog - Credits Tab', () => {
|
||||
provider={mockProvider}
|
||||
onUpdate={() => {}}
|
||||
onRemove={() => {}}
|
||||
initialTab="credits"
|
||||
/>
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user