You've already forked element-web
mirror of
https://github.com/element-hq/element-web.git
synced 2025-08-09 14:42:51 +03: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>
148 lines
5.4 KiB
TypeScript
148 lines
5.4 KiB
TypeScript
/*
|
|
Copyright 2024 New Vector Ltd.
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
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 { Bot } from "../../pages/bot";
|
|
import type { Locator, Page } from "@playwright/test";
|
|
import type { ElementAppPage } from "../../pages/ElementAppPage";
|
|
import { test, expect } from "../../element-web-test";
|
|
import { Credentials } from "../../plugins/homeserver";
|
|
import { isDendrite } from "../../plugins/homeserver/dendrite";
|
|
|
|
test.describe("Lazy Loading", () => {
|
|
test.skip(isDendrite, "due to a Dendrite bug https://github.com/element-hq/dendrite/issues/3488");
|
|
|
|
const charlies: Bot[] = [];
|
|
|
|
test.use({
|
|
displayName: "Alice",
|
|
botCreateOpts: { displayName: "Bob" },
|
|
});
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.addInitScript(() => {
|
|
window.localStorage.setItem("mx_lhs_size", "0"); // Collapse left panel for these tests
|
|
});
|
|
});
|
|
|
|
test.beforeEach(async ({ page, homeserver, user, bot, app }) => {
|
|
for (let i = 1; i <= 10; i++) {
|
|
const displayName = `Charly #${i}`;
|
|
const bot = new Bot(page, homeserver, { displayName, startClient: false, autoAcceptInvites: false });
|
|
charlies.push(bot);
|
|
}
|
|
await app.client.network.setupRoute();
|
|
});
|
|
|
|
const name = "Lazy Loading Test";
|
|
const charlyMsg1 = "hi bob!";
|
|
const charlyMsg2 = "how's it going??";
|
|
let roomId: string;
|
|
|
|
async function setupRoomWithBobAliceAndCharlies(
|
|
page: Page,
|
|
app: ElementAppPage,
|
|
user: Credentials,
|
|
bob: Bot,
|
|
charlies: Bot[],
|
|
) {
|
|
const alias = `#lltest:${user.homeServer}`;
|
|
const visibility = await page.evaluate(() => (window as any).matrixcs.Visibility.Public);
|
|
roomId = await bob.createRoom({
|
|
name,
|
|
room_alias_name: "lltest",
|
|
visibility,
|
|
});
|
|
|
|
await Promise.all(charlies.map((bot) => bot.joinRoom(alias)));
|
|
for (const charly of charlies) {
|
|
await charly.sendMessage(roomId, charlyMsg1);
|
|
}
|
|
for (const charly of charlies) {
|
|
await charly.sendMessage(roomId, charlyMsg2);
|
|
}
|
|
|
|
for (let i = 20; i >= 1; --i) {
|
|
await bob.sendMessage(roomId, `I will only say this ${i} time(s)!`);
|
|
}
|
|
await app.client.joinRoom(alias);
|
|
await app.viewRoomByName(name);
|
|
}
|
|
|
|
async function checkPaginatedDisplayNames(app: ElementAppPage, charlies: Bot[]) {
|
|
await app.timeline.scrollToTop();
|
|
for (const charly of charlies) {
|
|
await expect(await app.timeline.findEventTile(charly.credentials.displayName, charlyMsg1)).toBeAttached();
|
|
await expect(await app.timeline.findEventTile(charly.credentials.displayName, charlyMsg2)).toBeAttached();
|
|
}
|
|
}
|
|
|
|
async function openMemberlist(app: ElementAppPage): Promise<void> {
|
|
await app.toggleRoomInfoPanel();
|
|
const { page } = app;
|
|
await page.locator(".mx_RightPanel").getByRole("menuitem", { name: "People" }).click();
|
|
}
|
|
|
|
function getMemberInMemberlist(page: Page, name: string): Locator {
|
|
return page.locator(".mx_MemberListView .mx_MemberTileView_name").filter({ hasText: name });
|
|
}
|
|
|
|
async function checkMemberList(page: Page, charlies: Bot[]) {
|
|
await expect(getMemberInMemberlist(page, "Alice")).toBeAttached();
|
|
await expect(getMemberInMemberlist(page, "Bob")).toBeAttached();
|
|
for (const charly of charlies) {
|
|
await expect(getMemberInMemberlist(page, charly.credentials.displayName)).toBeAttached();
|
|
}
|
|
}
|
|
|
|
async function checkMemberListLacksCharlies(page: Page, charlies: Bot[]) {
|
|
for (const charly of charlies) {
|
|
await expect(getMemberInMemberlist(page, charly.credentials.displayName)).not.toBeAttached();
|
|
}
|
|
}
|
|
|
|
async function joinCharliesWhileAliceIsOffline(
|
|
page: Page,
|
|
app: ElementAppPage,
|
|
user: Credentials,
|
|
charlies: Bot[],
|
|
) {
|
|
const alias = `#lltest:${user.homeServer}`;
|
|
await app.client.network.goOffline();
|
|
for (const charly of charlies) {
|
|
await charly.joinRoom(alias);
|
|
}
|
|
for (let i = 20; i >= 1; --i) {
|
|
await charlies[0].sendMessage(roomId, "where is charly?");
|
|
}
|
|
await app.client.network.goOnline();
|
|
await app.client.waitForNextSync();
|
|
}
|
|
|
|
test("should handle lazy loading properly even when offline", async ({ page, app, bot, user }) => {
|
|
test.slow();
|
|
const charly1to5 = charlies.slice(0, 5);
|
|
const charly6to10 = charlies.slice(5);
|
|
|
|
// Set up room with alice, bob & charlies 1-5
|
|
await setupRoomWithBobAliceAndCharlies(page, app, user, bot, charly1to5);
|
|
// Alice should see 2 messages from every charly with the correct display name
|
|
await checkPaginatedDisplayNames(app, charly1to5);
|
|
|
|
await openMemberlist(app);
|
|
await checkMemberList(page, charly1to5);
|
|
await joinCharliesWhileAliceIsOffline(page, app, user, charly6to10);
|
|
await checkMemberList(page, charly6to10);
|
|
|
|
for (const charly of charlies) {
|
|
await charly.evaluate((client, roomId) => client.leave(roomId), roomId);
|
|
}
|
|
|
|
await checkMemberListLacksCharlies(page, charlies);
|
|
});
|
|
});
|