|
| 1 | +/* |
| 2 | +Copyright 2023 The Matrix.org Foundation C.I.C. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +import { test, expect } from "../../element-web-test"; |
| 18 | + |
| 19 | +test.describe("Presence tests", () => { |
| 20 | + test.use({ |
| 21 | + displayName: "Janet", |
| 22 | + botCreateOpts: { displayName: "Bob" }, |
| 23 | + }); |
| 24 | + |
| 25 | + test.describe("bob unreachable", () => { |
| 26 | + test("renders unreachable presence state correctly", async ({ page, app, user, bot: bob }) => { |
| 27 | + await app.client.createRoom({ name: "My Room", invite: [bob.credentials.userId] }); |
| 28 | + await app.viewRoomByName("My Room"); |
| 29 | + |
| 30 | + await bob.evaluate(async (client) => { |
| 31 | + client.stopClient(); |
| 32 | + }); |
| 33 | + |
| 34 | + await page.route( |
| 35 | + `**/sync*`, |
| 36 | + async (route) => { |
| 37 | + const response = await route.fetch(); |
| 38 | + await route.fulfill({ |
| 39 | + json: { |
| 40 | + ...(await response.json()), |
| 41 | + presence: { |
| 42 | + events: [ |
| 43 | + { |
| 44 | + type: "m.presence", |
| 45 | + sender: bob.credentials.userId, |
| 46 | + content: { |
| 47 | + presence: "io.element.unreachable", |
| 48 | + currently_active: false, |
| 49 | + }, |
| 50 | + }, |
| 51 | + ], |
| 52 | + }, |
| 53 | + }, |
| 54 | + }); |
| 55 | + }, |
| 56 | + { times: 1 }, |
| 57 | + ); |
| 58 | + await app.client.createRoom({}); // trigger sync |
| 59 | + |
| 60 | + await page.getByRole("button", { name: "Room info" }).click(); |
| 61 | + await page.locator(".mx_RightPanel").getByText("People").click(); |
| 62 | + await expect(page.locator(".mx_EntityTile_unreachable")).toContainText("Bob"); |
| 63 | + await expect(page.locator(".mx_EntityTile_unreachable")).toContainText("User's server unreachable"); |
| 64 | + }); |
| 65 | + }); |
| 66 | +}); |
0 commit comments