95 lines
3.1 KiB
JavaScript
95 lines
3.1 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
import { readI18nRuntimeMessages } from "./helpers/readI18nRuntimeMessages";
|
|
|
|
const locales = {
|
|
da: readI18nRuntimeMessages("da"),
|
|
en: readI18nRuntimeMessages("en"),
|
|
sv: readI18nRuntimeMessages("sv"),
|
|
de: readI18nRuntimeMessages("de"),
|
|
no: readI18nRuntimeMessages("no"),
|
|
};
|
|
|
|
const flattenKeys = (value, prefix = "") => {
|
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
return [prefix];
|
|
}
|
|
|
|
const keys = [];
|
|
for (const [key, nestedValue] of Object.entries(value)) {
|
|
const nestedPrefix = prefix ? `${prefix}.${key}` : key;
|
|
keys.push(...flattenKeys(nestedValue, nestedPrefix));
|
|
}
|
|
return keys;
|
|
};
|
|
|
|
describe("workfeed i18n coverage", () => {
|
|
it("defines configuration.workfeed namespace in every active locale", () => {
|
|
for (const [locale, data] of Object.entries(locales)) {
|
|
expect(data.configuration?.workfeed, `missing configuration.workfeed in ${locale}`).toBeTruthy();
|
|
}
|
|
});
|
|
|
|
it("keeps the same workfeed key set across locales", () => {
|
|
const baselineKeys = flattenKeys(locales.en.configuration.workfeed).sort();
|
|
|
|
for (const [locale, data] of Object.entries(locales)) {
|
|
const localeKeys = flattenKeys(data.configuration.workfeed).sort();
|
|
expect(localeKeys, `mismatched key set in ${locale}`).toEqual(baselineKeys);
|
|
}
|
|
});
|
|
|
|
it("contains required keys used by configuration view", () => {
|
|
const requiredKeys = [
|
|
"title",
|
|
"subtitle",
|
|
"general_settings",
|
|
"enable",
|
|
"api_settings",
|
|
"api_url",
|
|
"company_id",
|
|
"company_id_desc",
|
|
"api_key",
|
|
"close",
|
|
"lookup",
|
|
"validation_required",
|
|
"request_failed",
|
|
"diagnostics.title",
|
|
"diagnostics.description",
|
|
"diagnostics.list_departments",
|
|
"diagnostics.list_employees",
|
|
"diagnostics.list_shifts",
|
|
"diagnostics.get_employee",
|
|
"diagnostics.get_shift",
|
|
"diagnostics.no_params_required",
|
|
"diagnostics.prompt_start_from",
|
|
"diagnostics.prompt_start_to",
|
|
"diagnostics.placeholder_start_from",
|
|
"diagnostics.placeholder_start_to",
|
|
"diagnostics.prompt_employee_id_optional",
|
|
"diagnostics.prompt_released_optional",
|
|
"diagnostics.placeholder_released",
|
|
"diagnostics.select_employee_all",
|
|
"diagnostics.select_released_all",
|
|
"diagnostics.select_released_true",
|
|
"diagnostics.select_released_false",
|
|
"diagnostics.prompt_search_optional",
|
|
"diagnostics.prompt_status_optional",
|
|
"diagnostics.prompt_employee_id",
|
|
"diagnostics.prompt_shift_id",
|
|
"diagnostics.validation_shift_range_required",
|
|
"diagnostics.validation_released_boolean",
|
|
"diagnostics.validation_datetime_invalid",
|
|
"diagnostics.result_departments",
|
|
"diagnostics.result_employees",
|
|
"diagnostics.result_shifts",
|
|
"diagnostics.result_employee",
|
|
"diagnostics.result_shift",
|
|
];
|
|
|
|
const availableKeys = new Set(flattenKeys(locales.en.configuration.workfeed));
|
|
requiredKeys.forEach((key) => {
|
|
expect(availableKeys.has(key)).toBe(true);
|
|
});
|
|
});
|
|
});
|