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

Commit e269c68

Browse files
authored
Fix url preview AXE and layout issue & add percy test (#9189)
1 parent 0e43f3c commit e269c68

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

cypress/e2e/timeline/timeline.spec.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,49 @@ describe("Timeline", () => {
274274
cy.get(".mx_EventTile:not(.mx_EventTile_contextual)").find(".mx_EventTile_searchHighlight").should("exist");
275275
cy.get(".mx_RoomView_searchResultsPanel").percySnapshotElement("Highlighted search results");
276276
});
277+
278+
it("should render url previews", () => {
279+
cy.intercept("**/_matrix/media/r0/thumbnail/matrix.org/2022-08-16_yaiSVSRIsNFfxDnV?*", {
280+
statusCode: 200,
281+
fixture: "riot.png",
282+
headers: {
283+
"Content-Type": "image/png",
284+
},
285+
}).as("mxc");
286+
cy.intercept("**/_matrix/media/r0/preview_url?url=https%3A%2F%2Fcall.element.io%2F&ts=*", {
287+
statusCode: 200,
288+
body: {
289+
"og:title": "Element Call",
290+
"og:description": null,
291+
"og:image:width": 48,
292+
"og:image:height": 48,
293+
"og:image": "mxc://matrix.org/2022-08-16_yaiSVSRIsNFfxDnV",
294+
"og:image:type": "image/png",
295+
"matrix:image:size": 2121,
296+
},
297+
headers: {
298+
"Content-Type": "application/json",
299+
},
300+
}).as("preview_url");
301+
302+
cy.sendEvent(
303+
roomId,
304+
null,
305+
"m.room.message" as EventType,
306+
MessageEvent.from("https://call.element.io/").serialize().content,
307+
);
308+
cy.visit("/#/room/" + roomId);
309+
310+
cy.get(".mx_LinkPreviewWidget").should("exist").should("contain.text", "Element Call");
311+
312+
cy.wait("@preview_url");
313+
cy.wait("@mxc");
314+
315+
cy.checkA11y();
316+
cy.get(".mx_EventTile_last").percySnapshotElement("URL Preview", {
317+
widths: [800, 400],
318+
});
319+
});
277320
});
278321

279322
describe("message sending", () => {

res/css/views/rooms/_LinkPreviewWidget.pcss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ limitations under the License.
3232
display: flex;
3333
flex-wrap: wrap;
3434
row-gap: $spacing-8;
35+
flex: 1;
3536

3637
.mx_LinkPreviewWidget_image,
3738
.mx_LinkPreviewWidget_caption {

src/components/views/rooms/LinkPreviewWidget.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,13 @@ export default class LinkPreviewWidget extends React.Component<IProps> {
112112
let img;
113113
if (image) {
114114
img = <div className="mx_LinkPreviewWidget_image" style={{ height: thumbHeight }}>
115-
<img ref={this.image} style={{ maxWidth: imageMaxWidth, maxHeight: imageMaxHeight }} src={image} onClick={this.onImageClick} />
115+
<img
116+
ref={this.image}
117+
style={{ maxWidth: imageMaxWidth, maxHeight: imageMaxHeight }}
118+
src={image}
119+
onClick={this.onImageClick}
120+
alt=""
121+
/>
116122
</div>;
117123
}
118124

0 commit comments

Comments
 (0)