Skip to content

Commit b9aaf78

Browse files
authored
chore(ui5-illustrated-message): migrate wdio tests to cypress (#11788)
Convert illustrated message wdio tests to Cypress component tests while maintaining test coverage and functionality parity with original specs. JIRA: BGSOFUIPIRIN-6816
1 parent 0d23914 commit b9aaf78

File tree

2 files changed

+167
-216
lines changed

2 files changed

+167
-216
lines changed

packages/fiori/cypress/specs/IllustratedMessage.cy.tsx

Lines changed: 167 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import IllustratedMessage from "../../src/IllustratedMessage.js";
22
import Label from "@ui5/webcomponents/dist/Label.js";
33
import "@ui5/webcomponents-fiori/dist/illustrations/AllIllustrations.js"
4+
import Panel from "@ui5/webcomponents/dist/Panel.js";
45

56
describe("Accessibility", () => {
67
it("should add aria-hidden and role=presetation to the SVG when decorative is true", () => {
@@ -96,4 +97,169 @@ describe('SVG CSP Compliance', () => {
9697
cy.log(`✅ Validated ${results.length} SVG files - all CSP compliant`);
9798
})
9899
})
99-
})
100+
})
101+
102+
describe("IllustratedMessage 'design' property", () => {
103+
it("should show up properly, when in panel and it expand/collapse", () => {
104+
cy.mount(
105+
<Panel noAnimation>
106+
<IllustratedMessage name="AddColumn" />
107+
</Panel>
108+
);
109+
110+
cy.get("[ui5-panel]")
111+
.invoke("prop", "collapsed", true);
112+
113+
cy.get("[ui5-illustrated-message]")
114+
.should("have.prop", "media", "base");
115+
116+
cy.get("[ui5-panel]")
117+
.invoke("prop", "collapsed", false);
118+
119+
cy.get("[ui5-illustrated-message]")
120+
.should("have.prop", "media")
121+
.and("not.equal", "base");
122+
});
123+
});
124+
125+
describe("Vertical responsiveness", () => {
126+
it("content with auto design shrinks to fit the parent container", () => {
127+
const expectedMedia = "dialog";
128+
129+
cy.mount(
130+
<div style={{ height: "300px" }}>
131+
<IllustratedMessage />
132+
</div>
133+
);
134+
135+
cy.get("[ui5-illustrated-message]")
136+
.shadow()
137+
.find(".ui5-illustrated-message-root")
138+
.should(($contents) => {
139+
const scrollHeight = $contents[0].scrollHeight;
140+
const offsetHeight = $contents[0].offsetHeight;
141+
142+
expect(scrollHeight).to.be.lessThan(300);
143+
expect(scrollHeight).to.equal(offsetHeight);
144+
});
145+
146+
cy.get("[ui5-illustrated-message]")
147+
.should("have.prop", "media", expectedMedia);
148+
});
149+
150+
it("content with auto design expands to fit the parent container", () => {
151+
const expectedMedia = "scene";
152+
153+
cy.mount(
154+
<div style={{ height: "500px" }}>
155+
<IllustratedMessage />
156+
</div>
157+
);
158+
159+
cy.get("[ui5-illustrated-message]")
160+
.shadow()
161+
.find(".ui5-illustrated-message-root")
162+
.should(($contents) => {
163+
const scrollHeight = $contents[0].scrollHeight;
164+
const offsetHeight = $contents[0].offsetHeight;
165+
expect(scrollHeight).to.be.lessThan(500);
166+
expect(scrollHeight).to.equal(offsetHeight);
167+
});
168+
169+
cy.get("[ui5-illustrated-message]")
170+
.should("have.prop", "media", expectedMedia);
171+
});
172+
173+
it("content with fixed design fits the parent container", () => {
174+
cy.mount(
175+
<div>
176+
<IllustratedMessage design="Dialog" />
177+
</div>
178+
);
179+
180+
cy.get("div")
181+
.invoke("css", "height", "250px");
182+
183+
cy.get("[ui5-illustrated-message]")
184+
.shadow()
185+
.find(".ui5-illustrated-message-root")
186+
.should(($contents) => {
187+
const scrollHeight = $contents[0].scrollHeight;
188+
const offsetHeight = $contents[0].offsetHeight;
189+
expect(scrollHeight).to.be.lessThan(250);
190+
expect(scrollHeight).to.equal(offsetHeight);
191+
});
192+
});
193+
194+
it("shows image with unconstrained height when container has auto height", () => {
195+
cy.mount(
196+
<div style={{ width: "400px" }}>
197+
<IllustratedMessage />
198+
</div>
199+
);
200+
201+
cy.get("div")
202+
.invoke("css", "height", "auto");
203+
204+
cy.get("[ui5-illustrated-message]")
205+
.shadow()
206+
.find(".ui5-illustrated-message-illustration svg")
207+
.should("have.css", "height", "160px");
208+
});
209+
210+
it("Illustration visible, when container fit content height", () => {
211+
cy.mount(
212+
<div style={{ height: "440px" }}>
213+
<IllustratedMessage design="Scene" />
214+
</div>
215+
);
216+
217+
cy.get("[ui5-illustrated-message]")
218+
.shadow()
219+
.find(".ui5-illustrated-message-illustration svg")
220+
.should(($illustration) => {
221+
const scrollHeight = $illustration[0].scrollHeight;
222+
expect(scrollHeight).to.not.equal(0);
223+
});
224+
});
225+
226+
it("Illustration visible, when IM slotted and container has fixed height", () => {
227+
cy.mount(
228+
<Panel style={{ height: "19rem" }} noAnimation>
229+
<IllustratedMessage name="AddColumn" />
230+
</Panel>
231+
);
232+
233+
cy.get("[ui5-illustrated-message]")
234+
.shadow()
235+
.find(".ui5-illustrated-message-illustration svg")
236+
.should(($illustration) => {
237+
const scrollHeight = $illustration[0].scrollHeight;
238+
expect(scrollHeight).to.not.equal(0);
239+
});
240+
});
241+
});
242+
243+
describe("Dot design resource handling", () => {
244+
it("uses substitute Spot illustration", () => {
245+
cy.mount(
246+
<IllustratedMessage name="TntUnableToLoad" design="Dot" />
247+
);
248+
249+
cy.get("[ui5-illustrated-message]")
250+
.shadow()
251+
.find(".ui5-illustrated-message-illustration svg")
252+
.should("have.id", "tnt-Spot-UnableToLoad");
253+
});
254+
255+
it("uses original Dot illustration", () => {
256+
cy.mount(
257+
<IllustratedMessage name="AddPeople" design="Dot" />
258+
);
259+
260+
cy.get("[ui5-illustrated-message]")
261+
.shadow()
262+
.find(".ui5-illustrated-message-illustration svg")
263+
.should("have.id", "sapIllus-Dot-AddPeople");
264+
});
265+
});

packages/fiori/test/specs/IllustratedMessage.spec.js

Lines changed: 0 additions & 215 deletions
This file was deleted.

0 commit comments

Comments
 (0)