-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogin.spec.ts
More file actions
57 lines (45 loc) · 1.68 KB
/
login.spec.ts
File metadata and controls
57 lines (45 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { test, expect } from "@playwright/test";
test.describe("Login Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/");
});
test("should display login form", async ({ page }) => {
// Wait for form to be visible
const form = await page.getByTestId("login-form");
await expect(form).toBeVisible();
// Check form elements
await expect(page.getByTestId("user-input")).toBeVisible();
await expect(page.getByTestId("password-input")).toBeVisible();
await expect(page.getByTestId("login-button")).toBeVisible();
});
test("should show error message with invalid credentials", async ({
page,
}) => {
// Fill in invalid credentials
await page.getByTestId("user-input").fill("invalid");
await page.getByTestId("password-input").fill("invalid");
// Click login button
await page.getByTestId("login-button").click();
// Wait for error message
await expect(
page.getByText("Usuario y/o password no válidos")
).toBeVisible();
});
test("should login successfully with valid credentials", async ({ page }) => {
// Fill in valid credentials
await page.getByTestId("user-input").fill("admin");
await page.getByTestId("password-input").fill("test");
// Click login button
await page.getByTestId("login-button").click();
// Wait for navigation
await page.waitForURL("#/submodule-list");
});
// Debug helper test
test("debug page content", async ({ page }) => {
await page.goto("/");
// Log the page content for debugging
console.log(await page.content());
// Take a screenshot
await page.screenshot({ path: "login-debug.png", fullPage: true });
});
});