From b2cf75fa4b3b9b37d6304cc321645809dd14d516 Mon Sep 17 00:00:00 2001 From: Dev Singh Date: Sun, 9 Feb 2025 10:57:01 -0600 Subject: [PATCH 1/4] fix stripe API unit tests --- tests/unit/stripe.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit/stripe.test.ts b/tests/unit/stripe.test.ts index ffa27f73..4e28dcdb 100644 --- a/tests/unit/stripe.test.ts +++ b/tests/unit/stripe.test.ts @@ -193,6 +193,7 @@ describe("Test Stripe link creation", async () => { active: true, invoiceId: "ACM102", amount: 100, + createdAt: "2025-02-09T16:55:50+0000", }), ], }); @@ -209,6 +210,7 @@ describe("Test Stripe link creation", async () => { active: true, invoiceId: "ACM102", invoiceAmountUsd: 100, + createdAt: "2025-02-09T16:55:50+0000", }, ]); }); @@ -226,6 +228,7 @@ describe("Test Stripe link creation", async () => { active: true, invoiceId: "ACM103", amount: 999, + createdAt: "2025-02-09T16:55:50+0000", }), ], }); @@ -246,6 +249,7 @@ describe("Test Stripe link creation", async () => { active: true, invoiceId: "ACM103", invoiceAmountUsd: 999, + createdAt: "2025-02-09T16:55:50+0000", }, ]); }); From c8c8658f4575a1c963ac2cdd13ffa1389b481f52 Mon Sep 17 00:00:00 2001 From: Dev Singh Date: Sun, 9 Feb 2025 11:05:17 -0600 Subject: [PATCH 2/4] add a basic stripe e2e test --- tests/e2e/stripe.spec.ts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/e2e/stripe.spec.ts diff --git a/tests/e2e/stripe.spec.ts b/tests/e2e/stripe.spec.ts new file mode 100644 index 00000000..fa33b349 --- /dev/null +++ b/tests/e2e/stripe.spec.ts @@ -0,0 +1,37 @@ +import { expect } from "@playwright/test"; +import { test } from "./base"; +import { describe } from "node:test"; + +describe("Stripe Link Creation Tests", () => { + test("A user can see the link creation screen", async ({ + page, + becomeUser, + }) => { + await becomeUser(page); + await expect( + page.locator("a").filter({ hasText: "Management Portal DEV ENV" }), + ).toBeVisible(); + await expect( + page.locator("a").filter({ hasText: "Stripe Link Creator" }), + ).toBeVisible(); + await page.locator("a").filter({ hasText: "Stripe Link Creator" }).click(); + await expect( + page.getByRole("textbox", { name: "Invoice Recipient Email" }), + ).toBeVisible(); + await expect( + page.getByRole("heading", { name: "Stripe Link Creator" }), + ).toBeVisible(); + await expect( + page.getByRole("textbox", { name: "Invoice ID" }), + ).toBeVisible(); + await expect( + page.getByRole("textbox", { name: "Invoice Amount" }), + ).toBeVisible(); + await expect( + page.getByRole("textbox", { name: "Invoice Recipient Name" }), + ).toBeVisible(); + await expect( + page.getByRole("textbox", { name: "Invoice Recipient Email" }), + ).toBeVisible(); + }); +}); From a543c320cdfcaccee1e358a656ad12ac5021036e Mon Sep 17 00:00:00 2001 From: Dev Singh Date: Sun, 9 Feb 2025 11:15:35 -0600 Subject: [PATCH 3/4] fix types --- src/common/types/stripe.ts | 2 +- tests/unit/stripe.test.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/types/stripe.ts b/src/common/types/stripe.ts index 1ca18db7..5fb01538 100644 --- a/src/common/types/stripe.ts +++ b/src/common/types/stripe.ts @@ -28,7 +28,7 @@ export const invoiceLinkGetResponseSchema = z.array( active: z.boolean(), invoiceId: z.string().min(1), invoiceAmountUsd: z.number().min(50), - createdAt: z.union([z.string().date(), z.null()]), + createdAt: z.union([z.string().datetime(), z.null()]), }), ); diff --git a/tests/unit/stripe.test.ts b/tests/unit/stripe.test.ts index 4e28dcdb..de4563a8 100644 --- a/tests/unit/stripe.test.ts +++ b/tests/unit/stripe.test.ts @@ -193,7 +193,7 @@ describe("Test Stripe link creation", async () => { active: true, invoiceId: "ACM102", amount: 100, - createdAt: "2025-02-09T16:55:50+0000", + createdAt: "2025-02-09T17:11:30.762Z", }), ], }); @@ -210,7 +210,7 @@ describe("Test Stripe link creation", async () => { active: true, invoiceId: "ACM102", invoiceAmountUsd: 100, - createdAt: "2025-02-09T16:55:50+0000", + createdAt: "2025-02-09T17:11:30.762Z", }, ]); }); @@ -228,7 +228,7 @@ describe("Test Stripe link creation", async () => { active: true, invoiceId: "ACM103", amount: 999, - createdAt: "2025-02-09T16:55:50+0000", + createdAt: "2025-02-09T17:11:30.762Z", }), ], }); @@ -249,7 +249,7 @@ describe("Test Stripe link creation", async () => { active: true, invoiceId: "ACM103", invoiceAmountUsd: 999, - createdAt: "2025-02-09T16:55:50+0000", + createdAt: "2025-02-09T17:11:30.762Z", }, ]); }); From 531e8eb0b06bdbb4d26372a6ce0825f6f0df5223 Mon Sep 17 00:00:00 2001 From: Dev Singh Date: Sun, 9 Feb 2025 11:20:32 -0600 Subject: [PATCH 4/4] fix UI error throwing --- src/ui/pages/stripe/CreateLink.tsx | 2 +- src/ui/pages/stripe/CurrentLinks.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/pages/stripe/CreateLink.tsx b/src/ui/pages/stripe/CreateLink.tsx index 8b612890..9b4110a5 100644 --- a/src/ui/pages/stripe/CreateLink.tsx +++ b/src/ui/pages/stripe/CreateLink.tsx @@ -60,7 +60,7 @@ export const StripeCreateLinkPanel: React.FC = ({ cr color: 'red', icon: , }); - throw e; + console.error(e); } }; diff --git a/src/ui/pages/stripe/CurrentLinks.tsx b/src/ui/pages/stripe/CurrentLinks.tsx index 98ce6f54..33e2c9b2 100644 --- a/src/ui/pages/stripe/CurrentLinks.tsx +++ b/src/ui/pages/stripe/CurrentLinks.tsx @@ -40,6 +40,7 @@ export const StripeCurrentLinksPanel: React.FC = ( color: 'red', icon: , }); + console.error(e); } }; getLinksOnLoad();