mirror of
https://github.com/vector-im/element-web.git
synced 2026-03-04 04:52:04 +01:00
* Split translations between EW and shared components Uses update module API with global TranslationKey type that can be overridden. WIP. * Removed the wrong script (for now) * Add the type files * Add shared components i18n file * More i18n strings * Add i18n check for shared conmponents * Needs a different name * rerun i18n for merge from develop, fix test * Move translated strings to shared components file NB. there are lots of removed strings for a few languages where we seem to have hit a localazy bug or something where the key/value for plurals got switched, making the translations invalid. They've been missing for a while so I'm removing them rather than trying to restore them, * Add shared components files to localazy * Merge element web & shared component translations for the built app * Use right translations for shared component tests and fix missign en_EN strings * Pull shared components translations too * Fix/disable warnings * We can now remove the build:res call ...right? (right?) * Remove webpack import for languages index ..and just load it using a relative path which we do for the individual language files and also did anyway for the index because even in non-test it was an object, not a string, so we always usesd the 'test' code path. * Make the storybook language selector work ...without referring to the parent app's files * Revert unnecessary yarn lock change * Typo Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Add comment on why we use merge * Fix localazy download config to actually put the translations in the right place * Better typescript syntax Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Watch both translations files --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
140 lines
5.9 KiB
TypeScript
140 lines
5.9 KiB
TypeScript
/*
|
|
Copyright 2024 New Vector Ltd.
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
|
|
|
|
import ServerSupportUnstableFeatureController from "../../../../src/settings/controllers/ServerSupportUnstableFeatureController";
|
|
import { SettingLevel } from "../../../../src/settings/SettingLevel";
|
|
import { type FeatureSettingKey, LabGroup, SETTINGS } from "../../../../src/settings/Settings";
|
|
import { stubClient } from "../../../test-utils";
|
|
import { WatchManager } from "../../../../src/settings/WatchManager";
|
|
import MatrixClientBackedController from "../../../../src/settings/controllers/MatrixClientBackedController";
|
|
|
|
describe("ServerSupportUnstableFeatureController", () => {
|
|
const watchers = new WatchManager();
|
|
const setting = "setting_name" as FeatureSettingKey;
|
|
|
|
async function prepareSetting(
|
|
cli: MatrixClient,
|
|
controller: ServerSupportUnstableFeatureController,
|
|
): Promise<void> {
|
|
SETTINGS[setting] = {
|
|
isFeature: true,
|
|
labsGroup: LabGroup.Messaging,
|
|
displayName: "name of some kind" as TranslationKey,
|
|
supportedLevels: [SettingLevel.DEVICE, SettingLevel.CONFIG],
|
|
default: false,
|
|
controller,
|
|
};
|
|
|
|
const deferred = Promise.withResolvers<any>();
|
|
watchers.watchSetting(setting, null, deferred.resolve);
|
|
MatrixClientBackedController.matrixClient = cli;
|
|
await deferred.promise;
|
|
}
|
|
|
|
describe("getValueOverride()", () => {
|
|
it("should return forced value is setting is disabled", async () => {
|
|
const cli = stubClient();
|
|
cli.doesServerSupportUnstableFeature = jest.fn(async () => false);
|
|
|
|
const controller = new ServerSupportUnstableFeatureController(
|
|
setting,
|
|
watchers,
|
|
[["feature"]],
|
|
undefined,
|
|
undefined,
|
|
"other_value",
|
|
);
|
|
await prepareSetting(cli, controller);
|
|
|
|
expect(controller.getValueOverride(SettingLevel.DEVICE, null, true, SettingLevel.ACCOUNT)).toEqual(
|
|
"other_value",
|
|
);
|
|
});
|
|
|
|
it("should pass through to the handler if setting is not disabled", async () => {
|
|
const cli = stubClient();
|
|
cli.doesServerSupportUnstableFeature = jest.fn(async () => true);
|
|
|
|
const controller = new ServerSupportUnstableFeatureController(
|
|
setting,
|
|
watchers,
|
|
[["feature"]],
|
|
"other_value",
|
|
);
|
|
await prepareSetting(cli, controller);
|
|
|
|
expect(controller.getValueOverride(SettingLevel.DEVICE, null, true, SettingLevel.ACCOUNT)).toEqual(null);
|
|
});
|
|
});
|
|
|
|
describe("settingDisabled()", () => {
|
|
it("considered disabled if there is no matrix client", () => {
|
|
const controller = new ServerSupportUnstableFeatureController(setting, watchers, [["org.matrix.msc3030"]]);
|
|
expect(controller.settingDisabled).toEqual(true);
|
|
});
|
|
|
|
it("considered disabled if not all required features in the only feature group are supported", async () => {
|
|
const cli = stubClient();
|
|
cli.doesServerSupportUnstableFeature = jest.fn(async (featureName) => {
|
|
return featureName === "org.matrix.msc3827.stable";
|
|
});
|
|
|
|
const controller = new ServerSupportUnstableFeatureController(setting, watchers, [
|
|
["org.matrix.msc3827.stable", "org.matrix.msc3030"],
|
|
]);
|
|
await prepareSetting(cli, controller);
|
|
|
|
expect(controller.settingDisabled).toEqual(true);
|
|
});
|
|
|
|
it("considered enabled if all required features in the only feature group are supported", async () => {
|
|
const cli = stubClient();
|
|
cli.doesServerSupportUnstableFeature = jest.fn(async (featureName) => {
|
|
return featureName === "org.matrix.msc3827.stable" || featureName === "org.matrix.msc3030";
|
|
});
|
|
const controller = new ServerSupportUnstableFeatureController(setting, watchers, [
|
|
["org.matrix.msc3827.stable", "org.matrix.msc3030"],
|
|
]);
|
|
await prepareSetting(cli, controller);
|
|
|
|
expect(controller.settingDisabled).toEqual(false);
|
|
});
|
|
|
|
it("considered enabled if all required features in one of the feature groups are supported", async () => {
|
|
const cli = stubClient();
|
|
cli.doesServerSupportUnstableFeature = jest.fn(async (featureName) => {
|
|
return featureName === "org.matrix.msc3827.stable" || featureName === "org.matrix.msc3030";
|
|
});
|
|
const controller = new ServerSupportUnstableFeatureController(setting, watchers, [
|
|
["foo-unsupported", "bar-unsupported"],
|
|
["org.matrix.msc3827.stable", "org.matrix.msc3030"],
|
|
]);
|
|
await prepareSetting(cli, controller);
|
|
|
|
expect(controller.settingDisabled).toEqual(false);
|
|
});
|
|
|
|
it("considered disabled if not all required features in one of the feature groups are supported", async () => {
|
|
const cli = stubClient();
|
|
cli.doesServerSupportUnstableFeature = jest.fn(async (featureName) => {
|
|
return featureName === "org.matrix.msc3827.stable";
|
|
});
|
|
|
|
const controller = new ServerSupportUnstableFeatureController(setting, watchers, [
|
|
["foo-unsupported", "bar-unsupported"],
|
|
["org.matrix.msc3827.stable", "org.matrix.msc3030"],
|
|
]);
|
|
await prepareSetting(cli, controller);
|
|
|
|
expect(controller.settingDisabled).toEqual(true);
|
|
});
|
|
});
|
|
});
|