Update Retention Playwright tests to use real Synapse config endpoint (#33906)
* Use real interface type for SynapseConfig * Reconfigure for Synapse retention config * Add beforeEach * fix import * lint lint * fix number type * fix * cleanup * formatted
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2026 Element Creations 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 { rejectToastIfExists } from "@element-hq/element-web-playwright-common";
|
||||
|
||||
import { isDendrite } from "../../plugins/homeserver/dendrite";
|
||||
import { checkRetentionInRoom } from "./utils";
|
||||
import { test } from "../../element-web-test";
|
||||
|
||||
const ONE_MINUTE_STR = "60s";
|
||||
|
||||
test.use({
|
||||
synapseConfig: {
|
||||
retention: {
|
||||
enabled: true,
|
||||
default_policy: {
|
||||
max_lifetime: ONE_MINUTE_STR,
|
||||
},
|
||||
allowed_lifetime_min: ONE_MINUTE_STR,
|
||||
allowed_lifetime_max: ONE_MINUTE_STR,
|
||||
},
|
||||
experimental_features: {
|
||||
msc1763_enabled: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
test.describe("global retention rules", () => {
|
||||
test.skip(isDendrite, "dendrite does not support retention");
|
||||
test.use({
|
||||
displayName: "Tom",
|
||||
botCreateOpts: {
|
||||
displayName: "Bob",
|
||||
},
|
||||
labsFlags: ["feature_retention"],
|
||||
});
|
||||
test.beforeEach(async ({ app, homeserver, page, user }) => {
|
||||
await rejectToastIfExists(page, "Verify this device");
|
||||
await rejectToastIfExists(page, "Notifications");
|
||||
await page.clock.install();
|
||||
});
|
||||
|
||||
test("should apply", async ({ app, bot, page }) => {
|
||||
const roomId = await app.client.createRoom({
|
||||
name: "Test",
|
||||
invite: [bot.credentials.userId],
|
||||
});
|
||||
await checkRetentionInRoom({ app, bot, page }, roomId);
|
||||
});
|
||||
});
|
||||
@@ -7,30 +7,28 @@
|
||||
|
||||
import { rejectToastIfExists } from "@element-hq/element-web-playwright-common";
|
||||
|
||||
import { test, expect, type TestFixtures } from "../../element-web-test";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { isDendrite } from "../../plugins/homeserver/dendrite";
|
||||
import { test, expect } from "../../element-web-test";
|
||||
import { checkRetentionInRoom, ONE_MINUTE } from "./utils";
|
||||
|
||||
const ONE_MINUTE = 60 * 1000;
|
||||
const ONE_MINUTE_STR = "60s";
|
||||
|
||||
async function checkRetentionInRoom(
|
||||
{ bot, app, page }: Pick<TestFixtures, "app" | "bot"> & { page: Page },
|
||||
roomId: string,
|
||||
) {
|
||||
await bot.joinRoom(roomId);
|
||||
await app.viewRoomById(roomId);
|
||||
const tiles = (
|
||||
await Promise.all(Array.from({ length: 5 }).map((_o, index) => bot.sendMessage(roomId, `Message ${index}`)))
|
||||
).map(({ event_id: evtId }) => page.locator(`.mx_RoomView_MessageList .mx_EventTile[data-event-id='${evtId}']`));
|
||||
for (const tile of tiles) {
|
||||
await expect(tile).toBeVisible();
|
||||
}
|
||||
await page.clock.fastForward(ONE_MINUTE + 1);
|
||||
for (const tile of tiles) {
|
||||
await expect(tile).toBeHidden();
|
||||
}
|
||||
}
|
||||
test.use({
|
||||
synapseConfig: {
|
||||
retention: {
|
||||
enabled: true,
|
||||
// deliberately no default policy.
|
||||
allowed_lifetime_min: ONE_MINUTE_STR,
|
||||
allowed_lifetime_max: ONE_MINUTE_STR,
|
||||
},
|
||||
experimental_features: {
|
||||
msc1763_enabled: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
test.describe("Retention", () => {
|
||||
test.skip(isDendrite, "dendrite does not support retention");
|
||||
test.use({
|
||||
displayName: "Tom",
|
||||
botCreateOpts: {
|
||||
@@ -65,32 +63,6 @@ test.describe("Retention", () => {
|
||||
await checkRetentionInRoom({ app, bot, page }, roomId);
|
||||
});
|
||||
|
||||
test.describe("global retention rules", () => {
|
||||
test.use({
|
||||
page: async ({ page }, runFixture) => {
|
||||
await page.route("**/_matrix/client/unstable/org.matrix.msc1763/retention/configuration", (route) => {
|
||||
return route.fulfill({
|
||||
json: {
|
||||
policies: {
|
||||
"*": {
|
||||
max_lifetime: ONE_MINUTE,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
await runFixture(page);
|
||||
},
|
||||
});
|
||||
test("should apply", async ({ app, bot, page }) => {
|
||||
const roomId = await app.client.createRoom({
|
||||
name: "Test",
|
||||
invite: [bot.credentials.userId],
|
||||
});
|
||||
await checkRetentionInRoom({ app, bot, page }, roomId);
|
||||
});
|
||||
});
|
||||
|
||||
test("retention rules should apply after restart", async ({ app, bot, page }) => {
|
||||
const roomId = await app.client.createRoom({
|
||||
name: "Test",
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2026 Element Creations 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 { expect, type TestFixtures } from "../../element-web-test";
|
||||
import type { Page } from "@playwright/test";
|
||||
|
||||
export const ONE_MINUTE = 60 * 1000;
|
||||
|
||||
export async function checkRetentionInRoom(
|
||||
{ bot, app, page }: Pick<TestFixtures, "app" | "bot"> & { page: Page },
|
||||
roomId: string,
|
||||
) {
|
||||
await bot.joinRoom(roomId);
|
||||
await app.viewRoomById(roomId);
|
||||
const tiles = (
|
||||
await Promise.all(Array.from({ length: 5 }).map((_o, index) => bot.sendMessage(roomId, `Message ${index}`)))
|
||||
).map(({ event_id: evtId }) => page.locator(`.mx_RoomView_MessageList .mx_EventTile[data-event-id='${evtId}']`));
|
||||
for (const tile of tiles) {
|
||||
await expect(tile).toBeVisible();
|
||||
}
|
||||
await page.clock.fastForward(ONE_MINUTE + 1);
|
||||
for (const tile of tiles) {
|
||||
await expect(tile).toBeHidden();
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
import { SynapseContainer as BaseSynapseContainer } from "@element-hq/element-web-playwright-common/lib/testcontainers/index.js";
|
||||
|
||||
const DOCKER_IMAGE =
|
||||
"ghcr.io/element-hq/synapse:develop@sha256:9ec4c58ea1384d3a854cd4b25a56b5a9e98b7b0c36844c8e3a442f2a9aa0c5bc";
|
||||
"ghcr.io/element-hq/synapse:develop@sha256:34656f82f110460b44c4ec7b77830b04ee325f0f7dc423ec2f95810737ba357e";
|
||||
|
||||
/**
|
||||
* SynapseContainer which freezes the docker digest to stabilise tests,
|
||||
|
||||
Reference in New Issue
Block a user