| 1 | import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor"; |
| 2 | import { loginAsAdmin, logout } from "../common/authentication"; |
| 3 | import { navigateTo } from "../common/navigation"; |
| 4 | import { isOptionSelected, selectOption } from "../common/ui/select"; |
| 5 | |
| 6 | Given("subid for owner {string} exists", (owner: string) => { |
| 7 | loginAsAdmin(); |
| 8 | navigateTo("subordinate-ids"); |
| 9 | |
| 10 | cy.dataCy("subids-button-add").click(); |
| 11 | cy.dataCy("add-subid-modal").should("exist"); |
| 12 | |
| 13 | selectOption(owner, "modal-simple-owner-select"); |
| 14 | isOptionSelected(owner, "modal-simple-owner-select"); |
| 15 | |
| 16 | cy.dataCy("modal-button-add").click(); |
| 17 | cy.dataCy("add-subid-modal").should("not.exist"); |
| 18 | cy.dataCy("add-subid-success").should("exist"); |
| 19 | |
| 20 | cy.get("table[id='subordinate-ids-table'] tr a").should("exist"); |
| 21 | logout(); |
| 22 | }); |
| 23 | |
| 24 | When("I click on the first subid", () => { |
| 25 | cy.get("table[id='subordinate-ids-table'] tr a").first().click(); |
| 26 | }); |
| 27 | |
| 28 | Then("I should be on the subid settings page", () => { |
| 29 | const re = |
| 30 | /subordinate-ids\/[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$/; |
| 31 | cy.url().should("match", re); |
| 32 | }); |