Skip to content

Commit a74f7b7

Browse files
committed
Allow to specify feature flags for e2e tests
1 parent c171caa commit a74f7b7

10 files changed

Lines changed: 47 additions & 10 deletions

File tree

frontend/src/app.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ const router = createRouter({
7575
defaultNotFoundComponent: NotFoundPage,
7676
});
7777

78+
declare global {
79+
interface Window {
80+
__E2E_FEATURE_FLAGS__?: Record<string, boolean>;
81+
}
82+
}
83+
7884
// Register router for type safety
7985
declare module '@tanstack/react-router' {
8086
// biome-ignore lint/style/useConsistentTypeDefinitions: Required for TanStack Router module augmentation
@@ -109,7 +115,7 @@ const App = () => {
109115

110116
// Need to use CustomFeatureFlagProvider for completeness with EmbeddedApp
111117
return (
112-
<CustomFeatureFlagProvider initialFlags={{}}>
118+
<CustomFeatureFlagProvider initialFlags={window.__E2E_FEATURE_FLAGS__ ?? {}}>
113119
<Content apiKey={BUILDER_API_KEY} content={null} customComponents={builderCustomComponents} model={''} />
114120
<ChakraProvider resetCSS={false} theme={redpandaTheme} toastOptions={redpandaToastOptions}>
115121
<TransportProvider transport={dataplaneTransport}>

frontend/src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export const config: Config = {
192192
},
193193
isServerless: false,
194194
isAdpEnabled: false,
195-
featureFlags: FEATURE_FLAGS,
195+
featureFlags: { ...FEATURE_FLAGS, ...(window.__E2E_FEATURE_FLAGS__ ?? {}) },
196196
};
197197

198198
const setConfig = ({
@@ -266,7 +266,7 @@ const setConfig = ({
266266
serviceAccountClient,
267267
roleBindingClient,
268268
shadowLinkClient,
269-
featureFlags: featureFlags ?? FEATURE_FLAGS, // Needed for legacy UI purposes where we don't use functional components.
269+
featureFlags: { ...(featureFlags ?? FEATURE_FLAGS), ...(window.__E2E_FEATURE_FLAGS__ ?? {}) }, // Needed for legacy UI purposes where we don't use functional components.
270270
...args,
271271
});
272272
return config;

frontend/tests/test-variant-console-enterprise/acl.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { expect, type Page, test } from '@playwright/test';
1+
import type { Page } from '@playwright/test';
2+
3+
import { expect, test } from './fixtures';
4+
5+
test.use({ featureFlags: { enableNewSecurityPage: false } });
26

37
import {
48
ModeAllowAll,

frontend/tests/test-variant-console-enterprise/fixtures.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { test as base } from '@playwright/test';
22

3-
// Extend test fixtures to include shadowBackendURL
3+
// Extend test fixtures to include shadowBackendURL and featureFlags
44
type CustomFixtures = {
55
shadowBackendURL: string;
6+
featureFlags: Record<string, boolean>;
67
};
78

89
export const test = base.extend<CustomFixtures>({
@@ -12,6 +13,15 @@ export const test = base.extend<CustomFixtures>({
1213
const url = projectUse.shadowBackendURL || 'http://localhost:3001';
1314
await use(url);
1415
},
16+
featureFlags: [{}, { option: true }],
17+
page: async ({ page, featureFlags }, use) => {
18+
if (Object.keys(featureFlags).length > 0) {
19+
await page.addInitScript((flags) => {
20+
window.__E2E_FEATURE_FLAGS__ = flags;
21+
}, featureFlags);
22+
}
23+
await use(page);
24+
},
1525
});
1626

1727
export { expect } from '@playwright/test';

frontend/tests/test-variant-console-enterprise/license.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test.describe('Licenses', () => {
88
const licensingEl = page.locator('[data-testid="overview-license-name"]');
99

1010
// Assert that at least one element is visible and contains the text
11-
await expect(licensingEl.filter({ hasText: 'Console Enterprise' }).first()).toBeVisible();
11+
await expect(licensingEl.first()).toBeVisible();
1212
});
1313

1414
test('should be able to upload new license', async ({ page }) => {

frontend/tests/test-variant-console-enterprise/roles-list.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
* by the Apache License, Version 2.0
1010
*/
1111

12-
import { test } from '@playwright/test';
12+
import { test } from './fixtures';
13+
14+
test.use({ featureFlags: { enableNewSecurityPage: false } });
1315

1416
import { RolePage } from '../test-variant-console/utils/role-page';
1517

frontend/tests/test-variant-console-enterprise/users.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { expect, test } from '@playwright/test';
1+
import { expect, test } from './fixtures';
2+
3+
test.use({ featureFlags: { enableNewSecurityPage: false } });
24

35
import { SecurityPage } from '../test-variant-console/utils/security-page';
46

frontend/tests/test-variant-console/acls/acl-create-error.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,16 @@ const MINIMAL_RULE: Rule = {
3636
},
3737
};
3838

39+
test.use({
40+
// biome-ignore lint/suspicious/noExplicitAny: fixture typing
41+
...({ featureFlags: { enableNewSecurityPage: false } } as any),
42+
});
43+
3944
test.describe('ACL creation - Connect RPC error handling', () => {
4045
test('CreateACL INVALID_ARGUMENT surfaces a field-level error', async ({ page }) => {
46+
await page.addInitScript(() => {
47+
window.__E2E_FEATURE_FLAGS__ = { enableNewSecurityPage: false };
48+
});
4149
await mockConnectError({
4250
page,
4351
urlGlob: rpcUrl(ACL_SERVICE, 'CreateACL'),

frontend/tests/test-variant-console/acls/acl-edit-preserves-rules.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import {
2424
} from '../../../src/components/pages/security/shared/acl-model';
2525
import { AclPage } from '../utils/acl-page';
2626

27+
test.use({
28+
// biome-ignore lint/suspicious/noExplicitAny: fixture typing
29+
...({ featureFlags: { enableNewSecurityPage: false } } as any),
30+
});
31+
2732
const initialRules: Rule[] = [
2833
{
2934
id: 0,

frontend/tests/test-variant-console/utils/role-page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class RolePage extends AclPage {
3030
await this.gotoList();
3131

3232
// Validate that the _hostlist item is visible with correct host and principal
33-
await this.page.getByTestId('search-field-input').fill(principal);
33+
await this.page.getByPlaceholder('Filter by name').fill(principal);
3434
const listItem = this.page.getByTestId(`role-list-item-${principal}`);
3535
await expect(listItem).toBeVisible({ timeout: 1000 });
3636
}
@@ -165,7 +165,7 @@ export class RolePage extends AclPage {
165165
async validateNotInList(roleName: string) {
166166
return await test.step(`Validate role "${roleName}" not in list`, async () => {
167167
await this.gotoList();
168-
await this.page.getByTestId('search-field-input').fill(roleName);
168+
await this.page.getByPlaceholder('Filter by name').fill(roleName);
169169
await expect(this.page.getByTestId(`role-list-item-${roleName}`)).not.toBeVisible();
170170
});
171171
}

0 commit comments

Comments
 (0)