Add Module Composer API (#33284)
* Spec composer API * Add composer api implementation * Tests * Copyright * update sigs * cleanup * a snap * cleanup * linting * Tidy up * Adjust
This commit is contained in:
@@ -71,6 +71,7 @@ import ErrorDialog from "../../../../src/components/views/dialogs/ErrorDialog.ts
|
||||
import * as pinnedEventHooks from "../../../../src/hooks/usePinnedEvents";
|
||||
import { TimelineRenderingType } from "../../../../src/contexts/RoomContext";
|
||||
import { ModuleApi } from "../../../../src/modules/Api";
|
||||
import { type ComposerInsertPayload, ComposerType } from "../../../../src/dispatcher/payloads/ComposerInsertPayload.ts";
|
||||
|
||||
// Used by group calls
|
||||
jest.spyOn(MediaDeviceHandler, "getDevices").mockResolvedValue({
|
||||
@@ -1075,6 +1076,80 @@ describe("RoomView", () => {
|
||||
expect(onRoomViewUpdateMock).toHaveBeenCalledWith(true);
|
||||
});
|
||||
|
||||
describe("handles Action.ComposerInsert", () => {
|
||||
it("redispatches an empty composerType, timelineRenderingType with the current state", async () => {
|
||||
await mountRoomView();
|
||||
const promise = untilDispatch((payload) => {
|
||||
try {
|
||||
expect(payload).toEqual({
|
||||
action: Action.ComposerInsert,
|
||||
text: "Hello world",
|
||||
timelineRenderingType: TimelineRenderingType.Room,
|
||||
composerType: ComposerType.Send,
|
||||
});
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, defaultDispatcher);
|
||||
defaultDispatcher.dispatch({
|
||||
action: Action.ComposerInsert,
|
||||
text: "Hello world",
|
||||
} satisfies ComposerInsertPayload);
|
||||
await promise;
|
||||
});
|
||||
it("redispatches an empty composerType with the current state", async () => {
|
||||
await mountRoomView();
|
||||
const promise = untilDispatch((payload) => {
|
||||
try {
|
||||
expect(payload).toEqual({
|
||||
action: Action.ComposerInsert,
|
||||
text: "Hello world",
|
||||
timelineRenderingType: TimelineRenderingType.Room,
|
||||
composerType: ComposerType.Send,
|
||||
});
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, defaultDispatcher);
|
||||
defaultDispatcher.dispatch({
|
||||
action: Action.ComposerInsert,
|
||||
text: "Hello world",
|
||||
timelineRenderingType: TimelineRenderingType.Room,
|
||||
} satisfies ComposerInsertPayload);
|
||||
await promise;
|
||||
});
|
||||
it("ignores payloads with a timelineRenderingType != TimelineRenderingType.Thread", async () => {
|
||||
await mountRoomView();
|
||||
const promise = untilDispatch(
|
||||
(payload) => {
|
||||
try {
|
||||
expect(payload).toStrictEqual({
|
||||
action: Action.ComposerInsert,
|
||||
text: "Hello world",
|
||||
timelineRenderingType: TimelineRenderingType.Thread,
|
||||
composerType: ComposerType.Send,
|
||||
});
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
defaultDispatcher,
|
||||
500,
|
||||
);
|
||||
defaultDispatcher.dispatch({
|
||||
action: Action.ComposerInsert,
|
||||
text: "Hello world",
|
||||
composerType: ComposerType.Send,
|
||||
timelineRenderingType: TimelineRenderingType.Room,
|
||||
viaTest: true,
|
||||
} satisfies ComposerInsertPayload);
|
||||
await expect(promise).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when there is a RoomView", () => {
|
||||
const widget1Id = "widget1";
|
||||
const widget2Id = "widget2";
|
||||
|
||||
Reference in New Issue
Block a user