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

Commit 232daaf

Browse files
luixxiulKerry
andauthored
Fix decryption failure bar covering the timeline (#10360)
* Use grid layout instead - BEM naming style - Increase block gap from 4px to 8px - Use flexbox inside 'header' grid-area to let the buttons wrapped - Use variables - Remove 4px gap when one of the buttons is not rendered - Change 'body' to 'message' - Set 'align-self: start' to the icon and spinner Signed-off-by: Suguru Hirahara <[email protected]> * Unset height of spinner Signed-off-by: Suguru Hirahara <[email protected]> * Break lines at newline characters with white-space: pre-line Signed-off-by: Suguru Hirahara <[email protected]> * Edit tests to check decryption failure bars on narrow timeline - checkTimelineNarrow() looks for buttons by default - Test indicator as well Signed-off-by: Suguru Hirahara <[email protected]> * Remove a line Signed-off-by: Suguru Hirahara <[email protected]> * Edit the test to have it check mx_EventTile_last only inside mx_RoomView_body Signed-off-by: Suguru Hirahara <[email protected]> * Fix double underscores Signed-off-by: Suguru Hirahara <[email protected]> * Fix double underscores - pcss Signed-off-by: Suguru Hirahara <[email protected]> * Iterate - buttons at the bottom - Set common spacing to buttons with variables - Remove line breaks, yarn run i18n - Set data-testid for headlines and buttons in case the tested strings would be displayed elsewhere simultaneously Signed-off-by: Suguru Hirahara <[email protected]> * Check waiting headline as well Signed-off-by: Suguru Hirahara <[email protected]> * Increase spacing between the message and the buttons Signed-off-by: Suguru Hirahara <[email protected]> * lint Signed-off-by: Suguru Hirahara <[email protected]> * Increase block gap between wrapped buttons for clickability Apply 8px between wrapped buttons Signed-off-by: Suguru Hirahara <[email protected]> * Revert bottom margin of buttons which are not expected to be wrapped Signed-off-by: Suguru Hirahara <[email protected]> * Check visibility instead of existence This commit removes data-testid from headlines and data-testid-button and checks whether the elements are really visible, not overflowing the viewport. Signed-off-by: Suguru Hirahara <[email protected]> * Remove redundant gap between 'mx_DecryptionFailureBar_start' and the bottom edge This commit adds '.mx_DecryptionFailureBar--withEnd' class name to have it applied to the bar only if it has button(s). This way the bar is rendered with a flexbox and the row-gap declaration is respected only if there is a 'mx_DecryptionFailureBar--withEnd' element. The element currently includes the button(s) only. Signed-off-by: Suguru Hirahara <[email protected]> * lint - prettier Signed-off-by: Suguru Hirahara <[email protected]> * Have Percy take a snapshot of the bar loading spinner before checkTimelineNarrow() The loading spinner is likely to disappear while checking the bar on the narrow timeline. Signed-off-by: Suguru Hirahara <[email protected]> --------- Signed-off-by: Suguru Hirahara <[email protected]> Co-authored-by: Kerry <[email protected]>
1 parent bebfbac commit 232daaf

File tree

5 files changed

+471
-238
lines changed

5 files changed

+471
-238
lines changed

cypress/e2e/crypto/decryption-failure.spec.ts

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,28 @@ const handleVerificationRequest = (request: VerificationRequest): Chainable<Emoj
5757
);
5858
};
5959

60+
const checkTimelineNarrow = (button = true) => {
61+
cy.viewport(800, 600); // SVGA
62+
cy.get(".mx_LeftPanel_minimized").should("exist"); // Wait until the left panel is minimized
63+
cy.get(".mx_RightPanel_roomSummaryButton").click(); // Open the right panel to make the timeline narrow
64+
cy.get(".mx_BaseCard").should("exist");
65+
66+
// Ensure the failure bar does not cover the timeline
67+
cy.get(".mx_RoomView_body .mx_EventTile.mx_EventTile_last").should("be.visible");
68+
69+
// Ensure the indicator does not overflow the timeline
70+
cy.get("[data-testid='decryption-failure-bar-indicator']").should("be.visible");
71+
72+
if (button) {
73+
// Ensure the button does not overflow the timeline
74+
cy.get("[data-testid='decryption-failure-bar-button']:last-of-type").should("be.visible");
75+
}
76+
77+
cy.get(".mx_RightPanel_roomSummaryButton").click(); // Close the right panel
78+
cy.get(".mx_BaseCard").should("not.exist");
79+
cy.viewport(1000, 660); // Reset to the default size
80+
};
81+
6082
describe("Decryption Failure Bar", () => {
6183
let homeserver: HomeserverInstance | undefined;
6284
let testUser: UserCredentials | undefined;
@@ -113,10 +135,13 @@ describe("Decryption Failure Bar", () => {
113135
})
114136
.then(() => {
115137
cy.botSendMessage(bot, roomId, "test");
138+
cy.contains(".mx_DecryptionFailureBar_start_headline", "Decrypting messages…").should("be.visible");
116139
cy.contains(
117-
".mx_DecryptionFailureBar .mx_DecryptionFailureBar_message_headline",
140+
".mx_DecryptionFailureBar_start_headline",
118141
"Verify this device to access all messages",
119-
);
142+
).should("be.visible");
143+
144+
checkTimelineNarrow();
120145

121146
cy.get(".mx_DecryptionFailureBar").percySnapshotElement(
122147
"DecryptionFailureBar prompts user to verify",
@@ -125,12 +150,14 @@ describe("Decryption Failure Bar", () => {
125150
},
126151
);
127152

128-
cy.contains(".mx_DecryptionFailureBar_button", "Resend key requests").should("not.exist");
129-
cy.contains(".mx_DecryptionFailureBar_button", "Verify").click();
153+
cy.contains(".mx_DecryptionFailureBar_end", "Resend key requests").should("not.exist");
154+
cy.contains(".mx_DecryptionFailureBar_end", "Verify").should("be.visible").click();
130155

131156
const verificationRequestPromise = waitForVerificationRequest(otherDevice);
132157
cy.get(".mx_CompleteSecurity_actionRow .mx_AccessibleButton").click();
133-
cy.contains("To proceed, please accept the verification request on your other device.");
158+
cy.contains("To proceed, please accept the verification request on your other device.").should(
159+
"be.visible",
160+
);
134161
cy.wrap(verificationRequestPromise).then((verificationRequest: VerificationRequest) => {
135162
cy.wrap(verificationRequest.accept());
136163
handleVerificationRequest(verificationRequest).then((emojis) => {
@@ -146,10 +173,12 @@ describe("Decryption Failure Bar", () => {
146173
cy.get(".mx_VerificationPanel_verified_section .mx_E2EIcon_verified").should("exist");
147174
cy.contains(".mx_AccessibleButton", "Got it").click();
148175

149-
cy.get(".mx_DecryptionFailureBar .mx_DecryptionFailureBar_message_headline").should(
150-
"have.text",
176+
cy.contains(
177+
".mx_DecryptionFailureBar_start_headline",
151178
"Open another device to load encrypted messages",
152-
);
179+
).should("be.visible");
180+
181+
checkTimelineNarrow();
153182

154183
cy.get(".mx_DecryptionFailureBar").percySnapshotElement(
155184
"DecryptionFailureBar prompts user to open another device, with Resend Key Requests button",
@@ -159,9 +188,12 @@ describe("Decryption Failure Bar", () => {
159188
);
160189

161190
cy.intercept("/_matrix/client/r0/sendToDevice/m.room_key_request/*").as("keyRequest");
162-
cy.contains(".mx_DecryptionFailureBar_button", "Resend key requests").click();
191+
cy.contains(".mx_DecryptionFailureBar_end_button", "Resend key requests").should("be.visible").click();
163192
cy.wait("@keyRequest");
164-
cy.contains(".mx_DecryptionFailureBar_button", "Resend key requests").should("not.exist");
193+
cy.contains(".mx_DecryptionFailureBar_end_button", "Resend key requests").should("not.exist");
194+
cy.contains(".mx_DecryptionFailureBar_end_button", "View your device list").should("be.visible");
195+
196+
checkTimelineNarrow();
165197

166198
cy.get(".mx_DecryptionFailureBar").percySnapshotElement(
167199
"DecryptionFailureBar prompts user to open another device, without Resend Key Requests button",
@@ -184,15 +216,17 @@ describe("Decryption Failure Bar", () => {
184216

185217
cy.botSendMessage(bot, roomId, "test");
186218
cy.contains(
187-
".mx_DecryptionFailureBar .mx_DecryptionFailureBar_message_headline",
219+
".mx_DecryptionFailureBar_start_headline",
188220
"Reset your keys to prevent future decryption errors",
189-
);
221+
).should("be.visible");
222+
223+
checkTimelineNarrow();
190224

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

195-
cy.contains(".mx_DecryptionFailureBar_button", "Reset").click();
229+
cy.contains(".mx_DecryptionFailureBar_end_button", "Reset").should("be.visible").click();
196230

197231
// Set up key backup
198232
cy.get(".mx_Dialog").within(() => {
@@ -204,11 +238,12 @@ describe("Decryption Failure Bar", () => {
204238
cy.contains("Done").click();
205239
});
206240

207-
cy.get(".mx_DecryptionFailureBar .mx_DecryptionFailureBar_message_headline").should(
208-
"have.text",
209-
"Some messages could not be decrypted",
241+
cy.contains(".mx_DecryptionFailureBar_start_headline", "Some messages could not be decrypted").should(
242+
"be.visible",
210243
);
211244

245+
checkTimelineNarrow(false); // button should not be rendered here
246+
212247
cy.get(".mx_DecryptionFailureBar").percySnapshotElement(
213248
"DecryptionFailureBar displays general message with no call to action",
214249
{
@@ -233,9 +268,11 @@ describe("Decryption Failure Bar", () => {
233268
widths: [320, 640],
234269
});
235270

271+
checkTimelineNarrow();
272+
236273
cy.wait(5000);
237274
cy.get(".mx_DecryptionFailureBar .mx_Spinner").should("not.exist");
238-
cy.get(".mx_DecryptionFailureBar .mx_DecryptionFailureBar_icon").should("exist");
275+
cy.get("[data-testid='decryption-failure-bar-icon']").should("be.visible");
239276

240277
cy.get(".mx_RoomView_messagePanel").scrollTo("top");
241278
cy.get(".mx_DecryptionFailureBar").should("not.exist");
@@ -245,5 +282,7 @@ describe("Decryption Failure Bar", () => {
245282

246283
cy.get(".mx_RoomView_messagePanel").scrollTo("bottom");
247284
cy.get(".mx_DecryptionFailureBar").should("exist");
285+
286+
checkTimelineNarrow();
248287
});
249288
});

res/css/_common.pcss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ $timeline-image-border-radius: 8px;
4343
--transition-short: 0.1s;
4444
--transition-standard: 0.3s;
4545
--MessageTimestamp-width: $MessageTimestamp_width;
46+
--buttons-dialog-gap-row: $spacing-8;
47+
--buttons-dialog-gap-column: $spacing-8;
4648
}
4749

4850
@media only percy {
@@ -525,8 +527,8 @@ legend {
525527
margin-inline-start: auto;
526528

527529
/* default gap among elements */
528-
column-gap: $spacing-8; /* See margin-right below inside the button style */
529-
row-gap: 5px; /* See margin-bottom below inside the button style */
530+
column-gap: var(--buttons-dialog-gap-column);
531+
row-gap: var(--buttons-dialog-gap-row);
530532

531533
button {
532534
margin: 0 !important; /* override the margin settings */
@@ -548,7 +550,7 @@ legend {
548550
.mx_Dialog_buttons input[type="submit"] {
549551
@mixin mx_DialogButton;
550552
margin-left: 0px;
551-
margin-right: 8px;
553+
margin-right: var(--buttons-dialog-gap-column);
552554
margin-bottom: 5px;
553555

554556
/* flip colours for the secondary ones */

res/css/views/rooms/_DecryptionFailureBar.pcss

Lines changed: 60 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,73 @@ limitations under the License.
1515
*/
1616

1717
.mx_DecryptionFailureBar {
18+
--gap-row: $spacing-8;
19+
--gap-column: $spacing-12;
20+
--gap: var(--gap-row) var(--gap-column);
21+
--size-icon: 24px;
22+
1823
background-color: $system;
1924
padding: $spacing-12;
20-
margin-left: $spacing-16;
21-
margin-right: $spacing-16;
25+
margin-inline: $spacing-16;
2226
border-radius: 4px;
23-
display: flex;
24-
align-items: flex-start;
25-
gap: $spacing-12;
26-
}
2727

28-
.mx_DecryptionFailureBar_icon {
29-
width: 24px;
30-
height: 24px;
31-
mask-image: url("$(res)/img/e2e/decryption-failure.svg");
32-
background-color: $e2e-warning-color;
33-
mask-repeat: no-repeat;
34-
mask-position: center;
35-
mask-size: contain;
36-
}
28+
&.mx_DecryptionFailureBar--withEnd {
29+
display: flex;
30+
flex-flow: wrap;
31+
align-items: flex-start;
32+
justify-content: space-between;
33+
row-gap: calc(var(--gap-row) + $spacing-4); /* Increase spacing between the message and the buttons */
3734

38-
.mx_DecryptionFailureBar_icon,
39-
.mx_DecryptionFailureBar .mx_Spinner {
40-
flex-shrink: 0;
41-
flex-grow: 0;
42-
}
35+
.mx_DecryptionFailureBar_end {
36+
display: flex;
37+
flex-wrap: wrap; /* Let the buttons wrapped on a narrow column */
38+
gap: var(--buttons-dialog-gap-row) var(--buttons-dialog-gap-column);
39+
margin-inline-start: calc(var(--size-icon) + var(--gap-column)); /* Align the button(s) and the message */
40+
}
41+
}
4342

44-
.mx_DecryptionFailureBar_message {
45-
flex-grow: 1;
46-
}
43+
.mx_DecryptionFailureBar_start {
44+
display: grid;
45+
gap: var(--gap);
46+
grid-template-areas:
47+
"status headline"
48+
". message";
49+
grid-template-columns: var(--size-icon) auto;
4750

48-
.mx_DecryptionFailureBar_message_headline {
49-
font-weight: $font-semi-bold;
50-
font-size: $font-16px;
51-
margin-bottom: $spacing-4;
52-
}
51+
.mx_DecryptionFailureBar_start_status {
52+
grid-area: status;
5353

54-
.mx_DecryptionFailureBar_message_body {
55-
color: $secondary-content;
56-
}
54+
display: flex;
55+
align-items: center;
56+
gap: var(--gap);
57+
58+
.mx_Spinner {
59+
height: unset; /* Unset height: 100% */
60+
}
61+
62+
.mx_DecryptionFailureBar_start_status_icon {
63+
min-width: var(--size-icon);
64+
height: var(--size-icon);
65+
mask-image: url("$(res)/img/e2e/decryption-failure.svg");
66+
background-color: $e2e-warning-color;
67+
mask-repeat: no-repeat;
68+
mask-position: center;
69+
mask-size: contain;
70+
}
71+
}
72+
73+
.mx_DecryptionFailureBar_start_headline {
74+
grid-area: headline;
75+
76+
font-weight: $font-semi-bold;
77+
font-size: $font-16px;
78+
align-self: center;
79+
}
80+
81+
.mx_DecryptionFailureBar_start_message {
82+
grid-area: message;
5783

58-
.mx_DecryptionFailureBar_button {
59-
flex-shrink: 0;
84+
color: $secondary-content;
85+
}
86+
}
6087
}

0 commit comments

Comments
 (0)