Skip to content

Commit

Permalink
E2E test: add vehicle, set availability, request ride (#149)
Browse files Browse the repository at this point in the history
* wip

* wip

* E2E test: addvehicle, set availability, request ride

* wip

* wip

* test: move tour

* format
  • Loading branch information
steffenheger authored Sep 11, 2024
1 parent 1ec2d6e commit 633d292
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 6 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
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
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
115 changes: 115 additions & 0 deletions tests/setAvailability.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import { expect, test } from '@playwright/test';
import { login, ENTREPENEUR } from './utils';

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

test('Set company data, complete and consistent', async ({ page }) => {
await login(page, ENTREPENEUR);
await expect(page.getByRole('heading', { name: 'Stammdaten Ihres Unternehmens' })).toBeVisible();

await page.getByLabel('Name').fill('Taxi Weißwasser');
await page
.getByLabel('Unternehmenssitz')
.fill('Werner-Seelenbinder-Straße 70A, 02943 Weißwasser/Oberlausitz');
await page.waitForTimeout(250);
await page.getByLabel('Pflichtfahrgebiet').selectOption({ label: 'Weißwasser' });
await page.getByLabel('Gemeinde').selectOption({ label: 'Weißwasser/O.L.' });
await page.getByRole('button', { name: 'Übernehmen' }).click();
});

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)'
);
});

0 comments on commit 633d292

Please sign in to comment.