Refactor: simplify login test by removing helpers and describe block
Some checks failed
Playwright Tests / test (push) Has been cancelled
Some checks failed
Playwright Tests / test (push) Has been cancelled
This commit is contained in:
@@ -1,30 +1,17 @@
|
|||||||
import { test, expect, type Page } from "@playwright/test";
|
import { test, expect } from "@playwright/test";
|
||||||
|
|
||||||
const LOGIN_URL = "/auth/login?returnUrl=/admin";
|
const LOGIN_URL = "/auth/login?returnUrl=/admin";
|
||||||
|
|
||||||
const getPhoneInput = (page: Page) =>
|
test("09111111111 should redirect to /admin on successful login", async ({
|
||||||
page.getByRole("spinbutton", { name: "شماره موبایل" });
|
page,
|
||||||
const getContinueButton = (page: Page) =>
|
baseURL,
|
||||||
page.getByRole("button", { name: "ادامه" });
|
}) => {
|
||||||
const getPasswordInput = (page: Page) =>
|
await page.goto(LOGIN_URL);
|
||||||
page.getByRole("textbox", { name: "کلمه عبور" });
|
await page
|
||||||
const getLoginButton = (page: Page) =>
|
.getByRole("spinbutton", { name: "شماره موبایل" })
|
||||||
page.getByRole("button", { name: "ورود" });
|
.fill("09111111111");
|
||||||
|
await page.getByRole("button", { name: "ادامه" }).click();
|
||||||
test.describe("login tests - 09111111111", () => {
|
await page.getByRole("textbox", { name: "کلمه عبور" }).fill("123456");
|
||||||
test.beforeEach(async ({ page }) => {
|
await page.getByRole("button", { name: "ورود" }).click();
|
||||||
await page.goto(LOGIN_URL);
|
await expect(page).toHaveURL(`${baseURL}/admin`);
|
||||||
await getPhoneInput(page).fill("09111111111");
|
|
||||||
await getContinueButton(page).click();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should have password", async ({ page }) => {
|
|
||||||
await expect(getPasswordInput(page)).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should redirect to /admin on successful login", async ({ page }) => {
|
|
||||||
await getPasswordInput(page).fill("123456");
|
|
||||||
await getLoginButton(page).click();
|
|
||||||
await expect(page).toHaveURL("https://dev-gate.raysa.app/admin");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user