Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Hide tooltips for certain playwright screenshots to avoid flakiness (#…
Browse files Browse the repository at this point in the history
…12770)

* Hide tooltips for certain playwright screenshots to avoid flakiness

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

* Typo

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

* tsc

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

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
  • Loading branch information
t3chguy authored Jul 12, 2024
1 parent 08ee1b8 commit 1082d76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions playwright/e2e/timeline/timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ test.describe("Timeline", () => {
{
// Exclude timestamp from snapshot of mx_MainSplit
mask: [page.locator(".mx_MessageTimestamp")],
hideTooltips: true,
},
);

Expand All @@ -427,6 +428,7 @@ test.describe("Timeline", () => {
await expect(page.locator(".mx_MainSplit")).toMatchScreenshot("expanded-gels-and-messages-irc-layout.png", {
// Exclude timestamp from snapshot of mx_MainSplit
mask: [page.locator(".mx_MessageTimestamp")],
hideTooltips: true,
});

// 3. Alignment of expanded GELS and placeholder of deleted message
Expand All @@ -447,6 +449,7 @@ test.describe("Timeline", () => {
await expect(page.locator(".mx_MainSplit")).toMatchScreenshot("expanded-gels-redaction-placeholder.png", {
// Exclude timestamp from snapshot of mx_MainSplit
mask: [page.locator(".mx_MessageTimestamp")],
hideTooltips: true,
});

// 4. Alignment of expanded GELS, placeholder of deleted message, and emote
Expand All @@ -469,6 +472,7 @@ test.describe("Timeline", () => {
await expect(page.locator(".mx_MainSplit")).toMatchScreenshot("expanded-gels-emote-irc-layout.png", {
// Exclude timestamp from snapshot of mx_MainSplit
mask: [page.locator(".mx_MessageTimestamp")],
hideTooltips: true,
});
});

Expand All @@ -481,6 +485,7 @@ test.describe("Timeline", () => {
display: none !important;
}
`,
hideTooltips: true,
};

await sendEvent(app.client, room.roomId);
Expand Down
11 changes: 11 additions & 0 deletions playwright/element-web-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,22 @@ export const expect = baseExpect.extend({
options?: {
mask?: Array<Locator>;
omitBackground?: boolean;
hideTooltips?: boolean;
timeout?: number;
css?: string;
},
) {
const page = "page" in receiver ? receiver.page() : receiver;

let hideTooltipsCss: string | undefined;
if (options?.hideTooltips) {
hideTooltipsCss = `
.mx_Tooltip_visible {
visibility: hidden !important;
}
`;
}

// We add a custom style tag before taking screenshots
const style = (await page.addStyleTag({
content: `
Expand Down Expand Up @@ -339,6 +349,7 @@ export const expect = baseExpect.extend({
.mx_MessageTimestamp {
font-family: Inconsolata !important;
}
${hideTooltipsCss ?? ""}
${options?.css ?? ""}
`,
})) as ElementHandle<Element>;
Expand Down

0 comments on commit 1082d76

Please sign in to comment.