CH-J Server Managerserver management over SSH
Menu
Published source

CH-J Server Manager

Browse directories and files for a specific application release.

Download source ZIP
CH-J Proprietary Software License 1.14

Source is provided under the CH-J Proprietary Software License 1.14. Its availability does not change the license terms or grant additional rights.

2,5 KB · 42 linesDownload file
1"use strict";
3const test = require("node:test");
4const assert = require("node:assert/strict");
5const fs = require("node:fs");
6const path = require("node:path");
7const { catalogs, createI18n } = require("../src/main/firstPartyPlugins/chj.hash-checksum/0.0.1/ui/i18n");
8const { ALGORITHMS } = require("../src/main/hashing/hashAlgorithms");
10const uiRoot = path.join(__dirname, "../src/main/firstPartyPlugins/chj.hash-checksum/0.0.1/ui");
12test("hash translations cover all UI phrases, algorithm categories, and result states in CS/DE/EN", () => {
13 const keys = Object.keys(catalogs.en).sort();
14 for (const language of ["cs", "de", "en"]) {
15 assert.deepEqual(Object.keys(catalogs[language]).sort(), keys);
16 for (const key of keys) assert.ok(catalogs[language][key].trim(), `${language}: ${key}`);
17 for (const algorithm of ALGORITHMS) assert.ok(catalogs[language][`category.${algorithm.category}`]);
18 for (const status of ["queued", "running", "completed", "failed", "cancelled", "COMPLETED", "MATCH", "MISMATCH", "ERROR", "MISSING", "INVALID ENTRY"]) assert.ok(catalogs[language][status]);
19 }
20 const html = fs.readFileSync(path.join(uiRoot, "index.html"), "utf8");
21 const script = fs.readFileSync(path.join(uiRoot, "index.js"), "utf8");
22 const usedKeys = [
23 ...[...html.matchAll(/data-i18n(?:-aria-label)?="([^"]+)"/g)].map((match) => match[1].replaceAll("&", "&")),
24 ...[...script.matchAll(/\bt\("([^"]+)"/g)].map((match) => match[1])
25 ];
26 for (const key of usedKeys) assert.ok(Object.hasOwn(catalogs.en, key), `Missing hash phrase: ${key}`);
27});
29test("hash language changes translate interpolation, IPC errors, and states", () => {
30 const i18n = createI18n("cs-CZ");
31 assert.equal(i18n.t("{count} file(s) completed", { count: 2 }), "Dokončeno souborů: 2");
32 assert.equal(i18n.t("MATCH"), "SHODA");
33 assert.equal(i18n.errorMessage(new Error("Error invoking remote method 'plugin:hashing:start': Error: HASH_INVALID_KEY: Invalid key")), catalogs.cs.HASH_INVALID_KEY);
34 i18n.setLanguage("de-DE");
35 assert.equal(i18n.t("COMPLETED"), "ABGESCHLOSSEN");
36 assert.equal(i18n.t("HEX key ({bytes} bytes; zero key if blank)", { bytes: 32 }), "HEX-Schlüssel (32 Bytes; leer = Nullschlüssel)");
37 assert.equal(i18n.errorMessage({ code: "ENOENT", message: "not found" }), catalogs.de.ENOENT);
38 i18n.setLanguage("en");
39 assert.equal(i18n.errorMessage({ code: "HASH_INVALID_KEY", message: "Invalid key" }), "Invalid key");
40 assert.equal(i18n.setLanguage("__proto__"), "en");
41 assert.equal(i18n.t("Unknown phrase"), "Unknown phrase");
42});

SHA-256: d1b1c73b054153379f9706d053818963a7005a15e214ca788e8114cf9cb54af2

Archive SHA-256: 5ac91caf4fa32a6fdb114f2430deed486fbe7489d5eea343d1f034169fafb5e0