Skip to content

Commit 685de8d

Browse files
committed
Activate account-overview and compact-view kill-switch flags in e2e tests so Features and Beta sections render on default seed
1 parent 3d75764 commit 685de8d

2 files changed

Lines changed: 67 additions & 8 deletions

File tree

application/account/WebApp/tests/e2e/feature-flag-flows.spec.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ async function activateAndPinRollout(page: Page, flagKey: string, rolloutPercent
5050
expect(rolloutResponse.ok()).toBe(true);
5151
}
5252

53+
// Globally activate a kill-switch flag via the back-office API. The reconciler creates kill-switch
54+
// flags inactive on first sight, so an admin must Activate before tenants can evaluate them or
55+
// before owner-configurable flags surface in the /account/settings Features section. The PUT is
56+
// idempotent — calling it on an already-active flag just refreshes EnabledAt.
57+
async function activateKillSwitchFlag(page: Page, flagKey: string): Promise<void> {
58+
const headers = await getAntiforgeryHeaders(page);
59+
const activateResponse = await page.request.put(
60+
`${BACK_OFFICE_BASE_URL}/api/back-office/feature-flags/${flagKey}/activate`,
61+
{ headers }
62+
);
63+
expect(activateResponse.ok()).toBe(true);
64+
}
65+
5366
// Remove every tenant-override on `flagKey` across the entire database. The override toggles in
5467
// @smoke pick the first "Test Organization" row, but the back-office tables interleave every
5568
// worker's tenant (and stale rows from old runs), so the .first() row is unpredictable unless we
@@ -179,11 +192,17 @@ test.describe("@smoke", () => {
179192

180193
// Both @smoke and @comprehensive mutate the shared beta-features rollout; both leave it at 100
181194
// and remove any tenant-override they created, so cross-test ordering is deterministic.
182-
await step("Activate beta-features and pin rollout to 100 via back-office API & verify tenants evaluate enabled")(
183-
async () => {
184-
await activateAndPinRollout(page, "beta-features", 100);
185-
}
186-
)();
195+
// account-overview and compact-view are kill-switch flags created inactive by the reconciler —
196+
// activate them here so the Features section on /account/settings and the Feature preferences
197+
// section on /user/preferences later in this test are non-empty (those sections are hidden when
198+
// no tenant- or user-configurable flag has an active base row).
199+
await step(
200+
"Activate beta-features, account-overview, compact-view and pin beta-features rollout to 100 via back-office API & verify tenants evaluate enabled"
201+
)(async () => {
202+
await activateAndPinRollout(page, "beta-features", 100);
203+
await activateKillSwitchFlag(page, "account-overview");
204+
await activateKillSwitchFlag(page, "compact-view");
205+
})();
187206

188207
await step("Remove all leftover tenant overrides for beta-features & verify clean precondition")(async () => {
189208
await removeAllTenantOverrides(page, "beta-features");

application/account/WebApp/tests/e2e/user-management-flows.spec.ts

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,43 @@
1-
import { expect } from "@playwright/test";
1+
import { type BrowserContext, expect, type Page } from "@playwright/test";
22
import { test } from "@shared/e2e/fixtures/page-auth";
3+
import { getBackOfficeBaseUrl } from "@shared/e2e/utils/constants";
34
import {
45
createTestContext,
56
expectToastMessage,
67
selectOption,
78
typeOneTimeCode
89
} 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";
1011
import { step } from "@shared/e2e/utils/test-step-wrapper";
1112

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+
1241
test.describe("@smoke", () => {
1342
/**
1443
* COMPREHENSIVE USER MANAGEMENT WORKFLOW
@@ -470,12 +499,23 @@ test.describe("@comprehensive", () => {
470499
* - Permanent delete user via confirmation dialog
471500
* - Empty recycle bin functionality
472501
*/
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+
}) => {
474506
const context = createTestContext(page);
475507
const owner = testUser();
476508
const user1 = testUser();
477509
const user2 = testUser();
478510

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+
479519
// === USER SETUP SECTION ===
480520
await step("Complete owner signup & verify dashboard")(async () => {
481521
await completeSignupFlow(page, expect, owner, context);

0 commit comments

Comments
 (0)