♻️(frontend) replace env NEXT_PUBLIC_FEATURE_TEAM
NEXT_PUBLIC_FEATURE_TEAM is a buid-time env variable, it is not easy to overload it per environment. We will use the config endpoint to get the feature flag at runtime. To do so, we are using the ConfigStore.
This commit is contained in:
@@ -24,6 +24,6 @@ test.describe('404', () => {
|
||||
page,
|
||||
}) => {
|
||||
await page.getByText('Back to home page').click();
|
||||
await expect(page).toHaveURL('/');
|
||||
await expect(page).toHaveURL('/teams/');
|
||||
});
|
||||
});
|
||||
|
||||
63
src/frontend/apps/e2e/__tests__/app-desk/config.spec.ts
Normal file
63
src/frontend/apps/e2e/__tests__/app-desk/config.spec.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
import { keyCloakSignIn } from './common';
|
||||
|
||||
test.describe('Config', () => {
|
||||
test.beforeEach(async ({ page, browserName }) => {
|
||||
await page.goto('/');
|
||||
await keyCloakSignIn(page, browserName);
|
||||
});
|
||||
|
||||
test('it checks the config api is called', async ({ page }) => {
|
||||
const responsePromise = page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/config/') && response.status() === 200,
|
||||
);
|
||||
|
||||
const response = await responsePromise;
|
||||
expect(response.ok()).toBeTruthy();
|
||||
|
||||
expect(await response.json()).toStrictEqual({
|
||||
LANGUAGES: [
|
||||
['en-us', 'English'],
|
||||
['fr-fr', 'French'],
|
||||
],
|
||||
FEATURES: { TEAMS: true },
|
||||
});
|
||||
});
|
||||
|
||||
test('it checks that the config can deactivate the feature "teams"', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.route('**/api/v1.0/config/', async (route) => {
|
||||
const request = route.request();
|
||||
if (request.method().includes('GET')) {
|
||||
await route.fulfill({
|
||||
json: {
|
||||
LANGUAGES: [
|
||||
['en-us', 'English'],
|
||||
['fr-fr', 'French'],
|
||||
],
|
||||
FEATURES: { TEAMS: false },
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await route.continue();
|
||||
}
|
||||
});
|
||||
|
||||
await expect(page.locator('menu')).toBeHidden();
|
||||
|
||||
await expect(
|
||||
page.getByRole('button', {
|
||||
name: 'Create a new team',
|
||||
}),
|
||||
).toBeHidden();
|
||||
|
||||
await expect(
|
||||
page.getByRole('button', {
|
||||
name: 'Add your mail domain',
|
||||
}),
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -12,7 +12,7 @@ test.describe('Menu', () => {
|
||||
{
|
||||
name: 'Teams',
|
||||
isDefault: true,
|
||||
expectedUrl: '',
|
||||
expectedUrl: '/teams/',
|
||||
expectedText: 'Create a new team',
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user