Skip to content

Commit 74ebb19

Browse files
authored
fix(cypress-commands): make the options optional for clickUi5ListItemByText (#7316)
1 parent 7243b5f commit 74ebb19

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/cypress-commands/src/commands.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ declare global {
6969
* __Note:__ Chaining this command to a `ui5-list` selector is recommended.
7070
*
7171
* @param {string} text The text of the list item that should be clicked.
72-
* @param options ClickOptions
72+
* @param {Partial<ClickOptions>} [options] ClickOptions (without `force`)
7373
* @example
7474
* cy.get('[ui5-list]').clickUi5ListItemByText("List Item")
7575
* cy.clickUi5ListItemByText("List Item")
7676
*/
77-
clickUi5ListItemByText(text: string, options: Partial<ClickOptions>): Chainable<Element>;
77+
clickUi5ListItemByText(text: string, options?: Partial<Omit<ClickOptions, 'force'>>): Chainable<Element>;
7878

7979
/**
8080
* Click on an `ui5-option` of the `ui5-select` component by text.
@@ -85,7 +85,7 @@ declare global {
8585
* @param options ClickOptions
8686
*
8787
*
88-
* @example cy.get('[ui5-select]').clickUi5SelectOptionByText('Option2');*
88+
* @example cy.get('[ui5-select]').clickUi5SelectOptionByText('Option2');
8989
*/
9090
clickUi5SelectOptionByText(text: string, options?: Partial<ClickOptions>): Chainable<Element>;
9191

@@ -194,15 +194,15 @@ Cypress.Commands.add('closeUi5PopupWithEsc', () => {
194194
cy.get('body').type('{esc}', { force: true });
195195
});
196196

197-
Cypress.Commands.add('clickUi5ListItemByText', { prevSubject: 'optional' }, (subject, text) => {
197+
Cypress.Commands.add('clickUi5ListItemByText', { prevSubject: 'optional' }, (subject, text, options = {}) => {
198198
cy.document().then((doc) => {
199199
const _subject = (subject as Cypress.JQueryWithSelector<UI5Element>)?.[0] || doc;
200200
const li = _subject.querySelector(`[text="${text}"]`);
201201

202202
if (li) {
203-
cy.wrap(li).click();
203+
cy.wrap(li).click(options);
204204
} else {
205-
cy.wrap(_subject).contains(text).click();
205+
cy.wrap(_subject).contains(text).click(options);
206206
}
207207
});
208208
});

0 commit comments

Comments
 (0)