// @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(); }) test('login page exists', async ({page}) => { await page.goto('/web/login'); await expect(page.getByRole('heading', { name: 'Login'})).toBeVisible(); await expect(page.getByRole('button', { name: 'Login' })).toBeVisible(); }) test('login faild user not exists', async ({page, browserName}) => { await page.goto('/web/login'); await page.getByLabel('Username').fill('kekskurseNO'+browserName); await page.getByLabel('Password', {name: 'password', exact: true}).fill('7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%'); await page.getByRole('button', { name: 'Login' }).click(); await expect(page.getByText('cant login')).toBeVisible(); const text = 'cant execute query'; const textLocator = page.locator(`text=${text}`); await expect(textLocator).toHaveCount(0); }) test('login faild passwordwrong', async ({page, browserName}) => { await page.goto('/web/login'); await page.getByLabel('Username').fill('kekskurse'+browserName); await page.getByLabel('Password', {name: 'password', exact: true}).fill('NO7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%'); await page.getByRole('button', { name: 'Login' }).click(); await expect(page.getByText('cant login')).toBeVisible(); const text = 'cant execute query'; const textLocator = page.locator(`text=${text}`); await expect(textLocator).toHaveCount(0); }) test('login success', async ({page, browserName}) => { await page.goto('/web/login'); await page.getByLabel('Username').fill('kekskurse'+browserName); await page.getByLabel('Password', {name: 'password', exact: true}).fill('7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%'); await page.getByRole('button', { name: 'Login' }).click(); await expect(page.getByText('Login ok!')).toBeVisible(); })