|
1 | | -import { expect } from "@playwright/test"; |
| 1 | +import { type BrowserContext, expect, type Page } from "@playwright/test"; |
2 | 2 | import { test } from "@shared/e2e/fixtures/page-auth"; |
| 3 | +import { getBackOfficeBaseUrl } from "@shared/e2e/utils/constants"; |
3 | 4 | import { |
4 | 5 | createTestContext, |
5 | 6 | expectToastMessage, |
6 | 7 | selectOption, |
7 | 8 | typeOneTimeCode |
8 | 9 | } from "@shared/e2e/utils/test-assertions"; |
9 | | -import { completeSignupFlow, getVerificationCode, testUser } from "@shared/e2e/utils/test-data"; |
| 10 | +import { completeSignupFlow, getVerificationCode, logInAsAdmin, testUser } from "@shared/e2e/utils/test-data"; |
10 | 11 | import { step } from "@shared/e2e/utils/test-step-wrapper"; |
11 | 12 |
|
| 13 | +const BACK_OFFICE_BASE_URL = getBackOfficeBaseUrl(); |
| 14 | + |
| 15 | +// account-overview is a kill-switch flag — the reconciler creates the base row inactive on first |
| 16 | +// sight, so the Features section on /account/settings stays empty (the section returns null when |
| 17 | +// no tenant-configurable flag has an active base row) until an admin explicitly activates it. |
| 18 | +// Activating is idempotent (PUT just resets EnabledAt), so this can run for every test that needs |
| 19 | +// the toggle without coordinating across tests. |
| 20 | +async function activateAccountOverviewFlag(browserContext: BrowserContext): Promise<void> { |
| 21 | + const backOfficePage = await browserContext.newPage(); |
| 22 | + await backOfficePage.goto(`${BACK_OFFICE_BASE_URL}/feature-flags`); |
| 23 | + await logInAsAdmin(backOfficePage, `${BACK_OFFICE_BASE_URL}/feature-flags`); |
| 24 | + |
| 25 | + const antiforgeryToken = await getAntiforgeryToken(backOfficePage); |
| 26 | + const activateResponse = await backOfficePage.request.put( |
| 27 | + `${BACK_OFFICE_BASE_URL}/api/back-office/feature-flags/account-overview/activate`, |
| 28 | + { headers: { "x-xsrf-token": antiforgeryToken } } |
| 29 | + ); |
| 30 | + expect(activateResponse.ok()).toBe(true); |
| 31 | + |
| 32 | + await backOfficePage.close(); |
| 33 | +} |
| 34 | + |
| 35 | +async function getAntiforgeryToken(page: Page): Promise<string> { |
| 36 | + return page.evaluate( |
| 37 | + () => document.head.querySelector('meta[name="antiforgeryToken"]')?.getAttribute("content") ?? "" |
| 38 | + ); |
| 39 | +} |
| 40 | + |
12 | 41 | test.describe("@smoke", () => { |
13 | 42 | /** |
14 | 43 | * COMPREHENSIVE USER MANAGEMENT WORKFLOW |
@@ -470,12 +499,23 @@ test.describe("@comprehensive", () => { |
470 | 499 | * - Permanent delete user via confirmation dialog |
471 | 500 | * - Empty recycle bin functionality |
472 | 501 | */ |
473 | | - test("should handle single and bulk user deletion workflows with dashboard integration", async ({ page }) => { |
| 502 | + test("should handle single and bulk user deletion workflows with dashboard integration", async ({ |
| 503 | + page, |
| 504 | + browser |
| 505 | + }) => { |
474 | 506 | const context = createTestContext(page); |
475 | 507 | const owner = testUser(); |
476 | 508 | const user1 = testUser(); |
477 | 509 | const user2 = testUser(); |
478 | 510 |
|
| 511 | + // The Features section on /account/settings only renders when at least one tenant-configurable |
| 512 | + // flag has an active base row. account-overview is the only such flag and is a kill-switch flag |
| 513 | + // (created inactive by the reconciler), so activate it once via the back-office API up front so |
| 514 | + // the later "Enable the account-overview feature flag via settings" step finds the section. |
| 515 | + const backOfficeContext = await browser.newContext({ baseURL: BACK_OFFICE_BASE_URL, ignoreHTTPSErrors: true }); |
| 516 | + await activateAccountOverviewFlag(backOfficeContext); |
| 517 | + await backOfficeContext.close(); |
| 518 | + |
479 | 519 | // === USER SETUP SECTION === |
480 | 520 | await step("Complete owner signup & verify dashboard")(async () => { |
481 | 521 | await completeSignupFlow(page, expect, owner, context); |
|
0 commit comments