| 1 | import { Then, When } from "@badeball/cypress-cucumber-preprocessor"; |
| 2 | |
| 3 | When("I click on search link in dual list", () => { |
| 4 | cy.dataCy("dual-list-search-link").click(); |
| 5 | }); |
| 6 | |
| 7 | When("I click on {string} dual list item", (item: string) => { |
| 8 | cy.dataCy(item).click(); |
| 9 | }); |
| 10 | |
| 11 | Then("I should see {string} dual list item", (item: string) => { |
| 12 | cy.dataCy(item).should("exist"); |
| 13 | }); |
| 14 | |
| 15 | Then("I should see {string} dual list item selected", (item: string) => { |
| 16 | cy.dataCy(item).should("have.attr", "aria-selected", "true"); |
| 17 | }); |
| 18 | |
| 19 | Then("I should see {string} dual list item not selected", (item: string) => { |
| 20 | cy.dataCy(item).should("have.attr", "aria-selected", "false"); |
| 21 | }); |
| 22 | |
| 23 | Then("I should see {string} dual list item on the left", (item: string) => { |
| 24 | cy.dataCy("dual-list-left").find(`[data-cy='${item}']`).should("exist"); |
| 25 | }); |
| 26 | |
| 27 | Then("I should see {string} dual list item on the right", (item: string) => { |
| 28 | cy.dataCy("dual-list-right").find(`[data-cy='${item}']`).should("exist"); |
| 29 | }); |
| 30 | |
| 31 | export const addItemToRightList = (item: string) => { |
| 32 | const dualListItem = `item-${item}`; |
| 33 | cy.dataCy(dualListItem).should("exist"); |
| 34 | |
| 35 | cy.dataCy(dualListItem).click(); |
| 36 | cy.dataCy(dualListItem).should("have.attr", "aria-selected", "true"); |
| 37 | |
| 38 | cy.dataCy("dual-list-add-selected").click(); |
| 39 | cy.dataCy("dual-list-right") |
| 40 | .find(`[data-cy='${dualListItem}']`) |
| 41 | .should("exist"); |
| 42 | cy.dataCy(dualListItem).should("have.attr", "aria-selected", "false"); |
| 43 | }; |