|
| 1 | +/* |
| 2 | +Copyright 2022 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 { Locator, Page } from "@playwright/test"; |
| 18 | + |
| 19 | +import { test, expect } from "../../element-web-test"; |
| 20 | + |
| 21 | +test.describe("Location sharing", () => { |
| 22 | + const selectLocationShareTypeOption = (page: Page, shareType: string): Locator => { |
| 23 | + return page.getByTestId(`share-location-option-${shareType}`); |
| 24 | + }; |
| 25 | + |
| 26 | + const submitShareLocation = (page: Page): Promise<void> => { |
| 27 | + return page.getByRole("button", { name: "Share location" }).click(); |
| 28 | + }; |
| 29 | + |
| 30 | + test.use({ |
| 31 | + displayName: "Tom", |
| 32 | + }); |
| 33 | + |
| 34 | + test.beforeEach(async ({ page }) => { |
| 35 | + await page.addInitScript(() => { |
| 36 | + window.localStorage.setItem("mx_lhs_size", "0"); |
| 37 | + }); |
| 38 | + }); |
| 39 | + |
| 40 | + test("sends and displays pin drop location message successfully", async ({ page, user, app }) => { |
| 41 | + const roomId = await app.createRoom({}); |
| 42 | + await page.goto(`/#/room/${roomId}`); |
| 43 | + |
| 44 | + const composerOptions = await app.openMessageComposerOptions(); |
| 45 | + await composerOptions.getByRole("menuitem", { name: "Location", exact: true }).click(); |
| 46 | + |
| 47 | + await selectLocationShareTypeOption(page, "Pin").click(); |
| 48 | + |
| 49 | + await page.locator("#mx_LocationPicker_map").click(); |
| 50 | + |
| 51 | + await submitShareLocation(page); |
| 52 | + |
| 53 | + await page.locator(".mx_RoomView_body .mx_EventTile .mx_MLocationBody").click({ |
| 54 | + position: { |
| 55 | + x: 225, |
| 56 | + y: 150, |
| 57 | + }, |
| 58 | + }); |
| 59 | + |
| 60 | + // clicking location tile opens maximised map |
| 61 | + await expect(page.getByRole("dialog")).toBeVisible(); |
| 62 | + |
| 63 | + await app.closeDialog(); |
| 64 | + |
| 65 | + await expect(page.locator(".mx_Marker")).toBeVisible(); |
| 66 | + }); |
| 67 | +}); |
0 commit comments