Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: make checkout tests run in parallel

Abdullah Attae4720c4ca90d
diff --git a/apps/web/__e2e__/checkout.test.ts b/apps/web/__e2e__/checkout.test.ts
index fa19dc813..393675e62 100644
--- a/apps/web/__e2e__/checkout.test.ts
+++ b/apps/web/__e2e__/checkout.test.ts
@@ -23,29 +23,13 @@ import { AppModel } from "./models/app.model";
import { PriceItem } from "./models/types";
test.setTimeout(45 * 1000);
-test.describe.configure({ mode: "serial" });
-let page: Page;
-let app: AppModel;
-
-test.beforeAll(async ({ browser }) => {
- const { email, key, password } = USER.CURRENT;
- if (!email || !password) throw new Error("Failed to load user credentials.");
-
- // Create page yourself and sign in.
- page = await browser.newPage();
- app = new AppModel(page);
+async function login(page: Page) {
+ const app = new AppModel(page);
await app.auth.goto();
- await app.auth.login({ email, key, password });
-});
-
-test.afterAll(async () => {
- await page.close();
-});
-
-test.afterEach(async () => {
- await app.goto();
-});
+ await app.auth.login(USER.CURRENT);
+ return app;
+}
function roundOffPrices(prices: PriceItem[]) {
return prices
@@ -60,7 +44,8 @@ function roundOffPrices(prices: PriceItem[]) {
.join("\n");
}
-test("change plans", async () => {
+test("change plans", async ({ page }) => {
+ const app = await login(page);
await app.checkout.goto();
const plans = await app.checkout.getPlans();
@@ -76,7 +61,8 @@ test("change plans", async () => {
expect(titles.join("").length).toBeGreaterThan(0);
});
-test("confirm plan prices", async () => {
+test("confirm plan prices", async ({ page }) => {
+ const app = await login(page);
await app.checkout.goto();
const plans = await app.checkout.getPlans();
@@ -95,7 +81,8 @@ test("confirm plan prices", async () => {
}
});
-test("changing locale should show localized prices", async () => {
+test("changing locale should show localized prices", async ({ page }) => {
+ const app = await login(page);
await app.checkout.goto();
const plans = await app.checkout.getPlans();
@@ -115,7 +102,10 @@ test("changing locale should show localized prices", async () => {
}
});
-test("applying coupon should change discount & total price", async () => {
+test("applying coupon should change discount & total price", async ({
+ page
+}) => {
+ const app = await login(page);
await app.checkout.goto();
const plans = await app.checkout.getPlans();
@@ -137,7 +127,8 @@ test("applying coupon should change discount & total price", async () => {
}
});
-test("apply coupon through url", async () => {
+test("apply coupon through url", async ({ page }) => {
+ const app = await login(page);
const planPrices: Record<string, string> = {};
for (const plan of ["monthly", "yearly"] as const) {
await app.checkout.goto(plan, "INTRO50");
@@ -156,7 +147,8 @@ test("apply coupon through url", async () => {
}
});
-test("apply coupon after changing country", async () => {
+test("apply coupon after changing country", async ({ page }) => {
+ const app = await login(page);
await app.checkout.goto();
const plans = await app.checkout.getPlans();