-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathimage.cy.ts
62 lines (55 loc) · 1.65 KB
/
image.cy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../../support/index.d.ts" />
describe("Message with Image", { retries: 3 }, () => {
beforeEach(() => {
cy.visitWebchat().initMockWebchat().openWebchat().startConversation();
});
it("should render image", () => {
cy.withMessageFixture("image", () => {
cy.get(".webchat-message-row img").should("be.visible");
});
});
it("should have class 'webchat-media-template-image'", () => {
cy.withMessageFixture("image", () => {
cy.get(".webchat-message-row .webchat-media-template-image");
});
});
it("should have alt attibute", () => {
cy.withMessageFixture("image", () => {
cy.get(".webchat-media-template-image img")
.should("have.attr", "alt", "Attachment Image")
});
});
it("should render the image in a fixed aspect ratio", () => {
cy.withMessageFixture("image", () => {
cy.get(".webchat-media-template-image img")
.should("be.visible")
.then(element => {
const imageRatio = (element.innerWidth() / element.innerHeight()).toFixed(1);
const targetRatio = (16 / 9).toFixed(1);
expect(imageRatio).to.equal(targetRatio);
});
});
});
it("should render the image in a dynamic aspect ratio", () => {
cy.visitWebchat();
cy.initMockWebchat({
settings: {
layout: {
dynamicImageAspectRatio: true,
},
},
});
cy.openWebchat();
cy.startConversation();
cy.withMessageFixture("image", () => {
cy.get(".webchat-media-template-image img")
.should("be.visible")
.then(element => {
expect(element.innerHeight().toFixed()).to.equal(
element.innerWidth().toFixed(),
);
});
});
});
});