1
0
mirror of https://github.com/element-hq/element-web.git synced 2025-08-08 03:42:14 +03:00

Fix and stabilise sliding sync playwright tests (#28809)

* Fix and stabilise sliding sync playwright tests

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Revert test enablement

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Debug

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Unskip now fixed tests

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2025-01-02 20:20:13 +00:00
committed by GitHub
parent 0555701829
commit bd3e93e8dd
8 changed files with 147 additions and 84 deletions

View File

@@ -6,6 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/
import type { BrowserContext, Route } from "@playwright/test";
import { getFreePort } from "../utils/port";
import { Docker } from "../docker";
import { PG_PASSWORD, PostgresDocker } from "../postgres";
@@ -24,7 +25,19 @@ export class SlidingSyncProxy {
private readonly postgresDocker = new PostgresDocker("sliding-sync");
private instance: ProxyInstance;
constructor(private synapseIp: string) {}
constructor(
private synapseIp: string,
private context: BrowserContext,
) {}
private syncHandler = async (route: Route) => {
if (!this.instance) return route.abort("blockedbyclient");
const baseUrl = `http://localhost:${this.instance.port}`;
await route.continue({
url: new URL(route.request().url().split("/").slice(3).join("/"), baseUrl).href,
});
};
async start(): Promise<ProxyInstance> {
console.log(new Date(), "Starting sliding sync proxy...");
@@ -50,10 +63,13 @@ export class SlidingSyncProxy {
console.log(new Date(), "started!");
this.instance = { containerId, postgresId, port };
await this.context.route("**/_matrix/client/unstable/org.matrix.msc3575/sync*", this.syncHandler);
return this.instance;
}
async stop(): Promise<void> {
await this.context.unroute("**/_matrix/client/unstable/org.matrix.msc3575/sync*", this.syncHandler);
await this.postgresDocker.stop();
await this.proxyDocker.stop();
console.log(new Date(), "Stopped sliding sync proxy.");