Use Cypress Testing Library - `decryption-failure.spec.ts` (#10513)

* 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>
pull/28788/head^2
Suguru Hirahara 2023-04-06 16:20:39 +00:00 committed by GitHub
parent 9cecac0cee
commit d8203895e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 30 deletions

View File

@ -105,7 +105,7 @@ describe("Decryption Failure Bar", () => {
.then(() => { .then(() => {
cy.inviteUser(roomId, bot.getUserId()); cy.inviteUser(roomId, bot.getUserId());
cy.visit("/#/room/" + roomId); 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(() => { .then(() => {
cy.getClient() cy.getClient()
@ -135,11 +135,10 @@ describe("Decryption Failure Bar", () => {
}) })
.then(() => { .then(() => {
cy.botSendMessage(bot, roomId, "test"); cy.botSendMessage(bot, roomId, "test");
cy.contains(".mx_DecryptionFailureBar_start_headline", "Decrypting messages…").should("be.visible"); cy.get(".mx_DecryptionFailureBar_start_headline").within(() => {
cy.contains( cy.findByText("Decrypting messages…").should("be.visible");
".mx_DecryptionFailureBar_start_headline", cy.findByText("Verify this device to access all messages").should("be.visible");
"Verify this device to access all messages", });
).should("be.visible");
checkTimelineNarrow(); checkTimelineNarrow();
@ -150,12 +149,14 @@ describe("Decryption Failure Bar", () => {
}, },
); );
cy.contains(".mx_DecryptionFailureBar_end", "Resend key requests").should("not.exist"); cy.get(".mx_DecryptionFailureBar_end").within(() => {
cy.contains(".mx_DecryptionFailureBar_end", "Verify").should("be.visible").click(); cy.findByText("Resend key requests").should("not.exist");
cy.findButton("Verify").click();
});
const verificationRequestPromise = waitForVerificationRequest(otherDevice); const verificationRequestPromise = waitForVerificationRequest(otherDevice);
cy.get(".mx_CompleteSecurity_actionRow .mx_AccessibleButton").click(); cy.findButton("Verify with another device").click();
cy.contains("To proceed, please accept the verification request on your other device.").should( cy.findByText("To proceed, please accept the verification request on your other device.").should(
"be.visible", "be.visible",
); );
cy.wrap(verificationRequestPromise).then((verificationRequest: VerificationRequest) => { cy.wrap(verificationRequestPromise).then((verificationRequest: VerificationRequest) => {
@ -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.get(".mx_VerificationPanel_verified_section .mx_E2EIcon_verified").should("exist");
cy.contains(".mx_AccessibleButton", "Got it").click(); cy.findButton("Got it").click();
cy.contains( cy.get(".mx_DecryptionFailureBar_start_headline").within(() => {
".mx_DecryptionFailureBar_start_headline", cy.findByText("Open another device to load encrypted messages").should("be.visible");
"Open another device to load encrypted messages", });
).should("be.visible");
checkTimelineNarrow(); checkTimelineNarrow();
@ -188,10 +188,12 @@ describe("Decryption Failure Bar", () => {
); );
cy.intercept("/_matrix/client/r0/sendToDevice/m.room_key_request/*").as("keyRequest"); 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.wait("@keyRequest");
cy.contains(".mx_DecryptionFailureBar_end_button", "Resend key requests").should("not.exist"); cy.get(".mx_DecryptionFailureBar_end").within(() => {
cy.contains(".mx_DecryptionFailureBar_end_button", "View your device list").should("be.visible"); cy.findByText("Resend key requests").should("not.exist");
cy.findButton("View your device list").should("be.visible");
});
checkTimelineNarrow(); checkTimelineNarrow();
@ -215,10 +217,9 @@ describe("Decryption Failure Bar", () => {
); );
cy.botSendMessage(bot, roomId, "test"); cy.botSendMessage(bot, roomId, "test");
cy.contains( cy.get(".mx_DecryptionFailureBar_start_headline").within(() => {
".mx_DecryptionFailureBar_start_headline", cy.findByText("Reset your keys to prevent future decryption errors").should("be.visible");
"Reset your keys to prevent future decryption errors", });
).should("be.visible");
checkTimelineNarrow(); checkTimelineNarrow();
@ -226,21 +227,21 @@ describe("Decryption Failure Bar", () => {
widths: [320, 640], widths: [320, 640],
}); });
cy.contains(".mx_DecryptionFailureBar_end_button", "Reset").should("be.visible").click(); cy.findButton("Reset").click();
// Set up key backup // Set up key backup
cy.get(".mx_Dialog").within(() => { 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"); 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 // 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(".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( cy.get(".mx_DecryptionFailureBar_start_headline").within(() => {
"be.visible", cy.findByText("Some messages could not be decrypted").should("be.visible");
); });
checkTimelineNarrow(false); // button should not be rendered here checkTimelineNarrow(false); // button should not be rendered here