Add stable unstable version for jump to date before v1.6
is fully supported on a homeserver (#10398)
Add stable unstable version (`org.matrix.msc3030.stable`) for jump to date [before `v1.6` is fully supported on a homeserver](https://github.com/matrix-org/synapse/issues/15089). Related to https://github.com/vector-im/element-web/issues/24362 but does not solve immediately because Synapse does not supply `org.matrix.msc3030.stable` yet Also refactored `ServerSupportUnstableFeatureController` to support multiple feature groups where any one of them will enable the setting. All features in a feature group are required. This way having either `org.matrix.msc3030` or `org.matrix.msc3030.stable` will enable the jump to date feature flag with a config of `[["org.matrix.msc3030"], ["org.matrix.msc3030.stable"]]`
This commit is contained in:
parent
f3f87054b4
commit
bc60e59eda
3 changed files with 74 additions and 24 deletions
|
@ -55,7 +55,7 @@ describe("ServerSupportUnstableFeatureController", () => {
|
|||
const controller = new ServerSupportUnstableFeatureController(
|
||||
setting,
|
||||
watchers,
|
||||
["feature"],
|
||||
[["feature"]],
|
||||
undefined,
|
||||
undefined,
|
||||
"other_value",
|
||||
|
@ -74,7 +74,7 @@ describe("ServerSupportUnstableFeatureController", () => {
|
|||
const controller = new ServerSupportUnstableFeatureController(
|
||||
setting,
|
||||
watchers,
|
||||
["feature"],
|
||||
[["feature"]],
|
||||
"other_value",
|
||||
);
|
||||
await prepareSetting(cli, controller);
|
||||
|
@ -84,38 +84,65 @@ describe("ServerSupportUnstableFeatureController", () => {
|
|||
});
|
||||
|
||||
describe("settingDisabled()", () => {
|
||||
it("returns true if there is no matrix client", () => {
|
||||
const controller = new ServerSupportUnstableFeatureController(setting, watchers, ["org.matrix.msc3030"]);
|
||||
it("considered disabled if there is no matrix client", () => {
|
||||
const controller = new ServerSupportUnstableFeatureController(setting, watchers, [["org.matrix.msc3030"]]);
|
||||
expect(controller.settingDisabled).toEqual(true);
|
||||
});
|
||||
|
||||
it("returns true if not all required features are supported", async () => {
|
||||
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",
|
||||
["org.matrix.msc3827.stable", "org.matrix.msc3030"],
|
||||
]);
|
||||
await prepareSetting(cli, controller);
|
||||
|
||||
expect(controller.settingDisabled).toEqual(true);
|
||||
});
|
||||
|
||||
it("returns false if all required features are supported", async () => {
|
||||
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",
|
||||
["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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue