From 9b1e966cd8e9b76910cccddd03b1466c4946cc03 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Mon, 9 Sep 2024 10:14:11 +0300 Subject: [PATCH] test: refactor tests --- tests/e2e/lib/genericadminpage.ts | 2 +- tests/e2e/lib/loginpage.ts | 10 +--------- tests/e2e/lib/profilepage.ts | 2 +- tests/e2e/lib/test-helpers.ts | 2 +- tests/e2e/lib/webauthsettingspage.ts | 2 +- tests/e2e/specs/login.spec.ts | 2 +- tests/e2e/specs/rename.spec.ts | 2 +- tests/e2e/specs/revoke.spec.ts | 2 +- 8 files changed, 8 insertions(+), 16 deletions(-) diff --git a/tests/e2e/lib/genericadminpage.ts b/tests/e2e/lib/genericadminpage.ts index c30d704e..33f11a2f 100644 --- a/tests/e2e/lib/genericadminpage.ts +++ b/tests/e2e/lib/genericadminpage.ts @@ -1,4 +1,4 @@ -import { Locator, Page } from '@playwright/test'; +import type { Locator, Page } from '@playwright/test'; const selectors = { menuBarMyAccount: '#wp-admin-bar-my-account', diff --git a/tests/e2e/lib/loginpage.ts b/tests/e2e/lib/loginpage.ts index d89e108e..ac451649 100644 --- a/tests/e2e/lib/loginpage.ts +++ b/tests/e2e/lib/loginpage.ts @@ -1,4 +1,4 @@ -import { Locator, Page } from '@playwright/test'; +import type { Locator, Page } from '@playwright/test'; const selectors = { userField: '#user_login', @@ -37,16 +37,8 @@ export class LoginPage { } public async login(username: string, password: string): Promise { - await this.userFieldLocator.click(); - // eslint-disable-next-line playwright/no-wait-for-timeout - await this.page.waitForTimeout(60); await this.userFieldLocator.fill(username); - await this.passwordFieldLocator.click(); - // eslint-disable-next-line playwright/no-wait-for-timeout - await this.page.waitForTimeout(60); await this.passwordFieldLocator.fill(password); - // eslint-disable-next-line playwright/no-wait-for-timeout - await this.page.waitForTimeout(60); await this.submitButtonLocator.click(); await this.page.waitForLoadState('domcontentloaded'); } diff --git a/tests/e2e/lib/profilepage.ts b/tests/e2e/lib/profilepage.ts index 9fd849a8..03ec9058 100644 --- a/tests/e2e/lib/profilepage.ts +++ b/tests/e2e/lib/profilepage.ts @@ -1,4 +1,4 @@ -import { Locator, Page, Response } from '@playwright/test'; +import type { Locator, Page, Response } from '@playwright/test'; const selectors = { twoFactorOptions: '#two-factor-options', diff --git a/tests/e2e/lib/test-helpers.ts b/tests/e2e/lib/test-helpers.ts index 1560be6b..a0a3370b 100644 --- a/tests/e2e/lib/test-helpers.ts +++ b/tests/e2e/lib/test-helpers.ts @@ -1,4 +1,4 @@ -import { Page, CDPSession, expect } from '@playwright/test'; +import { type Page, type CDPSession, expect } from '@playwright/test'; import { LoginPage } from './loginpage'; import type { Protocol } from 'playwright-core/types/protocol'; import { ProfilePage } from './profilepage'; diff --git a/tests/e2e/lib/webauthsettingspage.ts b/tests/e2e/lib/webauthsettingspage.ts index c4719a37..e3011928 100644 --- a/tests/e2e/lib/webauthsettingspage.ts +++ b/tests/e2e/lib/webauthsettingspage.ts @@ -1,4 +1,4 @@ -import { Locator, Page } from '@playwright/test'; +import type { Locator, Page } from '@playwright/test'; const selectors = { authenticatorAttachment: '#authenticator_attachment', diff --git a/tests/e2e/specs/login.spec.ts b/tests/e2e/specs/login.spec.ts index 8ac4ad80..f60d9dbc 100644 --- a/tests/e2e/specs/login.spec.ts +++ b/tests/e2e/specs/login.spec.ts @@ -1,4 +1,4 @@ -import { test, expect, CDPSession } from '@playwright/test'; +import { test, expect, type CDPSession } from '@playwright/test'; import { LoginPage } from '../lib/loginpage'; import { ProfilePage } from '../lib/profilepage'; import { GenericAdminPage } from '../lib/genericadminpage'; diff --git a/tests/e2e/specs/rename.spec.ts b/tests/e2e/specs/rename.spec.ts index 5585794a..c024f9b3 100644 --- a/tests/e2e/specs/rename.spec.ts +++ b/tests/e2e/specs/rename.spec.ts @@ -1,4 +1,4 @@ -import { test, expect, CDPSession } from '@playwright/test'; +import { test, expect, type CDPSession } from '@playwright/test'; import settings from '../e2e-settings'; import { addVirtualAuthenticator, clearCredentials, removeVirtualAuthenticator } from '../lib/webauthn-helpers'; import { login, registerKey } from '../lib/test-helpers'; diff --git a/tests/e2e/specs/revoke.spec.ts b/tests/e2e/specs/revoke.spec.ts index 08a7e91c..31d3adb0 100644 --- a/tests/e2e/specs/revoke.spec.ts +++ b/tests/e2e/specs/revoke.spec.ts @@ -1,4 +1,4 @@ -import { test, expect, CDPSession } from '@playwright/test'; +import { test, expect, type CDPSession } from '@playwright/test'; import settings from '../e2e-settings'; import { addVirtualAuthenticator, removeVirtualAuthenticator } from '../lib/webauthn-helpers'; import { login, registerKey } from '../lib/test-helpers';