Skip to content

Commit

Permalink
fix stripe integration tests (#51)
Browse files Browse the repository at this point in the history
* fix stripe API unit tests

* add a basic stripe e2e test

* fix types

* fix UI error throwing
  • Loading branch information
devksingh4 authored Feb 9, 2025
1 parent a6ab6de commit 1a83fa3
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/common/types/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()]),
}),
);

Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/stripe/CreateLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const StripeCreateLinkPanel: React.FC<StripeCreateLinkPanelProps> = ({ cr
color: 'red',
icon: <IconAlertCircle size={16} />,
});
throw e;
console.error(e);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/ui/pages/stripe/CurrentLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const StripeCurrentLinksPanel: React.FC<StripeCurrentLinksPanelProps> = (
color: 'red',
icon: <IconAlertCircle size={16} />,
});
console.error(e);
}
};
getLinksOnLoad();
Expand Down
37 changes: 37 additions & 0 deletions tests/e2e/stripe.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
4 changes: 4 additions & 0 deletions tests/unit/stripe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ describe("Test Stripe link creation", async () => {
active: true,
invoiceId: "ACM102",
amount: 100,
createdAt: "2025-02-09T17:11:30.762Z",
}),
],
});
Expand All @@ -209,6 +210,7 @@ describe("Test Stripe link creation", async () => {
active: true,
invoiceId: "ACM102",
invoiceAmountUsd: 100,
createdAt: "2025-02-09T17:11:30.762Z",
},
]);
});
Expand All @@ -226,6 +228,7 @@ describe("Test Stripe link creation", async () => {
active: true,
invoiceId: "ACM103",
amount: 999,
createdAt: "2025-02-09T17:11:30.762Z",
}),
],
});
Expand All @@ -246,6 +249,7 @@ describe("Test Stripe link creation", async () => {
active: true,
invoiceId: "ACM103",
invoiceAmountUsd: 999,
createdAt: "2025-02-09T17:11:30.762Z",
},
]);
});
Expand Down

0 comments on commit 1a83fa3

Please sign in to comment.