Skip to content

Commit 2c0df8c

Browse files
committed
✅(tests) adds customization for translations
Part of customization PoC
1 parent a47af11 commit 2c0df8c

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

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

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const config = {
1010
COLLABORATION_WS_URL: 'ws://localhost:4444/collaboration/ws/',
1111
ENVIRONMENT: 'development',
1212
FRONTEND_CSS_URL: null,
13+
FRONTEND_CUSTOM_TRANSLATIONS_URL: null,
1314
FRONTEND_FOOTER_FEATURE_ENABLED: true,
1415
FRONTEND_THEME: 'default',
1516
MEDIA_BASE_URL: 'http://localhost:8083',
@@ -190,6 +191,67 @@ test.describe('Config', () => {
190191
.first(),
191192
).toBeAttached();
192193
});
194+
195+
test('it checks FRONTEND_CUSTOM_TRANSLATIONS_URL config', async ({
196+
page,
197+
}) => {
198+
// Create mock URL for translations
199+
const mockTranslationsUrl =
200+
'http://dummyhost.example.com/translations/custom.json';
201+
202+
// Mock the config endpoint to include the custom translations URL
203+
await page.route('**/api/v1.0/config/', async (route) => {
204+
const request = route.request();
205+
if (request.method().includes('GET')) {
206+
await route.fulfill({
207+
json: {
208+
...config,
209+
FRONTEND_CUSTOM_TRANSLATIONS_URL: mockTranslationsUrl,
210+
},
211+
});
212+
} else {
213+
await route.continue();
214+
}
215+
});
216+
217+
// Mock the translations endpoint to return our custom translations
218+
await page.route(mockTranslationsUrl, async (route) => {
219+
await route.fulfill({
220+
json: {
221+
en: {
222+
translation: {
223+
Docs: 'CustomDocsEn',
224+
},
225+
},
226+
fr: {
227+
translation: {
228+
Docs: 'CustomDocsFR',
229+
},
230+
},
231+
},
232+
status: 200,
233+
headers: {
234+
'Content-Type': 'application/json',
235+
'Access-Control-Allow-Origin': '*',
236+
},
237+
});
238+
});
239+
240+
// Intercept requests to the translations URL
241+
const translationsPromise = page.waitForRequest((req) => {
242+
return req.url() === mockTranslationsUrl;
243+
});
244+
245+
// Navigate to the page
246+
await page.goto('/');
247+
248+
// Verify that the application attempted to load the translations
249+
const translationsRequest = await translationsPromise;
250+
expect(translationsRequest).toBeTruthy();
251+
252+
// Extra test to prove that the translations were applied
253+
await expect(page.getByText('CustomDocsEn')).toBeAttached();
254+
});
193255
});
194256

195257
test.describe('Config: Not loggued', () => {

0 commit comments

Comments
 (0)