From af54dcc5a7e312e8c86abbc9a1b4eb12fc055149 Mon Sep 17 00:00:00 2001 From: Svana Date: Fri, 15 Nov 2024 12:30:12 +0000 Subject: [PATCH] Minor tweaks --- apps/web/e2e/smoke/homepage.spec.ts | 2 +- apps/web/e2e/smoke/search.spec.ts | 2 +- .../e2e/smoke/sites-of-institutions.spec.ts | 4 +- apps/web/e2e/utils/addons.ts | 40 ------------------- apps/web/playwright.config.ts | 2 - libs/testing/e2e/src/index.ts | 3 +- 6 files changed, 6 insertions(+), 47 deletions(-) delete mode 100644 apps/web/e2e/utils/addons.ts diff --git a/apps/web/e2e/smoke/homepage.spec.ts b/apps/web/e2e/smoke/homepage.spec.ts index ca1f5d6da928..93367e15048b 100644 --- a/apps/web/e2e/smoke/homepage.spec.ts +++ b/apps/web/e2e/smoke/homepage.spec.ts @@ -1,5 +1,5 @@ import { - BrowserContext, + type BrowserContext, createPageAndNavigate, expect, session, diff --git a/apps/web/e2e/smoke/search.spec.ts b/apps/web/e2e/smoke/search.spec.ts index 59ac59f09d03..d1a38872936a 100644 --- a/apps/web/e2e/smoke/search.spec.ts +++ b/apps/web/e2e/smoke/search.spec.ts @@ -1,5 +1,5 @@ import { - BrowserContext, + type BrowserContext, expect, session, test, diff --git a/apps/web/e2e/smoke/sites-of-institutions.spec.ts b/apps/web/e2e/smoke/sites-of-institutions.spec.ts index 5bac4e00b321..71aa1a2e411a 100644 --- a/apps/web/e2e/smoke/sites-of-institutions.spec.ts +++ b/apps/web/e2e/smoke/sites-of-institutions.spec.ts @@ -1,9 +1,9 @@ import slugify from 'slugify' import { - BrowserContext, + type BrowserContext, expect, - Page, + type Page, session, test, } from '@island.is/testing/e2e' diff --git a/apps/web/e2e/utils/addons.ts b/apps/web/e2e/utils/addons.ts deleted file mode 100644 index e012fa9e99ac..000000000000 --- a/apps/web/e2e/utils/addons.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { expect, Locator, Page, sleep } from '@island.is/testing/e2e' - -expect.extend({ - async toHaveCountGreaterThan( - received: Locator, - value: number, - options: { timeout: number; sleepTime: number } = { - timeout: 10000, - sleepTime: 100, - }, - ) { - const initialTime = Date.now() - let count = -1 - while (count <= value) { - count = await received.count() - if (Date.now() > initialTime + options.timeout) - return { message: () => 'Timeout', pass: false } - await sleep(options.sleepTime) - } - return { - message: () => `Found ${count} elements`, - pass: true, - } - }, - async toBeApplication(received: string | Page, applicationType = '\\w+') { - const url: string = typeof received == 'string' ? received : received.url() - const protocol = 'https?://' - const host = '[^/]+' - const applicationId = '(/(\\w|-)*)?' - const applicationRegExp = new RegExp( - `^${protocol}${host}/umsoknir/${applicationType}${applicationId}$`, - ) - const pass = applicationRegExp.test(url) - const message = () => - `Current page is ${pass ? '' : '*not* '}an application - Pattern ${applicationRegExp} - URL is ${url}` - return { message, pass } - }, -}) diff --git a/apps/web/playwright.config.ts b/apps/web/playwright.config.ts index 171cc5502dd2..f08f9fb5b6b0 100644 --- a/apps/web/playwright.config.ts +++ b/apps/web/playwright.config.ts @@ -1,7 +1,5 @@ import { createPlaywrightConfig } from '@island.is/testing/e2e' -import './e2e/utils/addons' - const webConfig = createPlaywrightConfig({ webServerUrl: 'http://localhost:4200', command: '(yarn dev-init web && yarn dev web)', diff --git a/libs/testing/e2e/src/index.ts b/libs/testing/e2e/src/index.ts index 1e4c8baa004e..f7fba34a0d79 100644 --- a/libs/testing/e2e/src/index.ts +++ b/libs/testing/e2e/src/index.ts @@ -9,4 +9,5 @@ export * from './lib/session/session' export * from './lib/modules/urls' export * from './lib/helpers/utils' export * from './lib/config/playwright-config' -export { test, expect, Page, Locator, BrowserContext } from '@playwright/test' +export { test, expect } from '@playwright/test' +export type { Page, Locator, BrowserContext } from '@playwright/test'