-
Notifications
You must be signed in to change notification settings - Fork 10k
/
home-content.ts
247 lines (195 loc) · 8.31 KB
/
home-content.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
import type { Locator, Page } from '@playwright/test';
export class FederationHomeContent {
protected readonly page: Page;
constructor(page: Page) {
this.page = page;
}
get inputMessage(): Locator {
return this.page.locator('[name="msg"]');
}
get messagePopUpItems(): Locator {
return this.page.locator('role=menu[name="People"]');
}
get lastUserMessage(): Locator {
return this.page.locator('[data-qa-type="message"]').last();
}
get lastUserMessageBody(): Locator {
return this.lastUserMessage.locator('[data-qa-type="message-body"]');
}
get lastUserMessageNotSequential(): Locator {
return this.page.locator('[data-qa-type="message"][data-sequential="false"]').last();
}
get typingIndicator(): Locator {
return this.page.locator('.rc-message-box__activity');
}
async sendMessage(text: string): Promise<void> {
await this.page.locator('[name="msg"]').type(text);
await this.page.locator('button[aria-label="Send"]').click();
}
async sendMessageUsingEnter(text: string): Promise<void> {
await this.page.locator('[name="msg"]').type(text);
await this.page.keyboard.press('Enter');
}
async editLastMessage(message: string): Promise<void> {
await this.openLastMessageMenu();
await this.btnOptionEditMessage.click();
await this.page.locator('[name="msg"]').fill(message);
await this.page.keyboard.press('Enter');
}
async deleteLastMessage(): Promise<void> {
await this.openLastMessageMenu();
await this.btnOptionDeleteMessage.click();
await this.page.locator('#modal-root dialog .rcx-modal__inner .rcx-modal__footer .rcx-button--danger').click();
}
async starLastMessage(): Promise<void> {
await this.openLastMessageMenu();
await this.btnOptionStarMessage.waitFor();
await this.btnOptionStarMessage.click();
}
async replyInDm(message: string): Promise<void> {
await this.openLastMessageMenu();
await this.btnOptionReplyDirectly.click();
await this.page.waitForTimeout(2000);
await this.page.locator('[name="msg"]').type(message, { delay: 100 });
await this.page.waitForTimeout(2000);
await this.page.keyboard.press('Enter');
}
async sendAudioRecordedMessage(): Promise<void> {
await this.btnRecordAudio.click();
await this.page.waitForTimeout(3000);
await this.page.locator('.rc-message-box__icon.rc-message-box__audio-message-done').click();
await this.btnModalConfirm.click();
}
async sendVideoRecordedMessage(): Promise<void> {
await this.btnVideoMessage.click();
await this.page.locator('.rcx-box.rcx-box--full.rcx-icon--name-rec').click();
await this.page.waitForTimeout(3000);
await this.page.locator('.rcx-box.rcx-box--full.rcx-icon--name-stop-unfilled').click();
await this.page.locator('button >> text="Send"').click();
await this.page.waitForTimeout(3000);
await this.btnModalConfirm.click();
}
async dispatchSlashCommand(text: string): Promise<void> {
await this.page.locator('[name="msg"]').fill(text);
await this.page.locator('button[aria-label="Send"]').waitFor();
await this.page.locator('button[aria-label="Send"]').click();
}
get btnModalCancel(): Locator {
return this.page.locator('#modal-root .rcx-button-group--align-end .rcx-button--secondary');
}
get modalFilePreview(): Locator {
return this.page.locator(
'//div[@id="modal-root"]//header//following-sibling::div[1]//div//div//img | //div[@id="modal-root"]//header//following-sibling::div[1]//div//div//div//i',
);
}
get btnModalConfirm(): Locator {
return this.page.locator('#modal-root .rcx-button-group--align-end .rcx-button--primary');
}
get descriptionInput(): Locator {
return this.page.locator('//div[@id="modal-root"]//fieldset//div[2]//span//input');
}
get getLastFileAttachmentContent(): Locator {
return this.page.locator('.rcx-attachment__content').last();
}
get getLastFileName(): Locator {
return this.page.locator('.rcx-message-attachment').last();
}
get fileNameInput(): Locator {
return this.page.locator('//div[@id="modal-root"]//fieldset//div[1]//span//input');
}
get lastMessageFileName(): Locator {
return this.page.locator('[data-qa-type="message"]:last-child');
}
async getLastFileMessageByFileName(filename: string): Promise<Locator> {
return this.page.locator('[data-qa-type="message"]:last-child .rcx-message-container').last().locator(`div[title="${filename}"]`);
}
async getLastVideoMessageFileName(filename: string): Promise<Locator> {
return this.getLastFileMessageByFileName(filename);
}
get lastFileMessage(): Locator {
return this.page.locator('[data-qa-type="message"]:last-child .rcx-message-container').last();
}
get waitForLastMessageTextAttachmentEqualsText(): Locator {
return this.page.locator('[data-qa-type="message"]:last-child .rcx-attachment__details .rcx-message-body');
}
get btnOptionEditMessage(): Locator {
return this.page.locator('[data-qa-id="edit-message"]');
}
get btnOptionDeleteMessage(): Locator {
return this.page.locator('[data-qa-id="delete-message"]');
}
get btnOptionPinMessage(): Locator {
return this.page.locator('[data-qa-id="pin-message"]');
}
get btnOptionStarMessage(): Locator {
return this.page.locator('[data-qa-id="star-message"]');
}
get btnOptionFileUpload(): Locator {
return this.page.locator('[data-qa-id="file-upload"]');
}
get btnVideoMessage(): Locator {
return this.page.locator('[data-qa-id="video-message"]');
}
get btnRecordAudio(): Locator {
return this.page.locator('[data-qa-id="audio-record"]');
}
get btnMenuMoreActions() {
return this.page.locator('[data-qa-id="menu-more-actions"]');
}
get linkUserCard(): Locator {
return this.page.locator('[data-qa="UserCard"] a');
}
get btnContactInformation(): Locator {
return this.page.locator('[data-qa-id="ToolBoxAction-user"]');
}
get btnContactEdit(): Locator {
return this.page.locator('.rcx-vertical-bar button:has-text("Edit")');
}
get btnOptionReplyInThread(): Locator {
return this.page.locator('[data-qa-id="reply-in-thread"]');
}
get btnOptionStartDiscussion(): Locator {
return this.page.locator('[data-qa-id="start-discussion"]');
}
get btnOptionReplyDirectly(): Locator {
return this.page.locator('[data-qa-id="reply-directly"]');
}
async pickEmoji(emoji: string, section = 'icon-people') {
await this.page.locator('.rc-message-box__icon.emoji-picker-icon').click();
await this.page.locator(`//*[contains(@class, "emoji-picker")]//*[contains(@class, "${section}")]`).click();
await this.page.locator(`//*[contains(@class, "emoji-picker")]//*[contains(@class, "${emoji}")]`).first().click();
}
async sendFileMessage(fileName: string): Promise<void> {
await this.page.locator('input[type=file]').setInputFiles(`./tests/e2e/federation/files/${fileName}`);
}
async openLastMessageMenu(): Promise<void> {
await this.page.locator('[data-qa-type="message"]').last().hover();
await this.page.locator('[data-qa-type="message"]').last().locator('[data-qa-type="message-action-menu"][data-qa-id="menu"]').waitFor();
await this.page.locator('[data-qa-type="message"]').last().locator('[data-qa-type="message-action-menu"][data-qa-id="menu"]').click();
}
async quoteMessage(message: string): Promise<void> {
await this.openLastMessageMenu();
await this.page.locator('[data-qa-id="quote-message"]').click();
await this.page.locator('[name="msg"]').fill(message);
await this.page.keyboard.press('Enter');
}
async reactToMessage(emoji: string): Promise<void> {
await this.openLastMessageMenu();
await this.page.locator('[data-qa-id="reaction-message"]').click();
await this.page.locator('input.js-emojipicker-search').type(emoji);
await this.page.locator(`[data-emoji="${emoji}"]`).last().click();
}
async unreactLastMessage(): Promise<void> {
await this.page.locator('[data-qa-type="message"]').last().locator('.rcx-message-reactions__reaction').nth(1).waitFor();
await this.page.locator('[data-qa-type="message"]').last().locator('.rcx-message-reactions__reaction').nth(1).click();
}
async getSystemMessageByText(text: string): Promise<Locator> {
return this.page.locator('div[data-qa="system-message"] div[data-qa-type="system-message-body"]', { hasText: text });
}
async getLastSystemMessageName(): Promise<Locator> {
return this.page.locator('div[data-qa="system-message"]:last-child span.rcx-message-system__name');
}
async getAllReactions(): Promise<Locator> {
return this.page.locator('[data-qa-type="message"]').last().locator('.rcx-message-reactions__reaction');
}
}