Skip to content

Commit 366c32b

Browse files
committed
Move actions relating to room to file
1 parent 77a83ac commit 366c32b

File tree

2 files changed

+99
-50
lines changed

2 files changed

+99
-50
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
}

cypress/e2e/trafficlight/trafficlight.spec.ts

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ import {
2727
verifyCrossSigningEmoji,
2828
verifyDeviceIsTrusted,
2929
} from "./actions/e2ee";
30+
import {
31+
acceptInvite,
32+
changeRoomHistoryVisibility,
33+
createDm,
34+
createRoom,
35+
inviteUser,
36+
openRoom,
37+
} from "./actions/room";
3038

3139
type JSONValue =
3240
| string
@@ -102,66 +110,30 @@ function runAction(action: string, data: JSONValue): string | undefined {
102110
case "enable_key_backup":
103111
return enableKeyBackup(data);
104112

113+
// Room
114+
case 'create_room':
115+
return createRoom(data);
116+
case 'create_dm':
117+
return createDm(data);
118+
case "change_room_history_visibility":
119+
return changeRoomHistoryVisibility(data);
120+
case "open-room":
121+
return openRoom(data);
122+
case "accept_invite":
123+
return acceptInvite();
124+
case "invite_user":
125+
return inviteUser(data);
126+
105127
case 'idle':
106128
cy.wait(5000);
107129
break;
108-
case 'create_room':
109-
cy.get('.mx_RoomListHeader_plusButton').click();
110-
cy.get('.mx_ContextualMenu').contains('New room').click();
111-
cy.get('.mx_CreateRoomDialog_name input').type(data['name']);
112-
if (data['topic']) {
113-
cy.get('.mx_CreateRoomDialog_topic input').type(data['topic']);
114-
}
115-
// do this to prevent https://github.com/vector-im/element-web/issues/22590, weirdly
116-
// cy.get('.mx_CreateRoomDialog_name input').click();
117-
// cy.wait(5000);
118-
119-
cy.get('.mx_Dialog_primary').click();
120-
//cy.get('.mx_RoomHeader_nametext').should('contain', data['name']);
121-
return "room_created";
122-
case 'create_dm':
123-
cy.get('.mx_RoomListHeader_plusButton').click();
124-
cy.get('.mx_ContextualMenu').contains('Start new chat').click();
125-
cy.get('[data-testid="invite-dialog-input"]').type(`@${data["userId"]}`);
126-
cy.get('.mx_InviteDialog_goButton').click();
127-
return "dm_created";
128130
case 'send_message':
129131
cy.get('.mx_SendMessageComposer div[contenteditable=true]')
130132
.click()
131133
.type(data['message'])
132134
.type("{enter}");
133135
//cy.contains(data['message']).closest('mx_EventTile').should('have.class', 'mx_EventTile_receiptSent');
134136
return "message_sent";
135-
case "change_room_history_visibility":
136-
cy.get(".mx_RightPanel_roomSummaryButton").click();
137-
cy.get(".mx_RoomSummaryCard_icon_settings").click();
138-
cy.get(`[data-testid='settings-tab-ROOM_SECURITY_TAB']`).click();
139-
// should be either "shared", "invited" or "joined"
140-
// TODO: has doesn't seem to work
141-
cy.get(`#historyVis-${data['historyVisibility']}`).parents("label").click();
142-
cy.get(".mx_Dialog_cancelButton").click();
143-
cy.get("[data-test-id=base-card-close-button]").click();
144-
return "changed";
145-
case "invite_user": {
146-
cy.get(".mx_RightPanel_roomSummaryButton").click();
147-
cy.get(".mx_RoomSummaryCard_icon_people").click();
148-
cy.get(".mx_MemberList_invite").click();
149-
cy.get(".mx_InviteDialog_addressBar input")
150-
.type(`@${data["userId"]}`)
151-
.type("{enter}");
152-
cy.get(".mx_InviteDialog_goButton").click();
153-
cy.get(".mx_AccessibleButton.mx_BaseCard_back").click();
154-
cy.get(".mx_AccessibleButton.mx_BaseCard_close", { timeout: 30000 }).click();
155-
return "invited";
156-
}
157-
case "open-room": {
158-
cy.get(".mx_RoomSublist_tiles").contains(data["name"]).click();
159-
return "room-opened";
160-
}
161-
case "accept_invite":
162-
cy.get(".mx_RoomTile").click();
163-
cy.get(".mx_RoomPreviewBar_actions .mx_AccessibleButton_kind_primary").click();
164-
return "accepted";
165137
case "verify_message_in_timeline":
166138
cy.contains(data["message"]);
167139
return "verified";

0 commit comments

Comments
 (0)