-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate one-off Select inputs to Ant (#5475)
- Loading branch information
1 parent
1c8b2d7
commit 523c1ab
Showing
39 changed files
with
567 additions
and
730 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/// <reference types="cypress" /> | ||
|
||
declare global { | ||
namespace Cypress { | ||
interface Chainable { | ||
getAntSelectOption: (optionLabel: string | number) => Chainable; | ||
/** | ||
* Select an option from an Ant Design Select component | ||
* @param option The label of the option to select or the index of the option | ||
*/ | ||
antSelect: ( | ||
option: string | number, | ||
clickOptions?: { force?: boolean }, | ||
) => void; | ||
/** | ||
* Clear all options from an Ant Design Select component | ||
*/ | ||
antClearSelect: () => void; | ||
} | ||
} | ||
} | ||
|
||
Cypress.Commands.add("getAntSelectOption", (option: string | number) => | ||
typeof option === "string" | ||
? cy.get(`.ant-select-item-option[title="${option}"]`) | ||
: cy.get(`.ant-select-item-option`).eq(option), | ||
); | ||
|
||
Cypress.Commands.add( | ||
"antSelect", | ||
{ | ||
prevSubject: "element", | ||
}, | ||
(subject, option, clickOptions) => { | ||
cy.get(subject.selector).first().should("have.class", "ant-select"); | ||
cy.get(subject.selector) | ||
.first() | ||
.invoke("attr", "class") | ||
.then((classes) => { | ||
if (classes.includes("ant-select-disabled")) { | ||
throw new Error("Cannot select from a disabled Ant Select component"); | ||
} | ||
if (!classes.includes("ant-select-open")) { | ||
cy.get(subject.selector).first().click(clickOptions); | ||
} | ||
}); | ||
cy.getAntSelectOption(option).should("be.visible").click(clickOptions); | ||
}, | ||
); | ||
|
||
Cypress.Commands.add( | ||
"antClearSelect", | ||
{ | ||
prevSubject: "element", | ||
}, | ||
(subject) => { | ||
cy.get(subject.selector).should("have.class", "ant-select-allow-clear"); | ||
cy.get(subject.selector).find(".ant-select-clear").click({ force: true }); | ||
}, | ||
); | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.