Skip to content

Commit d63550d

Browse files
committed
✅(e2e) e2e instances compatibility
We want to be able to run our e2e tests on any instance of Docs, to do so we need to make some adjustments to our tests and configuration. We will use environment variables to configure the tests.
1 parent 4b4319d commit d63550d

31 files changed

Lines changed: 1060 additions & 764 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to
1010

1111
- 🔧(backend) settings CONVERSION_UPLOAD_ENABLED to control usage of docspec
1212
- 🥚(frontend) add easter egg on doc emoji creation #2155
13+
- ✅ E2E - Any instance friendly #2142
1314

1415
### Changed
1516

src/frontend/apps/e2e/.env

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PORT=3000
2+
BASE_URL=http://localhost:3000
3+
BASE_API_URL=http://localhost:8071/api/v1.0
4+
COLLABORATION_WS_URL=ws://localhost:4444/collaboration/ws/
5+
COLLABORATION_WS_NOT_CONNECTED_READY_ONLY=true
6+
MEDIA_BASE_URL=http://localhost:8083
7+
CUSTOM_SIGN_IN=false
8+
IS_INSTANCE=false
9+
SIGN_IN_EL_LOGIN_PAGE='.login-pf #kc-header-wrapper'
10+
SIGN_IN_EL_TRIGGER=Start Writing
11+
FIRST_NAME=E2E
12+
SIGN_IN_USERNAME_CHROMIUM=user.test@chromium.test
13+
USERNAME_CHROMIUM=E2E Chromium
14+
SIGN_IN_USERNAME_WEBKIT=user.test@webkit.test
15+
USERNAME_WEBKIT=E2E Webkit
16+
SIGN_IN_USERNAME_FIREFOX=user.test@firefox.test
17+
USERNAME_FIREFOX=E2E Firefox
18+
# To test server to server API calls
19+
SERVER_TO_SERVER_API_TOKENS='server-api-token'
20+
SUB_CHROMIUM=user.test@chromium.test
21+
SUB_WEBKIT=user.test@webkit.test
22+
SUB_FIREFOX=user.test@firefox.test

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
PORT=3000
2+
BASE_URL=http://localhost:3000
3+
BASE_API_URL=http://localhost:8071/api/v1.0
4+
COLLABORATION_WS_URL=ws://localhost:4444/collaboration/ws/
5+
COLLABORATION_WS_NOT_CONNECTED_READY_ONLY=true
6+
MEDIA_BASE_URL=http://localhost:8083
7+
IS_INSTANCE=false
8+
CUSTOM_SIGN_IN=false
9+
SIGN_IN_EL_LOGIN_PAGE='.login-pf #kc-header-wrapper'
10+
SIGN_IN_EL_TRIGGER=Start Writing
11+
FIRST_NAME=E2E
12+
SIGN_IN_USERNAME_CHROMIUM=user.test@chromium.test
13+
USERNAME_CHROMIUM=E2E Chromium
14+
SIGN_IN_USERNAME_WEBKIT=user.test@webkit.test
15+
USERNAME_WEBKIT=E2E Webkit
16+
SIGN_IN_USERNAME_FIREFOX=user.test@firefox.test
17+
USERNAME_FIREFOX=E2E Firefox
18+
# Used only on instance with custom sign in
19+
SIGN_IN_EL_USERNAME_INPUT=
20+
SIGN_IN_EL_USERNAME_VALIDATION=
21+
SIGN_IN_EL_PASSWORD_INPUT=
22+
SIGN_IN_PASSWORD_CHROMIUM=
23+
SIGN_IN_PASSWORD_WEBKIT=
24+
SIGN_IN_PASSWORD_FIREFOX=
25+
# To test server to server API calls
26+
SERVER_TO_SERVER_API_TOKENS='server-api-token'
27+
SUB_CHROMIUM=user.test@chromium.test
28+
SUB_WEBKIT=user.test@webkit.test
29+
SUB_FIREFOX=user.test@firefox.test

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: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,25 @@ import { expect, test } from '@playwright/test';
55
import { CONFIG, createDoc, overrideConfig } from './utils-common';
66

77
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',
8+
if (process.env.IS_INSTANCE !== 'true') {
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
});
14-
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-
});
26+
}
2527

2628
test('it checks that media server is configured from config endpoint', async ({
2729
page,
@@ -55,7 +57,7 @@ test.describe('Config', () => {
5557

5658
// Check src of image
5759
expect(await image.getAttribute('src')).toMatch(
58-
/http:\/\/localhost:8083\/media\/.*\/attachments\/.*.png/,
60+
new RegExp(`${process.env.MEDIA_BASE_URL}/media/.*?/attachments/.*?.png`),
5961
);
6062
});
6163

@@ -71,9 +73,9 @@ test.describe('Config', () => {
7173
.click();
7274

7375
const webSocket = await page.waitForEvent('websocket', (webSocket) => {
74-
return webSocket.url().includes('ws://localhost:4444/collaboration/ws/');
76+
return webSocket.url().includes(`${process.env.COLLABORATION_WS_URL}`);
7577
});
76-
expect(webSocket.url()).toContain('ws://localhost:4444/collaboration/ws/');
78+
expect(webSocket.url()).toContain(`${process.env.COLLABORATION_WS_URL}`);
7779
});
7880

7981
test('it checks that Crisp is trying to init from config endpoint', async ({
@@ -85,9 +87,8 @@ test.describe('Config', () => {
8587

8688
await page.goto('/');
8789

88-
await expect(
89-
page.locator('#crisp-chatbox').getByText('Invalid website'),
90-
).toBeVisible();
90+
const crispElement = page.locator('#crisp-chatbox');
91+
await expect(crispElement).toBeAttached();
9192
});
9293

9394
test('it checks FRONTEND_CSS_URL config', async ({ page }) => {
@@ -118,20 +119,22 @@ test.describe('Config', () => {
118119
).toBeAttached();
119120
});
120121

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-
);
122+
if (process.env.IS_INSTANCE !== 'true') {
123+
test('it checks the config api is called', async ({ page }) => {
124+
const responsePromise = page.waitForResponse(
125+
(response) =>
126+
response.url().includes('/config/') && response.status() === 200,
127+
);
126128

127-
await page.goto('/');
129+
await page.goto('/');
128130

129-
const response = await responsePromise;
130-
expect(response.ok()).toBeTruthy();
131+
const response = await responsePromise;
132+
expect(response.ok()).toBeTruthy();
131133

132-
const json = (await response.json()) as typeof CONFIG;
133-
expect(json).toStrictEqual(CONFIG);
134-
});
134+
const json = (await response.json()) as typeof CONFIG;
135+
expect(json).toStrictEqual(CONFIG);
136+
});
137+
}
135138
});
136139

137140
test.describe('Config: Not logged', () => {

0 commit comments

Comments
 (0)