From c5b5be991ab27dd0f08fe18c9447d06d6fb11840 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Fri, 20 Sep 2024 19:33:18 +0200 Subject: [PATCH] Make tests more stable. --- tools/e2e/tests/given-app/_setup.ts | 7 +------ tools/e2e/tests/given-login/apps.spec.ts | 1 - tools/e2e/tests/given-login/clients.spec.ts | 6 +----- tools/e2e/tests/given-login/languages.spec.ts | 6 +----- tools/e2e/tests/given-login/settings.spec.ts | 6 +----- tools/e2e/tests/pages/apps.ts | 12 +++++++++++- 6 files changed, 15 insertions(+), 23 deletions(-) diff --git a/tools/e2e/tests/given-app/_setup.ts b/tools/e2e/tests/given-app/_setup.ts index d9bb844264..9bfa7a4798 100644 --- a/tools/e2e/tests/given-app/_setup.ts +++ b/tools/e2e/tests/given-app/_setup.ts @@ -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); diff --git a/tools/e2e/tests/given-login/apps.spec.ts b/tools/e2e/tests/given-login/apps.spec.ts index 7dc8c40285..9b07ce2603 100644 --- a/tools/e2e/tests/given-login/apps.spec.ts +++ b/tools/e2e/tests/given-login/apps.spec.ts @@ -20,6 +20,5 @@ test('create app', async ({ page, appsPage }) => { await appDialog.save(); const newApp = page.getByRole('heading', { name: appName }); - await expect(newApp).toBeVisible(); }); \ No newline at end of file diff --git a/tools/e2e/tests/given-login/clients.spec.ts b/tools/e2e/tests/given-login/clients.spec.ts index f304958748..d04ba01f48 100644 --- a/tools/e2e/tests/given-login/clients.spec.ts +++ b/tools/e2e/tests/given-login/clients.spec.ts @@ -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); }); diff --git a/tools/e2e/tests/given-login/languages.spec.ts b/tools/e2e/tests/given-login/languages.spec.ts index 6d55e58a84..e54adbb990 100644 --- a/tools/e2e/tests/given-login/languages.spec.ts +++ b/tools/e2e/tests/given-login/languages.spec.ts @@ -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); }); diff --git a/tools/e2e/tests/given-login/settings.spec.ts b/tools/e2e/tests/given-login/settings.spec.ts index 5462dc0240..158a66c153 100644 --- a/tools/e2e/tests/given-login/settings.spec.ts +++ b/tools/e2e/tests/given-login/settings.spec.ts @@ -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); }); diff --git a/tools/e2e/tests/pages/apps.ts b/tools/e2e/tests/pages/apps.ts index 603f957296..af379ccbef 100644 --- a/tools/e2e/tests/pages/apps.ts +++ b/tools/e2e/tests/pages/apps.ts @@ -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) {} @@ -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 {