Skip to content

Commit

Permalink
Make tests more stable.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Sep 20, 2024
1 parent ce769da commit c5b5be9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 23 deletions.
7 changes: 1 addition & 6 deletions tools/e2e/tests/given-app/_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import { test as setup } from './../given-login/_fixture';

setup('prepare app', async ({ appsPage }) => {
const appName = `my-app-${getRandomId()}`;

await appsPage.goto();

const dialog = await appsPage.openAppDialog();
await dialog.enterName(appName);
await dialog.save();
await appsPage.createNewApp(appName);

await appsPage.gotoApp(appName);

Expand Down
1 change: 0 additions & 1 deletion tools/e2e/tests/given-login/apps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ test('create app', async ({ page, appsPage }) => {
await appDialog.save();

const newApp = page.getByRole('heading', { name: appName });

await expect(newApp).toBeVisible();
});
6 changes: 1 addition & 5 deletions tools/e2e/tests/given-login/clients.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ test.beforeEach(async ({ context, appsPage, clientsPage }) => {
await context.grantPermissions(['clipboard-read', 'clipboard-write']);

const appName = `my-app-${getRandomId()}`;

await appsPage.goto();
const appDialog = await appsPage.openAppDialog();
await appDialog.enterName(appName);
await appDialog.save();
await appsPage.createNewApp(appName);

await clientsPage.goto(appName);
});
Expand Down
6 changes: 1 addition & 5 deletions tools/e2e/tests/given-login/languages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import { expect, test } from './_fixture';

test.beforeEach(async ({ languagesPage, appsPage }) => {
const appName = `my-app-${getRandomId()}`;

await appsPage.goto();
const appDialog = await appsPage.openAppDialog();
await appDialog.enterName(appName);
await appDialog.save();
await appsPage.createNewApp(appName);

await languagesPage.goto(appName);
});
Expand Down
6 changes: 1 addition & 5 deletions tools/e2e/tests/given-login/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import { getRandomId } from '../utils';

test.beforeEach(async ({ appsPage, settingsPage }) => {
const appName = `my-app-${getRandomId()}`;

await appsPage.goto();
const appDialog = await appsPage.openAppDialog();
await appDialog.enterName(appName);
await appDialog.save();
await appsPage.createNewApp(appName);

await settingsPage.goto(appName);
});
Expand Down
12 changes: 11 additions & 1 deletion tools/e2e/tests/pages/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/

import { Page } from '@playwright/test';
import { expect, Page } from '@playwright/test';

export class AppsPage {
constructor(private readonly page: Page) {}
Expand All @@ -23,6 +23,16 @@ export class AppsPage {

return new AppDialog(this.page);
}

public async createNewApp(appName: string) {
await this.goto();
const appDialog = await this.openAppDialog();
await appDialog.enterName(appName);
await appDialog.save();

const newApp = this.page.getByRole('heading', { name: appName });
await expect(newApp).toBeVisible();
}
}

class AppDialog {
Expand Down

0 comments on commit c5b5be9

Please sign in to comment.