diff --git a/e2e/core/global-setup.ts b/e2e/core/global-setup.ts deleted file mode 100644 index ed4f81b84..000000000 --- a/e2e/core/global-setup.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { request } from "@playwright/test"; -import * as dotenv from "dotenv"; - -dotenv.config(); - -/** - * This configuration is to reuse the signed-in state in the tests - * by log in only once using the API and then skip the log in step for all the tests. - * - * https://playwright.dev/docs/auth#reuse-signed-in-state - */ - -async function globalSetup() { - const requestContext = await request.newContext(); - const token = Buffer.from( - `${process.env.E2E_USER_ADMIN_USERNAME}:${process.env.E2E_USER_ADMIN_PASSWORD}` - ).toString("base64"); - await requestContext.post(`${process.env.E2E_BASE_URL}/ws/rest/v1/session`, { - data: { - sessionLocation: process.env.E2E_LOGIN_DEFAULT_LOCATION_UUID, - locale: "en", - }, - headers: { - "Content-Type": "application/json", - Authorization: `Basic ${token}`, - }, - }); - await requestContext.storageState({ path: "e2e/storageState.json" }); - await requestContext.dispose(); -} - -export default globalSetup; diff --git a/e2e/core/test.ts b/e2e/core/test.ts index 9617014af..2b2f6b3b5 100644 --- a/e2e/core/test.ts +++ b/e2e/core/test.ts @@ -1,5 +1,4 @@ -import { APIRequestContext, Page, test as base } from "@playwright/test"; -import { api } from "../fixtures"; +import { test as base } from "@playwright/test"; // This file sets up our custom test harness using the custom fixtures. // See https://playwright.dev/docs/test-fixtures#creating-a-fixture for details. @@ -7,14 +6,4 @@ import { api } from "../fixtures"; // exported from this file must be used instead of the default `test` function // provided by playwright. -export interface CustomTestFixtures { - loginAsAdmin: Page; -} - -export interface CustomWorkerFixtures { - api: APIRequestContext; -} - -export const test = base.extend({ - api: [api, { scope: "worker" }], -}); +export const test = base.extend({}); diff --git a/e2e/fixtures/api.ts b/e2e/fixtures/api.ts deleted file mode 100644 index 5b6055d80..000000000 --- a/e2e/fixtures/api.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { - APIRequestContext, - PlaywrightWorkerArgs, - WorkerFixture, -} from "@playwright/test"; - -/** - * A fixture which initializes an [`APIRequestContext`](https://playwright.dev/docs/api/class-apirequestcontext) - * that is bound to the configured OpenMRS API server. The context is automatically authenticated - * using the configured admin account. - * - * Use the request context like this: - * ```ts - * test('your test', async ({ api }) => { - * const res = await api.get('patient/1234'); - * await expect(res.ok()).toBeTruthy(); - * }); - * ``` - */ -export const api: WorkerFixture< - APIRequestContext, - PlaywrightWorkerArgs -> = async ({ playwright }, use) => { - const ctx = await playwright.request.newContext({ - baseURL: `${process.env.E2E_BASE_URL}/ws/rest/v1/`, - httpCredentials: { - username: process.env.E2E_USER_ADMIN_USERNAME, - password: process.env.E2E_USER_ADMIN_PASSWORD, - }, - }); - - await use(ctx); -}; diff --git a/playwright.config.ts b/playwright.config.ts index 99cc24dbb..8b35042c2 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -15,7 +15,6 @@ const config: PlaywrightTestConfig = { reporter: process.env.CI ? [["junit", { outputFile: "results.xml" }], ["html"]] : [["html"]], - globalSetup: require.resolve("./e2e/core/global-setup"), use: { baseURL: `${process.env.E2E_BASE_URL}/spa/`, storageState: "e2e/storageState.json",