From 245cdf7a16d76fffce3866cc7abd836249c14bb4 Mon Sep 17 00:00:00 2001 From: Stas Tserkovny Date: Sat, 21 Dec 2024 16:05:28 -0700 Subject: [PATCH] Test changing up expect awaits --- tests/fixtures/bwFixture.ts | 8 ++++---- tests/fixtures/gameFixture.ts | 10 ++++------ tests/fixtures/setupFixture.ts | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/fixtures/bwFixture.ts b/tests/fixtures/bwFixture.ts index a958dbf..b64783b 100644 --- a/tests/fixtures/bwFixture.ts +++ b/tests/fixtures/bwFixture.ts @@ -74,8 +74,8 @@ class RollDialog { constructor(private readonly page: Page) {} async expectOpened(skill: string) { - expect( - await this.page.locator('h4').filter({ hasText: `${skill} Test` }) + await expect( + this.page.locator('h4').filter({ hasText: `${skill} Test` }) ).toBeVisible(); } @@ -83,8 +83,8 @@ class RollDialog { await this.page .locator(`a:text("Close"):near(h4:text("${skill} Test"))`) .click(); - expect( - await this.page.locator('h4').filter({ hasText: `${skill} Test` }) + await expect( + this.page.locator('h4').filter({ hasText: `${skill} Test` }) ).not.toBeVisible(); } } diff --git a/tests/fixtures/gameFixture.ts b/tests/fixtures/gameFixture.ts index fb31fb4..403f60f 100644 --- a/tests/fixtures/gameFixture.ts +++ b/tests/fixtures/gameFixture.ts @@ -35,11 +35,11 @@ export class GameFixture { await test.step('clean up some page basics', async () => { await this.page.getByLabel(/clear chat log/i).click(); await expect( - await this.page.getByRole('heading', { name: 'Flush Chat Log' }) + this.page.getByRole('heading', { name: 'Flush Chat Log' }) ).toBeVisible(); await this.page.getByRole('button', { name: /yes/i }).click(); await expect( - await this.page.getByRole('heading', { name: 'Flush Chat Log' }) + this.page.getByRole('heading', { name: 'Flush Chat Log' }) ).not.toBeVisible(); }); } @@ -57,14 +57,12 @@ export class GameFixture { await this.openTab('Actors'); await test.step(`Open actor named '${name}'`, async () => { await this.page.getByText(name).click(); - await expect( - await this.page.locator('div.app.bw-app') - ).toBeVisible(); + await expect(this.page.locator('div.app.bw-app')).toBeVisible(); }); } async getSelectedValue(select: Locator) { - return await select.locator('option[selected]').innerText(); + return select.locator('option[selected]').innerText(); } } diff --git a/tests/fixtures/setupFixture.ts b/tests/fixtures/setupFixture.ts index 72a0065..1300e15 100644 --- a/tests/fixtures/setupFixture.ts +++ b/tests/fixtures/setupFixture.ts @@ -8,7 +8,7 @@ class SetupPage { async navigateToLoginPage() { await setupFixture.step('dismiss tour notifications', async () => { await expect( - await this.page.getByText(/backups overview/i) + this.page.getByText(/backups overview/i) ).toBeVisible(); await this.page.waitForTimeout(250); // let animations settle await this.page.locator('i.close.fas.fa-times-circle').click(); @@ -17,7 +17,7 @@ class SetupPage { .getByRole('button') .dispatchEvent('click'); await expect( - await this.page.getByText(/backups overview/i) + this.page.getByText(/backups overview/i) ).not.toBeVisible(); }); await setupFixture.step('navigate to login page', async () => {