2022-01-07 20:23:37 +00:00
|
|
|
import { expect, test } from "@playwright/test";
|
|
|
|
|
|
|
|
test("Can reset forgotten password", async ({ browser }) => {
|
2022-03-16 16:40:56 +00:00
|
|
|
test.fixme(true, "TODO: This test is failing randomly, disabled for now");
|
2022-01-07 20:23:37 +00:00
|
|
|
// Create a new incognito browser context
|
|
|
|
const context = await browser.newContext({
|
|
|
|
extraHTTPHeaders: {
|
|
|
|
// Only needed for bypassing emails while testing
|
|
|
|
"X-Playwright-Secret": process.env.PLAYWRIGHT_SECRET || "",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
// Create a new page inside context.
|
|
|
|
const page = await context.newPage();
|
|
|
|
|
|
|
|
// Got to reset password flow
|
|
|
|
await page.goto("/auth/forgot-password");
|
|
|
|
|
|
|
|
// Fill [placeholder="john.doe@example.com"]
|
|
|
|
await page.fill('input[name="email"]', "pro@example.com");
|
|
|
|
|
|
|
|
// Press Enter
|
|
|
|
await Promise.all([
|
|
|
|
page.waitForNavigation({
|
|
|
|
url: "/auth/forgot-password/*",
|
|
|
|
}),
|
|
|
|
page.press('input[type="email"]', "Enter"),
|
|
|
|
]);
|
|
|
|
|
2022-01-19 15:54:54 +00:00
|
|
|
// Wait for page to fully load
|
|
|
|
await page.waitForSelector("text=Reset Password");
|
2022-01-07 20:23:37 +00:00
|
|
|
// Fill input[name="password"]
|
|
|
|
await page.fill('input[name="password"]', "pro");
|
|
|
|
|
|
|
|
// Click text=Submit
|
|
|
|
await page.click('button[type="submit"]');
|
|
|
|
|
|
|
|
await page.waitForSelector("text=Success", {
|
|
|
|
timeout: 3000,
|
|
|
|
});
|
2022-01-17 18:15:18 +00:00
|
|
|
|
|
|
|
await expect(page.locator(`text=Success`)).toBeVisible();
|
2022-01-07 20:23:37 +00:00
|
|
|
|
|
|
|
// Click button:has-text("Login")
|
|
|
|
await Promise.all([page.waitForNavigation({ url: "/auth/login" }), page.click('button:has-text("Login")')]);
|
|
|
|
|
|
|
|
// Fill input[name="email"]
|
|
|
|
await page.fill('input[name="email"]', "pro@example.com");
|
|
|
|
await page.fill('input[name="password"]', "pro");
|
|
|
|
await page.press('input[name="password"]', "Enter");
|
|
|
|
await page.waitForSelector("[data-testid=dashboard-shell]");
|
2022-01-17 18:15:18 +00:00
|
|
|
|
|
|
|
await expect(page.locator("[data-testid=dashboard-shell]")).toBeVisible();
|
|
|
|
|
2022-01-07 20:23:37 +00:00
|
|
|
await context.close();
|
|
|
|
});
|