Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/vector-im/element-web in…
Browse files Browse the repository at this point in the history
…to t3chguy/flaky-tests-10jan

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

# Conflicts:
#	playwright/services.ts
#	playwright/testcontainers/synapse.ts
  • Loading branch information
t3chguy committed Jan 14, 2025
2 parents 4ad16af + 37f8d70 commit 7b69861
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 32 deletions.
1 change: 1 addition & 0 deletions playwright/e2e/crypto/invisible-crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { bootstrapCrossSigningForClient } from "../../pages/client.ts";

/** Tests for the "invisible crypto" behaviour -- i.e., when the "exclude insecure devices" setting is enabled */
test.describe("Invisible cryptography", () => {
test.slow();
test.use({
displayName: "Alice",
botCreateOpts: { displayName: "Bob" },
Expand Down
28 changes: 6 additions & 22 deletions playwright/e2e/integration-manager/kick.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,13 @@ async function sendActionFromIntegrationManager(
await iframe.getByRole("button", { name: "Press to send action" }).click();
}

async function clickUntilGone(page: Page, selector: string, attempt = 0) {
if (attempt === 11) {
throw new Error("clickUntilGone attempt count exceeded");
}

await page.locator(selector).last().click();

const count = await page.locator(selector).count();
if (count > 0) {
return clickUntilGone(page, selector, ++attempt);
}
}

async function expectKickedMessage(page: Page, shouldExist: boolean) {
// Expand any event summaries, we can't use a click multiple here because clicking one might de-render others
// This is quite horrible but seems the most stable way of clicking 0-N buttons,
// one at a time with a full re-evaluation after each click
await clickUntilGone(page, ".mx_GenericEventListSummary_toggle[aria-expanded=false]");

// Check for the event message (or lack thereof)
await expect(page.getByText(`${USER_DISPLAY_NAME} removed ${BOT_DISPLAY_NAME}: ${KICK_REASON}`)).toBeVisible({
visible: shouldExist,
});
await expect(async () => {
await page.locator(".mx_GenericEventListSummary_toggle[aria-expanded=false]").last().click();
await expect(page.getByText(`${USER_DISPLAY_NAME} removed ${BOT_DISPLAY_NAME}: ${KICK_REASON}`)).toBeVisible({
visible: shouldExist,
});
}).toPass();
}

test.describe("Integration Manager: Kick", () => {
Expand Down
6 changes: 1 addition & 5 deletions playwright/e2e/read-receipts/reactions-in-threads.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ test.describe("Read receipts", { tag: "@mergequeue" }, () => {
// Given a thread exists and I have marked it as read
await util.goTo(room1);
await util.assertRead(room2);
await util.receiveMessages(room2, [
"Msg1",
msg.threadedOff("Msg1", "Reply1"),
msg.reactionTo("Reply1", "🪿"),
]);
await util.receiveMessages(room2, ["Msg1", msg.threadedOff("Msg1", "Reply1")]);
await util.assertUnread(room2, 1);
await util.markAsRead(room2);
await util.assertRead(room2);
Expand Down
7 changes: 6 additions & 1 deletion playwright/e2e/timeline/timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,12 @@ test.describe("Timeline", () => {
await messageEdit(page);

// Click timestamp to highlight hidden event line
await page.locator(".mx_RoomView_body .mx_EventTile_info .mx_MessageTimestamp").click();
const timestamp = page.locator(".mx_RoomView_body .mx_EventTile_info a", {
has: page.locator(".mx_MessageTimestamp"),
});
// wait for the remote echo otherwise we get an error modal due to a 404 on the /event/ API
await expect(timestamp).not.toHaveAttribute("href", /~!/);
await timestamp.locator(".mx_MessageTimestamp").click();

// should not add inline start padding to a hidden event line on IRC layout
await app.settings.setValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
Expand Down
2 changes: 1 addition & 1 deletion playwright/plugins/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class ClientServerApi extends Api {
accessToken: json.access_token,
userId: json.user_id,
deviceId: json.device_id,
homeServer: json.home_server,
homeServer: json.home_server || json.user_id.split(":").slice(1).join(":"),
username: userId.slice(1).split(":")[0],
};
}
Expand Down
3 changes: 1 addition & 2 deletions playwright/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export const test = base.extend<TestFixtures, Services & Options>({
{ scope: "worker" },
],
mailhogClient: async ({ mailhog: container }, use) => {
await use(container.client);
await container.client.deleteAll();
await use(container.client);
},

synapseConfig: [{}, { scope: "worker" }],
Expand Down Expand Up @@ -143,6 +143,5 @@ export const test = base.extend<TestFixtures, Services & Options>({
await use(context);
await logger.onTestFinished(testInfo);
await homeserver.onTestFinished(testInfo);
await mailhogClient.deleteAll();
},
});
2 changes: 1 addition & 1 deletion playwright/testcontainers/synapse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export class StartedSynapseContainer extends AbstractStartedContainer implements
});

return {
homeServer: data.home_server,
homeServer: data.home_server || data.user_id.split(":").slice(1).join(":"),
accessToken: data.access_token,
userId: data.user_id,
deviceId: data.device_id,
Expand Down

0 comments on commit 7b69861

Please sign in to comment.