You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-28 15:22:05 +03:00
Add config to skip widget_build_url for DM rooms (#11044)
* Add config to skip widget_build_url for DM rooms * Add tests
This commit is contained in:
committed by
GitHub
parent
d340fa8d2a
commit
2e68479577
51
test/widgets/ManagedHybrid-test.ts
Normal file
51
test/widgets/ManagedHybrid-test.ts
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright 2023 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { isManagedHybridWidgetEnabled } from "../../src/widgets/ManagedHybrid";
|
||||
import DMRoomMap from "../../src/utils/DMRoomMap";
|
||||
import { stubClient } from "../test-utils";
|
||||
import SdkConfig from "../../src/SdkConfig";
|
||||
|
||||
describe("isManagedHybridWidgetEnabled", () => {
|
||||
let dmRoomMap: DMRoomMap;
|
||||
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
dmRoomMap = {
|
||||
getUserIdForRoomId: jest.fn().mockReturnValue("@user:server"),
|
||||
} as unknown as DMRoomMap;
|
||||
DMRoomMap.setShared(dmRoomMap);
|
||||
});
|
||||
|
||||
it("should return false if widget_build_url is unset", () => {
|
||||
expect(isManagedHybridWidgetEnabled("!room:server")).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should return true for DMs when widget_build_url_ignore_dm is unset", () => {
|
||||
SdkConfig.put({
|
||||
widget_build_url: "https://url",
|
||||
});
|
||||
expect(isManagedHybridWidgetEnabled("!room:server")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should return false for DMs when widget_build_url_ignore_dm is true", () => {
|
||||
SdkConfig.put({
|
||||
widget_build_url: "https://url",
|
||||
widget_build_url_ignore_dm: true,
|
||||
});
|
||||
expect(isManagedHybridWidgetEnabled("!room:server")).toBeFalsy();
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user