Skip to content

Commit

Permalink
Use Cypress Testing Library - decryption-failure.spec.ts (#10513)
Browse files Browse the repository at this point in the history
* Use Cypress Testing Library - decryption-failure.spec.ts

Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>

* findButton - view your device list

Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>

* Use findByText

Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>

---------

Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
  • Loading branch information
luixxiul committed Apr 6, 2023
1 parent 9cecac0 commit d820389
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions cypress/e2e/crypto/decryption-failure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe("Decryption Failure Bar", () => {
.then(() => {
cy.inviteUser(roomId, bot.getUserId());
cy.visit("/#/room/" + roomId);
cy.contains(".mx_TextualEvent", BOT_USER + " joined the room").should("exist");
cy.findByText(BOT_USER + " joined the room").should("exist");
})
.then(() => {
cy.getClient()
Expand Down Expand Up @@ -135,11 +135,10 @@ describe("Decryption Failure Bar", () => {
})
.then(() => {
cy.botSendMessage(bot, roomId, "test");
cy.contains(".mx_DecryptionFailureBar_start_headline", "Decrypting messages…").should("be.visible");
cy.contains(
".mx_DecryptionFailureBar_start_headline",
"Verify this device to access all messages",
).should("be.visible");
cy.get(".mx_DecryptionFailureBar_start_headline").within(() => {
cy.findByText("Decrypting messages…").should("be.visible");
cy.findByText("Verify this device to access all messages").should("be.visible");
});

checkTimelineNarrow();

Expand All @@ -150,12 +149,14 @@ describe("Decryption Failure Bar", () => {
},
);

cy.contains(".mx_DecryptionFailureBar_end", "Resend key requests").should("not.exist");
cy.contains(".mx_DecryptionFailureBar_end", "Verify").should("be.visible").click();
cy.get(".mx_DecryptionFailureBar_end").within(() => {
cy.findByText("Resend key requests").should("not.exist");
cy.findButton("Verify").click();
});

const verificationRequestPromise = waitForVerificationRequest(otherDevice);
cy.get(".mx_CompleteSecurity_actionRow .mx_AccessibleButton").click();
cy.contains("To proceed, please accept the verification request on your other device.").should(
cy.findButton("Verify with another device").click();
cy.findByText("To proceed, please accept the verification request on your other device.").should(
"be.visible",
);
cy.wrap(verificationRequestPromise).then((verificationRequest: VerificationRequest) => {
Expand All @@ -169,14 +170,13 @@ describe("Decryption Failure Bar", () => {
});
});
});
cy.contains(".mx_AccessibleButton", "They match").click();
cy.findButton("They match").click();
cy.get(".mx_VerificationPanel_verified_section .mx_E2EIcon_verified").should("exist");
cy.contains(".mx_AccessibleButton", "Got it").click();
cy.findButton("Got it").click();

cy.contains(
".mx_DecryptionFailureBar_start_headline",
"Open another device to load encrypted messages",
).should("be.visible");
cy.get(".mx_DecryptionFailureBar_start_headline").within(() => {
cy.findByText("Open another device to load encrypted messages").should("be.visible");
});

checkTimelineNarrow();

Expand All @@ -188,10 +188,12 @@ describe("Decryption Failure Bar", () => {
);

cy.intercept("/_matrix/client/r0/sendToDevice/m.room_key_request/*").as("keyRequest");
cy.contains(".mx_DecryptionFailureBar_end_button", "Resend key requests").should("be.visible").click();
cy.findButton("Resend key requests").click();
cy.wait("@keyRequest");
cy.contains(".mx_DecryptionFailureBar_end_button", "Resend key requests").should("not.exist");
cy.contains(".mx_DecryptionFailureBar_end_button", "View your device list").should("be.visible");
cy.get(".mx_DecryptionFailureBar_end").within(() => {
cy.findByText("Resend key requests").should("not.exist");
cy.findButton("View your device list").should("be.visible");
});

checkTimelineNarrow();

Expand All @@ -215,32 +217,31 @@ describe("Decryption Failure Bar", () => {
);

cy.botSendMessage(bot, roomId, "test");
cy.contains(
".mx_DecryptionFailureBar_start_headline",
"Reset your keys to prevent future decryption errors",
).should("be.visible");
cy.get(".mx_DecryptionFailureBar_start_headline").within(() => {
cy.findByText("Reset your keys to prevent future decryption errors").should("be.visible");
});

checkTimelineNarrow();

cy.get(".mx_DecryptionFailureBar").percySnapshotElement("DecryptionFailureBar prompts user to reset keys", {
widths: [320, 640],
});

cy.contains(".mx_DecryptionFailureBar_end_button", "Reset").should("be.visible").click();
cy.findButton("Reset").click();

// Set up key backup
cy.get(".mx_Dialog").within(() => {
cy.contains(".mx_Dialog_primary", "Continue").click();
cy.findButton("Continue").click();
cy.get(".mx_CreateSecretStorageDialog_recoveryKey code").invoke("text").as("securityKey");
// Clicking download instead of Copy because of https://github.com/cypress-io/cypress/issues/2851
cy.contains(".mx_AccessibleButton", "Download").click();
cy.findButton("Download").click();
cy.contains(".mx_Dialog_primary:not([disabled])", "Continue").click();
cy.contains("Done").click();
cy.findButton("Done").click();
});

cy.contains(".mx_DecryptionFailureBar_start_headline", "Some messages could not be decrypted").should(
"be.visible",
);
cy.get(".mx_DecryptionFailureBar_start_headline").within(() => {
cy.findByText("Some messages could not be decrypted").should("be.visible");
});

checkTimelineNarrow(false); // button should not be rendered here

Expand Down

0 comments on commit d820389

Please sign in to comment.