Skip to content

Commit 36b0ff9

Browse files
committed
✨(frontend) create generic theme
By default Docs will not be on the dsfr theme but on the generic theme. La Gaufre is part of the dsfr theme and is removed from the generic theme. Same for the "beta" keyword and the "proconnect" buttons.
1 parent 7a38395 commit 36b0ff9

31 files changed

+1048
-293
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to
1818
- ✨(backend) integrate maleware_detection from django-lasuite #936
1919
- 🏗️(frontend) Footer configurable #959
2020
- 🩺(CI) add lint spell mistakes #954
21+
- ✨(frontend) create generic theme #792
2122
- 🛂(frontend) block edition to not connected users #945
2223
- 🚸 Let loader during upload analyze #984
2324

env.d/development/common.dist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,3 @@ COLLABORATION_BACKEND_BASE_URL=http://app-dev:8000
6161
COLLABORATION_SERVER_ORIGIN=http://localhost:3000
6262
COLLABORATION_SERVER_SECRET=my-secret
6363
COLLABORATION_WS_URL=ws://localhost:4444/collaboration/ws/
64-
65-
# Frontend
66-
FRONTEND_THEME=default

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ test.beforeEach(async ({ page }) => {
1010

1111
test.describe('404', () => {
1212
test('Checks all the elements are visible', async ({ page }) => {
13-
await expect(page.getByLabel('Image 404')).toBeVisible();
14-
await expect(page.getByText('Ouch')).toBeVisible();
1513
await expect(
1614
page.getByText(
1715
'It seems that the page you are looking for does not exist or cannot be displayed correctly.',

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const CONFIG = {
77
ENVIRONMENT: 'development',
88
FRONTEND_CSS_URL: null,
99
FRONTEND_HOMEPAGE_FEATURE_ENABLED: true,
10-
FRONTEND_THEME: 'default',
10+
FRONTEND_THEME: null,
1111
MEDIA_BASE_URL: 'http://localhost:8083',
1212
LANGUAGES: [
1313
['en-us', 'English'],
@@ -20,7 +20,7 @@ export const CONFIG = {
2020
POSTHOG_KEY: {},
2121
SENTRY_DSN: null,
2222
theme_customization: {},
23-
};
23+
} as const;
2424

2525
export const overrideConfig = async (
2626
page: Page,
@@ -46,10 +46,7 @@ export const keyCloakSignIn = async (
4646
fromHome: boolean = true,
4747
) => {
4848
if (fromHome) {
49-
await page
50-
.getByRole('button', { name: 'Proconnect Login' })
51-
.first()
52-
.click();
49+
await page.getByRole('button', { name: 'Start Writing' }).first().click();
5350
}
5451

5552
const login = `user-e2e-${browserName}`;
@@ -109,9 +106,16 @@ export const createDoc = async (
109106
};
110107

111108
export const verifyDocName = async (page: Page, docName: string) => {
112-
const input = page.getByRole('textbox', { name: 'doc title input' });
109+
await expect(
110+
page.getByLabel('It is the card information about the document.'),
111+
).toBeVisible({
112+
timeout: 10000,
113+
});
114+
113115
try {
114-
await expect(input).toHaveText(docName);
116+
await expect(
117+
page.getByRole('textbox', { name: 'doc title input' }),
118+
).toHaveText(docName);
115119
} catch {
116120
await expect(page.getByRole('heading', { name: docName })).toBeVisible();
117121
}

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

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,6 @@ import { expect, test } from '@playwright/test';
55
import { CONFIG, createDoc, overrideConfig } from './common';
66

77
test.describe('Config', () => {
8-
test('it checks the config api is called', async ({ page }) => {
9-
const responsePromise = page.waitForResponse(
10-
(response) =>
11-
response.url().includes('/config/') && response.status() === 200,
12-
);
13-
14-
await page.goto('/');
15-
16-
const response = await responsePromise;
17-
expect(response.ok()).toBeTruthy();
18-
19-
const json = (await response.json()) as typeof CONFIG;
20-
const { theme_customization, ...configApi } = json;
21-
expect(theme_customization).toBeDefined();
22-
const { theme_customization: _, ...CONFIG_LEFT } = CONFIG;
23-
24-
expect(configApi).toStrictEqual(CONFIG_LEFT);
25-
});
26-
278
test('it checks that sentry is trying to init from config endpoint', async ({
289
page,
2910
}) => {
@@ -143,9 +124,7 @@ test.describe('Config', () => {
143124
test.describe('Config: Not loggued', () => {
144125
test.use({ storageState: { cookies: [], origins: [] } });
145126

146-
test('it checks that theme is configured from config endpoint', async ({
147-
page,
148-
}) => {
127+
test('it checks the config api is called', async ({ page }) => {
149128
const responsePromise = page.waitForResponse(
150129
(response) =>
151130
response.url().includes('/config/') && response.status() === 200,
@@ -156,8 +135,22 @@ test.describe('Config: Not loggued', () => {
156135
const response = await responsePromise;
157136
expect(response.ok()).toBeTruthy();
158137

159-
const jsonResponse = await response.json();
160-
expect(jsonResponse.FRONTEND_THEME).toStrictEqual('default');
138+
const json = (await response.json()) as typeof CONFIG;
139+
const { theme_customization, ...configApi } = json;
140+
expect(theme_customization).toBeDefined();
141+
const { theme_customization: _, ...CONFIG_LEFT } = CONFIG;
142+
143+
expect(configApi).toStrictEqual(CONFIG_LEFT);
144+
});
145+
146+
test('it checks that theme is configured from config endpoint', async ({
147+
page,
148+
}) => {
149+
await overrideConfig(page, {
150+
FRONTEND_THEME: 'dsfr',
151+
});
152+
153+
await page.goto('/');
161154

162155
const header = page.locator('header').first();
163156
// alt 'Gouvernement Logo' comes from the theme

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ test.describe('Documents filters', () => {
208208

209209
// Initial state
210210
await expect(allDocs).toBeVisible();
211-
await expect(allDocs).toHaveCSS('background-color', 'rgb(238, 238, 238)');
212211
await expect(allDocs).toHaveAttribute('aria-selected', 'true');
213212

214213
await expect(myDocs).toBeVisible();

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ test.describe('Doc Visibility: Restricted', () => {
101101
page,
102102
browserName,
103103
}) => {
104+
test.slow();
105+
104106
await page.goto('/');
105107
await keyCloakSignIn(page, browserName);
106108

@@ -121,14 +123,16 @@ test.describe('Doc Visibility: Restricted', () => {
121123
await keyCloakSignIn(page, otherBrowser!);
122124

123125
await expect(
124-
page.getByRole('link', { name: 'Docs Logo Docs BETA' }),
126+
page.getByRole('link', { name: 'Docs Logo Docs' }),
125127
).toBeVisible();
126128

127129
await page.goto(urlDoc);
128130

129131
await expect(
130132
page.getByText('You do not have permission to view this document.'),
131-
).toBeVisible();
133+
).toBeVisible({
134+
timeout: 10000,
135+
});
132136
});
133137

134138
test('A doc is accessible when member.', async ({ page, browserName }) => {
@@ -173,7 +177,7 @@ test.describe('Doc Visibility: Restricted', () => {
173177
await keyCloakSignIn(page, otherBrowser!);
174178

175179
await expect(
176-
page.getByRole('link', { name: 'Docs Logo Docs BETA' }),
180+
page.getByRole('link', { name: 'Docs Logo Docs' }),
177181
).toBeVisible();
178182

179183
await page.goto(urlDoc);
@@ -430,7 +434,7 @@ test.describe('Doc Visibility: Authenticated', () => {
430434
await keyCloakSignIn(page, otherBrowser!);
431435

432436
await expect(
433-
page.getByRole('link', { name: 'Docs Logo Docs BETA' }),
437+
page.getByRole('link', { name: 'Docs Logo Docs' }),
434438
).toBeVisible();
435439

436440
await page.goto(urlDoc);
@@ -490,7 +494,7 @@ test.describe('Doc Visibility: Authenticated', () => {
490494
await keyCloakSignIn(page, otherBrowser!);
491495

492496
await expect(
493-
page.getByRole('link', { name: 'Docs Logo Docs BETA' }),
497+
page.getByRole('link', { name: 'Docs Logo Docs' }),
494498
).toBeVisible();
495499

496500
await page.goto(urlDoc);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ test.describe('Footer', () => {
2020

2121
await expect(footer.getByAltText('Docs Logo')).toBeVisible();
2222
await expect(footer.getByRole('heading', { name: 'Docs' })).toBeVisible();
23-
await expect(footer.getByText('BETA')).toBeVisible();
2423

2524
await expect(footer.getByRole('link', { name: 'Github' })).toBeVisible();
2625
await expect(footer.getByRole('link', { name: 'DINUM' })).toBeVisible();
@@ -57,6 +56,7 @@ test.describe('Footer', () => {
5756

5857
test('checks the footer is correctly overrided', async ({ page }) => {
5958
await overrideConfig(page, {
59+
FRONTEND_THEME: 'dsfr',
6060
theme_customization: {
6161
footer: {
6262
default: {

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

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
11
import { expect, test } from '@playwright/test';
22

3-
import { expectLoginPage, keyCloakSignIn } from './common';
3+
import { expectLoginPage, keyCloakSignIn, overrideConfig } from './common';
44

55
test.describe('Header', () => {
6-
test.beforeEach(async ({ page }) => {
6+
test('checks all the elements are visible', async ({ page }) => {
77
await page.goto('/');
8-
});
98

10-
test('checks all the elements are visible', async ({ page }) => {
119
const header = page.locator('header').first();
1210

1311
await expect(header.getByLabel('Docs Logo')).toBeVisible();
1412
await expect(header.locator('h2').getByText('Docs')).toHaveCSS(
15-
'color',
16-
'rgb(0, 0, 145)',
13+
'font-family',
14+
/Roboto/i,
1715
);
16+
17+
await expect(
18+
header.getByRole('button', {
19+
name: 'Logout',
20+
}),
21+
).toBeVisible();
22+
23+
await expect(header.getByText('English')).toBeVisible();
24+
});
25+
26+
test('checks all the elements are visible with DSFR theme', async ({
27+
page,
28+
}) => {
29+
await overrideConfig(page, {
30+
FRONTEND_THEME: 'dsfr',
31+
});
32+
await page.goto('/');
33+
34+
const header = page.locator('header').first();
35+
36+
await expect(header.getByLabel('Docs Logo')).toBeVisible();
1837
await expect(header.locator('h2').getByText('Docs')).toHaveCSS(
1938
'font-family',
2039
/Marianne/i,
@@ -36,6 +55,11 @@ test.describe('Header', () => {
3655
});
3756

3857
test('checks La Gauffre interaction', async ({ page }) => {
58+
await overrideConfig(page, {
59+
FRONTEND_THEME: 'dsfr',
60+
});
61+
await page.goto('/');
62+
3963
const header = page.locator('header').first();
4064

4165
await expect(
@@ -68,11 +92,13 @@ test.describe('Header', () => {
6892
test.describe('Header mobile', () => {
6993
test.use({ viewport: { width: 500, height: 1200 } });
7094

71-
test.beforeEach(async ({ page }) => {
95+
test('it checks the header when mobile with DSFR theme', async ({ page }) => {
96+
await overrideConfig(page, {
97+
FRONTEND_THEME: 'dsfr',
98+
});
99+
72100
await page.goto('/');
73-
});
74101

75-
test('it checks the header when mobile', async ({ page }) => {
76102
const header = page.locator('header').first();
77103

78104
await expect(header.getByLabel('Open the header menu')).toBeVisible();

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,62 @@ test.beforeEach(async ({ page }) => {
99
test.describe('Home page', () => {
1010
test.use({ storageState: { cookies: [], origins: [] } });
1111
test('checks all the elements are visible', async ({ page }) => {
12+
await page.goto('/docs/');
13+
14+
// Check header content
15+
const header = page.locator('header').first();
16+
const footer = page.locator('footer').first();
17+
await expect(header).toBeVisible();
18+
await expect(
19+
header.getByRole('button', { name: /Language/ }),
20+
).toBeVisible();
21+
await expect(header.getByRole('img', { name: 'Docs logo' })).toBeVisible();
22+
await expect(header.getByRole('heading', { name: 'Docs' })).toBeVisible();
23+
24+
// Check the titles
25+
const h2 = page.locator('h2');
26+
await expect(h2.getByText('Govs ❤️ Open Source.')).toBeVisible();
27+
await expect(
28+
h2.getByText('Collaborative writing, Simplified.'),
29+
).toBeVisible();
30+
await expect(
31+
h2.getByText('An uncompromising writing experience.'),
32+
).toBeVisible();
33+
await expect(
34+
h2.getByText('Simple and secure collaboration.'),
35+
).toBeVisible();
36+
await expect(h2.getByText('Flexible export.')).toBeVisible();
37+
await expect(
38+
h2.getByText('A new way to organize knowledge.'),
39+
).toBeVisible();
40+
await expect(
41+
page.getByRole('button', { name: 'Start Writing' }),
42+
).toBeVisible();
43+
44+
await expect(footer).toBeVisible();
45+
});
46+
47+
test('checks all the elements are visible with dsfr theme', async ({
48+
page,
49+
}) => {
50+
await overrideConfig(page, {
51+
FRONTEND_THEME: 'dsfr',
52+
theme_customization: {
53+
footer: {
54+
default: {
55+
externalLinks: [
56+
{
57+
label: 'legifrance.gouv.fr',
58+
href: '#',
59+
},
60+
],
61+
},
62+
},
63+
},
64+
});
65+
66+
await page.goto('/docs/');
67+
1268
// Check header content
1369
const header = page.locator('header').first();
1470
const footer = page.locator('footer').first();

0 commit comments

Comments
 (0)