mirror of https://github.com/vector-im/riot-web
Improve Percy stability by better scoping snapshots (#10207)
parent
1a08c6ba3a
commit
26652138bd
|
@ -5,6 +5,9 @@ on:
|
||||||
workflows: ["Element Web - Build"]
|
workflows: ["Element Web - Build"]
|
||||||
types:
|
types:
|
||||||
- completed
|
- completed
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: ${{ workflow_run.event == 'pull_request' }}
|
||||||
jobs:
|
jobs:
|
||||||
prepare:
|
prepare:
|
||||||
name: Prepare
|
name: Prepare
|
||||||
|
|
|
@ -118,7 +118,12 @@ describe("Decryption Failure Bar", () => {
|
||||||
"Verify this device to access all messages",
|
"Verify this device to access all messages",
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.percySnapshot("DecryptionFailureBar prompts user to verify");
|
cy.get(".mx_DecryptionFailureBar").percySnapshotElement(
|
||||||
|
"DecryptionFailureBar prompts user to verify",
|
||||||
|
{
|
||||||
|
widths: [320, 640],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
cy.contains(".mx_DecryptionFailureBar_button", "Resend key requests").should("not.exist");
|
cy.contains(".mx_DecryptionFailureBar_button", "Resend key requests").should("not.exist");
|
||||||
cy.contains(".mx_DecryptionFailureBar_button", "Verify").click();
|
cy.contains(".mx_DecryptionFailureBar_button", "Verify").click();
|
||||||
|
@ -146,8 +151,11 @@ describe("Decryption Failure Bar", () => {
|
||||||
"Open another device to load encrypted messages",
|
"Open another device to load encrypted messages",
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.percySnapshot(
|
cy.get(".mx_DecryptionFailureBar").percySnapshotElement(
|
||||||
"DecryptionFailureBar prompts user to open another device, with Resend Key Requests button",
|
"DecryptionFailureBar prompts user to open another device, with Resend Key Requests button",
|
||||||
|
{
|
||||||
|
widths: [320, 640],
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.intercept("/_matrix/client/r0/sendToDevice/m.room_key_request/*").as("keyRequest");
|
cy.intercept("/_matrix/client/r0/sendToDevice/m.room_key_request/*").as("keyRequest");
|
||||||
|
@ -155,8 +163,11 @@ describe("Decryption Failure Bar", () => {
|
||||||
cy.wait("@keyRequest");
|
cy.wait("@keyRequest");
|
||||||
cy.contains(".mx_DecryptionFailureBar_button", "Resend key requests").should("not.exist");
|
cy.contains(".mx_DecryptionFailureBar_button", "Resend key requests").should("not.exist");
|
||||||
|
|
||||||
cy.percySnapshot(
|
cy.get(".mx_DecryptionFailureBar").percySnapshotElement(
|
||||||
"DecryptionFailureBar prompts user to open another device, " + "without Resend Key Requests button",
|
"DecryptionFailureBar prompts user to open another device, " + "without Resend Key Requests button",
|
||||||
|
{
|
||||||
|
widths: [320, 640],
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -177,7 +188,9 @@ describe("Decryption Failure Bar", () => {
|
||||||
"Reset your keys to prevent future decryption errors",
|
"Reset your keys to prevent future decryption errors",
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.percySnapshot("DecryptionFailureBar prompts user to reset keys");
|
cy.get(".mx_DecryptionFailureBar").percySnapshotElement("DecryptionFailureBar prompts user to reset keys", {
|
||||||
|
widths: [320, 640],
|
||||||
|
});
|
||||||
|
|
||||||
cy.contains(".mx_DecryptionFailureBar_button", "Reset").click();
|
cy.contains(".mx_DecryptionFailureBar_button", "Reset").click();
|
||||||
|
|
||||||
|
@ -196,7 +209,12 @@ describe("Decryption Failure Bar", () => {
|
||||||
"Some messages could not be decrypted",
|
"Some messages could not be decrypted",
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.percySnapshot("DecryptionFailureBar displays general message with no call to action");
|
cy.get(".mx_DecryptionFailureBar").percySnapshotElement(
|
||||||
|
"DecryptionFailureBar displays general message with no call to action",
|
||||||
|
{
|
||||||
|
widths: [320, 640],
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -210,7 +228,10 @@ describe("Decryption Failure Bar", () => {
|
||||||
cy.get(".mx_DecryptionFailureBar").should("exist");
|
cy.get(".mx_DecryptionFailureBar").should("exist");
|
||||||
cy.get(".mx_DecryptionFailureBar .mx_Spinner").should("exist");
|
cy.get(".mx_DecryptionFailureBar .mx_Spinner").should("exist");
|
||||||
|
|
||||||
cy.percySnapshot("DecryptionFailureBar displays loading spinner");
|
cy.get(".mx_DecryptionFailureBar").percySnapshotElement("DecryptionFailureBar displays loading spinner", {
|
||||||
|
allowSpinners: true,
|
||||||
|
widths: [320, 640],
|
||||||
|
});
|
||||||
|
|
||||||
cy.wait(5000);
|
cy.wait(5000);
|
||||||
cy.get(".mx_DecryptionFailureBar .mx_Spinner").should("not.exist");
|
cy.get(".mx_DecryptionFailureBar .mx_Spinner").should("not.exist");
|
||||||
|
|
|
@ -159,8 +159,8 @@ describe("Timeline", () => {
|
||||||
".mx_GenericEventListSummary_summary",
|
".mx_GenericEventListSummary_summary",
|
||||||
"created and configured the room.",
|
"created and configured the room.",
|
||||||
).should("exist");
|
).should("exist");
|
||||||
cy.get(".mx_Spinner").should("not.exist");
|
|
||||||
cy.percySnapshot("Configured room on IRC layout");
|
cy.get(".mx_MainSplit").percySnapshotElement("Configured room on IRC layout");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should add inline start margin to an event line on IRC layout", () => {
|
it("should add inline start margin to an event line on IRC layout", () => {
|
||||||
|
@ -185,11 +185,12 @@ describe("Timeline", () => {
|
||||||
.should("have.css", "margin-inline-start", "104px")
|
.should("have.css", "margin-inline-start", "104px")
|
||||||
.should("have.css", "inset-inline-start", "0px");
|
.should("have.css", "inset-inline-start", "0px");
|
||||||
|
|
||||||
cy.get(".mx_Spinner").should("not.exist");
|
|
||||||
// Exclude timestamp from snapshot
|
// Exclude timestamp from snapshot
|
||||||
const percyCSS =
|
const percyCSS =
|
||||||
".mx_RoomView_body .mx_EventTile_info .mx_MessageTimestamp " + "{ visibility: hidden !important; }";
|
".mx_RoomView_body .mx_EventTile_info .mx_MessageTimestamp { visibility: hidden !important; }";
|
||||||
cy.percySnapshot("Event line with inline start margin on IRC layout", { percyCSS });
|
cy.get(".mx_MainSplit").percySnapshotElement("Event line with inline start margin on IRC layout", {
|
||||||
|
percyCSS,
|
||||||
|
});
|
||||||
cy.checkA11y();
|
cy.checkA11y();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -213,8 +214,7 @@ describe("Timeline", () => {
|
||||||
cy.get(".mx_RoomView_body .mx_EventTile_info .mx_MessageTimestamp").click();
|
cy.get(".mx_RoomView_body .mx_EventTile_info .mx_MessageTimestamp").click();
|
||||||
|
|
||||||
// Exclude timestamp from snapshot
|
// Exclude timestamp from snapshot
|
||||||
const percyCSS =
|
const percyCSS = ".mx_RoomView_body .mx_EventTile .mx_MessageTimestamp { visibility: hidden !important; }";
|
||||||
".mx_RoomView_body .mx_EventTile .mx_MessageTimestamp " + "{ visibility: hidden !important; }";
|
|
||||||
|
|
||||||
// should not add inline start padding to a hidden event line on IRC layout
|
// should not add inline start padding to a hidden event line on IRC layout
|
||||||
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
|
||||||
|
@ -223,14 +223,20 @@ describe("Timeline", () => {
|
||||||
"padding-inline-start",
|
"padding-inline-start",
|
||||||
"0px",
|
"0px",
|
||||||
);
|
);
|
||||||
cy.percySnapshot("Hidden event line with zero padding on IRC layout", { percyCSS });
|
|
||||||
|
cy.get(".mx_MainSplit").percySnapshotElement("Hidden event line with zero padding on IRC layout", {
|
||||||
|
percyCSS,
|
||||||
|
});
|
||||||
|
|
||||||
// should add inline start padding to a hidden event line on modern layout
|
// should add inline start padding to a hidden event line on modern layout
|
||||||
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Group);
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Group);
|
||||||
cy.get(".mx_EventTile[data-layout=group].mx_EventTile_info .mx_EventTile_line")
|
cy.get(".mx_EventTile[data-layout=group].mx_EventTile_info .mx_EventTile_line")
|
||||||
// calc(var(--EventTile_group_line-spacing-inline-start) + 20px) = 64 + 20 = 84px
|
// calc(var(--EventTile_group_line-spacing-inline-start) + 20px) = 64 + 20 = 84px
|
||||||
.should("have.css", "padding-inline-start", "84px");
|
.should("have.css", "padding-inline-start", "84px");
|
||||||
cy.percySnapshot("Hidden event line with padding on modern layout", { percyCSS });
|
|
||||||
|
cy.get(".mx_MainSplit").percySnapshotElement("Hidden event line with padding on modern layout", {
|
||||||
|
percyCSS,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should click top left of view source event toggle", () => {
|
it("should click top left of view source event toggle", () => {
|
||||||
|
@ -329,7 +335,12 @@ describe("Timeline", () => {
|
||||||
cy.wait("@mxc");
|
cy.wait("@mxc");
|
||||||
|
|
||||||
cy.checkA11y();
|
cy.checkA11y();
|
||||||
|
|
||||||
|
// Exclude timestamp from snapshot
|
||||||
|
const percyCSS =
|
||||||
|
".mx_RoomView_body .mx_EventTile_info .mx_MessageTimestamp { visibility: hidden !important; }";
|
||||||
cy.get(".mx_EventTile_last").percySnapshotElement("URL Preview", {
|
cy.get(".mx_EventTile_last").percySnapshotElement("URL Preview", {
|
||||||
|
percyCSS,
|
||||||
widths: [800, 400],
|
widths: [800, 400],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,6 +22,7 @@ declare global {
|
||||||
namespace Cypress {
|
namespace Cypress {
|
||||||
interface SnapshotOptions extends PercySnapshotOptions {
|
interface SnapshotOptions extends PercySnapshotOptions {
|
||||||
domTransformation?: (documentClone: Document) => void;
|
domTransformation?: (documentClone: Document) => void;
|
||||||
|
allowSpinners?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Chainable {
|
interface Chainable {
|
||||||
|
@ -38,6 +39,10 @@ declare global {
|
||||||
}
|
}
|
||||||
|
|
||||||
Cypress.Commands.add("percySnapshotElement", { prevSubject: "element" }, (subject, name, options) => {
|
Cypress.Commands.add("percySnapshotElement", { prevSubject: "element" }, (subject, name, options) => {
|
||||||
|
if (!options?.allowSpinners) {
|
||||||
|
// Await spinners to vanish
|
||||||
|
cy.get(".mx_Spinner").should("not.exist");
|
||||||
|
}
|
||||||
cy.percySnapshot(name, {
|
cy.percySnapshot(name, {
|
||||||
domTransformation: (documentClone) => scope(documentClone, subject.selector),
|
domTransformation: (documentClone) => scope(documentClone, subject.selector),
|
||||||
...options,
|
...options,
|
||||||
|
|
Loading…
Reference in New Issue