miniauth/playwright/tests/example.spec.js
2025-03-16 01:16:06 +01:00

66 lines
3.3 KiB
JavaScript

// @ts-check
import { test, expect } from '@playwright/test';
test('check ping route', async ({ page }) => {
await page.goto('/ping');
// Expects page to have a heading with the name of Installation.
await expect(page.getByText('pong')).toBeVisible();
});
test('see register page', async ({page}) => {
await page.goto('/web/register');
await expect(page.getByRole('heading', { name: 'Register'})).toBeVisible();
await expect(page.getByRole('button', { name: 'Register' })).toBeVisible();
})
test('invalide username at register page', async ({page}) => {
await page.goto('/web/register');
await page.getByLabel('Username').fill('abc');
await page.getByLabel('E-mail Address').fill('error@error.error');
await page.getByLabel('Password', {name: 'password', exact: true}).fill('7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%%n3T7rKw');
await page.getByLabel('Repeat Password').fill('7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%%n3T7rKw');
await page.getByRole('button', { name: 'Register' }).click();
await expect(page.getByText('username has invalide chars: username has invalide chars ')).toBeVisible();
await page.screenshot({ path: 'screenshot.png' });
})
test('invalide mail at register page', async ({page, browserName}) => {
await page.goto('/web/register');
await page.getByLabel('Username').fill('kekskursefail');
await page.getByLabel('E-mail Address').fill('error@error.error');
await page.getByLabel('Password', {name: 'password', exact: true}).fill('7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%%n3T7rKw');
await page.getByLabel('Repeat Password').fill('7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%%n3T7rKw');
await page.getByRole('button', { name: 'Register' }).click();
await page.screenshot({ path: 'screenshot.png' });
await expect(page.getByText('cant send mail: cant send mail to error mail')).toBeVisible();
})
test('different passwords', async ({page}) => {
await page.goto('/web/register');
await page.getByLabel('Username').fill('kekskurse');
await page.getByLabel('E-mail Address').fill('error@error.error');
await page.getByLabel('Password', {name: 'password', exact: true}).fill('7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%');
await page.getByLabel('Repeat Password').fill('7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%%n3T7rKw');
await page.getByRole('button', { name: 'Register' }).click();
await page.screenshot({ path: 'screenshot.png' });
await expect(page.getByText('Passworts dont match')).toBeVisible();
})
test('register currect', async ({page, browserName}) => {
await page.goto('/web/register');
await page.getByLabel('Username').fill('kekskurse'+browserName);
await page.getByLabel('E-mail Address').fill('hello'+browserName+'@example.com');
await page.getByLabel('Password', {name: 'password', exact: true}).fill('7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%');
await page.getByLabel('Repeat Password').fill('7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%');
await page.getByRole('button', { name: 'Register' }).click();
await page.screenshot({ path: 'screenshot.png' });
await expect(page.getByText('Your account was created, you can login now')).toBeVisible();
})