2024-11-15 16:11:08 +01:00
|
|
|
import path from 'path';
|
|
|
|
|
|
2024-11-15 09:33:08 +01:00
|
|
|
import { expect, test } from '@playwright/test';
|
|
|
|
|
|
2024-11-25 12:10:16 +01:00
|
|
|
import { createDoc, verifyDocName } from './common';
|
2024-11-15 16:11:08 +01:00
|
|
|
|
2024-11-15 14:34:45 +01:00
|
|
|
const config = {
|
2024-11-25 16:50:12 +01:00
|
|
|
CRISP_WEBSITE_ID: null,
|
2025-03-19 15:41:05 +01:00
|
|
|
COLLABORATION_WS_URL: 'ws://localhost:4444/collaboration/ws/',
|
2024-11-15 14:34:45 +01:00
|
|
|
ENVIRONMENT: 'development',
|
2025-03-20 17:18:22 +01:00
|
|
|
FRONTEND_THEME: 'default',
|
2024-11-15 14:34:45 +01:00
|
|
|
MEDIA_BASE_URL: 'http://localhost:8083',
|
|
|
|
|
LANGUAGES: [
|
|
|
|
|
['en-us', 'English'],
|
2025-03-04 16:08:39 +01:00
|
|
|
['fr-fr', 'Français'],
|
|
|
|
|
['de-de', 'Deutsch'],
|
2025-03-17 15:02:49 +01:00
|
|
|
['nl-nl', 'Nederlands'],
|
2024-11-15 14:34:45 +01:00
|
|
|
],
|
|
|
|
|
LANGUAGE_CODE: 'en-us',
|
2025-01-21 14:18:44 +01:00
|
|
|
POSTHOG_KEY: {},
|
2024-11-15 14:34:45 +01:00
|
|
|
SENTRY_DSN: null,
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-15 09:33:08 +01:00
|
|
|
test.describe('Config', () => {
|
|
|
|
|
test('it checks the config api is called', async ({ page }) => {
|
|
|
|
|
const responsePromise = page.waitForResponse(
|
|
|
|
|
(response) =>
|
|
|
|
|
response.url().includes('/config/') && response.status() === 200,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await page.goto('/');
|
|
|
|
|
|
|
|
|
|
const response = await responsePromise;
|
|
|
|
|
expect(response.ok()).toBeTruthy();
|
|
|
|
|
|
2024-11-15 14:34:45 +01:00
|
|
|
expect(await response.json()).toStrictEqual(config);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('it checks that sentry is trying to init from config endpoint', async ({
|
|
|
|
|
page,
|
|
|
|
|
}) => {
|
|
|
|
|
await page.route('**/api/v1.0/config/', async (route) => {
|
|
|
|
|
const request = route.request();
|
|
|
|
|
if (request.method().includes('GET')) {
|
|
|
|
|
await route.fulfill({
|
|
|
|
|
json: {
|
|
|
|
|
...config,
|
|
|
|
|
SENTRY_DSN: 'https://sentry.io/123',
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await route.continue();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const invalidMsg = 'Invalid Sentry Dsn: https://sentry.io/123';
|
|
|
|
|
const consoleMessage = page.waitForEvent('console', {
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
predicate: (msg) => msg.text().includes(invalidMsg),
|
2024-11-15 09:33:08 +01:00
|
|
|
});
|
2024-11-15 14:34:45 +01:00
|
|
|
|
|
|
|
|
await page.goto('/');
|
|
|
|
|
|
|
|
|
|
expect((await consoleMessage).text()).toContain(invalidMsg);
|
2024-11-15 09:33:08 +01:00
|
|
|
});
|
2024-11-15 15:07:10 +01:00
|
|
|
|
2024-11-15 16:11:08 +01:00
|
|
|
test('it checks that media server is configured from config endpoint', async ({
|
|
|
|
|
page,
|
|
|
|
|
browserName,
|
|
|
|
|
}) => {
|
|
|
|
|
await page.goto('/');
|
|
|
|
|
|
|
|
|
|
await createDoc(page, 'doc-media', browserName, 1);
|
|
|
|
|
|
|
|
|
|
const fileChooserPromise = page.waitForEvent('filechooser');
|
|
|
|
|
|
2024-12-11 19:38:08 +01:00
|
|
|
await page.locator('.bn-block-outer').last().fill('Anything');
|
2024-11-15 16:11:08 +01:00
|
|
|
await page.locator('.bn-block-outer').last().fill('/');
|
|
|
|
|
await page.getByText('Resizable image with caption').click();
|
|
|
|
|
await page.getByText('Upload image').click();
|
|
|
|
|
|
|
|
|
|
const fileChooser = await fileChooserPromise;
|
|
|
|
|
await fileChooser.setFiles(
|
|
|
|
|
path.join(__dirname, 'assets/logo-suite-numerique.png'),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const image = page.getByRole('img', { name: 'logo-suite-numerique.png' });
|
|
|
|
|
|
|
|
|
|
await expect(image).toBeVisible();
|
|
|
|
|
|
|
|
|
|
// Check src of image
|
|
|
|
|
expect(await image.getAttribute('src')).toMatch(
|
|
|
|
|
/http:\/\/localhost:8083\/media\/.*\/attachments\/.*.png/,
|
|
|
|
|
);
|
|
|
|
|
});
|
2024-11-21 10:43:01 +01:00
|
|
|
|
|
|
|
|
test('it checks that collaboration server is configured from config endpoint', async ({
|
|
|
|
|
page,
|
|
|
|
|
browserName,
|
|
|
|
|
}) => {
|
|
|
|
|
const webSocketPromise = page.waitForEvent('websocket', (webSocket) => {
|
2025-03-19 15:41:05 +01:00
|
|
|
return webSocket.url().includes('ws://localhost:4444/collaboration/ws/');
|
2024-11-21 10:43:01 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await page.goto('/');
|
|
|
|
|
|
|
|
|
|
const randomDoc = await createDoc(
|
|
|
|
|
page,
|
|
|
|
|
'doc-collaboration',
|
|
|
|
|
browserName,
|
|
|
|
|
1,
|
|
|
|
|
);
|
2024-11-25 12:10:16 +01:00
|
|
|
|
|
|
|
|
await verifyDocName(page, randomDoc[0]);
|
2024-11-21 10:43:01 +01:00
|
|
|
|
|
|
|
|
const webSocket = await webSocketPromise;
|
2025-03-19 15:41:05 +01:00
|
|
|
expect(webSocket.url()).toContain('ws://localhost:4444/collaboration/ws/');
|
2024-11-21 10:43:01 +01:00
|
|
|
});
|
2024-11-25 16:50:12 +01:00
|
|
|
|
|
|
|
|
test('it checks that Crisp is trying to init from config endpoint', async ({
|
|
|
|
|
page,
|
|
|
|
|
}) => {
|
|
|
|
|
await page.route('**/api/v1.0/config/', async (route) => {
|
|
|
|
|
const request = route.request();
|
|
|
|
|
if (request.method().includes('GET')) {
|
|
|
|
|
await route.fulfill({
|
|
|
|
|
json: {
|
|
|
|
|
...config,
|
|
|
|
|
CRISP_WEBSITE_ID: '1234',
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await route.continue();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await page.goto('/');
|
|
|
|
|
|
|
|
|
|
await expect(
|
|
|
|
|
page.locator('#crisp-chatbox').getByText('Invalid website'),
|
|
|
|
|
).toBeVisible();
|
|
|
|
|
});
|
2024-11-15 09:33:08 +01:00
|
|
|
});
|
2025-02-03 11:02:29 +01:00
|
|
|
|
|
|
|
|
test.describe('Config: Not loggued', () => {
|
|
|
|
|
test.use({ storageState: { cookies: [], origins: [] } });
|
|
|
|
|
|
|
|
|
|
test('it checks that theme is configured from config endpoint', async ({
|
|
|
|
|
page,
|
|
|
|
|
}) => {
|
|
|
|
|
const responsePromise = page.waitForResponse(
|
|
|
|
|
(response) =>
|
|
|
|
|
response.url().includes('/config/') && response.status() === 200,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await page.goto('/');
|
|
|
|
|
|
|
|
|
|
const response = await responsePromise;
|
|
|
|
|
expect(response.ok()).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
const jsonResponse = await response.json();
|
2025-03-20 17:18:22 +01:00
|
|
|
expect(jsonResponse.FRONTEND_THEME).toStrictEqual('default');
|
2025-02-03 11:02:29 +01:00
|
|
|
|
|
|
|
|
const footer = page.locator('footer').first();
|
|
|
|
|
// alt 'Gouvernement Logo' comes from the theme
|
|
|
|
|
await expect(footer.getByAltText('Gouvernement Logo')).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
});
|