Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/testing-lab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Testing Lab CI

on:
push:
paths:
- '5 - Testing/Ejercicios/Testing-Lab/**'
pull_request:
paths:
- '5 - Testing/Ejercicios/Testing-Lab/**'

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./5 - Testing/Ejercicios/Testing-Lab

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: './5 - Testing/Ejercicios/Testing-Lab/package-lock.json'

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
directory: ./5 - Testing/Ejercicios/Testing-Lab/coverage
flags: unittests
1 change: 1 addition & 0 deletions 5 - Testing/Ejercicios/Testing-Lab/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NODE_ENV=test
7 changes: 7 additions & 0 deletions 5 - Testing/Ejercicios/Testing-Lab/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

# Playwright
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
57 changes: 57 additions & 0 deletions 5 - Testing/Ejercicios/Testing-Lab/e2e/login.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { test, expect } from "@playwright/test";

test.describe("Login Page", () => {

Check failure on line 3 in 5 - Testing/Ejercicios/Testing-Lab/e2e/login.spec.ts

View workflow job for this annotation

GitHub Actions / test

e2e/login.spec.ts

Error: Playwright Test did not expect test.describe() to be called here. Most common reasons include: - You are calling test.describe() in a configuration file. - You are calling test.describe() in a file that is imported by the configuration file. - You have two different versions of @playwright/test. This usually happens when one of the dependencies in your package.json depends on @playwright/test. ❯ TestTypeImpl._currentSuite node_modules/playwright/lib/common/testType.js:74:13 ❯ TestTypeImpl._describe node_modules/playwright/lib/common/testType.js:106:24 ❯ Function.describe node_modules/playwright/lib/transform/transform.js:288:12 ❯ e2e/login.spec.ts:3:6

Check failure on line 3 in 5 - Testing/Ejercicios/Testing-Lab/e2e/login.spec.ts

View workflow job for this annotation

GitHub Actions / test

e2e/login.spec.ts

Error: Playwright Test did not expect test.describe() to be called here. Most common reasons include: - You are calling test.describe() in a configuration file. - You are calling test.describe() in a file that is imported by the configuration file. - You have two different versions of @playwright/test. This usually happens when one of the dependencies in your package.json depends on @playwright/test. ❯ TestTypeImpl._currentSuite node_modules/playwright/lib/common/testType.js:74:13 ❯ TestTypeImpl._describe node_modules/playwright/lib/common/testType.js:106:24 ❯ Function.describe node_modules/playwright/lib/transform/transform.js:288:12 ❯ e2e/login.spec.ts:3:6
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 });
});
});
Loading
Loading