mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-07 21:26:13 +02:00
Update tests
This commit is contained in:
parent
1b2d9b392c
commit
757e4e1395
@ -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" },
|
||||
|
||||
@ -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 |
Loading…
x
Reference in New Issue
Block a user