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

Cypress test stability improvements #9156

Merged
merged 2 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions cypress/e2e/timeline/timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe("Timeline", () => {
cy.visit("/#/room/" + roomId);
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
cy.contains(".mx_RoomView_body .mx_GenericEventListSummary[data-layout=irc] " +
".mx_GenericEventListSummary_summary", "created and configured the room.");
".mx_GenericEventListSummary_summary", "created and configured the room.").should("exist");
cy.get(".mx_Spinner").should("not.exist");
cy.percySnapshot("Configured room on IRC layout");
});
Expand All @@ -166,7 +166,7 @@ describe("Timeline", () => {

// Wait until configuration is finished
cy.contains(".mx_RoomView_body .mx_GenericEventListSummary " +
".mx_GenericEventListSummary_summary", "created and configured the room.");
".mx_GenericEventListSummary_summary", "created and configured the room.").should("exist");

// Click "expand" link button
cy.get(".mx_GenericEventListSummary_toggle[aria-expanded=false]").click();
Expand All @@ -193,14 +193,14 @@ describe("Timeline", () => {
cy.visit("/#/room/" + roomId);
cy.setSettingValue("showHiddenEventsInTimeline", null, SettingLevel.DEVICE, true);
cy.contains(".mx_RoomView_body .mx_GenericEventListSummary .mx_GenericEventListSummary_summary",
"created and configured the room.");
"created and configured the room.").should("exist");

// Edit message
cy.contains(".mx_RoomView_body .mx_EventTile .mx_EventTile_line", "Message").within(() => {
cy.get('[aria-label="Edit"]').click({ force: true }); // Cypress has no ability to hover
cy.get(".mx_BasicMessageComposer_input").type("Edit{enter}");
});
cy.get(".mx_RoomView_body .mx_EventTile").contains(".mx_EventTile[data-scroll-tokens]", "MessageEdit");
cy.contains(".mx_EventTile[data-scroll-tokens]", "MessageEdit").should("exist");

// Click timestamp to highlight hidden event line
cy.get(".mx_RoomView_body .mx_EventTile_info .mx_MessageTimestamp").click();
Expand Down Expand Up @@ -228,18 +228,19 @@ describe("Timeline", () => {
cy.visit("/#/room/" + roomId);
cy.setSettingValue("showHiddenEventsInTimeline", null, SettingLevel.DEVICE, true);
cy.contains(".mx_RoomView_body .mx_GenericEventListSummary " +
".mx_GenericEventListSummary_summary", "created and configured the room.");
".mx_GenericEventListSummary_summary", "created and configured the room.").should("exist");

// Edit message
cy.contains(".mx_RoomView_body .mx_EventTile .mx_EventTile_line", "Message").within(() => {
cy.get('[aria-label="Edit"]').click({ force: true }); // Cypress has no ability to hover
cy.get(".mx_BasicMessageComposer_input").type("Edit{enter}");
});
cy.contains(".mx_RoomView_body .mx_EventTile[data-scroll-tokens]", "MessageEdit");
cy.contains(".mx_RoomView_body .mx_EventTile[data-scroll-tokens]", "MessageEdit").should("exist");

// Click top left of the event toggle, which should not be covered by MessageActionBar's safe area
cy.get(".mx_EventTile .mx_ViewSourceEvent").realHover()
.get(".mx_EventTile .mx_ViewSourceEvent .mx_ViewSourceEvent_toggle").click('topLeft', { force: false });
cy.get(".mx_EventTile .mx_ViewSourceEvent").realHover().within(() => {
cy.get(".mx_ViewSourceEvent_toggle").click('topLeft', { force: false });
});

// Make sure the expand toggle worked
cy.get(".mx_EventTile .mx_ViewSourceEvent_expanded .mx_ViewSourceEvent_toggle").should("be.visible");
Expand All @@ -249,17 +250,17 @@ describe("Timeline", () => {
cy.visit("/#/room/" + roomId);
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Bubble);
cy.contains(".mx_RoomView_body .mx_GenericEventListSummary[data-layout=bubble] " +
".mx_GenericEventListSummary_summary", "created and configured the room.");
".mx_GenericEventListSummary_summary", "created and configured the room.").should("exist");

// Click "expand" link button
cy.get(".mx_GenericEventListSummary_toggle[aria-expanded=false]").click();

// Click "collapse" link button on the first hovered info event line
cy.get(".mx_GenericEventListSummary_unstyledList .mx_EventTile_info:first-of-type").realHover()
.get(".mx_GenericEventListSummary_toggle[aria-expanded=true]").click({ force: false });
cy.get(".mx_GenericEventListSummary_unstyledList .mx_EventTile_info:first-of-type").realHover();
cy.get(".mx_GenericEventListSummary_toggle[aria-expanded=true]").click({ force: false });

// Make sure "collapse" link button worked
cy.get(".mx_GenericEventListSummary_toggle[aria-expanded=false]");
cy.get(".mx_GenericEventListSummary_toggle[aria-expanded=false]").should("exist");
});

it("should highlight search result words regardless of formatting", () => {
Expand All @@ -285,7 +286,7 @@ describe("Timeline", () => {
cy.getComposer().type(`${MESSAGE}{enter}`);

// Reply to the message
cy.get(".mx_RoomView_body .mx_EventTile").contains(".mx_EventTile_line", "Hello world").within(() => {
cy.get(".mx_RoomView_body").contains(".mx_EventTile_line", "Hello world").within(() => {
cy.get('[aria-label="Reply"]').click({ force: true }); // Cypress has no ability to hover
});
};
Expand All @@ -296,20 +297,22 @@ describe("Timeline", () => {

cy.getComposer().type(`${reply}{enter}`);

cy.get(".mx_RoomView_body .mx_EventTile .mx_EventTile_line").find(".mx_ReplyTile .mx_MTextBody")
cy.get(".mx_RoomView_body .mx_EventTile .mx_EventTile_line .mx_ReplyTile .mx_MTextBody")
.should("contain", MESSAGE);
cy.get(".mx_RoomView_body .mx_EventTile > .mx_EventTile_line > .mx_MTextBody").contains(reply)
cy.contains(".mx_RoomView_body .mx_EventTile > .mx_EventTile_line > .mx_MTextBody", reply)
.should("have.length", 1);
});

xit("can reply with a voice message", () => {
it("can reply with a voice message", () => {
viewRoomSendMessageAndSetupReply();

cy.openMessageComposerOptions().find(`[aria-label="Voice Message"]`).click();
cy.openMessageComposerOptions().within(() => {
cy.get(`[aria-label="Voice Message"]`).click();
});
cy.wait(3000);
cy.getComposer().find(".mx_MessageComposer_sendMessage").click();
cy.get(".mx_RoomView_body .mx_MessageComposer .mx_MessageComposer_sendMessage").click();

cy.get(".mx_RoomView_body .mx_EventTile .mx_EventTile_line").find(".mx_ReplyTile .mx_MTextBody")
cy.get(".mx_RoomView_body .mx_EventTile .mx_EventTile_line .mx_ReplyTile .mx_MTextBody")
.should("contain", MESSAGE);
cy.get(".mx_RoomView_body .mx_EventTile > .mx_EventTile_line > .mx_MVoiceMessageBody")
.should("have.length", 1);
Expand Down
4 changes: 2 additions & 2 deletions cypress/support/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ declare global {
* @param {*} value The new value of the setting, may be null.
* @return {Promise} Resolves when the setting has been changed.
*/
setSettingValue(name: string, roomId: string, level: SettingLevel, value: any): Chainable<void>;
setSettingValue(settingName: string, roomId: string, level: SettingLevel, value: any): Chainable<void>;

/**
* Gets the value of a setting. The room ID is optional if the
Expand All @@ -96,7 +96,7 @@ declare global {
* value.
* @return {*} The value, or null if not found
*/
getSettingValue<T>(name: string, roomId?: string, excludeDefault?: boolean): Chainable<T>;
getSettingValue<T>(settingName: string, roomId?: string, excludeDefault?: boolean): Chainable<T>;
}
}
}
Expand Down