From 6cb70ff3086de684d52b0a0ec356febdfd5dc30c Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 20 Jun 2024 13:00:07 +0100 Subject: [PATCH] playwright: remove redundant `TestOptions` --- playwright.config.ts | 4 +- playwright/element-web-test.ts | 134 ++++++++++++++++----------------- 2 files changed, 66 insertions(+), 72 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 3f9da597ec1..458cf98daf0 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -16,11 +16,9 @@ limitations under the License. import { defineConfig } from "@playwright/test"; -import { TestOptions } from "./playwright/element-web-test"; - const baseURL = process.env["BASE_URL"] ?? "http://localhost:8080"; -export default defineConfig({ +export default defineConfig({ use: { viewport: { width: 1280, height: 720 }, ignoreHTTPSErrors: true, diff --git a/playwright/element-web-test.ts b/playwright/element-web-test.ts index 672f158b9eb..75235fe03d0 100644 --- a/playwright/element-web-test.ts +++ b/playwright/element-web-test.ts @@ -63,79 +63,75 @@ const CONFIG_JSON: Partial = { }, }; -export type TestOptions = {}; - interface CredentialsWithDisplayName extends Credentials { displayName: string; } -export const test = base.extend< - TestOptions & { - axe: AxeBuilder; - checkA11y: () => Promise; - - /** - * The contents of the config.json to send when the client requests it. - */ - config: typeof CONFIG_JSON; - - /** - * The options with which to run the {@link #homeserver} fixture. - */ - startHomeserverOpts: StartHomeserverOpts | string; - - homeserver: HomeserverInstance; - oAuthServer: { port: number }; - - /** - * The displayname to use for the user registered in {@link #credentials}. - * - * To set it, call `test.use({ displayName: "myDisplayName" })` in the test file or `describe` block. - * See {@link https://playwright.dev/docs/api/class-test#test-use}. - */ - displayName?: string; - - /** - * A test fixture which registers a test user on the {@link #homeserver} and supplies the details - * of the registered user. - */ - credentials: CredentialsWithDisplayName; - - /** - * The same as {@link https://playwright.dev/docs/api/class-fixtures#fixtures-page|`page`}, - * but adds an initScript which will populate localStorage with the user's details from - * {@link #credentials} and {@link #homeserver}. - * - * Similar to {@link #user}, but doesn't load the app. - */ - pageWithCredentials: Page; - - /** - * A (rather poorly-named) test fixture which registers a user per {@link #credentials}, stores - * the credentials into localStorage per {@link #homeserver}, and then loads the front page of the - * app. - */ - user: CredentialsWithDisplayName; - - /** - * The same as {@link https://playwright.dev/docs/api/class-fixtures#fixtures-page|`page`}, - * but wraps the returned `Page` in a class of utilities for interacting with the Element-Web UI, - * {@link ElementAppPage}. - */ - app: ElementAppPage; - - mailhog: { api: mailhog.API; instance: Instance }; - crypto: Crypto; - room?: { roomId: string }; - toasts: Toasts; - uut?: Locator; // Unit Under Test, useful place to refer a prepared locator - botCreateOpts: CreateBotOpts; - bot: Bot; - slidingSyncProxy: ProxyInstance; - labsFlags: string[]; - webserver: Webserver; - } ->({ +export const test = base.extend<{ + axe: AxeBuilder; + checkA11y: () => Promise; + + /** + * The contents of the config.json to send when the client requests it. + */ + config: typeof CONFIG_JSON; + + /** + * The options with which to run the {@link #homeserver} fixture. + */ + startHomeserverOpts: StartHomeserverOpts | string; + + homeserver: HomeserverInstance; + oAuthServer: { port: number }; + + /** + * The displayname to use for the user registered in {@link #credentials}. + * + * To set it, call `test.use({ displayName: "myDisplayName" })` in the test file or `describe` block. + * See {@link https://playwright.dev/docs/api/class-test#test-use}. + */ + displayName?: string; + + /** + * A test fixture which registers a test user on the {@link #homeserver} and supplies the details + * of the registered user. + */ + credentials: CredentialsWithDisplayName; + + /** + * The same as {@link https://playwright.dev/docs/api/class-fixtures#fixtures-page|`page`}, + * but adds an initScript which will populate localStorage with the user's details from + * {@link #credentials} and {@link #homeserver}. + * + * Similar to {@link #user}, but doesn't load the app. + */ + pageWithCredentials: Page; + + /** + * A (rather poorly-named) test fixture which registers a user per {@link #credentials}, stores + * the credentials into localStorage per {@link #homeserver}, and then loads the front page of the + * app. + */ + user: CredentialsWithDisplayName; + + /** + * The same as {@link https://playwright.dev/docs/api/class-fixtures#fixtures-page|`page`}, + * but wraps the returned `Page` in a class of utilities for interacting with the Element-Web UI, + * {@link ElementAppPage}. + */ + app: ElementAppPage; + + mailhog: { api: mailhog.API; instance: Instance }; + crypto: Crypto; + room?: { roomId: string }; + toasts: Toasts; + uut?: Locator; // Unit Under Test, useful place to refer a prepared locator + botCreateOpts: CreateBotOpts; + bot: Bot; + slidingSyncProxy: ProxyInstance; + labsFlags: string[]; + webserver: Webserver; +}>({ config: CONFIG_JSON, page: async ({ context, page, config, labsFlags }, use) => { await context.route(`http://localhost:8080/config.json*`, async (route) => {