Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion static/gsApp/types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ export type Invoice = InvoiceBase & {

type BaseInvoiceItem = {
amount: number;
data: {period?: any; plan?: any; quantity?: any};
data: {period?: any; plan?: any; quantity?: any} | null;
description: string;
type: InvoiceItemType;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,31 @@ describe('CheckoutSuccess', () => {
expect(screen.queryByTestId('receipt')).not.toBeInTheDocument();
});

it('renders scheduled changes when a reserved item has null data', async () => {
render(
<CheckoutSuccess
basePlan={bizPlan}
nextQueryParams={[]}
previewData={PreviewDataFixture({
effectiveAt: moment(mockDate).add(1, 'day').toISOString(),
invoiceItems: [
{
type: 'reserved_errors',
description: '50,000 reserved errors',
amount: 0,
data: null,
period_start: '2025-01-02',
period_end: '2025-02-01',
},
],
})}
/>
);

expect(await screen.findByText('Consider it done (soon)')).toBeInTheDocument();
expect(screen.getByRole('heading', {name: /^From /})).toBeInTheDocument();
});

it('renders ondemand items in receipt', async () => {
const invoiceWithOnDemand = InvoiceFixture({
items: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function ScheduledChanges({
if (!defined(category)) {
return null;
}
const quantity = item.data.quantity ?? 0;
const quantity = item.data?.quantity ?? 0;
const reserved = isByteCategory(category) ? quantity / GIGABYTE : quantity;
if (reserved <= 0) {
return null;
Expand Down Expand Up @@ -352,7 +352,7 @@ function Receipt({
if (!defined(category)) {
return null;
}
const quantity = item.data.quantity ?? 0;
const quantity = item.data?.quantity ?? 0;
const reserved = isByteCategory(category)
? quantity / GIGABYTE
: quantity;
Expand Down
2 changes: 1 addition & 1 deletion static/gsApp/views/amCheckout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ function AMCheckout(props: Props) {
if (isSubmitted) {
const purchasedPlanItem = invoice?.items.find(item => item.type === 'subscription');
const basePlan = purchasedPlanItem
? getPlan(purchasedPlanItem.data.plan)
? getPlan(purchasedPlanItem.data?.plan)
: getPlan(formData.plan);

return (
Expand Down
Loading