Browse Source

fix(24-02): update CostDialog tests for new CostBreakdownItem interface

- Update test data to use new multi-provider interface fields
- Add test for unknown pricing indicator
- Remove resolution-specific test that no longer applies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 6 months ago
parent
commit
028f9a0404
  1. 45
      src/components/__tests__/CostDialog.test.tsx

45
src/components/__tests__/CostDialog.test.tsx

@ -47,21 +47,26 @@ describe("CostDialog", () => {
totalCost: 0.50, totalCost: 0.50,
breakdown: [ breakdown: [
{ {
model: "nano-banana", provider: "gemini",
resolution: "1K", modelId: "nano-banana",
modelName: "Nano Banana",
count: 5, count: 5,
unitCost: 0.039, unitCost: 0.039,
unit: "image",
subtotal: 0.195, subtotal: 0.195,
}, },
{ {
model: "nano-banana-pro", provider: "gemini",
resolution: "2K", modelId: "nano-banana-pro",
modelName: "Nano Banana Pro",
count: 2, count: 2,
unitCost: 0.134, unitCost: 0.134,
unit: "image",
subtotal: 0.268, subtotal: 0.268,
}, },
], ],
nodeCount: 7, nodeCount: 7,
unknownPricingCount: 0,
...overrides, ...overrides,
}); });
@ -184,7 +189,7 @@ describe("CostDialog", () => {
expect(screen.getByText(/2x Nano Banana Pro/)).toBeInTheDocument(); expect(screen.getByText(/2x Nano Banana Pro/)).toBeInTheDocument();
}); });
it("should show resolution for Nano Banana Pro models", () => { it("should show model names in breakdown", () => {
render( render(
<CostDialog <CostDialog
predictedCost={createPredictedCost()} predictedCost={createPredictedCost()}
@ -193,8 +198,34 @@ describe("CostDialog", () => {
/> />
); );
// Nano Banana Pro should show resolution // Model names should be displayed
expect(screen.getByText(/Nano Banana Pro.*\(2K\)/)).toBeInTheDocument(); expect(screen.getByText(/Nano Banana Pro/)).toBeInTheDocument();
});
it("should show no pricing indicator for models without pricing", () => {
render(
<CostDialog
predictedCost={createPredictedCost({
breakdown: [
{
provider: "replicate",
modelId: "some-model",
modelName: "Some Model",
count: 1,
unitCost: null,
unit: "image",
subtotal: null,
},
],
unknownPricingCount: 1,
})}
incurredCost={0}
onClose={vi.fn()}
/>
);
expect(screen.getByText(/no pricing/)).toBeInTheDocument();
expect(screen.getByText(/1 model without pricing/)).toBeInTheDocument();
}); });
it("should display subtotal for each model type", () => { it("should display subtotal for each model type", () => {

Loading…
Cancel
Save