diff --git a/playwright/e2e/modules/custom-component.spec.ts b/playwright/e2e/modules/custom-component.spec.ts index e0741f18cecd51bc4dca93b1dc64b688a0e385a4..0a48c800c7c126e206e9c109f472e1509cecd5a3 100644 --- a/playwright/e2e/modules/custom-component.spec.ts +++ b/playwright/e2e/modules/custom-component.spec.ts @@ -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" }, diff --git a/playwright/sample-files/custom-component-module.js b/playwright/sample-files/custom-component-module.js index 14cd37883849255e59ef1131876cb1c3a014fbdc..62cfe883daf2723a91a79c2ed41e333d7348c17b 100644 --- a/playwright/sample-files/custom-component-module.js +++ b/playwright/sample-files/custom-component-module.js @@ -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() {} } diff --git a/playwright/snapshots/modules/custom-component.spec.ts/custom-component-tile-fall-through-linux.png b/playwright/snapshots/modules/custom-component.spec.ts/custom-component-tile-fall-through-linux.png new file mode 100644 index 0000000000000000000000000000000000000000..952b0110b6526bed692a63031cc063ba9fd7165c Binary files /dev/null and b/playwright/snapshots/modules/custom-component.spec.ts/custom-component-tile-fall-through-linux.png differ diff --git a/playwright/snapshots/modules/custom-component.spec.ts/custom-component-tile-linux.png b/playwright/snapshots/modules/custom-component.spec.ts/custom-component-tile-linux.png index ed626c902a1972a8c65cea633abe6f492521b80a..410365982b864a0a97d16e2a78a4acf3421ef15a 100644 Binary files a/playwright/snapshots/modules/custom-component.spec.ts/custom-component-tile-linux.png and b/playwright/snapshots/modules/custom-component.spec.ts/custom-component-tile-linux.png differ