Skip to content

Commit e9ab099

Browse files
AntoLClunika
authored andcommitted
🚩(frontend) integrate homepage feature flag
If the homepage feature flag is enabled, the homepage will be displayed.
1 parent 67b69d0 commit e9ab099

File tree

6 files changed

+71
-34
lines changed

6 files changed

+71
-34
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ and this project adheres to
88

99
## [Unreleased]
1010

11+
## Added
12+
13+
- 🚩 add homepage feature flag #861
14+
15+
1116
## [3.1.0] - 2025-04-07
1217

1318
## Added

src/frontend/apps/e2e/__tests__/app-impress/common.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
import { Page, expect } from '@playwright/test';
22

3+
export const CONFIG = {
4+
AI_FEATURE_ENABLED: true,
5+
CRISP_WEBSITE_ID: null,
6+
COLLABORATION_WS_URL: 'ws://localhost:4444/collaboration/ws/',
7+
ENVIRONMENT: 'development',
8+
FRONTEND_CSS_URL: null,
9+
FRONTEND_HOMEPAGE_FEATURE_ENABLED: true,
10+
FRONTEND_FOOTER_FEATURE_ENABLED: true,
11+
FRONTEND_THEME: 'default',
12+
MEDIA_BASE_URL: 'http://localhost:8083',
13+
LANGUAGES: [
14+
['en-us', 'English'],
15+
['fr-fr', 'Français'],
16+
['de-de', 'Deutsch'],
17+
['nl-nl', 'Nederlands'],
18+
],
19+
LANGUAGE_CODE: 'en-us',
20+
POSTHOG_KEY: {},
21+
SENTRY_DSN: null,
22+
};
23+
324
export const keyCloakSignIn = async (
425
page: Page,
526
browserName: string,

src/frontend/apps/e2e/__tests__/app-impress/config.spec.ts

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,7 @@ import path from 'path';
22

33
import { expect, test } from '@playwright/test';
44

5-
import { createDoc } from './common';
6-
7-
const config = {
8-
AI_FEATURE_ENABLED: true,
9-
CRISP_WEBSITE_ID: null,
10-
COLLABORATION_WS_URL: 'ws://localhost:4444/collaboration/ws/',
11-
ENVIRONMENT: 'development',
12-
FRONTEND_CSS_URL: null,
13-
FRONTEND_HOMEPAGE_FEATURE_ENABLED: true,
14-
FRONTEND_FOOTER_FEATURE_ENABLED: true,
15-
FRONTEND_THEME: 'default',
16-
MEDIA_BASE_URL: 'http://localhost:8083',
17-
LANGUAGES: [
18-
['en-us', 'English'],
19-
['fr-fr', 'Français'],
20-
['de-de', 'Deutsch'],
21-
['nl-nl', 'Nederlands'],
22-
],
23-
LANGUAGE_CODE: 'en-us',
24-
POSTHOG_KEY: {},
25-
SENTRY_DSN: null,
26-
};
5+
import { CONFIG, createDoc } from './common';
276

287
test.describe('Config', () => {
298
test('it checks the config api is called', async ({ page }) => {
@@ -37,7 +16,7 @@ test.describe('Config', () => {
3716
const response = await responsePromise;
3817
expect(response.ok()).toBeTruthy();
3918

40-
expect(await response.json()).toStrictEqual(config);
19+
expect(await response.json()).toStrictEqual(CONFIG);
4120
});
4221

4322
test('it checks that sentry is trying to init from config endpoint', async ({
@@ -48,7 +27,7 @@ test.describe('Config', () => {
4827
if (request.method().includes('GET')) {
4928
await route.fulfill({
5029
json: {
51-
...config,
30+
...CONFIG,
5231
SENTRY_DSN: 'https://sentry.io/123',
5332
},
5433
});
@@ -121,7 +100,7 @@ test.describe('Config', () => {
121100
if (request.method().includes('GET')) {
122101
await route.fulfill({
123102
json: {
124-
...config,
103+
...CONFIG,
125104
AI_FEATURE_ENABLED: false,
126105
},
127106
});
@@ -152,7 +131,7 @@ test.describe('Config', () => {
152131
if (request.method().includes('GET')) {
153132
await route.fulfill({
154133
json: {
155-
...config,
134+
...CONFIG,
156135
CRISP_WEBSITE_ID: '1234',
157136
},
158137
});
@@ -174,7 +153,7 @@ test.describe('Config', () => {
174153
if (request.method().includes('GET')) {
175154
await route.fulfill({
176155
json: {
177-
...config,
156+
...CONFIG,
178157
FRONTEND_CSS_URL: 'http://localhost:123465/css/style.css',
179158
},
180159
});

src/frontend/apps/e2e/__tests__/app-impress/home.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { expect, test } from '@playwright/test';
22

3+
import { CONFIG } from './common';
4+
35
test.beforeEach(async ({ page }) => {
46
await page.goto('/docs/');
57
});
@@ -50,4 +52,27 @@ test.describe('Home page', () => {
5052

5153
await expect(footer).toBeVisible();
5254
});
55+
56+
test('it checks the homepage feature flag', async ({ page }) => {
57+
await page.route('**/api/v1.0/config/', async (route) => {
58+
const request = route.request();
59+
if (request.method().includes('GET')) {
60+
await route.fulfill({
61+
json: {
62+
...CONFIG,
63+
FRONTEND_HOMEPAGE_FEATURE_ENABLED: false,
64+
},
65+
});
66+
} else {
67+
await route.continue();
68+
}
69+
});
70+
71+
await page.goto('/');
72+
73+
// Keyclock login page
74+
await expect(
75+
page.locator('.login-pf-page-header').getByText('impress'),
76+
).toBeVisible();
77+
});
5378
});

src/frontend/apps/impress/src/core/config/api/useConfig.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ import { Theme } from '@/cunningham/';
55
import { PostHogConf } from '@/services';
66

77
interface ConfigResponse {
8-
LANGUAGES: [string, string][];
9-
LANGUAGE_CODE: string;
10-
ENVIRONMENT: string;
8+
AI_FEATURE_ENABLED?: boolean;
119
COLLABORATION_WS_URL?: string;
1210
CRISP_WEBSITE_ID?: string;
13-
FRONTEND_THEME?: Theme;
11+
ENVIRONMENT: string;
1412
FRONTEND_CSS_URL?: string;
13+
FRONTEND_HOMEPAGE_FEATURE_ENABLED?: boolean;
14+
FRONTEND_THEME?: Theme;
15+
LANGUAGES: [string, string][];
16+
LANGUAGE_CODE: string;
1517
MEDIA_BASE_URL?: string;
1618
POSTHOG_KEY?: PostHogConf;
1719
SENTRY_DSN?: string;
18-
AI_FEATURE_ENABLED?: boolean;
1920
}
2021

2122
export const getConfig = async (): Promise<ConfigResponse> => {

src/frontend/apps/impress/src/features/auth/components/Auth.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import { useRouter } from 'next/router';
33
import { PropsWithChildren } from 'react';
44

55
import { Box } from '@/components';
6+
import { useConfig } from '@/core';
67

78
import { useAuth } from '../hooks';
8-
import { getAuthUrl } from '../utils';
9+
import { getAuthUrl, gotoLogin } from '../utils';
910

1011
export const Auth = ({ children }: PropsWithChildren) => {
1112
const { isLoading, pathAllowed, isFetchedAfterMount, authenticated } =
1213
useAuth();
1314
const { replace, pathname } = useRouter();
15+
const { data: config } = useConfig();
1416

1517
if (isLoading && !isFetchedAfterMount) {
1618
return (
@@ -40,7 +42,11 @@ export const Auth = ({ children }: PropsWithChildren) => {
4042
* If the user is not authenticated and the path is not allowed, we redirect to the login page.
4143
*/
4244
if (!authenticated && !pathAllowed) {
43-
void replace('/login');
45+
if (config?.FRONTEND_HOMEPAGE_FEATURE_ENABLED) {
46+
void replace('/login');
47+
} else {
48+
gotoLogin();
49+
}
4450
return (
4551
<Box $height="100vh" $width="100vw" $align="center" $justify="center">
4652
<Loader />

0 commit comments

Comments
 (0)