test: test requesting send message permission in initialize widget
This commit is contained in:
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { beforeAll, describe, expect, vi, it } from "vitest";
|
import { describe, expect, vi, it, beforeEach } from "vitest";
|
||||||
import { createRoomWidgetClient, EventType } from "matrix-js-sdk";
|
import { createRoomWidgetClient, EventType } from "matrix-js-sdk";
|
||||||
|
|
||||||
import { getUrlParams } from "./UrlParams";
|
import { getUrlParams } from "./UrlParams";
|
||||||
@@ -35,11 +35,14 @@ vi.mock("./UrlParams", () => ({
|
|||||||
})),
|
})),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
initializeWidget("ANYRTCAPP");
|
beforeEach(() => {
|
||||||
describe("widget", () => {
|
createRoomWidgetClientSpy.mockClear();
|
||||||
beforeAll(() => {});
|
});
|
||||||
|
|
||||||
|
describe("widget", () => {
|
||||||
it("should create an embedded client with the correct params", () => {
|
it("should create an embedded client with the correct params", () => {
|
||||||
|
initializeWidget("ANYRTCAPP");
|
||||||
|
|
||||||
expect(getUrlParams()).toStrictEqual({
|
expect(getUrlParams()).toStrictEqual({
|
||||||
widgetId: "id",
|
widgetId: "id",
|
||||||
parentUrl: "http://parentUrl",
|
parentUrl: "http://parentUrl",
|
||||||
@@ -127,4 +130,32 @@ describe("widget", () => {
|
|||||||
});
|
});
|
||||||
expect(createRoomWidgetClientSpy.mock.calls[0][4]).toStrictEqual(false);
|
expect(createRoomWidgetClientSpy.mock.calls[0][4]).toStrictEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should request send message permission if requested", () => {
|
||||||
|
initializeWidget("ANYRTCAPP", true);
|
||||||
|
expect(createRoomWidgetClientSpy).toHaveBeenLastCalledWith(
|
||||||
|
expect.anything(),
|
||||||
|
// capabilities
|
||||||
|
expect.objectContaining({
|
||||||
|
sendEvent: expect.arrayContaining(["m.room.message"]),
|
||||||
|
}),
|
||||||
|
expect.anything(),
|
||||||
|
expect.anything(),
|
||||||
|
expect.anything(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not request send message permission when not requested", () => {
|
||||||
|
initializeWidget("", false);
|
||||||
|
expect(createRoomWidgetClientSpy).toHaveBeenLastCalledWith(
|
||||||
|
expect.anything(),
|
||||||
|
// capabilities
|
||||||
|
expect.objectContaining({
|
||||||
|
sendEvent: expect.not.arrayContaining(["m.room.message"]),
|
||||||
|
}),
|
||||||
|
expect.anything(),
|
||||||
|
expect.anything(),
|
||||||
|
expect.anything(),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user