Debian Codegraph @

install/freeipa-webui/cypress/e2e/common/member_of.ts

raw symbols SCIP
1 import { Given } from "@badeball/cypress-cucumber-preprocessor";
2 import { loginAsAdmin, logout } from "./authentication";
3 import { navigateTo } from "./navigation";
4 import { entryExists } from "./data_tables";
5 import { addItemToRightList } from "./ui/dual_list";
6 import { searchForMembersEntry } from "./members_table";
7
8 const ensureItemExistsInMemberOfTable = (
9 itemName: string,
10 tablePath: string,
11 useDualListSearchLink: boolean = false
12 ) => {
13 navigateTo(`netgroups/${tablePath}`);
14
15 cy.dataCy("member-of-button-add").click();
16 cy.dataCy("member-of-add-modal").should("exist");
17
18 if (useDualListSearchLink) {
19 cy.dataCy("dual-list-search-link").click();
20 }
21
22 addItemToRightList(itemName);
23 cy.dataCy("member-of-add-modal").should("exist");
24
25 cy.dataCy("modal-button-add").click();
26 cy.dataCy("member-of-add-modal").should("not.exist");
27 cy.dataCy("add-member-success").should("exist");
28
29 searchForMembersEntry(itemName);
30 entryExists(itemName);
31 };
32
33 // Allowed member entity values (readonly tuple)
34 const MEMBER_ENTITIES = [
35 "user group",
36 "hostgroup",
37 "host",
38 "user",
39 "netgroup",
40 "externalhost",
41 "group",
42 ] as const;
43
44 export type MemberEntity = (typeof MEMBER_ENTITIES)[number];
45
46 export const isMemberEntity = (value: string): value is MemberEntity => {
47 return MEMBER_ENTITIES.includes(value as MemberEntity);
48 };
49
50 export const assertMemberEntity = (value: string): void => {
51 if (!isMemberEntity(value)) {
52 throw new Error(`Invalid member entity: ${value}`);
53 }
54 };
55
56 Given("{string} exists in table {string}", (name: string, table: string) => {
57 loginAsAdmin();
58 ensureItemExistsInMemberOfTable(name, table);
59 logout();
60 });