Skip to content

Commit

Permalink
fix testing db
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Sep 11, 2024
1 parent 543e22a commit 90785a6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
11 changes: 8 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ export default defineConfig({
dependencies: ['setup db']
},
{
name: 'user test',
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
dependencies: ['setup db', 'login']
name: 'company data',
testMatch: /companyData\.test\.ts/,
dependencies: ['login']
},
{
name: 'availability',
testMatch: /setAvailability\.test\.ts/,
dependencies: ['company data']
}
]
});
6 changes: 4 additions & 2 deletions tests/companyData.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { expect, test } from '@playwright/test';
import { login, ENTREPENEUR } from './utils';

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

test('Set company data, incomplete 1', async ({ page }) => {
await login(page, ENTREPENEUR);
await expect(page.getByRole('heading', { name: 'Stammdaten Ihres Unternehmens' })).toBeVisible();
Expand Down Expand Up @@ -57,7 +59,7 @@ test('Set company data, complete and consistent', async ({ page }) => {
await page.getByLabel('Name').fill('Taxi Weißwasser');
await page
.getByLabel('Unternehmenssitz')
.fill('Werner-Seelenbinder-Straße 70A, 02943 Weißwasser/Oberlausitz');
.fill('Werner-Seelenbinder-Strasse 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.' });
Expand All @@ -68,7 +70,7 @@ test('Set company data, complete and consistent', async ({ page }) => {
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'
'Werner-Seelenbinder-Strasse 70A, 02943 Weißwasser/Oberlausitz'
);
await expect(page.getByLabel('Pflichtfahrgebiet')).toHaveValue('2' /* Görlitz */);
await expect(page.getByLabel('Gemeinde')).toHaveValue('85' /* Weißwasser */);
Expand Down
22 changes: 10 additions & 12 deletions tests/db.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@ setup('setup db', async () => {

await migrator.migrateToLatest();

await Promise.all([
db.deleteFrom('zone').execute(),
db.deleteFrom('company').execute(),
db.deleteFrom('vehicle').execute(),
db.deleteFrom('tour').execute(),
db.deleteFrom('availability').execute(),
db.deleteFrom('auth_user').execute(),
db.deleteFrom('user_session').execute(),
db.deleteFrom('event').execute(),
db.deleteFrom('address').execute(),
db.deleteFrom('request').execute()
]);
await db.deleteFrom('user_session').executeTakeFirstOrThrow();
await db.deleteFrom('auth_user').executeTakeFirstOrThrow();
await db.deleteFrom('availability').executeTakeFirstOrThrow();
await db.deleteFrom('event').executeTakeFirstOrThrow();
await db.deleteFrom('request').executeTakeFirstOrThrow();
await db.deleteFrom('tour').executeTakeFirstOrThrow();
await db.deleteFrom('vehicle').executeTakeFirstOrThrow();
await db.deleteFrom('company').executeTakeFirstOrThrow();
await db.deleteFrom('address').executeTakeFirstOrThrow();
await db.deleteFrom('zone').executeTakeFirstOrThrow();

const zonesSqlPath = path.join(__dirname, '../test_data/default/zone.sql');
const zonesQuery = fs.readFileSync(zonesSqlPath).toString();
Expand Down

0 comments on commit 90785a6

Please sign in to comment.