| 1 | import { Given } from "@badeball/cypress-cucumber-preprocessor"; |
| 2 | import { loginAsAdmin, logout } from "../common/authentication"; |
| 3 | import { |
| 4 | selectEntry, |
| 5 | searchForEntry, |
| 6 | entryDoesNotExist, |
| 7 | entryExists, |
| 8 | } from "../common/data_tables"; |
| 9 | import { navigateTo } from "../common/navigation"; |
| 10 | import { typeInTextbox } from "../common/ui/textbox"; |
| 11 | |
| 12 | Given("hbac rule {string} exists", (ruleName: string) => { |
| 13 | loginAsAdmin(); |
| 14 | navigateTo("hbac-rules"); |
| 15 | |
| 16 | cy.dataCy("hbac-rules-button-add").click(); |
| 17 | cy.dataCy("add-hbac-rule-modal").should("exist"); |
| 18 | |
| 19 | typeInTextbox("modal-textbox-rule-name", ruleName); |
| 20 | cy.dataCy("modal-textbox-rule-name").should("have.value", ruleName); |
| 21 | |
| 22 | cy.dataCy("modal-button-add").click(); |
| 23 | cy.dataCy("add-hbac-rule-modal").should("not.exist"); |
| 24 | |
| 25 | searchForEntry(ruleName); |
| 26 | entryExists(ruleName); |
| 27 | logout(); |
| 28 | }); |
| 29 | |
| 30 | Given("I delete hbac rule {string}", (ruleName: string) => { |
| 31 | loginAsAdmin(); |
| 32 | navigateTo("hbac-rules"); |
| 33 | selectEntry(ruleName); |
| 34 | |
| 35 | cy.dataCy("hbac-rules-button-delete").click(); |
| 36 | cy.dataCy("delete-hbac-rules-modal").should("exist"); |
| 37 | |
| 38 | cy.dataCy("modal-button-delete").click(); |
| 39 | cy.dataCy("delete-hbac-rules-modal").should("not.exist"); |
| 40 | |
| 41 | searchForEntry(ruleName); |
| 42 | entryDoesNotExist(ruleName); |
| 43 | logout(); |
| 44 | }); |