Skip to content

Commit 33ccd2d

Browse files
committed
save
1 parent cbe6a67 commit 33ccd2d

13 files changed

Lines changed: 571 additions & 415 deletions

File tree

src/frontend/apps/e2e/.env

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
PORT=3000
2+
BASE_URL=http://localhost:3000
3+
CUSTOM_SIGN_IN=false
4+
TEST_INSTANCE_ONLY=false
5+
SIGN_IN_EL_TRIGGER=Start Writing
6+
FIRST_NAME=E2E
7+
SIGN_IN_USERNAME_CHROMIUM=user.test@chromium.test
8+
SIGN_IN_USERNAME_WEBKIT=user.test@webkit.com
9+
SIGN_IN_USERNAME_FIREFOX=user.test@firefox.com
10+
# To test server to server API calls
11+
SERVER_TO_SERVER_API_TOKENS='server-api-token'
12+
SUB_CHROMIUM=user.test@chromium.test
13+
SUB_WEBKIT=user.test@webkit.com
14+
SUB_FIREFOX=user.test@firefox.com

src/frontend/apps/e2e/.env.example

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
PORT=3000
2+
BASE_URL=http://localhost:3000
3+
TEST_INSTANCE_ONLY=false
4+
CUSTOM_SIGN_IN=false
5+
SIGN_IN_EL_TRIGGER=Start Writing
6+
FIRST_NAME=E2E
7+
SIGN_IN_USERNAME_CHROMIUM=user.test@chromium.test
8+
SIGN_IN_USERNAME_WEBKIT=user.test@webkit.com
9+
SIGN_IN_USERNAME_FIREFOX=user.test@firefox.com
10+
# Used only on instance with custom sign in
11+
SIGN_IN_EL_USERNAME_INPUT=
12+
SIGN_IN_EL_USERNAME_VALIDATION=
13+
SIGN_IN_EL_PASSWORD_INPUT=
14+
SIGN_IN_PASSWORD_CHROMIUM=
15+
SIGN_IN_PASSWORD_WEBKIT=
16+
SIGN_IN_PASSWORD_FIREFOX=
17+
# To test server to server API calls
18+
SERVER_TO_SERVER_API_TOKENS='server-api-token'
19+
SUB_CHROMIUM=user.test@chromium.test
20+
SUB_WEBKIT=user.test@webkit.com
21+
SUB_FIREFOX=user.test@firefox.com

src/frontend/apps/e2e/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ blob-report/
55
playwright/.auth/
66
playwright/.cache/
77
screenshots/
8+
.env.local

src/frontend/apps/e2e/__tests__/app-impress/auth.setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FullConfig, FullProject, chromium, expect } from '@playwright/test';
22

3-
import { keyCloakSignIn } from './utils-common';
3+
import { SignIn } from './utils-signin';
44

55
const saveStorageState = async (
66
browserConfig: FullProject<unknown, unknown>,
@@ -22,7 +22,7 @@ const saveStorageState = async (
2222
await page.content();
2323
await expect(page.getByText('Docs').first()).toBeVisible();
2424

25-
await keyCloakSignIn(page, browserName);
25+
await SignIn(page, browserName);
2626

2727
await expect(
2828
page.locator('header').first().getByRole('button', {

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

Lines changed: 126 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -4,160 +4,166 @@ import { expect, test } from '@playwright/test';
44

55
import { CONFIG, createDoc, overrideConfig } from './utils-common';
66

7-
test.describe('Config', () => {
8-
test('it checks that sentry is trying to init from config endpoint', async ({
9-
page,
10-
}) => {
11-
await overrideConfig(page, {
12-
SENTRY_DSN: 'https://sentry.io/123',
7+
if (process.env.TEST_INSTANCE_ONLY !== 'true') {
8+
test.describe('Config', () => {
9+
test('it checks that sentry is trying to init from config endpoint', async ({
10+
page,
11+
}) => {
12+
await overrideConfig(page, {
13+
SENTRY_DSN: 'https://sentry.io/123',
14+
});
15+
16+
const invalidMsg = 'Invalid Sentry Dsn: https://sentry.io/123';
17+
const consoleMessage = page.waitForEvent('console', {
18+
timeout: 5000,
19+
predicate: (msg) => msg.text().includes(invalidMsg),
20+
});
21+
22+
await page.goto('/');
23+
24+
expect((await consoleMessage).text()).toContain(invalidMsg);
1325
});
1426

15-
const invalidMsg = 'Invalid Sentry Dsn: https://sentry.io/123';
16-
const consoleMessage = page.waitForEvent('console', {
17-
timeout: 5000,
18-
predicate: (msg) => msg.text().includes(invalidMsg),
19-
});
20-
21-
await page.goto('/');
22-
23-
expect((await consoleMessage).text()).toContain(invalidMsg);
24-
});
25-
26-
test('it checks that media server is configured from config endpoint', async ({
27-
page,
28-
browserName,
29-
}) => {
30-
await page.goto('/');
27+
test('it checks that media server is configured from config endpoint', async ({
28+
page,
29+
browserName,
30+
}) => {
31+
await page.goto('/');
3132

32-
await createDoc(page, 'doc-media', browserName, 1);
33+
await createDoc(page, 'doc-media', browserName, 1);
3334

34-
const fileChooserPromise = page.waitForEvent('filechooser');
35+
const fileChooserPromise = page.waitForEvent('filechooser');
3536

36-
await page.locator('.bn-block-outer').last().fill('Anything');
37-
await page.locator('.bn-block-outer').last().fill('/');
38-
await page.getByText('Resizable image with caption').click();
39-
await page.getByText('Upload image').click();
37+
await page.locator('.bn-block-outer').last().fill('Anything');
38+
await page.locator('.bn-block-outer').last().fill('/');
39+
await page.getByText('Resizable image with caption').click();
40+
await page.getByText('Upload image').click();
4041

41-
const fileChooser = await fileChooserPromise;
42-
await fileChooser.setFiles(
43-
path.join(__dirname, 'assets/logo-suite-numerique.png'),
44-
);
42+
const fileChooser = await fileChooserPromise;
43+
await fileChooser.setFiles(
44+
path.join(__dirname, 'assets/logo-suite-numerique.png'),
45+
);
4546

46-
const image = page
47-
.locator('.--docs--editor-container img.bn-visual-media')
48-
.first();
47+
const image = page
48+
.locator('.--docs--editor-container img.bn-visual-media')
49+
.first();
4950

50-
await expect(image).toBeVisible();
51-
52-
// Wait for the media-check to be processed
53-
54-
await page.waitForTimeout(1000);
55-
56-
// Check src of image
57-
expect(await image.getAttribute('src')).toMatch(
58-
/http:\/\/localhost:8083\/media\/.*\/attachments\/.*.png/,
59-
);
60-
});
51+
await expect(image).toBeVisible();
6152

62-
test('it checks that collaboration server is configured from config endpoint', async ({
63-
page,
64-
}) => {
65-
await page.goto('/');
53+
// Wait for the media-check to be processed
6654

67-
void page
68-
.getByRole('button', {
69-
name: 'New doc',
70-
})
71-
.click();
55+
await page.waitForTimeout(1000);
7256

73-
const webSocket = await page.waitForEvent('websocket', (webSocket) => {
74-
return webSocket.url().includes('ws://localhost:4444/collaboration/ws/');
57+
// Check src of image
58+
expect(await image.getAttribute('src')).toMatch(
59+
/http:\/\/localhost:8083\/media\/.*\/attachments\/.*.png/,
60+
);
7561
});
76-
expect(webSocket.url()).toContain('ws://localhost:4444/collaboration/ws/');
77-
});
7862

79-
test('it checks that Crisp is trying to init from config endpoint', async ({
80-
page,
81-
}) => {
82-
await overrideConfig(page, {
83-
CRISP_WEBSITE_ID: '1234',
63+
test('it checks that collaboration server is configured from config endpoint', async ({
64+
page,
65+
}) => {
66+
await page.goto('/');
67+
68+
void page
69+
.getByRole('button', {
70+
name: 'New doc',
71+
})
72+
.click();
73+
74+
const webSocket = await page.waitForEvent('websocket', (webSocket) => {
75+
return webSocket
76+
.url()
77+
.includes('ws://localhost:4444/collaboration/ws/');
78+
});
79+
expect(webSocket.url()).toContain(
80+
'ws://localhost:4444/collaboration/ws/',
81+
);
8482
});
8583

86-
await page.goto('/');
84+
test('it checks that Crisp is trying to init from config endpoint', async ({
85+
page,
86+
}) => {
87+
await overrideConfig(page, {
88+
CRISP_WEBSITE_ID: '1234',
89+
});
8790

88-
await expect(
89-
page.locator('#crisp-chatbox').getByText('Invalid website'),
90-
).toBeVisible();
91-
});
91+
await page.goto('/');
9292

93-
test('it checks FRONTEND_CSS_URL config', async ({ page }) => {
94-
await overrideConfig(page, {
95-
FRONTEND_CSS_URL: 'http://localhost:123465/css/style.css',
93+
await expect(
94+
page.locator('#crisp-chatbox').getByText('Invalid website'),
95+
).toBeVisible();
9696
});
9797

98-
await page.goto('/');
98+
test('it checks FRONTEND_CSS_URL config', async ({ page }) => {
99+
await overrideConfig(page, {
100+
FRONTEND_CSS_URL: 'http://localhost:123465/css/style.css',
101+
});
99102

100-
await expect(
101-
page
102-
.locator('head link[href="http://localhost:123465/css/style.css"]')
103-
.first(),
104-
).toBeAttached();
105-
});
103+
await page.goto('/');
106104

107-
test('it checks FRONTEND_JS_URL config', async ({ page }) => {
108-
await overrideConfig(page, {
109-
FRONTEND_JS_URL: 'http://localhost:123465/js/script.js',
105+
await expect(
106+
page
107+
.locator('head link[href="http://localhost:123465/css/style.css"]')
108+
.first(),
109+
).toBeAttached();
110110
});
111111

112-
await page.goto('/');
112+
test('it checks FRONTEND_JS_URL config', async ({ page }) => {
113+
await overrideConfig(page, {
114+
FRONTEND_JS_URL: 'http://localhost:123465/js/script.js',
115+
});
113116

114-
await expect(
115-
page
116-
.locator('script[src="http://localhost:123465/js/script.js"]')
117-
.first(),
118-
).toBeAttached();
119-
});
117+
await page.goto('/');
120118

121-
test('it checks the config api is called', async ({ page }) => {
122-
const responsePromise = page.waitForResponse(
123-
(response) =>
124-
response.url().includes('/config/') && response.status() === 200,
125-
);
119+
await expect(
120+
page
121+
.locator('script[src="http://localhost:123465/js/script.js"]')
122+
.first(),
123+
).toBeAttached();
124+
});
126125

127-
await page.goto('/');
126+
test('it checks the config api is called', async ({ page }) => {
127+
const responsePromise = page.waitForResponse(
128+
(response) =>
129+
response.url().includes('/config/') && response.status() === 200,
130+
);
128131

129-
const response = await responsePromise;
130-
expect(response.ok()).toBeTruthy();
132+
await page.goto('/');
131133

132-
const json = (await response.json()) as typeof CONFIG;
133-
expect(json).toStrictEqual(CONFIG);
134+
const response = await responsePromise;
135+
expect(response.ok()).toBeTruthy();
136+
137+
const json = (await response.json()) as typeof CONFIG;
138+
expect(json).toStrictEqual(CONFIG);
139+
});
134140
});
135-
});
136141

137-
test.describe('Config: Not logged', () => {
138-
test.use({ storageState: { cookies: [], origins: [] } });
142+
test.describe('Config: Not logged', () => {
143+
test.use({ storageState: { cookies: [], origins: [] } });
139144

140-
test('it checks that theme is configured from config endpoint', async ({
141-
page,
142-
}) => {
143-
await page.goto('/');
145+
test('it checks that theme is configured from config endpoint', async ({
146+
page,
147+
}) => {
148+
await page.goto('/');
144149

145-
await expect(
146-
page.getByText('Collaborative writing, Simplified.'),
147-
).toHaveCSS('font-family', /Roboto/i, {
148-
timeout: 10000,
149-
});
150+
await expect(
151+
page.getByText('Collaborative writing, Simplified.'),
152+
).toHaveCSS('font-family', /Roboto/i, {
153+
timeout: 10000,
154+
});
150155

151-
await overrideConfig(page, {
152-
FRONTEND_THEME: 'dsfr',
153-
});
156+
await overrideConfig(page, {
157+
FRONTEND_THEME: 'dsfr',
158+
});
154159

155-
await page.goto('/');
160+
await page.goto('/');
156161

157-
await expect(
158-
page.getByText('Collaborative writing, Simplified.'),
159-
).toHaveCSS('font-family', /Marianne/i, {
160-
timeout: 10000,
162+
await expect(
163+
page.getByText('Collaborative writing, Simplified.'),
164+
).toHaveCSS('font-family', /Marianne/i, {
165+
timeout: 10000,
166+
});
161167
});
162168
});
163-
});
169+
}

0 commit comments

Comments
 (0)