| 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("I delete view {string}", (viewName: string) => { |
| 13 | loginAsAdmin(); |
| 14 | navigateTo("id-views"); |
| 15 | selectEntry(viewName); |
| 16 | |
| 17 | cy.dataCy("id-views-button-delete").click(); |
| 18 | cy.dataCy("delete-id-views-modal").should("exist"); |
| 19 | |
| 20 | cy.dataCy("modal-button-delete").click(); |
| 21 | cy.dataCy("delete-id-views-modal").should("not.exist"); |
| 22 | |
| 23 | searchForEntry(viewName); |
| 24 | entryDoesNotExist(viewName); |
| 25 | logout(); |
| 26 | }); |
| 27 | |
| 28 | Given("view {string} exists", (viewName: string) => { |
| 29 | loginAsAdmin(); |
| 30 | navigateTo("id-views"); |
| 31 | |
| 32 | cy.dataCy("id-views-button-add").click(); |
| 33 | cy.dataCy("add-id-view-modal").should("exist"); |
| 34 | |
| 35 | typeInTextbox("modal-textbox-id-view-name", viewName); |
| 36 | cy.dataCy("modal-textbox-id-view-name").should("have.value", viewName); |
| 37 | |
| 38 | cy.dataCy("modal-button-add").click(); |
| 39 | cy.dataCy("add-id-view-modal").should("not.exist"); |
| 40 | |
| 41 | searchForEntry(viewName); |
| 42 | entryExists(viewName); |
| 43 | logout(); |
| 44 | }); |