Skip to content

Commit 5c7d21f

Browse files
committed
fix deploy action
1 parent e2a50db commit 5c7d21f

3 files changed

Lines changed: 114 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ jobs:
6060
with:
6161
app-id: ${{ secrets.ADNO_BOT_APP_ID }}
6262
private-key: ${{ secrets.ADNO_BOT_PRIVATE_KEY }}
63-
repositories: site
63+
repositories: w.adno.app
6464
owner: adnodev
6565

6666
- name: Trigger prod deploy
6767
run: |
68-
curl -X POST \
68+
curl -fsS -X POST \
6969
-H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" \
70-
-H "Accept: application/vnd.github.v3+json" \
71-
https://api.github.com/repos/adno-org/site/dispatches \
70+
-H "Accept: application/vnd.github+json" \
71+
https://api.github.com/repos/adnodev/w.adno.app/dispatches \
7272
-d '{"event_type":"new_release","client_payload":{"version":"${{ github.event.inputs.version }}"}}'

tests/i18n/key-parity.spec.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// @ts-check
2+
//
3+
// Static i18n checks — no browser, no dev server needed.
4+
// `en.json` is the reference (it is the i18next `fallbackLng`): every other
5+
// locale must expose exactly the same set of leaf keys, with no empty values.
6+
//
7+
// These tests read the JSON files directly, so they run in milliseconds and
8+
// catch the most common translation regressions: a key added to `en` but not
9+
// translated elsewhere (-> silent English fallback in the UI), a stale key left
10+
// behind after a rename, or a key translated to an empty string.
11+
12+
const { test, expect } = require('@playwright/test');
13+
14+
const en = require('../../langs/en.json');
15+
16+
/** Locales to check against `en` — keep in sync with langs/i18n_conf.js. */
17+
const LOCALES = {
18+
fr: require('../../langs/fr.json'),
19+
es: require('../../langs/es.json'),
20+
ja: require('../../langs/ja.json'),
21+
ta: require('../../langs/ta.json'),
22+
'zh-Hans': require('../../langs/zh-Hans.json'),
23+
'zh-Hant': require('../../langs/zh-Hant.json'),
24+
};
25+
26+
/**
27+
* Flatten a nested translation object into dot-separated leaf keys.
28+
* @param {Record<string, any>} obj
29+
* @param {string} prefix
30+
* @param {Record<string, string>} out
31+
* @returns {Record<string, string>}
32+
*/
33+
function flatten(obj, prefix = '', out = {}) {
34+
for (const [k, v] of Object.entries(obj)) {
35+
const key = prefix ? `${prefix}.${k}` : k;
36+
if (v && typeof v === 'object' && !Array.isArray(v)) {
37+
flatten(v, key, out);
38+
} else {
39+
out[key] = v;
40+
}
41+
}
42+
return out;
43+
}
44+
45+
const enFlat = flatten(en);
46+
const enKeys = Object.keys(enFlat);
47+
48+
for (const [name, dict] of Object.entries(LOCALES)) {
49+
test.describe(`i18n: ${name}`, () => {
50+
const flat = flatten(dict);
51+
const keys = Object.keys(flat);
52+
53+
test('has no missing keys (vs en)', () => {
54+
const missing = enKeys.filter((k) => !(k in flat));
55+
expect(missing, `Keys present in en.json but missing in ${name}.json`).toEqual([]);
56+
});
57+
58+
test('has no stale keys (absent from en)', () => {
59+
const extra = keys.filter((k) => !(k in enFlat));
60+
expect(extra, `Keys present in ${name}.json but no longer in en.json`).toEqual([]);
61+
});
62+
63+
test('has no empty translations', () => {
64+
const empty = keys.filter((k) => typeof flat[k] === 'string' && flat[k].trim() === '');
65+
expect(empty, `Keys translated to an empty string in ${name}.json`).toEqual([]);
66+
});
67+
});
68+
}

tests/i18n/ui-locale.spec.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// @ts-check
2+
//
3+
// End-to-end locale check — needs the dev server running on BASE_URL.
4+
// The app has no language switcher: `detectLanguage()` in langs/i18n_conf.js
5+
// reads the browser locale (navigator.languages). Playwright lets us force that
6+
// per test via `test.use({ locale })`, so each case boots Adno in one language
7+
// and asserts the home page renders that locale's intro text (proving the right
8+
// bundle was loaded, not the English fallback).
9+
10+
const { test, expect } = require('@playwright/test');
11+
const { BASE_URL } = require('../helpers');
12+
13+
/**
14+
* Browser locale -> language bundle that detectLanguage() should resolve to.
15+
* The values must trigger the matching branch in detectLanguage():
16+
* - zh-CN -> zh-Hans, zh-TW -> zh-Hant (script disambiguation)
17+
*/
18+
const CASES = [
19+
{ browserLocale: 'en-US', bundle: 'en' },
20+
{ browserLocale: 'fr-FR', bundle: 'fr' },
21+
{ browserLocale: 'es-ES', bundle: 'es' },
22+
{ browserLocale: 'ja-JP', bundle: 'ja' },
23+
{ browserLocale: 'ta-IN', bundle: 'ta' },
24+
{ browserLocale: 'zh-CN', bundle: 'zh-Hans' },
25+
{ browserLocale: 'zh-TW', bundle: 'zh-Hant' },
26+
];
27+
28+
for (const { browserLocale, bundle } of CASES) {
29+
test.describe(`UI locale: ${bundle} (navigator=${browserLocale})`, () => {
30+
test.use({ locale: browserLocale });
31+
32+
test('home renders the localized intro text', async ({ page }) => {
33+
// begin_msg exists in every bundle, so it is a safe anchor even for
34+
// partially translated locales.
35+
const expected = require(`../../langs/${bundle}.json`).begin_msg;
36+
37+
await page.goto(`${BASE_URL}/#/`);
38+
39+
await expect(page.locator('.adno_description')).toContainText(expected);
40+
});
41+
});
42+
}

0 commit comments

Comments
 (0)