Update tests

This commit is contained in:
Half-Shot 2025-06-03 13:57:57 +01:00
parent 1b2d9b392c
commit 757e4e1395
4 changed files with 16 additions and 1 deletions

View File

@ -28,6 +28,11 @@ test.describe("Custom Component Module", () => {
await app.client.sendMessage(room.roomId, "Simple message");
await expect(await page.getByText("Simple message")).toMatchScreenshot("custom-component-tile.png");
});
test("should fall through if one module does not render a component", { tag: "@screenshot" }, async ({ page, room, app }) => {
await app.viewRoomById(room.roomId);
await app.client.sendMessage(room.roomId, "Fall through here");
await expect(await page.getByText("Fall through here")).toMatchScreenshot("custom-component-tile-fall-through.png");
});
test(
"should render the original content of a textual event conditionally",
{ tag: "@screenshot" },

View File

@ -9,13 +9,23 @@ export default class CustomComponentModule {
static moduleApiVersion = "^1.0.0";
constructor(api) {
this.api = api;
this.api.customComponents.register("TextualBody", (props, originalComponent) => {
this.api.customComponents.registerMessageRenderer("m.room.message", (props, originalComponent) => {
const body = props.mxEvent.getContent().body;
if (body === "Do not replace me") {
return originalComponent();
}
else if (body === "Fall through here"){
return null;
}
return `Custom text for ${body}`;
});
this.api.customComponents.registerMessageRenderer(/m\.room\.message/, (props) => {
const body = props.mxEvent.getContent().body;
if (body !== "Fall through here") {
return null;
}
return `Fallthrough text for ${body}`;
});
}
async load() {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB