Skip to content

Commit

Permalink
update test utils
Browse files Browse the repository at this point in the history
  • Loading branch information
steffenheger committed Sep 9, 2024
2 parents c5723bc + 57f597c commit 95ae62d
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ node_modules
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
booking-generator/data/stops.txt
booking-generator/test/
booking-generator/test
.vscode
11 changes: 0 additions & 11 deletions booking-generator/test/generator.conf

This file was deleted.

26 changes: 0 additions & 26 deletions booking-generator/test/single_request.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/lib/ConfirmationDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</AlertDialog.Header>
<AlertDialog.Footer>
<AlertDialog.Cancel>Abbrechen</AlertDialog.Cancel>
<AlertDialog.Action on:click={handleConfirm}>Ok</AlertDialog.Action>
<AlertDialog.Action on:click={handleConfirm}>Bestätigen</AlertDialog.Action>
</AlertDialog.Footer>
</AlertDialog.Content>
</AlertDialog.Root>
Expand Down
48 changes: 0 additions & 48 deletions src/routes/(user)/taxi/ConfirmationDialog.svelte

This file was deleted.

8 changes: 4 additions & 4 deletions src/routes/request/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
let map = $state<undefined | maplibregl.Map>();
let start = $state<Coordinates>({
lat: 51.343543966724404,
lng: 14.843405973137568
lat: 51.526934461032994,
lng: 14.57712544716437
});
let destination = $state<Coordinates>({
lat: 51.30359310483892,
lng: 14.901901510528297
lat: 51.505730979747334,
lng: 14.638267982988827
});
let dummyAddress = {
street: '',
Expand Down
Empty file.
105 changes: 105 additions & 0 deletions tests/setAvailability.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { expect, test } from '@playwright/test';
import { login, ENTREPENEUR, setCompanyData, COMPANY1 } from './utils';

test.describe.configure({ mode: 'serial' });

test('Set company data', async ({ page }) => {
await setCompanyData(page, ENTREPENEUR, COMPANY1);
});

test('Set availability', async ({ page }) => {
await login(page, ENTREPENEUR);
await page.getByRole('link', { name: 'Taxi' }).click();
await expect(page.getByRole('heading', { name: 'Fahrzeuge und Touren' })).toBeVisible();
await page.waitForTimeout(500);
await page.getByRole('button', { name: 'Fahrzeug hinzufügen' }).click();
await page.getByPlaceholder('DA-AB-1234').fill('GR-TU-11');
await page.getByLabel('3 Passagiere').check();
await page
.locator('button')
.filter({ hasText: /^Fahrzeug hinzufügen$/ })
.click();

await page.goto('/taxi?offset=-120&date=2026-09-30');
await page.waitForTimeout(500);
await page.mouse.move(425, 465);
await page.mouse.down();
await page.mouse.move(525, 465);
await page.mouse.up();
});

test('Request ride', async ({ page }) => {
await login(page, ENTREPENEUR);
await page.waitForTimeout(500);
await page.goto('/request');
await page.getByRole('textbox').fill('');
await page.keyboard.down('0');
await page.keyboard.down('9');
await page.keyboard.down('3');
await page.keyboard.down('0');
await page.keyboard.down('2');
await page.keyboard.down('0');
await page.keyboard.down('2');
await page.keyboard.down('6');
await page.keyboard.press('ArrowRight');
await page.keyboard.down('1');
await page.keyboard.down('0');
await page.keyboard.down('4');
await page.keyboard.down('0');
await page.keyboard.press('ArrowRight');
await page.keyboard.down('A');
await page.getByRole('button', { name: 'Suchen' }).click();
await expect(page.getByRole('heading', { name: ': OK' })).toHaveText('200: OK');
});

test('Move tour to other vehicle', async ({ page }) => {
await login(page, ENTREPENEUR);
await page.getByRole('link', { name: 'Taxi' }).click();
await expect(page.getByRole('heading', { name: 'Fahrzeuge und Touren' })).toBeVisible();
await page.waitForTimeout(500);
await page.getByRole('button', { name: 'Fahrzeug hinzufügen' }).click();
await page.getByPlaceholder('DA-AB-1234').fill('GR-TU-12');
await page.getByLabel('3 Passagiere').check();
await page
.locator('button')
.filter({ hasText: /^Fahrzeug hinzufügen$/ })
.click();

await page.goto('/taxi?offset=-120&date=2026-09-30');
await page.waitForTimeout(1000);

await page
.locator('table:nth-child(2) > tbody > tr > td:nth-child(4) > .w-full > tbody > tr > td > .w-8')
.first()
.click();
await page.getByText('Tour redisponieren').click();
await page.getByText('Bestätigen').click();
await page.getByText('Ok').click();
await page.getByRole('button', { name: 'cross 2, Close' }).click();

await expect(
page
.locator(
'table:nth-child(2) > tbody > tr > td:nth-child(4) > .w-full > tbody > tr > td > .w-8'
)
.first()
).toHaveCSS('background-color', 'rgb(251, 146, 60)');

await page.mouse.move(425, 505);
await page.mouse.down();
await page.mouse.move(425, 540);
await page.waitForTimeout(1000);
await page.mouse.up();

await expect(
page
.locator(
'table:nth-child(2) > tbody > tr > td:nth-child(4) > .w-full > tbody > tr > td > .w-8'
)
.first()
).toHaveCSS('background-color', 'rgb(254, 249, 195)');
await expect(page.locator('.cursor-pointer').first()).toHaveCSS(
'background-color',
'rgb(251, 146, 60)'
);
});
Empty file added tests/tourRedisposition.test.ts
Empty file.
40 changes: 39 additions & 1 deletion tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,42 @@ export type UserCredentials = {
password: string;
};

export type Company = {
name: string;
address: string;
zone: string;
community: string;
};

export const MAINTAINER: UserCredentials = {
email: '[email protected]',
password: 'longEnough1'
};

export const ENTREPENEUR: UserCredentials = {
email: '[email protected]',
email: '[email protected]',
password: 'longEnough2'
};

export const ENTREPENEUR2: UserCredentials = {
email: '[email protected]',
password: 'longEnough2'
};

export const COMPANY1: Company = {
name: 'Taxi Weißwasser',
address: 'Werner-Seelenbinder-Straße 70A, 02943 Weißwasser/Oberlausitz',
zone: 'Weißwasser',
community: 'Weißwasser/O.L.'
};

export const COMPANY2: Company = {
name: 'Taxi Gablenz',
address: 'Schulstraße 21, 02953 Gablenz',
zone: 'Weißwasser',
community: 'Gablenz'
};

export async function login(page: Page, credentials: UserCredentials) {
await page.goto('/login');
await expect(page.getByRole('heading', { name: 'Login' })).toBeVisible();
Expand All @@ -33,3 +59,15 @@ export async function signup(page: Page, credentials: UserCredentials) {
page.getByRole('heading', { name: 'Willkommen beim Projekt PrimaÖV!' })
).toBeVisible();
}

export async function setCompanyData(page: Page, user: UserCredentials, company: Company) {
await login(page, user);
await expect(page.getByRole('heading', { name: 'Stammdaten Ihres Unternehmens' })).toBeVisible();

await page.getByLabel('Name').fill(company.name);
await page.getByLabel('Unternehmenssitz').fill(company.address);
await page.waitForTimeout(250);
await page.getByLabel('Pflichtfahrgebiet').selectOption({ label: company.zone });
await page.getByLabel('Gemeinde').selectOption({ label: company.community });
await page.getByRole('button', { name: 'Übernehmen' }).click();
}

0 comments on commit 95ae62d

Please sign in to comment.