|
| 1 | +/* |
| 2 | + * Wire |
| 3 | + * Copyright (C) 2025 Wire Swiss GmbH |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU General Public License as published by |
| 7 | + * the Free Software Foundation, either version 3 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License |
| 16 | + * along with this program. If not, see http://www.gnu.org/licenses/. |
| 17 | + * |
| 18 | + */ |
| 19 | + |
| 20 | +import {getUser} from 'test/e2e_tests/data/user'; |
| 21 | +import {PageManager} from 'test/e2e_tests/pageManager'; |
| 22 | +import {setupBasicTestScenario} from 'test/e2e_tests/utils/setup.util'; |
| 23 | +import {tearDownAll} from 'test/e2e_tests/utils/tearDown.util'; |
| 24 | +import {createGroup, loginUser} from 'test/e2e_tests/utils/userActions'; |
| 25 | + |
| 26 | +import {test, expect} from '../../test.fixtures'; |
| 27 | + |
| 28 | +test.describe('Accessibility', () => { |
| 29 | + test.slow(); |
| 30 | + |
| 31 | + let owner = getUser(); |
| 32 | + const members = Array.from({length: 2}, () => getUser()); |
| 33 | + const [memberA, memberB] = members; |
| 34 | + const teamName = 'Accessibility'; |
| 35 | + const conversationName = 'AccTest'; |
| 36 | + const textMessage = 'long text message'; |
| 37 | + const narrowViewport = {width: 480, height: 800}; |
| 38 | + const loginTimeOut = 60_000; |
| 39 | + |
| 40 | + test.beforeAll(async ({api}) => { |
| 41 | + const user = await setupBasicTestScenario(api, members, owner, teamName); |
| 42 | + owner = {...owner, ...user}; |
| 43 | + }); |
| 44 | + |
| 45 | + const navigateToConversation = async (pageManager: PageManager, name: string) => { |
| 46 | + await pageManager.webapp.pages.conversationList().openConversation(name); |
| 47 | + }; |
| 48 | + |
| 49 | + test( |
| 50 | + 'I want to see typing indicator in group conversation', |
| 51 | + {tag: ['@TC-46', '@regression']}, |
| 52 | + async ({pageManager: memberPageManagerA, browser}) => { |
| 53 | + const memberContext = await browser.newContext(); |
| 54 | + const memberPage = await memberContext.newPage(); |
| 55 | + const memberPageManagerB = new PageManager(memberPage); |
| 56 | + |
| 57 | + const toggleTypingIndicator = async (pageManager: PageManager) => { |
| 58 | + await pageManager.webapp.components.conversationSidebar().clickPreferencesButton(); |
| 59 | + await pageManager.webapp.pages.account().toggleTypingIndicator(); |
| 60 | + await pageManager.webapp.components.conversationSidebar().clickAllConversationsButton(); |
| 61 | + }; |
| 62 | + |
| 63 | + const typeAndCheckIndicator = async ( |
| 64 | + senderPage: PageManager, |
| 65 | + receiverPage: PageManager, |
| 66 | + message: string, |
| 67 | + expectedState: boolean, |
| 68 | + ) => { |
| 69 | + await senderPage.webapp.pages.conversation().typeMessage(message); |
| 70 | + // Wait for a short moment for the indicator to appear/disappear |
| 71 | + await senderPage.waitForTimeout(800); |
| 72 | + const isVisible = await receiverPage.webapp.pages.conversation().isTypingIndicator.isVisible(); |
| 73 | + expect(isVisible).toBe(expectedState); |
| 74 | + }; |
| 75 | + |
| 76 | + // Initial setup |
| 77 | + await memberPageManagerA.openMainPage(); |
| 78 | + await memberPageManagerB.openMainPage(); |
| 79 | + await loginUser(memberA, memberPageManagerA); |
| 80 | + await loginUser(memberB, memberPageManagerB); |
| 81 | + |
| 82 | + await memberPageManagerA.webapp.components |
| 83 | + .conversationSidebar() |
| 84 | + .personalUserName.waitFor({state: 'visible', timeout: loginTimeOut}); |
| 85 | + |
| 86 | + await memberPageManagerA.webapp.modals.dataShareConsent().clickDecline(); |
| 87 | + await memberPageManagerB.webapp.modals.dataShareConsent().clickDecline(); |
| 88 | + |
| 89 | + await createGroup(memberPageManagerA, conversationName, [memberB]); |
| 90 | + |
| 91 | + await navigateToConversation(memberPageManagerA, conversationName); |
| 92 | + await navigateToConversation(memberPageManagerB, conversationName); |
| 93 | + |
| 94 | + await test.step('User A starts typing in group and B sees typing indicator', async () => { |
| 95 | + await typeAndCheckIndicator(memberPageManagerA, memberPageManagerB, textMessage, true); |
| 96 | + }); |
| 97 | + |
| 98 | + await test.step('User A starts typing in group and B does not see typing indicator', async () => { |
| 99 | + // Disable typing indicator for user A |
| 100 | + await toggleTypingIndicator(memberPageManagerA); |
| 101 | + await navigateToConversation(memberPageManagerA, conversationName); |
| 102 | + |
| 103 | + await typeAndCheckIndicator(memberPageManagerA, memberPageManagerB, textMessage, false); |
| 104 | + |
| 105 | + // Re-enable typing indicator for user A for subsequent tests |
| 106 | + await toggleTypingIndicator(memberPageManagerA); |
| 107 | + await navigateToConversation(memberPageManagerA, conversationName); |
| 108 | + }); |
| 109 | + |
| 110 | + await test.step('User B turns indicator off and does not see typing indicator', async () => { |
| 111 | + // Disable typing indicator for user B |
| 112 | + await toggleTypingIndicator(memberPageManagerB); |
| 113 | + await navigateToConversation(memberPageManagerB, conversationName); |
| 114 | + |
| 115 | + await typeAndCheckIndicator(memberPageManagerA, memberPageManagerB, textMessage, false); |
| 116 | + }); |
| 117 | + |
| 118 | + await test.step('User B turns indicator on again and sees typing indicator', async () => { |
| 119 | + // Re-enable typing indicator for user B |
| 120 | + await toggleTypingIndicator(memberPageManagerB); |
| 121 | + await navigateToConversation(memberPageManagerB, conversationName); |
| 122 | + |
| 123 | + await typeAndCheckIndicator(memberPageManagerA, memberPageManagerB, textMessage, true); |
| 124 | + }); |
| 125 | + |
| 126 | + await memberContext.close(); |
| 127 | + }, |
| 128 | + ); |
| 129 | + |
| 130 | + test('I want to see collapsed view when app is narrow', {tag: ['@TC-48', '@regression']}, async ({pageManager}) => { |
| 131 | + await (await pageManager.getPage()).setViewportSize(narrowViewport); |
| 132 | + |
| 133 | + await pageManager.openMainPage(); |
| 134 | + await loginUser(memberA, pageManager); |
| 135 | + const {components, pages} = pageManager.webapp; |
| 136 | + |
| 137 | + await pages.historyInfo().clickConfirmButton(); |
| 138 | + await components.conversationSidebar().sidebar.waitFor({state: 'visible', timeout: loginTimeOut}); |
| 139 | + |
| 140 | + await expect(components.conversationSidebar().sidebar).toHaveAttribute('data-is-collapsed', 'true'); |
| 141 | + }); |
| 142 | + |
| 143 | + test( |
| 144 | + 'I should not lose a drafted message when switching between conversations in collapsed view', |
| 145 | + {tag: ['@TC-51', '@regression']}, |
| 146 | + async ({pageManager}) => { |
| 147 | + const message = 'test'; |
| 148 | + const {components, modals, pages} = pageManager.webapp; |
| 149 | + await pageManager.openMainPage(); |
| 150 | + await loginUser(memberA, pageManager); |
| 151 | + |
| 152 | + await pages.historyInfo().clickConfirmButton(); |
| 153 | + await components.conversationSidebar().sidebar.waitFor({state: 'visible', timeout: loginTimeOut}); |
| 154 | + |
| 155 | + await createGroup(pageManager, conversationName, [memberB]); |
| 156 | + |
| 157 | + await pages.conversation().typeMessage(message); |
| 158 | + const page = await pageManager.getPage(); |
| 159 | + |
| 160 | + await components.conversationSidebar().clickConnectButton(); |
| 161 | + |
| 162 | + await page.locator('[data-uie-name="highlighted"]').nth(0).click(); |
| 163 | + await modals.userProfile().clickStartConversation(); |
| 164 | + await expect(page.locator('[data-uie-name="secondary-line"]')).toHaveText(message); |
| 165 | + |
| 166 | + await pages.conversationList().openConversation(memberB.fullName); |
| 167 | + |
| 168 | + await pages.conversationList().openConversation(conversationName); |
| 169 | + await expect(await pages.conversation().messageInput).toHaveText(message); |
| 170 | + }, |
| 171 | + ); |
| 172 | + |
| 173 | + test.afterAll(async ({api}) => { |
| 174 | + await tearDownAll(api); |
| 175 | + }); |
| 176 | +}); |
0 commit comments