|
| 1 | +import { Locator, Page } from "@playwright/test"; |
| 2 | + |
| 3 | +/** |
| 4 | + * ROLES_PAGE_COMPONENTS - Roles list page: edit and delete buttons |
| 5 | + */ |
| 6 | +export const ROLES_PAGE_COMPONENTS = { |
| 7 | + getEditRoleButton: (page: Page, name: string): Locator => |
| 8 | + page.getByTestId(`edit-role-${name}`), |
| 9 | + |
| 10 | + getDeleteRoleButton: (page: Page, name: string): Locator => |
| 11 | + page.getByTestId(`delete-role-${name}`), |
| 12 | + |
| 13 | + getFilterInput: (page: Page): Locator => page.getByPlaceholder("Filter"), |
| 14 | +}; |
| 15 | + |
| 16 | +/** |
| 17 | + * DELETE_ROLE_COMPONENTS - Delete role confirmation dialog |
| 18 | + */ |
| 19 | +export const DELETE_ROLE_COMPONENTS = { |
| 20 | + getRoleNameInput: (page: Page): Locator => |
| 21 | + page.locator('input[name="delete-role"]'), |
| 22 | +}; |
| 23 | + |
| 24 | +/** |
| 25 | + * ROLE_OVERVIEW_COMPONENTS - Role overview page action buttons |
| 26 | + */ |
| 27 | +export const ROLE_OVERVIEW_COMPONENTS = { |
| 28 | + getUpdatePoliciesButton: (page: Page): Locator => |
| 29 | + page.getByTestId("update-policies"), |
| 30 | + |
| 31 | + getUpdateMembersButton: (page: Page): Locator => |
| 32 | + page.getByTestId("update-members"), |
| 33 | +}; |
| 34 | + |
| 35 | +/** |
| 36 | + * ROLE_FORM_COMPONENTS - Role creation / edit form fields |
| 37 | + */ |
| 38 | +export const ROLE_FORM_COMPONENTS = { |
| 39 | + getRoleNameInput: (page: Page): Locator => page.locator('input[name="name"]'), |
| 40 | + |
| 41 | + getRoleOwnerInput: (page: Page): Locator => |
| 42 | + page.locator('textarea[name="owner"]'), |
| 43 | + |
| 44 | + getUsersAndGroupsField: (page: Page): Locator => |
| 45 | + page.locator('input[name="add-users-and-groups"]'), |
| 46 | + |
| 47 | + getMemberOption: (page: Page, label: string): Locator => |
| 48 | + page.locator(`span[data-testid="${label}"]`), |
| 49 | + |
| 50 | + getDropdownToggle: (page: Page): Locator => |
| 51 | + page.getByTestId("ArrowDropDownIcon"), |
| 52 | + |
| 53 | + getSelectPluginsCombobox: (page: Page): Locator => |
| 54 | + page.getByRole("combobox", { name: "Select plugins" }), |
| 55 | + |
| 56 | + getExpandCatalogRow: (page: Page): Locator => |
| 57 | + page.getByTestId("expand-row-catalog"), |
| 58 | + |
| 59 | + getNextButton2: (page: Page): Locator => |
| 60 | + page.getByTestId("nextButton-2").first(), |
| 61 | + |
| 62 | + getPermissionsSelectPlaceholder: (page: Page): Locator => |
| 63 | + page.getByText("Select..."), |
| 64 | +}; |
| 65 | + |
| 66 | +/** |
| 67 | + * CONDITIONAL_RULE_COMPONENTS - Conditions sidebar and rule builder |
| 68 | + */ |
| 69 | +export const CONDITIONAL_RULE_COMPONENTS = { |
| 70 | + getRulesSidebar: (page: Page): Locator => page.getByTestId("rules-sidebar"), |
| 71 | + |
| 72 | + getSaveConditionsButton: (page: Page): Locator => |
| 73 | + page.getByTestId("save-conditions"), |
| 74 | + |
| 75 | + getAnyOfButton: (page: Page): Locator => |
| 76 | + page.getByRole("button", { name: "AnyOf" }), |
| 77 | + |
| 78 | + getNotButton: (page: Page): Locator => |
| 79 | + page.getByRole("button", { name: "Not" }), |
| 80 | + |
| 81 | + getAddRuleButton: (page: Page): Locator => |
| 82 | + page.getByRole("button", { name: "Add rule" }), |
| 83 | + |
| 84 | + getAddNestedConditionButton: (page: Page): Locator => |
| 85 | + page.getByRole("button", { name: "Add Nested Condition" }), |
| 86 | + |
| 87 | + getHasSpecButton: (page: Page): Locator => page.getByText("HAS_SPEC"), |
| 88 | + |
| 89 | + getHasAnnotationButton: (page: Page): Locator => |
| 90 | + page.getByText("HAS_ANNOTATION"), |
| 91 | + |
| 92 | + getHasLabelButton: (page: Page): Locator => page.getByText("HAS_LABEL"), |
| 93 | + |
| 94 | + getIsEntityKindButton: (page: Page): Locator => |
| 95 | + page.getByText("IS_ENTITY_KIND"), |
| 96 | + |
| 97 | + getIsOwnerButton: (page: Page): Locator => page.getByText("IS_OWNER"), |
| 98 | + |
| 99 | + getKeyInput: (page: Page): Locator => page.getByLabel("key *"), |
| 100 | + |
| 101 | + getAnnotationInput: (page: Page): Locator => page.getByLabel("annotation *"), |
| 102 | + |
| 103 | + getLabelInput: (page: Page): Locator => page.getByLabel("label *"), |
| 104 | + |
| 105 | + getRuleBadge: (page: Page, count: string): Locator => |
| 106 | + page.locator('span[class*="MuiBadge-badge"]').filter({ hasText: count }), |
| 107 | +}; |
| 108 | + |
| 109 | +/** |
| 110 | + * SEARCH_COMPONENTS - Search inputs on the roles list page |
| 111 | + */ |
| 112 | +export const SEARCH_COMPONENTS = { |
| 113 | + getAriaLabelSearchInput: (page: Page): Locator => |
| 114 | + page.locator('input[aria-label="Search"]'), |
| 115 | + |
| 116 | + getPlaceholderSearchInput: (page: Page): Locator => |
| 117 | + page.locator('input[placeholder="Search"]'), |
| 118 | +}; |
0 commit comments