Improvements to Playwright test infrastructure (#12260)
* Move mailhog fixture to element-web-test.ts Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove spurious debug log Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Lazily set up ElementAppPage subfixtures to avoid conflicting on network routing Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update playwright/e2e/crypto/utils.ts --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/28217/head
parent
300f30eca9
commit
0e22413885
|
@ -36,9 +36,7 @@ import { ElementAppPage } from "../../pages/ElementAppPage";
|
||||||
export async function waitForVerificationRequest(client: Client): Promise<JSHandle<VerificationRequest>> {
|
export async function waitForVerificationRequest(client: Client): Promise<JSHandle<VerificationRequest>> {
|
||||||
return client.evaluateHandle((cli) => {
|
return client.evaluateHandle((cli) => {
|
||||||
return new Promise<VerificationRequest>((resolve) => {
|
return new Promise<VerificationRequest>((resolve) => {
|
||||||
console.log("~~");
|
|
||||||
const onVerificationRequestEvent = async (request: VerificationRequest) => {
|
const onVerificationRequestEvent = async (request: VerificationRequest) => {
|
||||||
console.log("@@", request);
|
|
||||||
await request.accept();
|
await request.accept();
|
||||||
resolve(request);
|
resolve(request);
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,20 +15,12 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { test, expect } from "../../element-web-test";
|
import { test, expect } from "../../element-web-test";
|
||||||
import { MailHogServer } from "../../plugins/mailhog";
|
|
||||||
import { isDendrite } from "../../plugins/homeserver/dendrite";
|
import { isDendrite } from "../../plugins/homeserver/dendrite";
|
||||||
|
|
||||||
test.describe("Email Registration", async () => {
|
test.describe("Email Registration", async () => {
|
||||||
test.skip(isDendrite, "not yet wired up");
|
test.skip(isDendrite, "not yet wired up");
|
||||||
|
|
||||||
test.use({
|
test.use({
|
||||||
// eslint-disable-next-line no-empty-pattern
|
|
||||||
mailhog: async ({}, use) => {
|
|
||||||
const mailhog = new MailHogServer();
|
|
||||||
const instance = await mailhog.start();
|
|
||||||
await use(instance);
|
|
||||||
await mailhog.stop();
|
|
||||||
},
|
|
||||||
startHomeserverOpts: ({ mailhog }, use) =>
|
startHomeserverOpts: ({ mailhog }, use) =>
|
||||||
use({
|
use({
|
||||||
template: "email",
|
template: "email",
|
||||||
|
|
|
@ -24,7 +24,7 @@ import type { IConfigOptions } from "../src/IConfigOptions";
|
||||||
import { Credentials, Homeserver, HomeserverInstance, StartHomeserverOpts } from "./plugins/homeserver";
|
import { Credentials, Homeserver, HomeserverInstance, StartHomeserverOpts } from "./plugins/homeserver";
|
||||||
import { Synapse } from "./plugins/homeserver/synapse";
|
import { Synapse } from "./plugins/homeserver/synapse";
|
||||||
import { Dendrite, Pinecone } from "./plugins/homeserver/dendrite";
|
import { Dendrite, Pinecone } from "./plugins/homeserver/dendrite";
|
||||||
import { Instance } from "./plugins/mailhog";
|
import { Instance, MailHogServer } from "./plugins/mailhog";
|
||||||
import { ElementAppPage } from "./pages/ElementAppPage";
|
import { ElementAppPage } from "./pages/ElementAppPage";
|
||||||
import { OAuthServer } from "./plugins/oauth_server";
|
import { OAuthServer } from "./plugins/oauth_server";
|
||||||
import { Crypto } from "./pages/crypto";
|
import { Crypto } from "./pages/crypto";
|
||||||
|
@ -86,7 +86,7 @@ export const test = base.extend<
|
||||||
user: CredentialsWithDisplayName;
|
user: CredentialsWithDisplayName;
|
||||||
displayName?: string;
|
displayName?: string;
|
||||||
app: ElementAppPage;
|
app: ElementAppPage;
|
||||||
mailhog?: { api: mailhog.API; instance: Instance };
|
mailhog: { api: mailhog.API; instance: Instance };
|
||||||
crypto: Crypto;
|
crypto: Crypto;
|
||||||
room?: { roomId: string };
|
room?: { roomId: string };
|
||||||
toasts: Toasts;
|
toasts: Toasts;
|
||||||
|
@ -234,6 +234,14 @@ export const test = base.extend<
|
||||||
await use(bot);
|
await use(bot);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-empty-pattern
|
||||||
|
mailhog: async ({}, use) => {
|
||||||
|
const mailhog = new MailHogServer();
|
||||||
|
const instance = await mailhog.start();
|
||||||
|
await use(instance);
|
||||||
|
await mailhog.stop();
|
||||||
|
},
|
||||||
|
|
||||||
slidingSyncProxy: async ({ page, user, homeserver }, use) => {
|
slidingSyncProxy: async ({ page, user, homeserver }, use) => {
|
||||||
const proxy = new SlidingSyncProxy(homeserver.config.dockerUrl);
|
const proxy = new SlidingSyncProxy(homeserver.config.dockerUrl);
|
||||||
const proxyInstance = await proxy.start();
|
const proxyInstance = await proxy.start();
|
||||||
|
|
|
@ -24,9 +24,23 @@ import { Spotlight } from "./Spotlight";
|
||||||
export class ElementAppPage {
|
export class ElementAppPage {
|
||||||
public constructor(public readonly page: Page) {}
|
public constructor(public readonly page: Page) {}
|
||||||
|
|
||||||
public settings = new Settings(this.page);
|
// We create these lazily on first access to avoid calling setup code which might cause conflicts,
|
||||||
public client: Client = new Client(this.page);
|
// e.g. the network routing code in the client subfixture.
|
||||||
public timeline: Timeline = new Timeline(this.page);
|
private _settings?: Settings;
|
||||||
|
public get settings(): Settings {
|
||||||
|
if (!this._settings) this._settings = new Settings(this.page);
|
||||||
|
return this._settings;
|
||||||
|
}
|
||||||
|
private _client?: Client;
|
||||||
|
public get client(): Client {
|
||||||
|
if (!this._client) this._client = new Client(this.page);
|
||||||
|
return this._client;
|
||||||
|
}
|
||||||
|
private _timeline?: Timeline;
|
||||||
|
public get timeline(): Timeline {
|
||||||
|
if (!this._timeline) this._timeline = new Timeline(this.page);
|
||||||
|
return this._timeline;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the top left user menu, returning a Locator to the resulting context menu.
|
* Open the top left user menu, returning a Locator to the resulting context menu.
|
||||||
|
|
Loading…
Reference in New Issue