From 1503e518b0124a79889db47c744b8a80e229ee20 Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Wed, 12 Apr 2023 20:13:20 +0900 Subject: [PATCH 1/2] Update user-view.spec.ts - use Cypress Testing Library Signed-off-by: Suguru Hirahara --- cypress/e2e/user-view/user-view.spec.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/user-view/user-view.spec.ts b/cypress/e2e/user-view/user-view.spec.ts index 529ef16cf16..e935642b219 100644 --- a/cypress/e2e/user-view/user-view.spec.ts +++ b/cypress/e2e/user-view/user-view.spec.ts @@ -40,8 +40,14 @@ describe("UserView", () => { cy.visit(`/#/user/${bot.getUserId()}`); }); - cy.get("#mx_RightPanel .mx_UserInfo_profile h2").should("contain", "Usman"); - cy.get(".mx_RightPanel .mx_Spinner").should("not.exist"); // wait for spinners to finish + cy.get(".mx_RightPanel").within(() => { + cy.get("mx_UserInfo_profile h2").within(() => { + cy.findByText("Usman").should("exist"); + }); + + cy.get(".mx_Spinner").should("not.exist"); // wait for spinners to finish + }); + cy.get(".mx_RightPanel").percySnapshotElement("User View", { // Hide the MXID field as it'll vary on each test percyCSS: ".mx_UserInfo_profile_mxid { visibility: hidden !important; }", From 8f20dba0a405dcad07365750d3c2f772bfa1250f Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Wed, 12 Apr 2023 20:16:19 +0900 Subject: [PATCH 2/2] Remove a line to have the test wait until the spinner disappears The custom command 'percySnapshotElement' waits until it disappears so there is no need to keep it. Signed-off-by: Suguru Hirahara --- cypress/e2e/user-view/user-view.spec.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/user-view/user-view.spec.ts b/cypress/e2e/user-view/user-view.spec.ts index e935642b219..2acfc9d5355 100644 --- a/cypress/e2e/user-view/user-view.spec.ts +++ b/cypress/e2e/user-view/user-view.spec.ts @@ -40,12 +40,8 @@ describe("UserView", () => { cy.visit(`/#/user/${bot.getUserId()}`); }); - cy.get(".mx_RightPanel").within(() => { - cy.get("mx_UserInfo_profile h2").within(() => { - cy.findByText("Usman").should("exist"); - }); - - cy.get(".mx_Spinner").should("not.exist"); // wait for spinners to finish + cy.get(".mx_RightPanel .mx_UserInfo_profile h2").within(() => { + cy.findByText("Usman").should("exist"); }); cy.get(".mx_RightPanel").percySnapshotElement("User View", {