2022-05-14 03:02:10 +00:00
|
|
|
import { expect } from "@playwright/test";
|
2022-01-07 20:23:37 +00:00
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
import { test } from "../lib/fixtures";
|
|
|
|
|
2023-03-01 20:18:51 +00:00
|
|
|
test.afterEach(({ users }) => users.deleteAll());
|
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
test("Can reset forgotten password", async ({ page, users }) => {
|
2023-06-06 11:59:57 +00:00
|
|
|
// eslint-disable-next-line playwright/no-skipped-test
|
2023-02-22 21:33:43 +00:00
|
|
|
test.skip(process.env.NEXT_PUBLIC_IS_E2E !== "1", "It shouldn't if we can't skip email");
|
2022-05-14 03:02:10 +00:00
|
|
|
const user = await users.create();
|
2023-06-06 11:59:57 +00:00
|
|
|
const newPassword = `${user.username}-123`;
|
2022-01-07 20:23:37 +00:00
|
|
|
// Got to reset password flow
|
|
|
|
await page.goto("/auth/forgot-password");
|
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
await page.waitForSelector("text=Forgot Password");
|
2022-01-07 20:23:37 +00:00
|
|
|
// Fill [placeholder="john.doe@example.com"]
|
2022-05-14 03:02:10 +00:00
|
|
|
await page.fill('input[name="email"]', `${user.username}@example.com`);
|
2022-01-07 20:23:37 +00:00
|
|
|
|
|
|
|
// Press Enter
|
|
|
|
await Promise.all([
|
2023-06-06 18:02:32 +00:00
|
|
|
page.waitForURL((u) => u.pathname.startsWith("/auth/forgot-password")),
|
2022-03-26 00:39:38 +00:00
|
|
|
page.press('input[name="email"]', "Enter"),
|
2022-01-07 20:23:37 +00:00
|
|
|
]);
|
|
|
|
|
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"]
|
2022-05-14 03:02:10 +00:00
|
|
|
await page.fill('input[name="password"]', newPassword);
|
2022-01-07 20:23:37 +00:00
|
|
|
|
|
|
|
// Click text=Submit
|
|
|
|
await page.click('button[type="submit"]');
|
|
|
|
|
2023-05-30 03:12:17 +00:00
|
|
|
await page.waitForSelector("text=Password updated");
|
2022-01-17 18:15:18 +00:00
|
|
|
|
2022-09-12 09:25:54 +00:00
|
|
|
await expect(page.locator(`text=Password updated`)).toBeVisible();
|
2022-01-07 20:23:37 +00:00
|
|
|
// Click button:has-text("Login")
|
2022-09-12 09:25:54 +00:00
|
|
|
await Promise.all([
|
2023-05-02 16:58:39 +00:00
|
|
|
page.waitForURL((u) => u.pathname.startsWith("/auth/login")),
|
2022-09-12 09:25:54 +00:00
|
|
|
page.click('a:has-text("Login")'),
|
|
|
|
]);
|
2022-01-07 20:23:37 +00:00
|
|
|
|
|
|
|
// Fill input[name="email"]
|
2022-05-14 03:02:10 +00:00
|
|
|
await page.fill('input[name="email"]', `${user.username}@example.com`);
|
|
|
|
await page.fill('input[name="password"]', newPassword);
|
2022-01-07 20:23:37 +00:00
|
|
|
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
|
|
|
});
|