| 1 | import { Given } from "@badeball/cypress-cucumber-preprocessor"; |
| 2 | import { entryExists, searchForEntry } from "../common/data_tables"; |
| 3 | import { navigateTo } from "../common/navigation"; |
| 4 | import { loginAsAdmin, logout } from "../common/authentication"; |
| 5 | import { |
| 6 | createDnsZone, |
| 7 | disableDnsZone, |
| 8 | isEnabled, |
| 9 | parseZoneName, |
| 10 | } from "./dnszones"; |
| 11 | |
| 12 | const addPermissionToDnsZone = (dnsZoneName: string) => { |
| 13 | navigateTo("dns-zones/" + dnsZoneName); |
| 14 | |
| 15 | cy.dataCy("dns-zones-settings").should("be.visible"); |
| 16 | cy.dataCy("dns-zones-tab-settings-kebab").click(); |
| 17 | cy.dataCy("dns-zones-tab-settings-kebab-kebab").should("be.visible"); |
| 18 | |
| 19 | cy.dataCy("dns-zones-tab-settings-kebab-add-permission") |
| 20 | .find("button") |
| 21 | .click(); |
| 22 | cy.dataCy("dns-zones-add-remove-permission-modal").should("be.visible"); |
| 23 | |
| 24 | cy.dataCy("modal-button-ok").click(); |
| 25 | cy.dataCy("dns-zones-add-remove-permission-modal").should("not.exist"); |
| 26 | cy.dataCy("success").should("be.visible"); |
| 27 | }; |
| 28 | |
| 29 | Given("DNS zone {string} exists and it is enabled", (dnsZoneName: string) => { |
| 30 | loginAsAdmin(); |
| 31 | navigateTo("dns-zones"); |
| 32 | |
| 33 | createDnsZone(dnsZoneName); |
| 34 | |
| 35 | searchForEntry(parseZoneName(dnsZoneName)); |
| 36 | entryExists(parseZoneName(dnsZoneName)); |
| 37 | isEnabled(parseZoneName(dnsZoneName)); |
| 38 | logout(); |
| 39 | }); |
| 40 | |
| 41 | Given("DNS zone {string} exists and it is disabled", (dnsZoneName: string) => { |
| 42 | loginAsAdmin(); |
| 43 | navigateTo("dns-zones"); |
| 44 | |
| 45 | createDnsZone(dnsZoneName); |
| 46 | |
| 47 | searchForEntry(parseZoneName(dnsZoneName)); |
| 48 | entryExists(parseZoneName(dnsZoneName)); |
| 49 | // When creating a DNS zone, it is enabled by default |
| 50 | disableDnsZone(parseZoneName(dnsZoneName)); |
| 51 | logout(); |
| 52 | }); |
| 53 | |
| 54 | Given("DNS zone {string} exists and has permission", (dnsZoneName: string) => { |
| 55 | loginAsAdmin(); |
| 56 | navigateTo("dns-zones"); |
| 57 | |
| 58 | createDnsZone(dnsZoneName); |
| 59 | |
| 60 | searchForEntry(parseZoneName(dnsZoneName)); |
| 61 | entryExists(parseZoneName(dnsZoneName)); |
| 62 | navigateTo("dns-zones/" + dnsZoneName); |
| 63 | addPermissionToDnsZone(dnsZoneName); |
| 64 | logout(); |
| 65 | }); |