|
| 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 | +export function createRoom(data: any): string { |
| 20 | + cy.get('.mx_RoomListHeader_plusButton').click(); |
| 21 | + cy.get('.mx_ContextualMenu').contains('New room').click(); |
| 22 | + cy.get('.mx_CreateRoomDialog_name input').type(data['name']); |
| 23 | + if (data['topic']) { |
| 24 | + cy.get('.mx_CreateRoomDialog_topic input').type(data['topic']); |
| 25 | + } |
| 26 | + // do this to prevent https://github.com/vector-im/element-web/issues/22590, weirdly |
| 27 | + // cy.get('.mx_CreateRoomDialog_name input').click(); |
| 28 | + // cy.wait(5000); |
| 29 | + |
| 30 | + cy.get('.mx_Dialog_primary').click(); |
| 31 | + //cy.get('.mx_RoomHeader_nametext').should('contain', data['name']); |
| 32 | + return "room_created"; |
| 33 | +} |
| 34 | + |
| 35 | +export function createDm(data: any): string { |
| 36 | + cy.get('.mx_RoomListHeader_plusButton').click(); |
| 37 | + cy.get('.mx_ContextualMenu').contains('Start new chat').click(); |
| 38 | + cy.get('[data-testid="invite-dialog-input"]').type(`@${data["userId"]}`); |
| 39 | + cy.get('.mx_InviteDialog_goButton').click(); |
| 40 | + return "dm_created"; |
| 41 | +} |
| 42 | + |
| 43 | +export function changeRoomHistoryVisibility(data: any): string { |
| 44 | + cy.get(".mx_RightPanel_roomSummaryButton").click(); |
| 45 | + cy.get(".mx_RoomSummaryCard_icon_settings").click(); |
| 46 | + cy.get(`[data-testid='settings-tab-ROOM_SECURITY_TAB']`).click(); |
| 47 | + // should be either "shared", "invited" or "joined" |
| 48 | + // TODO: has doesn't seem to work |
| 49 | + cy.get(`#historyVis-${data['historyVisibility']}`).parents("label").click(); |
| 50 | + cy.get(".mx_Dialog_cancelButton").click(); |
| 51 | + cy.get("[data-test-id=base-card-close-button]").click(); |
| 52 | + return "changed"; |
| 53 | +} |
| 54 | + |
| 55 | +export function openRoom(data: any): string { |
| 56 | + cy.get(".mx_RoomSublist_tiles").contains(data["name"]).click(); |
| 57 | + return "room-opened"; |
| 58 | +} |
| 59 | + |
| 60 | +export function acceptInvite(): string { |
| 61 | + cy.get(".mx_RoomTile").click(); |
| 62 | + cy.get(".mx_RoomPreviewBar_actions .mx_AccessibleButton_kind_primary").click(); |
| 63 | + return "accepted"; |
| 64 | +} |
| 65 | + |
| 66 | +export function inviteUser(data: any): string { |
| 67 | + cy.get(".mx_RightPanel_roomSummaryButton").click(); |
| 68 | + cy.get(".mx_RoomSummaryCard_icon_people").click(); |
| 69 | + cy.get(".mx_MemberList_invite").click(); |
| 70 | + cy.get(".mx_InviteDialog_addressBar input") |
| 71 | + .type(`@${data["userId"]}`) |
| 72 | + .type("{enter}"); |
| 73 | + cy.get(".mx_InviteDialog_goButton").click(); |
| 74 | + cy.get(".mx_AccessibleButton.mx_BaseCard_back").click(); |
| 75 | + cy.get(".mx_AccessibleButton.mx_BaseCard_close", { timeout: 30000 }).click(); |
| 76 | + return "invited"; |
| 77 | +} |
0 commit comments