Skip to content

Commit eacbe26

Browse files
authored
chore(ui5-multi-combobox): fix selector in multi-combobox cypress test (#11919)
* chore(ui5-multi-combobox): fix failing cypress test for mcb keyboard interaction
1 parent 71f5ab3 commit eacbe26

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

packages/main/cypress/specs/MultiComboBox.cy.tsx

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ describe("Keyboard interaction when pressing Ctrl + Alt + F8 for navigation", ()
137137
});
138138

139139
it("Should move the focus from the MultiComboBox to the first link in the value state message", () => {
140-
cy.get("ui5-multi-combobox")
140+
cy.get("[ui5-multi-combobox]")
141141
.shadow()
142142
.find("input")
143143
.as("innerInput");
144144

145-
cy.get("ui5-multi-combobox")
145+
cy.get("[ui5-multi-combobox]")
146146
.as("multi-combobox");
147147

148148
cy.get("@innerInput")
@@ -160,13 +160,13 @@ describe("Keyboard interaction when pressing Ctrl + Alt + F8 for navigation", ()
160160
cy.get("@popover")
161161
.should("have.attr", "open")
162162

163-
cy.get("ui5-link")
163+
cy.get("[ui5-link]")
164164
.eq(0)
165165
.should("have.focus");
166166
});
167167

168168
it("When pressing [Tab], the focus moves to the next value state message link. Pressing [Tab] again closes the popup and moves the focus to the next input", () => {
169-
cy.get("ui5-multi-combobox")
169+
cy.get("[ui5-multi-combobox]")
170170
.as("multi-combobox");
171171

172172
cy.get("@multi-combobox")
@@ -186,7 +186,7 @@ describe("Keyboard interaction when pressing Ctrl + Alt + F8 for navigation", ()
186186
.as("ui5-popover")
187187
.should("have.attr", "open");
188188

189-
cy.get("ui5-link")
189+
cy.get("[ui5-link]")
190190
.eq(0)
191191
.as("firstLink")
192192
.should("have.focus");
@@ -197,28 +197,28 @@ describe("Keyboard interaction when pressing Ctrl + Alt + F8 for navigation", ()
197197
cy.get("@firstLink")
198198
.should("not.have.focus");
199199

200-
cy.get("ui5-link")
200+
cy.get("[ui5-link]")
201201
.eq(1)
202202
.as("secondLink")
203203
.should("have.focus");
204204

205205
cy.get("@secondLink")
206206
.realPress("Tab");
207207

208-
cy.get("ui5-input")
208+
cy.get("[ui5-input]")
209209
.as("input");
210210

211211
cy.get("@input")
212212
.should("have.focus");
213213
});
214214

215215
it("Pressing [Shift + Tab] moves the focus from the second link in the value state message to the first one. Pressing it again shifts the focus to the MultiComboBox", () => {
216-
cy.get("ui5-multi-combobox")
216+
cy.get("[ui5-multi-combobox]")
217217
.shadow()
218218
.find("input")
219219
.as("innerInput");
220220

221-
cy.get("ui5-multi-combobox")
221+
cy.get("[ui5-multi-combobox]")
222222
.as("multi-combobox");
223223

224224
cy.get("@innerInput")
@@ -233,7 +233,7 @@ describe("Keyboard interaction when pressing Ctrl + Alt + F8 for navigation", ()
233233
.as("ui5-popover")
234234
.should("have.attr", "open");
235235

236-
cy.get("ui5-link")
236+
cy.get("[ui5-link]")
237237
.eq(0)
238238
.as("firstLink")
239239
.should("have.focus");
@@ -244,7 +244,7 @@ describe("Keyboard interaction when pressing Ctrl + Alt + F8 for navigation", ()
244244
cy.get("@firstLink")
245245
.should("not.have.focus");
246246

247-
cy.get("ui5-link")
247+
cy.get("[ui5-link]")
248248
.eq(1)
249249
.as("secondLink")
250250
.should("have.focus");
@@ -264,7 +264,7 @@ describe("Keyboard interaction when pressing Ctrl + Alt + F8 for navigation", ()
264264
});
265265

266266
it("When list item is selected and pressing [Ctrl + Alt + F8], first link is focused. [Arrow Down] moves focus to the first list item", () => {
267-
cy.get("ui5-multi-combobox")
267+
cy.get("[ui5-multi-combobox]")
268268
.as("multi-combobox");
269269

270270
cy.get("@multi-combobox")
@@ -277,26 +277,31 @@ describe("Keyboard interaction when pressing Ctrl + Alt + F8 for navigation", ()
277277
.realClick()
278278
.should("be.focused");
279279

280-
// focus the fisrt item
280+
// focuses the fisrt list item
281281
cy.realPress("F4");
282282

283283
cy.get("@multi-combobox")
284284
.shadow()
285285
.find<ResponsivePopover>("ui5-responsive-popover")
286-
.ui5ResponsivePopoverOpened()
286+
.ui5ResponsivePopoverOpened();
287287

288-
cy.get("ui5-mcb-item")
288+
cy.get("[ui5-mcb-item]").eq(0).as("firstItem");
289+
290+
cy.get("@firstItem").should("be.focused");
291+
292+
// Focus moves from the first item to the link in the value state header
293+
cy.get("@firstItem").realPress(["Control", "Alt", "F8"]);
294+
295+
cy.get("[ui5-link]")
289296
.eq(0)
290-
.realPress(["Control", "Alt", "F8"]);
297+
.as("firstLink");
291298

292-
cy.get("ui5-link")
293-
.as("firstLink")
294-
.should("have.focus");
299+
cy.focused().should("have.class", "ui5-link-root");
295300

296-
cy.get("@firstLink")
297-
.realPress("ArrowDown");
301+
// Focus moves from the link to the first list item
302+
cy.get("@firstLink").realPress("ArrowDown");
298303

299-
cy.get("ui5-mcb-item").eq(0).should("be.focused");
304+
cy.get("@firstItem").should("be.focused");
300305
});
301306
});
302307

0 commit comments

Comments
 (0)