mirror of
https://github.com/vector-im/element-web.git
synced 2025-11-15 15:41:10 +01:00
* Switch to TestContainers for manging services in Playwright Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Flip fixture dependency order Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove mas dep Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update matrix-authentication-service in Playwright tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * delint Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix SMTP port Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Comments Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Strip ansi from playwright logs to make them more readable Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Actually do the update Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove access to homeserver.config.baseUrl field in favour of homeserver.baseUrl Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Use sane default_server_config and specify server.invalid in the specific tests which demand it Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix mas run Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * break cycle Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * typo Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * prettier Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Wire up basics of dendriteHomeserver Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Run Playwright tests against Dendrite & Pinecone periodically Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix playwright-image-updates.yaml workflow Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add `X-Run-All-Tests` label for running all tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Ignore failing tests in stale-screenshot-reporter.ts to avoid confusing errors Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Specify Synapse ui_auth.session_timeout only on tests which require it As Dendrite lacks this configuration option Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * React to MatrixEvent sender/target sentinels being updated for rendering state events Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove test code Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * React to sentinel changes in EventListSummary Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Docs Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Avoid reusing user1234 Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix stale-screenshot-reporter.ts Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Clean up public rooms between tests on reused homeserver Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Deflake spotlight when homeserver is reused Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Deflake more tests using existing username Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Clean mailhog between tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix more flakes Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix missing _request Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix playwright flaky tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Wipe mailhog between test runs Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Delint Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * delint Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Deflake more tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix flaky tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix flaky tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix mas config Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix another flaky test Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix playwright flakes due to floating promises Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix flaky playwright tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update services.ts --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
170 lines
5.8 KiB
TypeScript
170 lines
5.8 KiB
TypeScript
/*
|
|
Copyright 2024 New Vector Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { test as base } from "@playwright/test";
|
|
import mailhog from "mailhog";
|
|
import { Network, StartedNetwork } from "testcontainers";
|
|
import { PostgreSqlContainer, StartedPostgreSqlContainer } from "@testcontainers/postgresql";
|
|
|
|
import { SynapseConfig, SynapseContainer } from "./testcontainers/synapse.ts";
|
|
import { Logger } from "./logger.ts";
|
|
import { StartedMatrixAuthenticationServiceContainer } from "./testcontainers/mas.ts";
|
|
import { HomeserverContainer, StartedHomeserverContainer } from "./testcontainers/HomeserverContainer.ts";
|
|
import { MailhogContainer, StartedMailhogContainer } from "./testcontainers/mailhog.ts";
|
|
import { OAuthServer } from "./plugins/oauth_server";
|
|
import { DendriteContainer, PineconeContainer } from "./testcontainers/dendrite.ts";
|
|
import { HomeserverType } from "./plugins/homeserver";
|
|
|
|
export interface TestFixtures {
|
|
mailhogClient: mailhog.API;
|
|
}
|
|
|
|
export interface Services {
|
|
logger: Logger;
|
|
|
|
network: StartedNetwork;
|
|
postgres: StartedPostgreSqlContainer;
|
|
mailhog: StartedMailhogContainer;
|
|
|
|
synapseConfig: SynapseConfig;
|
|
_homeserver: HomeserverContainer<any>;
|
|
homeserver: StartedHomeserverContainer;
|
|
// Set in masHomeserver only
|
|
mas?: StartedMatrixAuthenticationServiceContainer;
|
|
// Set in legacyOAuthHomeserver only
|
|
oAuthServer?: OAuthServer;
|
|
}
|
|
|
|
export interface Options {
|
|
homeserverType: HomeserverType;
|
|
}
|
|
|
|
export const test = base.extend<TestFixtures, Services & Options>({
|
|
logger: [
|
|
// eslint-disable-next-line no-empty-pattern
|
|
async ({}, use) => {
|
|
const logger = new Logger();
|
|
await use(logger);
|
|
},
|
|
{ scope: "worker" },
|
|
],
|
|
network: [
|
|
// eslint-disable-next-line no-empty-pattern
|
|
async ({}, use) => {
|
|
const network = await new Network().start();
|
|
await use(network);
|
|
await network.stop();
|
|
},
|
|
{ scope: "worker" },
|
|
],
|
|
postgres: [
|
|
async ({ logger, network }, use) => {
|
|
const container = await new PostgreSqlContainer()
|
|
.withNetwork(network)
|
|
.withNetworkAliases("postgres")
|
|
.withLogConsumer(logger.getConsumer("postgres"))
|
|
.withTmpFs({
|
|
"/dev/shm/pgdata/data": "",
|
|
})
|
|
.withEnvironment({
|
|
PG_DATA: "/dev/shm/pgdata/data",
|
|
})
|
|
.withCommand([
|
|
"-c",
|
|
"shared_buffers=128MB",
|
|
"-c",
|
|
`fsync=off`,
|
|
"-c",
|
|
`synchronous_commit=off`,
|
|
"-c",
|
|
"full_page_writes=off",
|
|
])
|
|
.start();
|
|
await use(container);
|
|
await container.stop();
|
|
},
|
|
{ scope: "worker" },
|
|
],
|
|
|
|
mailhog: [
|
|
async ({ logger, network }, use) => {
|
|
const container = await new MailhogContainer()
|
|
.withNetwork(network)
|
|
.withNetworkAliases("mailhog")
|
|
.withLogConsumer(logger.getConsumer("mailhog"))
|
|
.start();
|
|
await use(container);
|
|
await container.stop();
|
|
},
|
|
{ scope: "worker" },
|
|
],
|
|
mailhogClient: async ({ mailhog: container }, use) => {
|
|
await container.client.deleteAll();
|
|
await use(container.client);
|
|
},
|
|
|
|
synapseConfig: [{}, { scope: "worker" }],
|
|
homeserverType: ["synapse", { option: true, scope: "worker" }],
|
|
_homeserver: [
|
|
async ({ homeserverType }, use) => {
|
|
let container: HomeserverContainer<any>;
|
|
switch (homeserverType) {
|
|
case "synapse":
|
|
container = new SynapseContainer();
|
|
break;
|
|
case "dendrite":
|
|
container = new DendriteContainer();
|
|
break;
|
|
case "pinecone":
|
|
container = new PineconeContainer();
|
|
break;
|
|
}
|
|
|
|
await use(container);
|
|
},
|
|
{ scope: "worker" },
|
|
],
|
|
homeserver: [
|
|
async ({ homeserverType, logger, network, _homeserver: homeserver, synapseConfig, mas }, use) => {
|
|
if (homeserver instanceof SynapseContainer) {
|
|
homeserver.withConfig(synapseConfig);
|
|
}
|
|
const container = await homeserver
|
|
.withNetwork(network)
|
|
.withNetworkAliases("homeserver")
|
|
.withLogConsumer(logger.getConsumer(homeserverType))
|
|
.withMatrixAuthenticationService(mas)
|
|
.start();
|
|
|
|
await use(container);
|
|
await container.stop();
|
|
},
|
|
{ scope: "worker" },
|
|
],
|
|
mas: [
|
|
// eslint-disable-next-line no-empty-pattern
|
|
async ({}, use) => {
|
|
// we stub the mas fixture to allow `homeserver` to depend on it to ensure
|
|
// when it is specified by `masHomeserver` it is started before the homeserver
|
|
await use(undefined);
|
|
},
|
|
{ scope: "worker" },
|
|
],
|
|
|
|
context: async ({ homeserverType, synapseConfig, logger, context, request, homeserver }, use, testInfo) => {
|
|
testInfo.skip(
|
|
!(homeserver instanceof SynapseContainer) && Object.keys(synapseConfig).length > 0,
|
|
`Test specifies Synapse config options so is unsupported with ${homeserverType}`,
|
|
);
|
|
homeserver.setRequest(request);
|
|
await logger.onTestStarted(context);
|
|
await use(context);
|
|
await logger.onTestFinished(testInfo);
|
|
await homeserver.onTestFinished(testInfo);
|
|
},
|
|
});
|