|
| 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 | +/// <reference types="cypress" /> |
| 18 | + |
| 19 | +import { SynapseInstance } from "../../plugins/synapsedocker"; |
| 20 | + |
| 21 | +describe("Pills", () => { |
| 22 | + let synapse: SynapseInstance; |
| 23 | + |
| 24 | + beforeEach(() => { |
| 25 | + cy.startSynapse("default").then(data => { |
| 26 | + synapse = data; |
| 27 | + |
| 28 | + cy.initTestUser(synapse, "Sally"); |
| 29 | + }); |
| 30 | + }); |
| 31 | + |
| 32 | + afterEach(() => { |
| 33 | + cy.stopSynapse(synapse); |
| 34 | + }); |
| 35 | + |
| 36 | + it('should navigate clicks internally to the app', () => { |
| 37 | + const messageRoom = "Send Messages Here"; |
| 38 | + const targetLocalpart = "aliasssssssssssss"; |
| 39 | + cy.createRoom({ |
| 40 | + name: "Target", |
| 41 | + room_alias_name: targetLocalpart, |
| 42 | + }).as("targetRoomId"); |
| 43 | + cy.createRoom({ |
| 44 | + name: messageRoom, |
| 45 | + }).as("messageRoomId"); |
| 46 | + cy.all([ |
| 47 | + cy.get<string>("@targetRoomId"), |
| 48 | + cy.get<string>("@messageRoomId"), |
| 49 | + ]).then(([targetRoomId, messageRoomId]) => { // discard the target room ID - we don't need it |
| 50 | + cy.viewRoomByName(messageRoom); |
| 51 | + cy.url().should("contain", `/#/room/${messageRoomId}`); |
| 52 | + |
| 53 | + // send a message using the built-in room mention functionality (autocomplete) |
| 54 | + cy.get(".mx_SendMessageComposer .mx_BasicMessageComposer_input") |
| 55 | + .type(`Hello world! Join here: #${targetLocalpart.substring(0, 3)}`); |
| 56 | + cy.get(".mx_Autocomplete_Completion_title").click(); |
| 57 | + cy.get(".mx_MessageComposer_sendMessage").click(); |
| 58 | + |
| 59 | + // find the pill in the timeline and click it |
| 60 | + cy.get(".mx_EventTile_body .mx_Pill").click(); |
| 61 | + |
| 62 | + // verify we landed at a sane place |
| 63 | + cy.url().should("contain", `/#/room/#${targetLocalpart}:`); |
| 64 | + |
| 65 | + cy.wait(250); // let the room list settle |
| 66 | + |
| 67 | + // go back to the message room and try to click on the pill text, as a user would |
| 68 | + cy.viewRoomByName(messageRoom); |
| 69 | + cy.get(".mx_EventTile_body .mx_Pill .mx_Pill_linkText") |
| 70 | + .should("have.css", "pointer-events", "none") |
| 71 | + .click({ force: true }); // force is to ensure we bypass pointer-events |
| 72 | + cy.url().should("contain", `https://matrix.to/#/#${targetLocalpart}:`); |
| 73 | + }); |
| 74 | + }); |
| 75 | +}); |
0 commit comments