Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
playwright: remove redundant TestOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Jun 20, 2024
1 parent 32fa059 commit 6cb70ff
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 72 deletions.
4 changes: 1 addition & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestOptions>({
export default defineConfig({
use: {
viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: true,
Expand Down
134 changes: 65 additions & 69 deletions playwright/element-web-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,79 +63,75 @@ const CONFIG_JSON: Partial<IConfigOptions> = {
},
};

export type TestOptions = {};

interface CredentialsWithDisplayName extends Credentials {
displayName: string;
}

export const test = base.extend<
TestOptions & {
axe: AxeBuilder;
checkA11y: () => Promise<void>;

/**
* 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<void>;

/**
* 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) => {
Expand Down

0 comments on commit 6cb70ff

Please sign in to comment.