()
| 174 | } |
| 175 | |
| 176 | async getRecentUserMessage() { |
| 177 | const messageElements = await this.page.getByTestId('message-user').all(); |
| 178 | const lastMessageElement = messageElements.at(-1); |
| 179 | |
| 180 | if (!lastMessageElement) { |
| 181 | throw new Error('No user message found'); |
| 182 | } |
| 183 | |
| 184 | const content = await lastMessageElement |
| 185 | .getByTestId('message-content') |
| 186 | .innerText() |
| 187 | .catch(() => null); |
| 188 | |
| 189 | const hasAttachments = await lastMessageElement |
| 190 | .getByTestId('message-attachments') |
| 191 | .isVisible() |
| 192 | .catch(() => false); |
| 193 | |
| 194 | const attachments = hasAttachments |
| 195 | ? await lastMessageElement.getByTestId('message-attachments').all() |
| 196 | : []; |
| 197 | |
| 198 | const page = this.page; |
| 199 | |
| 200 | return { |
| 201 | element: lastMessageElement, |
| 202 | content, |
| 203 | attachments, |
| 204 | async edit(newMessage: string) { |
| 205 | await page.getByTestId('message-edit-button').click(); |
| 206 | await page.getByTestId('message-editor').fill(newMessage); |
| 207 | await page.getByTestId('message-editor-send-button').click(); |
| 208 | await expect( |
| 209 | page.getByTestId('message-editor-send-button'), |
| 210 | ).not.toBeVisible(); |
| 211 | }, |
| 212 | }; |
| 213 | } |
| 214 | |
| 215 | async expectToastToContain(text: string) { |
| 216 | await expect(this.page.getByTestId('toast')).toContainText(text); |
no outgoing calls
no test coverage detected