Stripe tests fixes

This commit is contained in:
zomars 2022-04-14 15:10:42 -06:00
parent e657aa36b8
commit 2899d4551c
2 changed files with 20 additions and 4 deletions

View File

@ -13,6 +13,7 @@ test.describe.serial("Stripe integration", () => {
test.afterAll(() => {
teardown.deleteAllPaymentsByEmail("pro@example.com");
teardown.deleteAllBookingsByEmail("pro@example.com");
teardown.deleteAllPaymentCredentialsByEmail("pro@example.com");
});
test.skip(!IS_STRIPE_ENABLED, "It should only run if Stripe is installed");
@ -69,14 +70,12 @@ test.describe.serial("Stripe integration", () => {
// Click button:has-text("Pay now")
await page.click('button:has-text("Pay now")');
// Make sure we're navigated to the paid page
// Make sure we're navigated to the success page
await page.waitForNavigation({
url(url) {
return url.pathname.endsWith("/paid");
return url.pathname.endsWith("/success");
},
});
await expect(page).toHaveURL(/.*payment/);
});
todo("Pending payment booking should not be confirmed by default");

View File

@ -44,3 +44,20 @@ export const deleteAllPaymentsByEmail = async (email: string) => {
},
});
};
export const deleteAllPaymentCredentialsByEmail = async (email: string) => {
await prisma.user.update({
where: {
email,
},
data: {
credentials: {
deleteMany: {
type: {
endsWith: "_payment",
},
},
},
},
});
};