-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add company data tests * format+lint * wip * format * fix tests * wip, fix tests * wip * update playwright.config * update playwright.config * fix tests * test * wip * wip * wip * sleep more * wip * test * fix typo * use docker container for tests --------- Co-authored-by: Steffen Heger <steffen.heger@gmail.com>
- Loading branch information
1 parent
e934366
commit 1ec2d6e
Showing
8 changed files
with
171 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { login, ENTREPENEUR } from './utils'; | ||
|
||
test('Set company data, incomplete 1', async ({ page }) => { | ||
await login(page, ENTREPENEUR); | ||
await expect(page.getByRole('heading', { name: 'Stammdaten Ihres Unternehmens' })).toBeVisible(); | ||
|
||
await page.getByLabel('Name').fill('Test'); | ||
await page.getByRole('button', { name: 'Übernehmen' }).click(); | ||
|
||
await expect(page.getByText('Adresse zu kurz.')).toBeVisible(); | ||
}); | ||
|
||
test('Set company data, incomplete 2', async ({ page }) => { | ||
await login(page, ENTREPENEUR); | ||
|
||
await page.getByLabel('Name').fill('Test'); | ||
await page.getByLabel('Unternehmenssitz').fill('Plantagenweg 3, 02827 Görlitz'); | ||
await page.getByRole('button', { name: 'Übernehmen' }).click(); | ||
|
||
await expect( | ||
page.getByText('Die Eingabe muss mindestens 2 Zeichen enthalten.') | ||
).not.toBeVisible(); | ||
await expect(page.getByText('Gemeinde nicht gesetzt.')).toBeVisible(); | ||
}); | ||
|
||
test('Set company data, incomplete 3', async ({ page }) => { | ||
await login(page, ENTREPENEUR); | ||
|
||
await page.getByLabel('Name').fill('Taxi Weißwasser'); | ||
await page | ||
.getByLabel('Unternehmenssitz') | ||
.fill('Werner-Seelenbinder-Straße 70A, 02943 Weißwasser/Oberlausitz'); | ||
await page.getByLabel('Pflichtfahrgebiet').selectOption({ label: 'Görlitz' }); | ||
await page.getByRole('button', { name: 'Übernehmen' }).click(); | ||
|
||
await expect(page.getByText('Gemeinde nicht gesetzt.')).toBeVisible(); | ||
}); | ||
|
||
test('Set company data, address not in community', 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('Plantagenweg 3, 02827 Görlitz'); | ||
await page.waitForTimeout(250); | ||
await page.getByLabel('Pflichtfahrgebiet').selectOption({ label: 'Görlitz' }); | ||
await page.getByLabel('Gemeinde').selectOption({ label: 'Weißwasser/O.L.' }); | ||
await page.getByRole('button', { name: 'Übernehmen' }).click(); | ||
|
||
await expect( | ||
page.getByText('Die Addresse liegt nicht in der ausgewählten Gemeinde.') | ||
).toBeVisible(); | ||
}); | ||
|
||
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(); | ||
|
||
await expect(page.getByRole('heading', { name: 'Stammdaten Ihres Unternehmens' })).toBeVisible(); | ||
|
||
const checkData = async () => { | ||
await expect(page.getByLabel('Name')).toHaveValue('Taxi Weißwasser'); | ||
await expect(page.getByLabel('Unternehmenssitz')).toHaveValue( | ||
'Werner-Seelenbinder-Straße 70A, 02943 Weißwasser/Oberlausitz' | ||
); | ||
await expect(page.getByLabel('Pflichtfahrgebiet')).toHaveValue('2' /* Görlitz */); | ||
await expect(page.getByLabel('Gemeinde')).toHaveValue('85' /* Weißwasser */); | ||
}; | ||
|
||
await checkData(); | ||
await page.reload(); | ||
await checkData(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { Kysely, PostgresDialect, sql } from 'kysely'; | ||
import { dbConfig } from './config'; | ||
import pg from 'pg'; | ||
import { login, signup, MAINTAINER, ENTREPENEUR } from './utils'; | ||
|
||
test.describe.configure({ mode: 'serial' }); | ||
|
||
test('signup maintainer', async ({ page }) => { | ||
await signup(page, MAINTAINER); | ||
const db = new Kysely<unknown>({ | ||
dialect: new PostgresDialect({ | ||
pool: new pg.Pool({ ...dbConfig, database: 'prima' }) | ||
}) | ||
}); | ||
await sql`UPDATE auth_user SET is_maintainer = true WHERE email = 'master@example.com'`.execute( | ||
db | ||
); | ||
db.destroy(); | ||
}); | ||
|
||
test('signup taxi', async ({ page }) => { | ||
await signup(page, ENTREPENEUR); | ||
}); | ||
|
||
test('activate taxi', async ({ page }) => { | ||
await login(page, MAINTAINER); | ||
await expect(page.getByRole('heading', { name: 'Unternehmer freischalten' })).toBeVisible(); | ||
await page.getByLabel('Email').fill(ENTREPENEUR.email); | ||
await page.getByRole('button', { name: 'Unternehmer freischalten' }).click(); | ||
await expect(page.getByText('Freischalten erfolgreich!')).toBeVisible(); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { expect, type Page } from '@playwright/test'; | ||
|
||
export type UserCredentials = { | ||
email: string; | ||
password: string; | ||
}; | ||
|
||
export const MAINTAINER: UserCredentials = { | ||
email: 'master@example.com', | ||
password: 'longEnough1' | ||
}; | ||
|
||
export const ENTREPENEUR: UserCredentials = { | ||
email: 'taxi@example.com', | ||
password: 'longEnough2' | ||
}; | ||
|
||
export async function login(page: Page, credentials: UserCredentials) { | ||
await page.goto('/login'); | ||
await expect(page.getByRole('heading', { name: 'Login' })).toBeVisible(); | ||
await page.getByLabel('Email').fill(credentials.email); | ||
await page.getByLabel('Password').fill(credentials.password); | ||
await page.getByRole('button', { name: 'Login' }).click(); | ||
} | ||
|
||
export async function signup(page: Page, credentials: UserCredentials) { | ||
await page.goto('/signup'); | ||
await expect(page.getByRole('heading', { name: 'Neuen Account erstellen' })).toBeVisible(); | ||
await page.getByLabel('Email').fill(credentials.email); | ||
await page.getByLabel('Password').fill(credentials.password); | ||
await page.getByRole('button', { name: 'Account erstellen' }).click(); | ||
await expect( | ||
page.getByRole('heading', { name: 'Willkommen beim Projekt PrimaÖV!' }) | ||
).toBeVisible(); | ||
} |