Skip to content

Commit c260e91

Browse files
authored
Merge pull request #2 from jsanzdev/feature/laboratorio-testing-opcional
Feature/laboratorio testing opcional
2 parents 4f09693 + 00ebf71 commit c260e91

11 files changed

Lines changed: 650 additions & 18 deletions

File tree

.github/workflows/testing-lab.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Testing Lab CI
2+
3+
on:
4+
push:
5+
paths:
6+
- '5 - Testing/Ejercicios/Testing-Lab/**'
7+
pull_request:
8+
paths:
9+
- '5 - Testing/Ejercicios/Testing-Lab/**'
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
working-directory: ./5 - Testing/Ejercicios/Testing-Lab
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '18'
25+
cache: 'npm'
26+
cache-dependency-path: './5 - Testing/Ejercicios/Testing-Lab/package-lock.json'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Run tests
32+
run: npm test
33+
34+
- name: Upload coverage reports to Codecov
35+
uses: codecov/codecov-action@v3
36+
with:
37+
directory: ./5 - Testing/Ejercicios/Testing-Lab/coverage
38+
flags: unittests
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NODE_ENV=test
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
# Playwright
3+
node_modules/
4+
/test-results/
5+
/playwright-report/
6+
/blob-report/
7+
/playwright/.cache/
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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

Comments
 (0)