Add an action to upload media files according to MSC4039 (#11311)
Signed-off-by: Dominik Henneke <dominik.henneke@nordeck.net>
This commit is contained in:
parent
902aea8bc4
commit
60bed46014
8 changed files with 66 additions and 7 deletions
|
@ -42,7 +42,7 @@ describe("StopGapWidget", () => {
|
|||
id: "test",
|
||||
creatorUserId: "@alice:example.org",
|
||||
type: "example",
|
||||
url: "https://example.org?user-id=$matrix_user_id&device-id=$org.matrix.msc3819.matrix_device_id",
|
||||
url: "https://example.org?user-id=$matrix_user_id&device-id=$org.matrix.msc3819.matrix_device_id&base-url=$org.matrix.msc4039.matrix_base_url",
|
||||
roomId: "!1:example.org",
|
||||
},
|
||||
room: mkRoom(client, "!1:example.org"),
|
||||
|
@ -62,7 +62,7 @@ describe("StopGapWidget", () => {
|
|||
|
||||
it("should replace parameters in widget url template", () => {
|
||||
expect(widget.embedUrl).toBe(
|
||||
"https://example.org/?user-id=%40userId%3Amatrix.org&device-id=ABCDEFGHI&widgetId=test&parentUrl=http%3A%2F%2Flocalhost%2F",
|
||||
"https://example.org/?user-id=%40userId%3Amatrix.org&device-id=ABCDEFGHI&base-url=https%3A%2F%2Fmatrix-client.matrix.org&widgetId=test&parentUrl=http%3A%2F%2Flocalhost%2F",
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -447,4 +447,44 @@ describe("StopGapWidgetDriver", () => {
|
|||
expect(client.searchUserDirectory).toHaveBeenCalledWith({ term: "foo", limit: 25 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("getMediaConfig", () => {
|
||||
let driver: WidgetDriver;
|
||||
|
||||
beforeEach(() => {
|
||||
driver = mkDefaultDriver();
|
||||
});
|
||||
|
||||
it("gets the media configuration", async () => {
|
||||
client.getMediaConfig.mockResolvedValue({
|
||||
"m.upload.size": 1000,
|
||||
});
|
||||
|
||||
await expect(driver.getMediaConfig()).resolves.toEqual({
|
||||
"m.upload.size": 1000,
|
||||
});
|
||||
|
||||
expect(client.getMediaConfig).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe("uploadFile", () => {
|
||||
let driver: WidgetDriver;
|
||||
|
||||
beforeEach(() => {
|
||||
driver = mkDefaultDriver();
|
||||
});
|
||||
|
||||
it("uploads a file", async () => {
|
||||
client.uploadContent.mockResolvedValue({
|
||||
content_uri: "mxc://...",
|
||||
});
|
||||
|
||||
await expect(driver.uploadFile("data")).resolves.toEqual({
|
||||
contentUri: "mxc://...",
|
||||
});
|
||||
|
||||
expect(client.uploadContent).toHaveBeenCalledWith("data");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue