You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
senzapaura_es/e2e-estudio/acceso.e2e.ts

69 lines
2.8 KiB

import { test, expect } from '@playwright/test';
test('el código fijo permite corregir errores y entrar repetidamente', async ({
page,
context
}) => {
await page.goto('/entrar');
await expect(page.getByRole('heading', { name: 'Introduce el código' })).toBeVisible();
await page.getByLabel('Código de prueba', { exact: true }).fill('999999');
await page.getByRole('button', { name: 'Entrar', exact: true }).click();
await expect(page.getByRole('alert')).toContainText('no coincide');
for (let i = 0; i < 2; i++) {
if (i) {
await context.clearCookies();
await page.goto('/entrar');
}
await page.getByLabel('Código de prueba', { exact: true }).fill('123456');
await page.getByRole('button', { name: 'Entrar', exact: true }).click();
await expect(page.getByRole('navigation', { name: 'Administración' })).toBeVisible();
}
});
test('un correo anterior en cookie o enlace no desvía a los códigos temporales', async ({
page,
context
}) => {
await context.addCookies([
{
name: 'estudio_correo_acceso',
value: 'otra@example.test',
domain: '127.0.0.1',
path: '/entrar'
}
]);
await page.goto('/entrar?email=otra%40example.test&paso=codigo&cambiar=1');
await expect(page.getByText('estudio@example.test', { exact: true })).toBeVisible();
await expect(page.getByRole('link', { name: 'Cambiar correo' })).toHaveCount(0);
await page.reload();
await expect(page.getByLabel('Código de prueba', { exact: true })).toBeVisible();
await page.setViewportSize({ width: 375, height: 812 });
await page.screenshot({ path: 'docs/assets/estudio/acceso-movil.png', fullPage: true });
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
await page.getByLabel('Código de prueba', { exact: true }).fill('123456');
await page.getByRole('button', { name: 'Entrar', exact: true }).click();
await expect(page.getByRole('navigation', { name: 'Administración' })).toBeVisible();
});
test('un formulario antiguo abre exclusivamente la cuenta demo y funciona sin JavaScript', async ({
browser,
request
}) => {
const r = await request.post('/entrar?/verificar', {
form: { email: 'otra@example.test', codigo: '123456' },
headers: { origin: 'http://127.0.0.1:5176', accept: 'text/html' },
maxRedirects: 0
});
expect(r.status()).toBe(303);
const html = await (await request.get('/')).text();
expect(html).toContain('estudio@example.test');
expect(html).not.toContain('otra@example.test');
const ctx = await browser.newContext({ javaScriptEnabled: false });
const page = await ctx.newPage();
await page.goto('http://127.0.0.1:5176/entrar');
await page.getByLabel('Código de prueba', { exact: true }).fill('123456');
await page.getByRole('button', { name: 'Entrar', exact: true }).click();
await expect(page.getByRole('navigation', { name: 'Administración' })).toBeVisible();
await ctx.close();
});

Powered by TurnKey Linux.