This commit is contained in:
Half-Shot 2025-06-03 14:00:46 +01:00
parent 757e4e1395
commit ce428b5e2d
2 changed files with 12 additions and 7 deletions

View File

@ -28,11 +28,17 @@ 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 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

@ -13,8 +13,7 @@ export default class CustomComponentModule {
const body = props.mxEvent.getContent().body;
if (body === "Do not replace me") {
return originalComponent();
}
else if (body === "Fall through here"){
} else if (body === "Fall through here") {
return null;
}
return `Custom text for ${body}`;