| 22 | ] as const; |
| 23 | |
| 24 | async function hasAccessToAdminSettings(page: Page, settings: AdminSetting[]) { |
| 25 | // Audit Logs requires a license to be visible |
| 26 | const visibleSettings = license |
| 27 | ? settings |
| 28 | : settings.filter((it) => it !== "Audit Logs"); |
| 29 | const adminSettingsButton = page.getByRole("button", { |
| 30 | name: "Admin settings", |
| 31 | }); |
| 32 | if (visibleSettings.length < 1) { |
| 33 | await expect(adminSettingsButton).not.toBeVisible(); |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | await adminSettingsButton.click(); |
| 38 | |
| 39 | for (const name of visibleSettings) { |
| 40 | await expect(page.getByText(name, { exact: true })).toBeVisible(); |
| 41 | } |
| 42 | |
| 43 | const hiddenSettings = adminSettings.filter( |
| 44 | (it) => !visibleSettings.includes(it), |
| 45 | ); |
| 46 | for (const name of hiddenSettings) { |
| 47 | await expect(page.getByText(name, { exact: true })).not.toBeVisible(); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | test.describe("roles admin settings access", () => { |
| 52 | test("member cannot see admin settings", async ({ page }) => { |