Skip to content

Commit 1a83fa3

Browse files
authored
fix stripe integration tests (#51)
* fix stripe API unit tests * add a basic stripe e2e test * fix types * fix UI error throwing
1 parent a6ab6de commit 1a83fa3

File tree

5 files changed

+44
-2
lines changed

5 files changed

+44
-2
lines changed

src/common/types/stripe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const invoiceLinkGetResponseSchema = z.array(
2828
active: z.boolean(),
2929
invoiceId: z.string().min(1),
3030
invoiceAmountUsd: z.number().min(50),
31-
createdAt: z.union([z.string().date(), z.null()]),
31+
createdAt: z.union([z.string().datetime(), z.null()]),
3232
}),
3333
);
3434

src/ui/pages/stripe/CreateLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const StripeCreateLinkPanel: React.FC<StripeCreateLinkPanelProps> = ({ cr
6060
color: 'red',
6161
icon: <IconAlertCircle size={16} />,
6262
});
63-
throw e;
63+
console.error(e);
6464
}
6565
};
6666

src/ui/pages/stripe/CurrentLinks.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const StripeCurrentLinksPanel: React.FC<StripeCurrentLinksPanelProps> = (
4040
color: 'red',
4141
icon: <IconAlertCircle size={16} />,
4242
});
43+
console.error(e);
4344
}
4445
};
4546
getLinksOnLoad();

tests/e2e/stripe.spec.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { expect } from "@playwright/test";
2+
import { test } from "./base";
3+
import { describe } from "node:test";
4+
5+
describe("Stripe Link Creation Tests", () => {
6+
test("A user can see the link creation screen", async ({
7+
page,
8+
becomeUser,
9+
}) => {
10+
await becomeUser(page);
11+
await expect(
12+
page.locator("a").filter({ hasText: "Management Portal DEV ENV" }),
13+
).toBeVisible();
14+
await expect(
15+
page.locator("a").filter({ hasText: "Stripe Link Creator" }),
16+
).toBeVisible();
17+
await page.locator("a").filter({ hasText: "Stripe Link Creator" }).click();
18+
await expect(
19+
page.getByRole("textbox", { name: "Invoice Recipient Email" }),
20+
).toBeVisible();
21+
await expect(
22+
page.getByRole("heading", { name: "Stripe Link Creator" }),
23+
).toBeVisible();
24+
await expect(
25+
page.getByRole("textbox", { name: "Invoice ID" }),
26+
).toBeVisible();
27+
await expect(
28+
page.getByRole("textbox", { name: "Invoice Amount" }),
29+
).toBeVisible();
30+
await expect(
31+
page.getByRole("textbox", { name: "Invoice Recipient Name" }),
32+
).toBeVisible();
33+
await expect(
34+
page.getByRole("textbox", { name: "Invoice Recipient Email" }),
35+
).toBeVisible();
36+
});
37+
});

tests/unit/stripe.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ describe("Test Stripe link creation", async () => {
193193
active: true,
194194
invoiceId: "ACM102",
195195
amount: 100,
196+
createdAt: "2025-02-09T17:11:30.762Z",
196197
}),
197198
],
198199
});
@@ -209,6 +210,7 @@ describe("Test Stripe link creation", async () => {
209210
active: true,
210211
invoiceId: "ACM102",
211212
invoiceAmountUsd: 100,
213+
createdAt: "2025-02-09T17:11:30.762Z",
212214
},
213215
]);
214216
});
@@ -226,6 +228,7 @@ describe("Test Stripe link creation", async () => {
226228
active: true,
227229
invoiceId: "ACM103",
228230
amount: 999,
231+
createdAt: "2025-02-09T17:11:30.762Z",
229232
}),
230233
],
231234
});
@@ -246,6 +249,7 @@ describe("Test Stripe link creation", async () => {
246249
active: true,
247250
invoiceId: "ACM103",
248251
invoiceAmountUsd: 999,
252+
createdAt: "2025-02-09T17:11:30.762Z",
249253
},
250254
]);
251255
});

0 commit comments

Comments
 (0)