Debian Codegraph @

install/freeipa-webui/cypress/e2e/automember/automember_hostgroup.ts

raw symbols SCIP
1 import { When, Then, Given } from "@badeball/cypress-cucumber-preprocessor";
2 import {
3 entryDoesNotExist,
4 entryExists,
5 searchForEntry,
6 selectEntry,
7 validateEntry,
8 } from "../common/data_tables";
9 import "../hostgroups/hostgroup";
10 import "../common/data_tables";
11 import { navigateTo } from "../common/navigation";
12 import { loginAsAdmin, logout } from "../common/authentication";
13 import { createHostgroup } from "../hostgroups/hostgroup";
14 import { isOptionSelected, selectOption } from "../common/ui/select";
15
16 const fillHostgroupRule = (hostgroupName: string) => {
17 selectOption(hostgroupName, "modal-select-automember");
18 isOptionSelected(hostgroupName, "modal-select-automember");
19 };
20
21 export const createHostgroupRule = (hostgroupName: string) => {
22 cy.dataCy("auto-member-host-rules-button-add").click();
23 cy.dataCy("add-rule-modal").should("exist");
24
25 fillHostgroupRule(hostgroupName);
26
27 cy.dataCy("modal-button-add").click();
28 cy.dataCy("add-hostgroup-rule-modal").should("not.exist");
29 };
30
31 const deleteHostgroupRule = (hostgroupName: string) => {
32 selectEntry(hostgroupName);
33
34 cy.dataCy("auto-member-host-rules-button-delete").click();
35 cy.dataCy("delete-rule-modal").should("exist");
36
37 cy.dataCy("modal-button-delete").click();
38 cy.dataCy("delete-rule-modal").should("not.exist");
39
40 searchForEntry(hostgroupName);
41 entryDoesNotExist(hostgroupName);
42 cy.dataCy("delete-rule-success").should("exist");
43 };
44
45 const setDefaultHostgroupRule = (hostgroupName: string) => {
46 cy.dataCy("typeahead-select-toggle").click();
47 cy.dataCy("typeahead-select-" + hostgroupName).click();
48 cy.dataCy("auto-member-default-host-rules-modal").should("exist");
49
50 cy.dataCy("modal-button-ok").click();
51 cy.dataCy("auto-member-default-host-rules-modal").should("not.exist");
52 cy.get("[data-cy='typeahead-select-toggle'] input").should(
53 "have.value",
54 hostgroupName
55 );
56 cy.dataCy("default-group-success").should("exist");
57 };
58
59 Given("hostgroup rule {string} exists", (hostgroupName: string) => {
60 loginAsAdmin();
61 navigateTo("host-groups");
62
63 createHostgroup(hostgroupName, "test");
64 searchForEntry(hostgroupName);
65 entryExists(hostgroupName);
66
67 navigateTo("host-group-rules");
68 createHostgroupRule(hostgroupName);
69
70 searchForEntry(hostgroupName);
71 entryExists(hostgroupName);
72 logout();
73 });
74
75 When(
76 "I create hostgroup rule based on hostgroup {string}",
77 (hostgroupName: string) => {
78 createHostgroupRule(hostgroupName);
79 }
80 );
81
82 Then(
83 "I should see hostgroup rule {string} in the hostgroup rule list",
84 (hostgroupName: string) => {
85 validateEntry(hostgroupName);
86 }
87 );
88
89 Then(
90 "I should see hostgroup rule {string} as the default hostgroup rule",
91 (hostgroupName: string) => {
92 cy.get("[data-cy='typeahead-select-toggle'] > button").click();
93 cy.get("[data-cy='typeahead-select-toggle'] > button").should(
94 "have.attr",
95 "aria-expanded",
96 "true"
97 );
98 cy.dataCy("typeahead-select-" + hostgroupName).click();
99 cy.dataCy("auto-member-default-host-rules-modal").should("exist");
100 }
101 );
102
103 Then(
104 "I should not see hostgroup rule {string} in the hostgroup rule list",
105 (hostgroupName: string) => {
106 searchForEntry(hostgroupName);
107 entryDoesNotExist(hostgroupName);
108 }
109 );
110
111 Given("I delete hostgroup rule {string}", (hostgroupName: string) => {
112 loginAsAdmin();
113 navigateTo("host-group-rules");
114
115 deleteHostgroupRule(hostgroupName);
116
117 searchForEntry(hostgroupName);
118 entryDoesNotExist(hostgroupName);
119 logout();
120 });
121
122 When("I try to delete hostgroup rule {string}", (hostgroupName: string) => {
123 navigateTo("host-group-rules");
124 deleteHostgroupRule(hostgroupName);
125 searchForEntry(hostgroupName);
126 entryDoesNotExist(hostgroupName);
127 });
128
129 When("I set default hostgroup rule {string}", (hostgroupName: string) => {
130 setDefaultHostgroupRule(hostgroupName);
131 });