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