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