@aerokit/sdk 14.68.0 → 14.69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aerokit/sdk",
3
- "version": "14.68.0",
3
+ "version": "14.69.0",
4
4
  "description": "Unified TypeScript SDK for modern cloud platforms.",
5
5
  "scripts": {
6
6
  "clean": "rm -rf dist",
@@ -1,6 +1,11 @@
1
1
  import { expect, test } from '../fixtures.js';
2
2
  import { listCrumb } from './list.js';
3
3
 
4
+ const LANGUAGE_KEY = 'codbex.harmonia.language';
5
+ // A reload in another language is three round trips on a cold instance - the page, the list's
6
+ // data GET and the translation overlay behind it - so the 5 s default flaked on slower runners.
7
+ const OVERLAY_TIMEOUT = 15_000;
8
+
4
9
  // The read-time translation overlay: switch the shared language key (what the Region &
5
10
  // Language setting writes), reload, and a known seed row shows its translated name.
6
11
  // Needs a concrete sample in the manifest: { language, base, translated }.
@@ -11,11 +16,45 @@ export function multilingualFlow(manifest, entity) {
11
16
  test(`${entity.name}: ${sample.language} translation overlays on read`, async ({ page }) => {
12
17
  await page.goto(manifest.standaloneShell + entity.route);
13
18
  await expect(listCrumb(page, entity)).toBeVisible();
14
- await page.evaluate((lang) => localStorage.setItem('codbex.harmonia.language', lang), sample.language);
15
- await page.reload();
16
- await expect(page.locator('tbody tr', { hasText: sample.translated }).first()).toBeVisible();
17
- await page.evaluate(() => localStorage.setItem('codbex.harmonia.language', 'en'));
18
- await page.reload();
19
- await expect(page.locator('tbody tr', { hasText: sample.base }).first()).toBeVisible();
19
+ const translatedRead = await reloadIn(page, manifest, entity, sample.language);
20
+ await expectRowShowing(page, sample.translated, translatedRead);
21
+ const baseRead = await reloadIn(page, manifest, entity, 'en');
22
+ await expectRowShowing(page, sample.base, baseRead);
20
23
  });
21
24
  }
25
+
26
+ // Set the language key and reload, waiting for the list's own data GET (the paged getAll on the
27
+ // entity's controller) so the assertion starts once the rows are on their way, and answering what
28
+ // that read asked for and got back - which is what tells a slow render from a missing translation.
29
+ async function reloadIn(page, manifest, entity, language) {
30
+ await page.evaluate(([key, lang]) => localStorage.setItem(key, lang), [LANGUAGE_KEY, language]);
31
+ const controllerPath = manifest.restBase + entity.api;
32
+ const listRead = page.waitForResponse(
33
+ (response) => response.request().method() === 'GET' && new URL(response.url()).pathname === controllerPath,
34
+ { timeout: OVERLAY_TIMEOUT },
35
+ );
36
+ await page.reload();
37
+ const response = await listRead;
38
+ return {
39
+ language,
40
+ acceptLanguage: await response.request().headerValue('accept-language'),
41
+ status: response.status(),
42
+ body: await response.text(),
43
+ };
44
+ }
45
+
46
+ async function expectRowShowing(page, text, read) {
47
+ const rows = page.locator('tbody tr');
48
+ try {
49
+ await expect(rows.filter({ hasText: text }).first()).toBeVisible({ timeout: OVERLAY_TIMEOUT });
50
+ } catch (error) {
51
+ const firstRow = (await rows.allInnerTexts())[0]?.replace(/\s+/g, ' ').trim();
52
+ throw new Error(
53
+ `no list row shows '${text}' after reloading in '${read.language}': the list GET sent Accept-Language ` +
54
+ `${read.acceptLanguage ?? '(none)'} and answered ${read.status}, ` +
55
+ `${read.body.includes(text) ? 'WITH' : 'WITHOUT'} '${text}' in its body; the table's first row reads ` +
56
+ `${firstRow ? `'${firstRow}'` : '(no rows)'}`,
57
+ { cause: error },
58
+ );
59
+ }
60
+ }