From 8565ee55efa77a40164d5da06150f3347fb3a344 Mon Sep 17 00:00:00 2001 From: Emi Date: Fri, 15 Sep 2023 21:19:18 +0200 Subject: [PATCH 01/17] Add new user to multiple users e2e test --- .../widgets/channels/BasicMessage.tsx | 2 +- packages/e2e-tests/src/selectors.ts | 11 ++ .../e2e-tests/src/tests/twoClients.test.ts | 149 +++++++++++++----- packages/e2e-tests/src/utils.ts | 2 - 4 files changed, 120 insertions(+), 44 deletions(-) diff --git a/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.tsx b/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.tsx index 966722fb21..96d30899a7 100644 --- a/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.tsx +++ b/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.tsx @@ -219,7 +219,7 @@ export const BasicMessageComponent: React.FC {/* {userLabel && ( - + (resolve => setTimeout(() => resolve(), 2000)) } + console.log('App closed', this.buildSetup.dataDir) } get saveStateButton() { @@ -256,6 +259,14 @@ export class Channel { ) } + async getUserLabels(username: string) { + const labels = await this.driver.wait( + until.elementsLocated(By.xpath(`//*[contains(@data-testid, "userLabel-${username}")]`)) + ) + console.log('labels', labels) + return labels.map(labelElement => labelElement.findElement(By.css('span')).getText()) + } + async getMessage(text: string) { return await this.driver.wait(until.elementLocated(By.xpath(`//span[contains(text(),"${text}")]`))) } diff --git a/packages/e2e-tests/src/tests/twoClients.test.ts b/packages/e2e-tests/src/tests/twoClients.test.ts index 463f585ef3..7ae4a74a68 100644 --- a/packages/e2e-tests/src/tests/twoClients.test.ts +++ b/packages/e2e-tests/src/tests/twoClients.test.ts @@ -13,14 +13,17 @@ import logger from '../logger' const log = logger('Two Clients:') jest.setTimeout(900000) -describe('Two Clients', () => { +describe('Multiple Clients', () => { let ownerApp: App let guestApp: App + let secondGuestApp: App let registerModal2: RegisterUsernameModal + let registerModal3: RegisterUsernameModal - let generalChannel: Channel + let ownerGeneralChannel: Channel let generalChannel2: Channel + let secondGuestGeneralChannel: Channel let secondChannel: Channel let secondChannel2: Channel @@ -37,7 +40,9 @@ describe('Two Clients', () => { const ownerMessages = ['Hi', 'Hello', 'After guest leave app'] const joiningUserUsername = 'alice-joining' const joiningUserUsername2 = 'alice2' - const joiningUserMessages = ['Nice to meet you all', 'Nice to meet you again'] + const joiningUserUsername3 = 'alice-unregistered' + + const joiningUserMessages = ['Nice to meet you all', 'Nice to meet you again', 'Hi everyone'] const newChannelName = 'mid-night-club' const sleep = async (time = 1000) => @@ -71,20 +76,20 @@ describe('Two Clients', () => { }) } - it('JoinCommunityModal - owner switch to create community', async () => { + it('JoinCommunityModal - owner switches to create community modal', async () => { const joinModal = new JoinCommunityModal(ownerApp.driver) const isJoinModal = await joinModal.element.isDisplayed() expect(isJoinModal).toBeTruthy() await joinModal.switchToCreateCommunity() }) - it('CreateCommunityModal - owner create his community', async () => { + it('CreateCommunityModal - owner creates the community', async () => { const createModal = new CreateCommunityModal(ownerApp.driver) const isCreateModal = await createModal.element.isDisplayed() expect(isCreateModal).toBeTruthy() await createModal.typeCommunityName(communityName) await createModal.submit() }) - it('RegisterUsernameModal - owner has registered', async () => { + it('RegisterUsernameModal - owner registers username', async () => { const registerModal = new RegisterUsernameModal(ownerApp.driver) const isRegisterModal = await registerModal.element.isDisplayed() expect(isRegisterModal).toBeTruthy() @@ -96,24 +101,24 @@ describe('Two Clients', () => { const isLoadingPanelCommunity = await loadingPanelCommunity.element.isDisplayed() expect(isLoadingPanelCommunity).toBeTruthy() }) - it('General channel check', async () => { - generalChannel = new Channel(ownerApp.driver, 'general') - const isGeneralChannel = await generalChannel.element.isDisplayed() - const generalChannelText = await generalChannel.element.getText() + it('Owner sees general channel', async () => { + ownerGeneralChannel = new Channel(ownerApp.driver, 'general') + const isGeneralChannel = await ownerGeneralChannel.element.isDisplayed() + const generalChannelText = await ownerGeneralChannel.element.getText() expect(isGeneralChannel).toBeTruthy() expect(generalChannelText).toEqual('# general') }) - it('Send message', async () => { - const isMessageInput = await generalChannel.messageInput.isDisplayed() + it('Owner sends a message', async () => { + const isMessageInput = await ownerGeneralChannel.messageInput.isDisplayed() expect(isMessageInput).toBeTruthy() - await generalChannel.sendMessage(ownerMessages[0]) + await ownerGeneralChannel.sendMessage(ownerMessages[0]) }) - it('Visible message', async () => { - const messages = await generalChannel.getUserMessages(ownerUsername) + it("Owner's message is visible on channel", async () => { + const messages = await ownerGeneralChannel.getUserMessages(ownerUsername) const text = await messages[1].getText() expect(text).toEqual(ownerMessages[0]) }) - it('Opens the settings tab and gets an invitation code', async () => { + it('Owner opens the settings tab and gets an invitation code', async () => { const settingsModal = await new Sidebar(ownerApp.driver).openSettings() const isSettingsModal = await settingsModal.element.isDisplayed() expect(isSettingsModal).toBeTruthy() @@ -130,7 +135,7 @@ describe('Two Clients', () => { await settingsModal.close() }) - it('Guest setup', async () => { + it('Guest opens the app', async () => { console.log('Second client') guestApp = new App() await guestApp.open() @@ -152,18 +157,7 @@ describe('Two Clients', () => { await joinCommunityModal.submit() }) - it.skip('RegisterUsernameModal - User tries to register already taken username, sees error', async () => { - console.log('new user - 4') - registerModal2 = new RegisterUsernameModal(guestApp.driver) - const isRegisterModal2 = await registerModal2.element.isDisplayed() - expect(isRegisterModal2).toBeTruthy() - await registerModal2.typeUsername(ownerUsername) - await registerModal2.submit() - const usernameTakenError = await registerModal2.error.isDisplayed() - expect(usernameTakenError).toBeTruthy() - }) - - it('RegisterUsernameModal - User successfully register not taken username', async () => { + it('RegisterUsernameModal - User submits the username', async () => { console.log('new user - 5') registerModal2 = new RegisterUsernameModal(guestApp.driver) const isRegisterModal = await registerModal2.element.isDisplayed() @@ -179,7 +173,7 @@ describe('Two Clients', () => { const isLoadingPanelCommunity2 = await loadingPanelCommunity2.element.isDisplayed() expect(isLoadingPanelCommunity2).toBeTruthy() }) - it('User sends a message', async () => { + it('User sees general channel and sends a message', async () => { console.log('new user - 7') generalChannel2 = new Channel(guestApp.driver, 'general') await generalChannel2.element.isDisplayed() @@ -194,6 +188,7 @@ describe('Two Clients', () => { await generalChannel2.sendMessage(joiningUserMessages[0]) }) it('Sent message is visible in a channel', async () => { + // check that message is tagged as 'registered' console.log('new user - 8') const messages2 = await generalChannel2.getUserMessages(joiningUserUsername) const messages1 = await generalChannel2.getUserMessages(ownerUsername) @@ -203,20 +198,93 @@ describe('Two Clients', () => { expect(text2).toEqual(joiningUserMessages[0]) }) - it('Channel creation - Owner create second channel', async () => { + // third user joins + it('Owner goes offline', async () => { + await ownerApp.close() + }) + + it('Second guest opens the app', async () => { + console.log('Third client') + secondGuestApp = new App() + await secondGuestApp.open() + }) + + it('Second guest starts to register when owner is offline', async () => { + // console.log('new user - 3') + const joinCommunityModal = new JoinCommunityModal(secondGuestApp.driver) + const isJoinCommunityModal = await joinCommunityModal.element.isDisplayed() + expect(isJoinCommunityModal).toBeTruthy() + console.log({ invitationCode }) + await joinCommunityModal.typeCommunityCode(invitationCode) + await joinCommunityModal.submit() + }) + + it('Second guest submits username', async () => { + console.log('nereeew user - 5') + registerModal3 = new RegisterUsernameModal(secondGuestApp.driver) + const isRegisterModal = await registerModal3.element.isDisplayed() + expect(isRegisterModal).toBeTruthy() + await registerModal3.clearInput() + await registerModal3.typeUsername(joiningUserUsername) + await registerModal3.submit() + }) + + it('Second quest sees general channel', async () => { + console.log('new user - 7') + secondGuestGeneralChannel = new Channel(secondGuestApp.driver, 'general') + await secondGuestGeneralChannel.element.isDisplayed() + const isMessageInput = await secondGuestGeneralChannel.messageInput.isDisplayed() + expect(isMessageInput).toBeTruthy() + }) + + it('Second guest can send a message, they message is tagged as "unregistered"', async () => { + console.log('FETCHING CHANNEL MESSAGES!') + await new Promise(resolve => + setTimeout(() => { + resolve() + }, 15000) + ) + await secondGuestGeneralChannel.sendMessage(joiningUserMessages[2]) + secondGuestGeneralChannel = new Channel(secondGuestApp.driver, 'general') + const guestlabels = await ownerGeneralChannel.getUserLabels(joiningUserUsername3) + expect(guestlabels.length).toEqual(1) + for (const label in guestlabels) { + expect(label).toEqual('Unregistered') + } + }) + + // TODO: check if other user also sees unregistered user marked as "registered" + + it('Owner goes back online', async () => { + await ownerApp.open() + const debugModal = new DebugModeModal(ownerApp.driver) + await debugModal.close() + }) + + it('Unregistered user receives certificate, the "Unregistered" label is removed', async () => { + // Probably need to wait + ownerGeneralChannel = new Channel(ownerApp.driver, 'general') + const ownerAppLabels = await ownerGeneralChannel.getUserLabels(joiningUserUsername3) + for (const label in ownerAppLabels) { + expect(label).toEqual('Registered') + } + }) + + // TODO: maybe add extra "it" with "channel creation"? + it('Channel creation - Owner creates second channel', async () => { sidebar = new Sidebar(ownerApp.driver) await sidebar.addNewChannel(newChannelName) await sidebar.switchChannel(newChannelName) const channels = await sidebar.getChannelList() expect(channels.length).toEqual(2) }) - it('Channel creation - Owner send message in second channel', async () => { + it('Channel creation - Owner sends message in second channel', async () => { secondChannel = new Channel(ownerApp.driver, newChannelName) const isMessageInput = await secondChannel.messageInput.isDisplayed() expect(isMessageInput).toBeTruthy() await secondChannel.sendMessage(ownerMessages[1]) }) - it('Channel creation - User read message in second channel', async () => { + it('Channel creation - User reads message in second channel', async () => { sidebar2 = new Sidebar(guestApp.driver) await sidebar2.switchChannel(newChannelName) secondChannel2 = new Channel(guestApp.driver, newChannelName) @@ -229,7 +297,7 @@ describe('Two Clients', () => { const text = await messages[1].getText() expect(text).toEqual(ownerMessages[1]) }) - it('Channel deletion - Owner delete second channel', async () => { + it('Channel deletion - Owner deletes second channel', async () => { channelContextMenu = new ChannelContextMenu(ownerApp.driver) await channelContextMenu.openMenu() await channelContextMenu.openDeletionChannelModal() @@ -237,14 +305,13 @@ describe('Two Clients', () => { const channels = await sidebar.getChannelList() expect(channels.length).toEqual(1) }) - it('Channel deletion - User see info about channel deletion in general channel', async () => { + it('Channel deletion - User sees info about channel deletion in general channel', async () => { await sleep(5000) const messages = await generalChannel2.getUserMessages(ownerUsername) const text = await messages[3].getText() expect(text).toEqual(`@${ownerUsername} deleted #${newChannelName}`) }) it('Channel deletion - User can create channel with the same name and is fresh channel', async () => { - console.log('TEST 1') await sidebar2.addNewChannel(newChannelName) await sidebar2.switchChannel(newChannelName) const messages = await secondChannel2.getUserMessages(joiningUserUsername) @@ -277,7 +344,7 @@ describe('Two Clients', () => { it('Channel deletion - Owner recreate general channel', async () => { console.log('TEST 3') await new Promise(resolve => setTimeout(() => resolve(), 10000)) - const isGeneralChannel = await generalChannel.messageInput.isDisplayed() + const isGeneralChannel = await ownerGeneralChannel.messageInput.isDisplayed() expect(isGeneralChannel).toBeTruthy() await channelContextMenu.openMenu() await channelContextMenu.openDeletionChannelModal() @@ -364,14 +431,14 @@ describe('Two Clients', () => { it('Guest close app - Owner send another message after guest leave app', async () => { console.log('TEST 10') - generalChannel = new Channel(ownerApp.driver, 'general') - const isMessageInput = await generalChannel.messageInput.isDisplayed() + ownerGeneralChannel = new Channel(ownerApp.driver, 'general') + const isMessageInput = await ownerGeneralChannel.messageInput.isDisplayed() expect(isMessageInput).toBeTruthy() - await generalChannel.sendMessage(ownerMessages[2]) + await ownerGeneralChannel.sendMessage(ownerMessages[2]) }) it('Guest close app - Check if message is visible for owner', async () => { console.log('TEST 11') - const messages = await generalChannel.getUserMessages(ownerUsername) + const messages = await ownerGeneralChannel.getUserMessages(ownerUsername) const text = await messages[messages.length - 1].getText() expect(text).toEqual(ownerMessages[2]) }) diff --git a/packages/e2e-tests/src/utils.ts b/packages/e2e-tests/src/utils.ts index 70ba424d44..96e2a11a61 100644 --- a/packages/e2e-tests/src/utils.ts +++ b/packages/e2e-tests/src/utils.ts @@ -15,8 +15,6 @@ export interface BuildSetupInit { export class BuildSetup { private driver?: ThenableWebDriver | null - public containerId?: string - public ipAddress?: string public port?: number public debugPort?: number public dataDir?: string From e1d07b74bd3e75f4323f55a04ce5377688945be2 Mon Sep 17 00:00:00 2001 From: Emi Date: Mon, 18 Sep 2023 11:31:39 +0200 Subject: [PATCH 02/17] Uncomment showing label --- .../src/renderer/components/widgets/channels/BasicMessage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.tsx b/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.tsx index 96d30899a7..e51dd27741 100644 --- a/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.tsx +++ b/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.tsx @@ -218,7 +218,7 @@ export const BasicMessageComponent: React.FC - {/* {userLabel && ( + {userLabel && ( - )} */} + )} {status !== 'failed' && ( Date: Tue, 19 Sep 2023 12:52:14 +0200 Subject: [PATCH 03/17] Fix few steps in e2e multiple user test --- .../e2e-tests/src/tests/twoClients.test.ts | 365 +++++++++--------- 1 file changed, 187 insertions(+), 178 deletions(-) diff --git a/packages/e2e-tests/src/tests/twoClients.test.ts b/packages/e2e-tests/src/tests/twoClients.test.ts index 7ae4a74a68..1687296c10 100644 --- a/packages/e2e-tests/src/tests/twoClients.test.ts +++ b/packages/e2e-tests/src/tests/twoClients.test.ts @@ -58,6 +58,8 @@ describe('Multiple Clients', () => { afterAll(async () => { await ownerApp?.close() + await guestApp?.close() + await secondGuestApp?.close() }) beforeEach(async () => { @@ -157,7 +159,7 @@ describe('Multiple Clients', () => { await joinCommunityModal.submit() }) - it('RegisterUsernameModal - User submits the username', async () => { + it('RegisterUsernameModal - Guest submits the username', async () => { console.log('new user - 5') registerModal2 = new RegisterUsernameModal(guestApp.driver) const isRegisterModal = await registerModal2.element.isDisplayed() @@ -173,7 +175,7 @@ describe('Multiple Clients', () => { const isLoadingPanelCommunity2 = await loadingPanelCommunity2.element.isDisplayed() expect(isLoadingPanelCommunity2).toBeTruthy() }) - it('User sees general channel and sends a message', async () => { + it('Guest sees general channel and sends a message', async () => { console.log('new user - 7') generalChannel2 = new Channel(guestApp.driver, 'general') await generalChannel2.element.isDisplayed() @@ -198,7 +200,7 @@ describe('Multiple Clients', () => { expect(text2).toEqual(joiningUserMessages[0]) }) - // third user joins + // third user joins when owner is offline. Does not use duplicated username it('Owner goes offline', async () => { await ownerApp.close() }) @@ -219,7 +221,7 @@ describe('Multiple Clients', () => { await joinCommunityModal.submit() }) - it('Second guest submits username', async () => { + it('Second guest submits username that is not used by other user', async () => { console.log('nereeew user - 5') registerModal3 = new RegisterUsernameModal(secondGuestApp.driver) const isRegisterModal = await registerModal3.element.isDisplayed() @@ -237,7 +239,7 @@ describe('Multiple Clients', () => { expect(isMessageInput).toBeTruthy() }) - it('Second guest can send a message, they message is tagged as "unregistered"', async () => { + it('Second guest can send a message, they see their message tagged as "unregistered"', async () => { console.log('FETCHING CHANNEL MESSAGES!') await new Promise(resolve => setTimeout(() => { @@ -254,6 +256,13 @@ describe('Multiple Clients', () => { }) // TODO: check if other user also sees unregistered user marked as "registered" + it('First user sees that unregistered user messages are marked as "unregistered"', async () => { + const guestlabels = await generalChannel2.getUserLabels(joiningUserUsername3) + expect(guestlabels.length).toEqual(1) + for (const label in guestlabels) { + expect(label).toEqual('Unregistered') + } + }) it('Owner goes back online', async () => { await ownerApp.open() @@ -270,178 +279,178 @@ describe('Multiple Clients', () => { } }) - // TODO: maybe add extra "it" with "channel creation"? - it('Channel creation - Owner creates second channel', async () => { - sidebar = new Sidebar(ownerApp.driver) - await sidebar.addNewChannel(newChannelName) - await sidebar.switchChannel(newChannelName) - const channels = await sidebar.getChannelList() - expect(channels.length).toEqual(2) - }) - it('Channel creation - Owner sends message in second channel', async () => { - secondChannel = new Channel(ownerApp.driver, newChannelName) - const isMessageInput = await secondChannel.messageInput.isDisplayed() - expect(isMessageInput).toBeTruthy() - await secondChannel.sendMessage(ownerMessages[1]) - }) - it('Channel creation - User reads message in second channel', async () => { - sidebar2 = new Sidebar(guestApp.driver) - await sidebar2.switchChannel(newChannelName) - secondChannel2 = new Channel(guestApp.driver, newChannelName) - await new Promise(resolve => - setTimeout(() => { - resolve() - }, 2000) - ) - const messages = await secondChannel2.getUserMessages(ownerUsername) - const text = await messages[1].getText() - expect(text).toEqual(ownerMessages[1]) - }) - it('Channel deletion - Owner deletes second channel', async () => { - channelContextMenu = new ChannelContextMenu(ownerApp.driver) - await channelContextMenu.openMenu() - await channelContextMenu.openDeletionChannelModal() - await channelContextMenu.deleteChannel() - const channels = await sidebar.getChannelList() - expect(channels.length).toEqual(1) - }) - it('Channel deletion - User sees info about channel deletion in general channel', async () => { - await sleep(5000) - const messages = await generalChannel2.getUserMessages(ownerUsername) - const text = await messages[3].getText() - expect(text).toEqual(`@${ownerUsername} deleted #${newChannelName}`) - }) - it('Channel deletion - User can create channel with the same name and is fresh channel', async () => { - await sidebar2.addNewChannel(newChannelName) - await sidebar2.switchChannel(newChannelName) - const messages = await secondChannel2.getUserMessages(joiningUserUsername) - expect(messages.length).toEqual(1) - await new Promise(resolve => - setTimeout(() => { - resolve() - }, 2000) - ) - const channels = await sidebar.getChannelList() - expect(channels.length).toEqual(2) - }) - // End of tests for Windows - if (process.platform !== 'win32') { - it('Leave community', async () => { - console.log('TEST 2') - const settingsModal = await new Sidebar(guestApp.driver).openSettings() - const isSettingsModal = await settingsModal.element.isDisplayed() - expect(isSettingsModal).toBeTruthy() - await settingsModal.openLeaveCommunityModal() - await settingsModal.leaveCommunityButton() - }) - if (process.env.TEST_MODE) { - it('Leave community - Close debug modal', async () => { - const debugModal = new DebugModeModal(guestApp.driver) - await debugModal.close() - }) - } - // Delete general channel while guest is absent - it('Channel deletion - Owner recreate general channel', async () => { - console.log('TEST 3') - await new Promise(resolve => setTimeout(() => resolve(), 10000)) - const isGeneralChannel = await ownerGeneralChannel.messageInput.isDisplayed() - expect(isGeneralChannel).toBeTruthy() - await channelContextMenu.openMenu() - await channelContextMenu.openDeletionChannelModal() - await channelContextMenu.deleteChannel() - const channels = await sidebar.getChannelList() - expect(channels.length).toEqual(2) - }) - - it('Leave community - Guest re-join to community successfully', async () => { - console.log('TEST 4') - const joinCommunityModal = new JoinCommunityModal(guestApp.driver) - const isJoinCommunityModal = await joinCommunityModal.element.isDisplayed() - expect(isJoinCommunityModal).toBeTruthy() - await joinCommunityModal.typeCommunityCode(invitationCode) - await joinCommunityModal.submit() - }) - it('Leave community - Guest register new username', async () => { - console.log('TEST 5') - const registerModal2 = new RegisterUsernameModal(guestApp.driver) - const isRegisterModal2 = await registerModal2.element.isDisplayed() - expect(isRegisterModal2).toBeTruthy() - await registerModal2.typeUsername(joiningUserUsername2) - await registerModal2.submit() - }) - - // Check correct channels replication - it('Channel deletion - User see information about recreation general channel and see correct amount of messages', async () => { - console.log('TEST 6') - generalChannel2 = new Channel(guestApp.driver, 'general') - await generalChannel2.element.isDisplayed() - await new Promise(resolve => - setTimeout(() => { - resolve() - }, 10000) - ) - const messages = await generalChannel2.getUserMessages(ownerUsername) - const text1 = await messages[0].getText() - const text2 = await messages[1].getText() - expect(messages.length).toEqual(2) - expect(text1).toEqual(`@${ownerUsername} deleted all messages in #general`) - expect(text2).toEqual(`@${joiningUserUsername2} has joined Testcommunity! 🎉`) - }) - - it('Leave community - Guest sends a message', async () => { - console.log('TEST 7') - generalChannel2 = new Channel(guestApp.driver, 'general') - await generalChannel2.element.isDisplayed() - const isMessageInput2 = await generalChannel2.messageInput.isDisplayed() - expect(isMessageInput2).toBeTruthy() - await new Promise(resolve => - setTimeout(() => { - resolve() - }, 5000) - ) - await generalChannel2.sendMessage(joiningUserMessages[1]) - }) - it('Leave community - Sent message is visible in a channel', async () => { - console.log('TEST 8') - const messages2 = await generalChannel2.getUserMessages(joiningUserUsername2) - const text2 = await messages2[0].getText() - expect(text2).toEqual(joiningUserMessages[1]) - }) - it('Owner close app', async () => { - await ownerApp.close({ forceSaveState: true }) - await new Promise(resolve => setTimeout(() => resolve(), 20000)) - }) - - it('Guest close app', async () => { - console.log('TEST 9') - await guestApp?.close() - }) - - it('Owner re-open app', async () => { - await ownerApp?.open() - await new Promise(resolve => setTimeout(() => resolve(), 10000)) - }) - - if (process.env.TEST_MODE) { - it('Close debug modal', async () => { - const debugModal = new DebugModeModal(ownerApp.driver) - await debugModal.close() - }) - } - - it('Guest close app - Owner send another message after guest leave app', async () => { - console.log('TEST 10') - ownerGeneralChannel = new Channel(ownerApp.driver, 'general') - const isMessageInput = await ownerGeneralChannel.messageInput.isDisplayed() - expect(isMessageInput).toBeTruthy() - await ownerGeneralChannel.sendMessage(ownerMessages[2]) - }) - it('Guest close app - Check if message is visible for owner', async () => { - console.log('TEST 11') - const messages = await ownerGeneralChannel.getUserMessages(ownerUsername) - const text = await messages[messages.length - 1].getText() - expect(text).toEqual(ownerMessages[2]) - }) - } + // // TODO: maybe add extra "it" with "channel creation"? + // it('Channel creation - Owner creates second channel', async () => { + // sidebar = new Sidebar(ownerApp.driver) + // await sidebar.addNewChannel(newChannelName) + // await sidebar.switchChannel(newChannelName) + // const channels = await sidebar.getChannelList() + // expect(channels.length).toEqual(2) + // }) + // it('Channel creation - Owner sends message in second channel', async () => { + // secondChannel = new Channel(ownerApp.driver, newChannelName) + // const isMessageInput = await secondChannel.messageInput.isDisplayed() + // expect(isMessageInput).toBeTruthy() + // await secondChannel.sendMessage(ownerMessages[1]) + // }) + // it('Channel creation - User reads message in second channel', async () => { + // sidebar2 = new Sidebar(guestApp.driver) + // await sidebar2.switchChannel(newChannelName) + // secondChannel2 = new Channel(guestApp.driver, newChannelName) + // await new Promise(resolve => + // setTimeout(() => { + // resolve() + // }, 2000) + // ) + // const messages = await secondChannel2.getUserMessages(ownerUsername) + // const text = await messages[1].getText() + // expect(text).toEqual(ownerMessages[1]) + // }) + // it('Channel deletion - Owner deletes second channel', async () => { + // channelContextMenu = new ChannelContextMenu(ownerApp.driver) + // await channelContextMenu.openMenu() + // await channelContextMenu.openDeletionChannelModal() + // await channelContextMenu.deleteChannel() + // const channels = await sidebar.getChannelList() + // expect(channels.length).toEqual(1) + // }) + // it('Channel deletion - User sees info about channel deletion in general channel', async () => { + // await sleep(5000) + // const messages = await generalChannel2.getUserMessages(ownerUsername) + // const text = await messages[3].getText() + // expect(text).toEqual(`@${ownerUsername} deleted #${newChannelName}`) + // }) + // it('Channel deletion - User can create channel with the same name and is fresh channel', async () => { + // await sidebar2.addNewChannel(newChannelName) + // await sidebar2.switchChannel(newChannelName) + // const messages = await secondChannel2.getUserMessages(joiningUserUsername) + // expect(messages.length).toEqual(1) + // await new Promise(resolve => + // setTimeout(() => { + // resolve() + // }, 2000) + // ) + // const channels = await sidebar.getChannelList() + // expect(channels.length).toEqual(2) + // }) + // // End of tests for Windows + // if (process.platform !== 'win32') { + // it('Leave community', async () => { + // console.log('TEST 2') + // const settingsModal = await new Sidebar(guestApp.driver).openSettings() + // const isSettingsModal = await settingsModal.element.isDisplayed() + // expect(isSettingsModal).toBeTruthy() + // await settingsModal.openLeaveCommunityModal() + // await settingsModal.leaveCommunityButton() + // }) + // if (process.env.TEST_MODE) { + // it('Leave community - Close debug modal', async () => { + // const debugModal = new DebugModeModal(guestApp.driver) + // await debugModal.close() + // }) + // } + // // Delete general channel while guest is absent + // it('Channel deletion - Owner recreate general channel', async () => { + // console.log('TEST 3') + // await new Promise(resolve => setTimeout(() => resolve(), 10000)) + // const isGeneralChannel = await ownerGeneralChannel.messageInput.isDisplayed() + // expect(isGeneralChannel).toBeTruthy() + // await channelContextMenu.openMenu() + // await channelContextMenu.openDeletionChannelModal() + // await channelContextMenu.deleteChannel() + // const channels = await sidebar.getChannelList() + // expect(channels.length).toEqual(2) + // }) + + // it('Leave community - Guest re-join to community successfully', async () => { + // console.log('TEST 4') + // const joinCommunityModal = new JoinCommunityModal(guestApp.driver) + // const isJoinCommunityModal = await joinCommunityModal.element.isDisplayed() + // expect(isJoinCommunityModal).toBeTruthy() + // await joinCommunityModal.typeCommunityCode(invitationCode) + // await joinCommunityModal.submit() + // }) + // it('Leave community - Guest register new username', async () => { + // console.log('TEST 5') + // const registerModal2 = new RegisterUsernameModal(guestApp.driver) + // const isRegisterModal2 = await registerModal2.element.isDisplayed() + // expect(isRegisterModal2).toBeTruthy() + // await registerModal2.typeUsername(joiningUserUsername2) + // await registerModal2.submit() + // }) + + // // Check correct channels replication + // it('Channel deletion - User see information about recreation general channel and see correct amount of messages', async () => { + // console.log('TEST 6') + // generalChannel2 = new Channel(guestApp.driver, 'general') + // await generalChannel2.element.isDisplayed() + // await new Promise(resolve => + // setTimeout(() => { + // resolve() + // }, 10000) + // ) + // const messages = await generalChannel2.getUserMessages(ownerUsername) + // const text1 = await messages[0].getText() + // const text2 = await messages[1].getText() + // expect(messages.length).toEqual(2) + // expect(text1).toEqual(`@${ownerUsername} deleted all messages in #general`) + // expect(text2).toEqual(`@${joiningUserUsername2} has joined Testcommunity! 🎉`) + // }) + + // it('Leave community - Guest sends a message', async () => { + // console.log('TEST 7') + // generalChannel2 = new Channel(guestApp.driver, 'general') + // await generalChannel2.element.isDisplayed() + // const isMessageInput2 = await generalChannel2.messageInput.isDisplayed() + // expect(isMessageInput2).toBeTruthy() + // await new Promise(resolve => + // setTimeout(() => { + // resolve() + // }, 5000) + // ) + // await generalChannel2.sendMessage(joiningUserMessages[1]) + // }) + // it('Leave community - Sent message is visible in a channel', async () => { + // console.log('TEST 8') + // const messages2 = await generalChannel2.getUserMessages(joiningUserUsername2) + // const text2 = await messages2[0].getText() + // expect(text2).toEqual(joiningUserMessages[1]) + // }) + // it('Owner close app', async () => { + // await ownerApp.close({ forceSaveState: true }) + // await new Promise(resolve => setTimeout(() => resolve(), 20000)) + // }) + + // it('Guest close app', async () => { + // console.log('TEST 9') + // await guestApp?.close() + // }) + + // it('Owner re-open app', async () => { + // await ownerApp?.open() + // await new Promise(resolve => setTimeout(() => resolve(), 10000)) + // }) + + // if (process.env.TEST_MODE) { + // it('Close debug modal', async () => { + // const debugModal = new DebugModeModal(ownerApp.driver) + // await debugModal.close() + // }) + // } + + // it('Guest close app - Owner send another message after guest leave app', async () => { + // console.log('TEST 10') + // ownerGeneralChannel = new Channel(ownerApp.driver, 'general') + // const isMessageInput = await ownerGeneralChannel.messageInput.isDisplayed() + // expect(isMessageInput).toBeTruthy() + // await ownerGeneralChannel.sendMessage(ownerMessages[2]) + // }) + // it('Guest close app - Check if message is visible for owner', async () => { + // console.log('TEST 11') + // const messages = await ownerGeneralChannel.getUserMessages(ownerUsername) + // const text = await messages[messages.length - 1].getText() + // expect(text).toEqual(ownerMessages[2]) + // }) + // } }) }) From 83e28cf0677c081d2870b7513b35e48e7a976da4 Mon Sep 17 00:00:00 2001 From: Emi Date: Tue, 19 Sep 2023 17:28:09 +0200 Subject: [PATCH 04/17] E2E tests - finish all steps for checking if unregistered user is labeled as registered until registered --- packages/e2e-tests/src/selectors.ts | 7 + .../e2e-tests/src/tests/assets/coffee.jpeg | Bin 0 -> 6932 bytes .../src/tests/invitationLink.test.ts | 15 - .../e2e-tests/src/tests/oneClient.test.ts | 14 - .../e2e-tests/src/tests/twoClients.test.ts | 375 +++++++++--------- packages/e2e-tests/src/utils.ts | 6 +- 6 files changed, 191 insertions(+), 226 deletions(-) create mode 100644 packages/e2e-tests/src/tests/assets/coffee.jpeg diff --git a/packages/e2e-tests/src/selectors.ts b/packages/e2e-tests/src/selectors.ts index 1e43f42bd5..35e0ace141 100644 --- a/packages/e2e-tests/src/selectors.ts +++ b/packages/e2e-tests/src/selectors.ts @@ -21,6 +21,13 @@ export class App { await this.buildSetup.createChromeDriver() this.thenableWebDriver = this.buildSetup.getDriver() await this.driver.getSession() + + if (process.env.TEST_MODE) { + it('Close debug modal', async () => { + const debugModal = new DebugModeModal(this.driver) + await debugModal.close() + }) + } } async close(options?: { forceSaveState?: boolean }) { diff --git a/packages/e2e-tests/src/tests/assets/coffee.jpeg b/packages/e2e-tests/src/tests/assets/coffee.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..43694913dfa86ae162cba2044f16ec20dc1d1f7c GIT binary patch literal 6932 zcmZveWl)@3vxVQm-Q67qcMtBtJy@{d?i$<&cMs0sE(sRg1A`?%upmJa-0hz8)s;VY zbye5uT6;gWtAFj+@2^_`j*5b^0ssO50O+3rUe|y~02K)t4-bzJ4+oF%UlIMM|FTPzuI?zi+8ST3SBfd| z&V}-$D1Snl$%F#dTdO*v2>$IS&kS6j^wn;CE_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^9PcSGpgz!HToWN-NKTt zIgvl*O7#Pbl`?gePg`Q^R_Pjy-yI)gEqX0={$|i%seIODBO)c6dT{WCN+ITh%C^;^ zj0S<_GK9rPzCuB@LPa>kYBIH)4G&5&MS!4Yi&kEw)udosVK`l(>)L}aIeZ@cLEps~ zg;|JUExpW(R!g)12_9k98f6HF1VM@wHwM9+K$r#x2f>|ebrj;JKwAWkn&xY)E4Scp z+gLmC&0K#Aa)F(g^D&RyspuncBi)i+B4>;m+;}y-0@KxHj!5LbCJC3Pg^bH+=JImw zd}Kv4ERk>t0?d;JqJ>Ig(R~nX_pDyDn~=9~Z)0pd*x$7gbqNB_O?fpMOxpIArI>xP zi+C_42s8mnDRgg(iJqT06cqUZCa$U+8k?xjZ$A-bNoqxkQLbFYm=QNY$IE3v(6$?< zPGzV$8ZM8R&?crpOO%_Gc`ja7s{`FIKJQ~{)674f^gLQJD$8>IHZ^GTEiIGoNwfDm zi~-M^m0Q(F%_ylD0Y`10MkYRv8ze)a6b}I*;B3)y5LDtuHi5?XM6>3O=%t1rawZ{I zj}vWG0oJ4yRhqF71x!}wlBDqIYtfDk)hcZwWbXHR4V!Z literal 0 HcmV?d00001 diff --git a/packages/e2e-tests/src/tests/invitationLink.test.ts b/packages/e2e-tests/src/tests/invitationLink.test.ts index 0b4e917019..e43f845071 100644 --- a/packages/e2e-tests/src/tests/invitationLink.test.ts +++ b/packages/e2e-tests/src/tests/invitationLink.test.ts @@ -44,14 +44,6 @@ describe('New user joins using invitation link while having app opened', () => { await ownerApp.open() }) - if (process.env.TEST_MODE) { - it('Owner closes debug modal', async () => { - console.log('Invitation Link', 2) - const debugModal = new DebugModeModal(ownerApp.driver) - await debugModal.close() - }) - } - it('JoinCommunityModal - owner switches to create community', async () => { console.log('Invitation Link', 4) const joinModal = new JoinCommunityModal(ownerApp.driver) @@ -121,13 +113,6 @@ describe('New user joins using invitation link while having app opened', () => { console.log('Guest opens app') await guestApp.open() }) - if (process.env.TEST_MODE) { - it('Close debug modal', async () => { - console.log('Invitation Link', 12) - const debugModal = new DebugModeModal(guestApp.driver) - await debugModal.close() - }) - } it.skip('Guest clicks invitation link with invalid invitation code', async () => { // Fix when modals ordering is fixed (joining modal hiddes warning modal) diff --git a/packages/e2e-tests/src/tests/oneClient.test.ts b/packages/e2e-tests/src/tests/oneClient.test.ts index ce774dcc4e..090f268708 100644 --- a/packages/e2e-tests/src/tests/oneClient.test.ts +++ b/packages/e2e-tests/src/tests/oneClient.test.ts @@ -26,13 +26,6 @@ describe('One Client', () => { await app.close() }) describe('User opens app for the first time', () => { - if (process.env.TEST_MODE) { - it('Close debug modal', async () => { - const debugModal = new DebugModeModal(app.driver) - await debugModal.close() - }) - } - it('Get opened app process data', () => { const processData = app.buildSetup.getProcessData() dataDirPath = processData.dataDirPath @@ -110,13 +103,6 @@ describe('One Client', () => { await app.open() }) - if (process.env.TEST_MODE) { - it('Close debug modal', async () => { - const debugModal = new DebugModeModal(app.driver) - await debugModal.close() - }) - } - it('User sees "general channel" page', async () => { const generalChannel = new Channel(app.driver, 'general') const isGeneralChannel = await generalChannel.element.isDisplayed() diff --git a/packages/e2e-tests/src/tests/twoClients.test.ts b/packages/e2e-tests/src/tests/twoClients.test.ts index 1687296c10..e6ddcac3db 100644 --- a/packages/e2e-tests/src/tests/twoClients.test.ts +++ b/packages/e2e-tests/src/tests/twoClients.test.ts @@ -71,13 +71,6 @@ describe('Multiple Clients', () => { await ownerApp.open() }) - if (process.env.TEST_MODE) { - it('Close debug modal', async () => { - const debugModal = new DebugModeModal(ownerApp.driver) - await debugModal.close() - }) - } - it('JoinCommunityModal - owner switches to create community modal', async () => { const joinModal = new JoinCommunityModal(ownerApp.driver) const isJoinModal = await joinModal.element.isDisplayed() @@ -98,7 +91,7 @@ describe('Multiple Clients', () => { await registerModal.typeUsername(ownerUsername) await registerModal.submit() }) - it('Connecting to peers modal', async () => { + it.skip('Connecting to peers modal', async () => { const loadingPanelCommunity = new JoiningLoadingPanel(ownerApp.driver) const isLoadingPanelCommunity = await loadingPanelCommunity.element.isDisplayed() expect(isLoadingPanelCommunity).toBeTruthy() @@ -142,12 +135,6 @@ describe('Multiple Clients', () => { guestApp = new App() await guestApp.open() }) - if (process.env.TEST_MODE) { - it('Close debug modal', async () => { - const debugModal = new DebugModeModal(guestApp.driver) - await debugModal.close() - }) - } it('Guest joins the new community successfully', async () => { console.log('new user - 3') @@ -190,8 +177,6 @@ describe('Multiple Clients', () => { await generalChannel2.sendMessage(joiningUserMessages[0]) }) it('Sent message is visible in a channel', async () => { - // check that message is tagged as 'registered' - console.log('new user - 8') const messages2 = await generalChannel2.getUserMessages(joiningUserUsername) const messages1 = await generalChannel2.getUserMessages(ownerUsername) @@ -200,6 +185,22 @@ describe('Multiple Clients', () => { expect(text2).toEqual(joiningUserMessages[0]) }) + it('Guest opens the settings tab and gets an updated invitation code', async () => { + const settingsModal = await new Sidebar(guestApp.driver).openSettings() + const isSettingsModal = await settingsModal.element.isDisplayed() + expect(isSettingsModal).toBeTruthy() + await sleep(2000) + await settingsModal.switchTab('invite') + await sleep(2000) + const invitationCodeElement = await settingsModal.invitationCode() + await sleep(2000) + invitationCode = await invitationCodeElement.getText() + await sleep(2000) + console.log(`${invitationCode} copied from first user`) + expect(invitationCode).not.toBeUndefined() + await settingsModal.close() + }) + // third user joins when owner is offline. Does not use duplicated username it('Owner goes offline', async () => { await ownerApp.close() @@ -209,6 +210,8 @@ describe('Multiple Clients', () => { console.log('Third client') secondGuestApp = new App() await secondGuestApp.open() + const debugModal = new DebugModeModal(secondGuestApp.driver) + await debugModal.close() }) it('Second guest starts to register when owner is offline', async () => { @@ -227,7 +230,7 @@ describe('Multiple Clients', () => { const isRegisterModal = await registerModal3.element.isDisplayed() expect(isRegisterModal).toBeTruthy() await registerModal3.clearInput() - await registerModal3.typeUsername(joiningUserUsername) + await registerModal3.typeUsername(joiningUserUsername3) await registerModal3.submit() }) @@ -271,186 +274,170 @@ describe('Multiple Clients', () => { }) it('Unregistered user receives certificate, the "Unregistered" label is removed', async () => { - // Probably need to wait ownerGeneralChannel = new Channel(ownerApp.driver, 'general') const ownerAppLabels = await ownerGeneralChannel.getUserLabels(joiningUserUsername3) - for (const label in ownerAppLabels) { - expect(label).toEqual('Registered') - } + expect(ownerAppLabels.length).toEqual(0) + }) + + // TODO: maybe add extra "it" with "channel creation"? + it('Channel creation - Owner creates second channel', async () => { + sidebar = new Sidebar(ownerApp.driver) + await sidebar.addNewChannel(newChannelName) + await sidebar.switchChannel(newChannelName) + const channels = await sidebar.getChannelList() + expect(channels.length).toEqual(2) + }) + it('Channel creation - Owner sends message in second channel', async () => { + secondChannel = new Channel(ownerApp.driver, newChannelName) + const isMessageInput = await secondChannel.messageInput.isDisplayed() + expect(isMessageInput).toBeTruthy() + await secondChannel.sendMessage(ownerMessages[1]) + }) + it('Channel creation - User reads message in second channel', async () => { + sidebar2 = new Sidebar(guestApp.driver) + await sidebar2.switchChannel(newChannelName) + secondChannel2 = new Channel(guestApp.driver, newChannelName) + await new Promise(resolve => + setTimeout(() => { + resolve() + }, 2000) + ) + const messages = await secondChannel2.getUserMessages(ownerUsername) + const text = await messages[1].getText() + expect(text).toEqual(ownerMessages[1]) + }) + it('Channel deletion - Owner deletes second channel', async () => { + channelContextMenu = new ChannelContextMenu(ownerApp.driver) + await channelContextMenu.openMenu() + await channelContextMenu.openDeletionChannelModal() + await channelContextMenu.deleteChannel() + const channels = await sidebar.getChannelList() + expect(channels.length).toEqual(1) + }) + it('Channel deletion - User sees info about channel deletion in general channel', async () => { + await sleep(5000) + const messages = await generalChannel2.getUserMessages(ownerUsername) + const text = await messages[3].getText() + expect(text).toEqual(`@${ownerUsername} deleted #${newChannelName}`) + }) + it('Channel deletion - User can create channel with the same name and is fresh channel', async () => { + await sidebar2.addNewChannel(newChannelName) + await sidebar2.switchChannel(newChannelName) + const messages = await secondChannel2.getUserMessages(joiningUserUsername) + expect(messages.length).toEqual(1) + await new Promise(resolve => + setTimeout(() => { + resolve() + }, 2000) + ) + const channels = await sidebar.getChannelList() + expect(channels.length).toEqual(2) }) + // End of tests for Windows + if (process.platform !== 'win32') { + it('Leave community', async () => { + console.log('TEST 2') + const settingsModal = await new Sidebar(guestApp.driver).openSettings() + const isSettingsModal = await settingsModal.element.isDisplayed() + expect(isSettingsModal).toBeTruthy() + await settingsModal.openLeaveCommunityModal() + await settingsModal.leaveCommunityButton() + }) + // Delete general channel while guest is absent + it('Channel deletion - Owner recreate general channel', async () => { + console.log('TEST 3') + await new Promise(resolve => setTimeout(() => resolve(), 10000)) + const isGeneralChannel = await ownerGeneralChannel.messageInput.isDisplayed() + expect(isGeneralChannel).toBeTruthy() + await channelContextMenu.openMenu() + await channelContextMenu.openDeletionChannelModal() + await channelContextMenu.deleteChannel() + const channels = await sidebar.getChannelList() + expect(channels.length).toEqual(2) + }) + + it('Leave community - Guest re-join to community successfully', async () => { + console.log('TEST 4') + const joinCommunityModal = new JoinCommunityModal(guestApp.driver) + const isJoinCommunityModal = await joinCommunityModal.element.isDisplayed() + expect(isJoinCommunityModal).toBeTruthy() + await joinCommunityModal.typeCommunityCode(invitationCode) + await joinCommunityModal.submit() + }) + it('Leave community - Guest register new username', async () => { + console.log('TEST 5') + const registerModal2 = new RegisterUsernameModal(guestApp.driver) + const isRegisterModal2 = await registerModal2.element.isDisplayed() + expect(isRegisterModal2).toBeTruthy() + await registerModal2.typeUsername(joiningUserUsername2) + await registerModal2.submit() + }) - // // TODO: maybe add extra "it" with "channel creation"? - // it('Channel creation - Owner creates second channel', async () => { - // sidebar = new Sidebar(ownerApp.driver) - // await sidebar.addNewChannel(newChannelName) - // await sidebar.switchChannel(newChannelName) - // const channels = await sidebar.getChannelList() - // expect(channels.length).toEqual(2) - // }) - // it('Channel creation - Owner sends message in second channel', async () => { - // secondChannel = new Channel(ownerApp.driver, newChannelName) - // const isMessageInput = await secondChannel.messageInput.isDisplayed() - // expect(isMessageInput).toBeTruthy() - // await secondChannel.sendMessage(ownerMessages[1]) - // }) - // it('Channel creation - User reads message in second channel', async () => { - // sidebar2 = new Sidebar(guestApp.driver) - // await sidebar2.switchChannel(newChannelName) - // secondChannel2 = new Channel(guestApp.driver, newChannelName) - // await new Promise(resolve => - // setTimeout(() => { - // resolve() - // }, 2000) - // ) - // const messages = await secondChannel2.getUserMessages(ownerUsername) - // const text = await messages[1].getText() - // expect(text).toEqual(ownerMessages[1]) - // }) - // it('Channel deletion - Owner deletes second channel', async () => { - // channelContextMenu = new ChannelContextMenu(ownerApp.driver) - // await channelContextMenu.openMenu() - // await channelContextMenu.openDeletionChannelModal() - // await channelContextMenu.deleteChannel() - // const channels = await sidebar.getChannelList() - // expect(channels.length).toEqual(1) - // }) - // it('Channel deletion - User sees info about channel deletion in general channel', async () => { - // await sleep(5000) - // const messages = await generalChannel2.getUserMessages(ownerUsername) - // const text = await messages[3].getText() - // expect(text).toEqual(`@${ownerUsername} deleted #${newChannelName}`) - // }) - // it('Channel deletion - User can create channel with the same name and is fresh channel', async () => { - // await sidebar2.addNewChannel(newChannelName) - // await sidebar2.switchChannel(newChannelName) - // const messages = await secondChannel2.getUserMessages(joiningUserUsername) - // expect(messages.length).toEqual(1) - // await new Promise(resolve => - // setTimeout(() => { - // resolve() - // }, 2000) - // ) - // const channels = await sidebar.getChannelList() - // expect(channels.length).toEqual(2) - // }) - // // End of tests for Windows - // if (process.platform !== 'win32') { - // it('Leave community', async () => { - // console.log('TEST 2') - // const settingsModal = await new Sidebar(guestApp.driver).openSettings() - // const isSettingsModal = await settingsModal.element.isDisplayed() - // expect(isSettingsModal).toBeTruthy() - // await settingsModal.openLeaveCommunityModal() - // await settingsModal.leaveCommunityButton() - // }) - // if (process.env.TEST_MODE) { - // it('Leave community - Close debug modal', async () => { - // const debugModal = new DebugModeModal(guestApp.driver) - // await debugModal.close() - // }) - // } - // // Delete general channel while guest is absent - // it('Channel deletion - Owner recreate general channel', async () => { - // console.log('TEST 3') - // await new Promise(resolve => setTimeout(() => resolve(), 10000)) - // const isGeneralChannel = await ownerGeneralChannel.messageInput.isDisplayed() - // expect(isGeneralChannel).toBeTruthy() - // await channelContextMenu.openMenu() - // await channelContextMenu.openDeletionChannelModal() - // await channelContextMenu.deleteChannel() - // const channels = await sidebar.getChannelList() - // expect(channels.length).toEqual(2) - // }) - - // it('Leave community - Guest re-join to community successfully', async () => { - // console.log('TEST 4') - // const joinCommunityModal = new JoinCommunityModal(guestApp.driver) - // const isJoinCommunityModal = await joinCommunityModal.element.isDisplayed() - // expect(isJoinCommunityModal).toBeTruthy() - // await joinCommunityModal.typeCommunityCode(invitationCode) - // await joinCommunityModal.submit() - // }) - // it('Leave community - Guest register new username', async () => { - // console.log('TEST 5') - // const registerModal2 = new RegisterUsernameModal(guestApp.driver) - // const isRegisterModal2 = await registerModal2.element.isDisplayed() - // expect(isRegisterModal2).toBeTruthy() - // await registerModal2.typeUsername(joiningUserUsername2) - // await registerModal2.submit() - // }) - - // // Check correct channels replication - // it('Channel deletion - User see information about recreation general channel and see correct amount of messages', async () => { - // console.log('TEST 6') - // generalChannel2 = new Channel(guestApp.driver, 'general') - // await generalChannel2.element.isDisplayed() - // await new Promise(resolve => - // setTimeout(() => { - // resolve() - // }, 10000) - // ) - // const messages = await generalChannel2.getUserMessages(ownerUsername) - // const text1 = await messages[0].getText() - // const text2 = await messages[1].getText() - // expect(messages.length).toEqual(2) - // expect(text1).toEqual(`@${ownerUsername} deleted all messages in #general`) - // expect(text2).toEqual(`@${joiningUserUsername2} has joined Testcommunity! 🎉`) - // }) - - // it('Leave community - Guest sends a message', async () => { - // console.log('TEST 7') - // generalChannel2 = new Channel(guestApp.driver, 'general') - // await generalChannel2.element.isDisplayed() - // const isMessageInput2 = await generalChannel2.messageInput.isDisplayed() - // expect(isMessageInput2).toBeTruthy() - // await new Promise(resolve => - // setTimeout(() => { - // resolve() - // }, 5000) - // ) - // await generalChannel2.sendMessage(joiningUserMessages[1]) - // }) - // it('Leave community - Sent message is visible in a channel', async () => { - // console.log('TEST 8') - // const messages2 = await generalChannel2.getUserMessages(joiningUserUsername2) - // const text2 = await messages2[0].getText() - // expect(text2).toEqual(joiningUserMessages[1]) - // }) - // it('Owner close app', async () => { - // await ownerApp.close({ forceSaveState: true }) - // await new Promise(resolve => setTimeout(() => resolve(), 20000)) - // }) - - // it('Guest close app', async () => { - // console.log('TEST 9') - // await guestApp?.close() - // }) - - // it('Owner re-open app', async () => { - // await ownerApp?.open() - // await new Promise(resolve => setTimeout(() => resolve(), 10000)) - // }) - - // if (process.env.TEST_MODE) { - // it('Close debug modal', async () => { - // const debugModal = new DebugModeModal(ownerApp.driver) - // await debugModal.close() - // }) - // } - - // it('Guest close app - Owner send another message after guest leave app', async () => { - // console.log('TEST 10') - // ownerGeneralChannel = new Channel(ownerApp.driver, 'general') - // const isMessageInput = await ownerGeneralChannel.messageInput.isDisplayed() - // expect(isMessageInput).toBeTruthy() - // await ownerGeneralChannel.sendMessage(ownerMessages[2]) - // }) - // it('Guest close app - Check if message is visible for owner', async () => { - // console.log('TEST 11') - // const messages = await ownerGeneralChannel.getUserMessages(ownerUsername) - // const text = await messages[messages.length - 1].getText() - // expect(text).toEqual(ownerMessages[2]) - // }) - // } + // Check correct channels replication + it('Channel deletion - User see information about recreation general channel and see correct amount of messages', async () => { + console.log('TEST 6') + generalChannel2 = new Channel(guestApp.driver, 'general') + await generalChannel2.element.isDisplayed() + await new Promise(resolve => + setTimeout(() => { + resolve() + }, 10000) + ) + const messages = await generalChannel2.getUserMessages(ownerUsername) + const text1 = await messages[0].getText() + const text2 = await messages[1].getText() + expect(messages.length).toEqual(2) + expect(text1).toEqual(`@${ownerUsername} deleted all messages in #general`) + expect(text2).toEqual(`@${joiningUserUsername2} has joined Testcommunity! 🎉`) + }) + + it('Leave community - Guest sends a message', async () => { + console.log('TEST 7') + generalChannel2 = new Channel(guestApp.driver, 'general') + await generalChannel2.element.isDisplayed() + const isMessageInput2 = await generalChannel2.messageInput.isDisplayed() + expect(isMessageInput2).toBeTruthy() + await new Promise(resolve => + setTimeout(() => { + resolve() + }, 5000) + ) + await generalChannel2.sendMessage(joiningUserMessages[1]) + }) + it('Leave community - Sent message is visible in a channel', async () => { + console.log('TEST 8') + const messages2 = await generalChannel2.getUserMessages(joiningUserUsername2) + const text2 = await messages2[0].getText() + expect(text2).toEqual(joiningUserMessages[1]) + }) + it('Owner close app', async () => { + await ownerApp.close({ forceSaveState: true }) + await new Promise(resolve => setTimeout(() => resolve(), 20000)) + }) + + it('Guest close app', async () => { + console.log('TEST 9') + await guestApp?.close() + }) + + it('Owner re-open app', async () => { + await ownerApp?.open() + await new Promise(resolve => setTimeout(() => resolve(), 10000)) + }) + + it('Guest close app - Owner send another message after guest leave app', async () => { + console.log('TEST 10') + ownerGeneralChannel = new Channel(ownerApp.driver, 'general') + const isMessageInput = await ownerGeneralChannel.messageInput.isDisplayed() + expect(isMessageInput).toBeTruthy() + await ownerGeneralChannel.sendMessage(ownerMessages[2]) + }) + it('Guest close app - Check if message is visible for owner', async () => { + console.log('TEST 11') + const messages = await ownerGeneralChannel.getUserMessages(ownerUsername) + const text = await messages[messages.length - 1].getText() + expect(text).toEqual(ownerMessages[2]) + }) + } }) }) diff --git a/packages/e2e-tests/src/utils.ts b/packages/e2e-tests/src/utils.ts index 96e2a11a61..0cdc0e4e2a 100644 --- a/packages/e2e-tests/src/utils.ts +++ b/packages/e2e-tests/src/utils.ts @@ -1,5 +1,5 @@ import { Browser, Builder, type ThenableWebDriver } from 'selenium-webdriver' -import { spawn, exec, type ChildProcessWithoutNullStreams, execSync } from 'child_process' +import { spawn, exec, execSync, type ChildProcessWithoutNullStreams } from 'child_process' import { type SupportedPlatformDesktop } from '@quiet/types' import getPort from 'get-port' import path from 'path' @@ -155,7 +155,7 @@ export class BuildSetup { }) this.child.stdin.on('data', data => { - console.error(`stdin: ${data}`) + console.log(`stdin: ${data}`) }) } @@ -194,7 +194,7 @@ export class BuildSetup { } } if (this.driver == null || this.driver === undefined) { - throw new Error('elo') + throw new Error('No driver') } return this.driver From 15a9d41cd40c24162a81398b94188eb5b77739ec Mon Sep 17 00:00:00 2001 From: Emi Date: Tue, 19 Sep 2023 18:31:16 +0200 Subject: [PATCH 05/17] Fix closing debug modal in test --- packages/e2e-tests/src/selectors.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/e2e-tests/src/selectors.ts b/packages/e2e-tests/src/selectors.ts index 35e0ace141..754a2deff3 100644 --- a/packages/e2e-tests/src/selectors.ts +++ b/packages/e2e-tests/src/selectors.ts @@ -21,12 +21,9 @@ export class App { await this.buildSetup.createChromeDriver() this.thenableWebDriver = this.buildSetup.getDriver() await this.driver.getSession() - if (process.env.TEST_MODE) { - it('Close debug modal', async () => { - const debugModal = new DebugModeModal(this.driver) - await debugModal.close() - }) + const debugModal = new DebugModeModal(this.driver) + await debugModal.close() } } From 6720c6fb736efec14dbfd2a3dcecbd0f6e7c6a39 Mon Sep 17 00:00:00 2001 From: Emi Date: Wed, 20 Sep 2023 11:51:28 +0200 Subject: [PATCH 06/17] Show Quiet logs in e2e tests --- packages/e2e-tests/src/utils.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/e2e-tests/src/utils.ts b/packages/e2e-tests/src/utils.ts index 0cdc0e4e2a..da63836759 100644 --- a/packages/e2e-tests/src/utils.ts +++ b/packages/e2e-tests/src/utils.ts @@ -102,16 +102,16 @@ export class BuildSetup { await this.initPorts() const env = { DATA_DIR: this.dataDir || 'Quiet', - DEBUG: 'backend*', + DEBUG: 'backend*,desktop*', } if (process.platform === 'win32') { console.log('!WINDOWS!') - this.child = spawn(`cd node_modules/.bin & chromedriver.cmd --port=${this.port}`, [], { + this.child = spawn(`cd node_modules/.bin & chromedriver.cmd --port=${this.port} --verbose`, [], { shell: true, env: Object.assign(process.env, env), }) } else { - this.child = spawn(`node_modules/.bin/chromedriver --port=${this.port}`, [], { + this.child = spawn(`node_modules/.bin/chromedriver --port=${this.port} --verbose`, [], { shell: true, detached: false, env: Object.assign(process.env, env), @@ -125,7 +125,7 @@ export class BuildSetup { ) this.child.on('error', () => { - console.log('ERROR') + console.error('ERROR') this.killNine() }) @@ -143,7 +143,7 @@ export class BuildSetup { console.log('message', data) }) this.child.on('error', data => { - console.log('error', data) + console.error('error', data) }) this.child.stdout.on('data', data => { @@ -151,7 +151,13 @@ export class BuildSetup { }) this.child.stderr.on('data', data => { - console.error(`stderr: ${data}`) + // Quiet logs (handled 'debug' package) are available in stderr and only with 'verbose' flag on chromedriver + const trashLogs = ['DevTools', 'COMMAND', 'INFO:CONSOLE', '[INFO]:'] + const dataString = `${data}` + for (const l of trashLogs) { + if (dataString.includes(l)) return + } + console.log(dataString) }) this.child.stdin.on('data', data => { From 6e19b17998c72d5c0993c1369757f0c987a55ebc Mon Sep 17 00:00:00 2001 From: Emi Date: Wed, 20 Sep 2023 15:31:19 +0200 Subject: [PATCH 07/17] Fixes --- .../connections-manager.service.ts | 1 - .../backend/src/nest/socket/socket.service.ts | 3 --- packages/e2e-tests/package.json | 3 ++- packages/e2e-tests/src/tests/assets/coffee.jpeg | Bin 6932 -> 0 bytes packages/e2e-tests/src/utils.ts | 4 ++-- 5 files changed, 4 insertions(+), 7 deletions(-) delete mode 100644 packages/e2e-tests/src/tests/assets/coffee.jpeg diff --git a/packages/backend/src/nest/connections-manager/connections-manager.service.ts b/packages/backend/src/nest/connections-manager/connections-manager.service.ts index 4df0b2ea68..614e43ce9d 100644 --- a/packages/backend/src/nest/connections-manager/connections-manager.service.ts +++ b/packages/backend/src/nest/connections-manager/connections-manager.service.ts @@ -361,7 +361,6 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI targetPort: this.ports.libp2pHiddenService, peers, } - this.logger('libp2p params', params) await this.libp2pService.createInstance(params) // KACPER diff --git a/packages/backend/src/nest/socket/socket.service.ts b/packages/backend/src/nest/socket/socket.service.ts index 332263f3f2..1a69e21d13 100644 --- a/packages/backend/src/nest/socket/socket.service.ts +++ b/packages/backend/src/nest/socket/socket.service.ts @@ -172,9 +172,6 @@ export class SocketService extends EventEmitter implements OnModuleInit { ownerCertificate: payload.certificate, rootCa: payload.permsData.certificate, } - - console.log('Metadata from state-manager', communityMetadataPayload) - this.emit(SocketActionTypes.SEND_COMMUNITY_METADATA, communityMetadataPayload) }) diff --git a/packages/e2e-tests/package.json b/packages/e2e-tests/package.json index e0db658d89..465eded682 100644 --- a/packages/e2e-tests/package.json +++ b/packages/e2e-tests/package.json @@ -10,7 +10,8 @@ "lint-ci": "eslint --ext .js,.ts ./src/", "prettier:write": "prettier --write .", "prettier:check": "prettier --check .", - "test": "jest --runInBand --detectOpenHandles --forceExit", + "test": "cross-env TEST_MODE=true jest --runInBand --detectOpenHandles --forceExit", + "test:prod": "jest --runInBand --detectOpenHandles --forceExit", "test:watch": "jest --watchAll" }, "devDependencies": { diff --git a/packages/e2e-tests/src/tests/assets/coffee.jpeg b/packages/e2e-tests/src/tests/assets/coffee.jpeg deleted file mode 100644 index 43694913dfa86ae162cba2044f16ec20dc1d1f7c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6932 zcmZveWl)@3vxVQm-Q67qcMtBtJy@{d?i$<&cMs0sE(sRg1A`?%upmJa-0hz8)s;VY zbye5uT6;gWtAFj+@2^_`j*5b^0ssO50O+3rUe|y~02K)t4-bzJ4+oF%UlIMM|FTPzuI?zi+8ST3SBfd| z&V}-$D1Snl$%F#dTdO*v2>$IS&kS6j^wn;CE_^YsHe&`~r0dKgX zdqgJYFK?R;R=V7-=t`wJT^tAx0EEhh0~D$}h@U{QD3P=S2tz%#_;D&9?-x&y>ViTu z4f{A(*EqOEI_>+&u?uRM>}2!VqeV1Qy{rh&+ZHyf6P~A$4|ojwxFLahlz;l|*0$JN zdhfzbuDyDKm#9;Oa%@*MO;TILF^c(o)&tRB0r$60!;HUjtUBnj@9PGNXq1G?H?gnj zJ2><01~)91uX(dqJ#L<|8bE=q)!M^lfsp#=a_UJg@m+y4qn}a>d54#{b&}*Gnly~I zFDq{>pU7R6T_j+T?o!^9+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>Ig(R~nX_pDyDn~=9~Z)0pd*x$7gbqNB_O?fpMOxpIArI>xP zi+C_42s8mnDRgg(iJqT06cqUZCa$U+8k?xjZ$A-bNoqxkQLbFYm=QNY$IE3v(6$?< zPGzV$8ZM8R&?crpOO%_Gc`ja7s{`FIKJQ~{)674f^gLQJD$8>IHZ^GTEiIGoNwfDm zi~-M^m0Q(F%_ylD0Y`10MkYRv8ze)a6b}I*;B3)y5LDtuHi5?XM6>3O=%t1rawZ{I zj}vWG0oJ4yRhqF71x!}wlBDqIYtfDk)hcZwWbXHR4V!Z diff --git a/packages/e2e-tests/src/utils.ts b/packages/e2e-tests/src/utils.ts index da63836759..7379e81199 100644 --- a/packages/e2e-tests/src/utils.ts +++ b/packages/e2e-tests/src/utils.ts @@ -151,8 +151,8 @@ export class BuildSetup { }) this.child.stderr.on('data', data => { - // Quiet logs (handled 'debug' package) are available in stderr and only with 'verbose' flag on chromedriver - const trashLogs = ['DevTools', 'COMMAND', 'INFO:CONSOLE', '[INFO]:'] + // Quiet logs (handled by 'debug' package) are available in stderr and only with 'verbose' flag on chromedriver + const trashLogs = ['DevTools', 'COMMAND', 'INFO:CONSOLE', '[INFO]:', 'libnotify-WARNING', 'ALSA lib'] const dataString = `${data}` for (const l of trashLogs) { if (dataString.includes(l)) return From b7686e849488965f253c95f831ad37bc5e72d467 Mon Sep 17 00:00:00 2001 From: Emi Date: Thu, 21 Sep 2023 15:11:52 +0200 Subject: [PATCH 08/17] Fix selectors in e2e tests --- .../widgets/channels/BasicMessage.tsx | 1 + packages/e2e-tests/src/selectors.ts | 75 ++++++++++++++----- .../e2e-tests/src/tests/twoClients.test.ts | 66 +++++++++------- 3 files changed, 96 insertions(+), 46 deletions(-) diff --git a/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.tsx b/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.tsx index e51dd27741..90c4773145 100644 --- a/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.tsx +++ b/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.tsx @@ -193,6 +193,7 @@ export const BasicMessageComponent: React.FC diff --git a/packages/e2e-tests/src/selectors.ts b/packages/e2e-tests/src/selectors.ts index 754a2deff3..b1b2401ea8 100644 --- a/packages/e2e-tests/src/selectors.ts +++ b/packages/e2e-tests/src/selectors.ts @@ -4,6 +4,7 @@ import { BuildSetup, type BuildSetupInit } from './utils' export class App { thenableWebDriver?: ThenableWebDriver buildSetup: BuildSetup + isOpened: boolean constructor(buildSetupConfig?: BuildSetupInit) { this.buildSetup = new BuildSetup({ ...buildSetupConfig }) } @@ -19,16 +20,16 @@ export class App { console.log('Opening the app', this.buildSetup.dataDir) this.buildSetup.resetDriver() await this.buildSetup.createChromeDriver() + this.isOpened = true this.thenableWebDriver = this.buildSetup.getDriver() await this.driver.getSession() - if (process.env.TEST_MODE) { - const debugModal = new DebugModeModal(this.driver) - await debugModal.close() - } + const debugModal = new DebugModeModal(this.driver) + await debugModal.close() } async close(options?: { forceSaveState?: boolean }) { console.log('Closing the app', this.buildSetup.dataDir) + if (!this.isOpened) return if (options?.forceSaveState) { await this.saveState() // Selenium creates community and closes app so fast that redux state may not be saved properly await this.waitForSavedState() @@ -39,6 +40,7 @@ export class App { this.buildSetup.killNine() await new Promise(resolve => setTimeout(() => resolve(), 2000)) } + this.isOpened = false console.log('App closed', this.buildSetup.dataDir) } @@ -66,12 +68,6 @@ export class StartingLoadingPanel { get element() { return this.driver.wait(until.elementLocated(By.xpath('//div[@data-testid="startingPanelComponent"]'))) } - // get element() { - // return this.driver.wait(until.elementLocated(By.xpath(`//span[text()="${this.text}"]`))) - // } - // get title() { - // return this.driver.findElement(By.xpath(`//span[text()="${this.text}"]`)) - // } } export class WarningModal { @@ -234,6 +230,19 @@ export class Channel { return await messagesGroup.findElement(By.xpath('//p[@data-testid="/messagesGroupContent-/"]')) } + async waitForUserMessage(username: string, messageContent: string) { + console.log(`Waiting for user "${username}" message "${messageContent}"`) + return this.driver.wait(async () => { + const messages = await this.getUserMessages(username) + const hasMessage = messages.find(async msg => { + const messageText = await msg.getText() + console.log(`got message "${messageText}"`) + return messageText.includes(messageContent) + }) + return hasMessage + }) + } + get getAllMessages() { return this.driver.wait(until.elementsLocated(By.xpath('//*[contains(@data-testid, "userMessages-")]'))) } @@ -263,12 +272,29 @@ export class Channel { ) } + async getUserMessagesWrapper(username: string) { + return await this.driver.wait( + until.elementsLocated(By.xpath(`//*[contains(@data-testid, "userMessagesWrapper-${username}")]`)) + ) + } + async getUserLabels(username: string) { - const labels = await this.driver.wait( - until.elementsLocated(By.xpath(`//*[contains(@data-testid, "userLabel-${username}")]`)) + const messages = await this.getUserMessagesWrapper(username) + console.log(`getUserLabels, wrappers for ${username}`, messages.length) + const labelsElements = messages.filter(async msg => { + return (await msg.findElements(By.xpath(`//*[contains(@data-testid, "userLabel-${username}")]`))).length > 0 + }) + console.log(`getUserLabels, elements for ${username}`, labelsElements.length) + // console.log('get user labels', username) + // const labels = await this.driver.wait( + // until.elementsLocated(By.xpath(`//*[contains(@data-testid, "userLabel-${username}")]`)) + // ) + // console.log('labels', labels.length) + const labelsText = await Promise.all( + labelsElements.map(async labelElement => labelElement.findElement(By.css('span')).getText()) ) - console.log('labels', labels) - return labels.map(labelElement => labelElement.findElement(By.css('span')).getText()) + console.log(`getUserLabels, labelsText for ${username}`, labelsText) + return labelsText } async getMessage(text: string) { @@ -390,18 +416,27 @@ export class DebugModeModal { } get element() { - return this.driver.wait(until.elementLocated(By.xpath("//h3[text()='App is running in debug mode']"))) + return this.driver.wait(until.elementLocated(By.xpath("//h3[text()='App is running in debug mode']")), 5000) } get button() { - return this.driver.wait(until.elementLocated(By.xpath("//button[text()='Understand']"))) + return this.driver.wait(until.elementLocated(By.xpath("//button[text()='Understand']")), 5000) } async close() { - console.log('Closing debug modal') - await this.element.isDisplayed() - const button = await this.button - console.log('Debug modal title is displayed') + if (!process.env.TEST_MODE) return + let button + try { + console.log('Closing debug modal') + await this.element.isDisplayed() + console.log('Debug modal title is displayed') + button = await this.button + console.log('Debug modal button is displayed') + } catch (e) { + console.log('Debug modal might have been covered by "join community" modal', e.message) + return + } + await button.isDisplayed() console.log('Button is displayed') await button.click() diff --git a/packages/e2e-tests/src/tests/twoClients.test.ts b/packages/e2e-tests/src/tests/twoClients.test.ts index e6ddcac3db..a7f0077ab9 100644 --- a/packages/e2e-tests/src/tests/twoClients.test.ts +++ b/packages/e2e-tests/src/tests/twoClients.test.ts @@ -36,6 +36,7 @@ describe('Multiple Clients', () => { let sidebar2: Sidebar const communityName = 'testcommunity' + const displayedCommunityName = 'Testcommunity' const ownerUsername = 'bob' const ownerMessages = ['Hi', 'Hello', 'After guest leave app'] const joiningUserUsername = 'alice-joining' @@ -253,7 +254,7 @@ describe('Multiple Clients', () => { secondGuestGeneralChannel = new Channel(secondGuestApp.driver, 'general') const guestlabels = await ownerGeneralChannel.getUserLabels(joiningUserUsername3) expect(guestlabels.length).toEqual(1) - for (const label in guestlabels) { + for (const label of guestlabels) { expect(label).toEqual('Unregistered') } }) @@ -262,7 +263,7 @@ describe('Multiple Clients', () => { it('First user sees that unregistered user messages are marked as "unregistered"', async () => { const guestlabels = await generalChannel2.getUserLabels(joiningUserUsername3) expect(guestlabels.length).toEqual(1) - for (const label in guestlabels) { + for (const label of guestlabels) { expect(label).toEqual('Unregistered') } }) @@ -273,7 +274,14 @@ describe('Multiple Clients', () => { await debugModal.close() }) - it('Unregistered user receives certificate, the "Unregistered" label is removed', async () => { + it('Unregistered user receives certificate, they can see confirmation that they registered', async () => { + await secondGuestGeneralChannel.waitForUserMessage( + ownerUsername, + `@${joiningUserUsername3} has joined ${displayedCommunityName}!` + ) + }) + + it('"Unregistered" label is removed', async () => { ownerGeneralChannel = new Channel(ownerApp.driver, 'general') const ownerAppLabels = await ownerGeneralChannel.getUserLabels(joiningUserUsername3) expect(ownerAppLabels.length).toEqual(0) @@ -316,9 +324,7 @@ describe('Multiple Clients', () => { }) it('Channel deletion - User sees info about channel deletion in general channel', async () => { await sleep(5000) - const messages = await generalChannel2.getUserMessages(ownerUsername) - const text = await messages[3].getText() - expect(text).toEqual(`@${ownerUsername} deleted #${newChannelName}`) + await generalChannel2.waitForUserMessage(ownerUsername, `@${ownerUsername} deleted #${newChannelName}`) }) it('Channel deletion - User can create channel with the same name and is fresh channel', async () => { await sidebar2.addNewChannel(newChannelName) @@ -344,7 +350,7 @@ describe('Multiple Clients', () => { await settingsModal.leaveCommunityButton() }) // Delete general channel while guest is absent - it('Channel deletion - Owner recreate general channel', async () => { + it('Channel deletion - Owner recreates general channel', async () => { console.log('TEST 3') await new Promise(resolve => setTimeout(() => resolve(), 10000)) const isGeneralChannel = await ownerGeneralChannel.messageInput.isDisplayed() @@ -358,13 +364,15 @@ describe('Multiple Clients', () => { it('Leave community - Guest re-join to community successfully', async () => { console.log('TEST 4') + const debugModal = new DebugModeModal(guestApp.driver) + await debugModal.close() const joinCommunityModal = new JoinCommunityModal(guestApp.driver) const isJoinCommunityModal = await joinCommunityModal.element.isDisplayed() expect(isJoinCommunityModal).toBeTruthy() await joinCommunityModal.typeCommunityCode(invitationCode) await joinCommunityModal.submit() }) - it('Leave community - Guest register new username', async () => { + it('Leave community - Guest registers new username', async () => { console.log('TEST 5') const registerModal2 = new RegisterUsernameModal(guestApp.driver) const isRegisterModal2 = await registerModal2.element.isDisplayed() @@ -374,7 +382,7 @@ describe('Multiple Clients', () => { }) // Check correct channels replication - it('Channel deletion - User see information about recreation general channel and see correct amount of messages', async () => { + it('Channel deletion - User sees information about recreation general channel and see correct amount of messages', async () => { console.log('TEST 6') generalChannel2 = new Channel(guestApp.driver, 'general') await generalChannel2.element.isDisplayed() @@ -383,12 +391,15 @@ describe('Multiple Clients', () => { resolve() }, 10000) ) - const messages = await generalChannel2.getUserMessages(ownerUsername) - const text1 = await messages[0].getText() - const text2 = await messages[1].getText() - expect(messages.length).toEqual(2) - expect(text1).toEqual(`@${ownerUsername} deleted all messages in #general`) - expect(text2).toEqual(`@${joiningUserUsername2} has joined Testcommunity! 🎉`) + + await generalChannel2.waitForUserMessage(ownerUsername, `@${ownerUsername} deleted all messages in #general`) + await generalChannel2.waitForUserMessage(ownerUsername, `@${joiningUserUsername2} has joined Testcommunity! 🎉`) + // const messages = await generalChannel2.getUserMessages(ownerUsername) + // const text1 = await messages[0].getText() + // const text2 = await messages[1].getText() + // expect(messages.length).toEqual(2) + // expect(text1).toEqual(`@${ownerUsername} deleted all messages in #general`) + // expect(text2).toEqual(`@${joiningUserUsername2} has joined Testcommunity! 🎉`) }) it('Leave community - Guest sends a message', async () => { @@ -406,37 +417,40 @@ describe('Multiple Clients', () => { }) it('Leave community - Sent message is visible in a channel', async () => { console.log('TEST 8') - const messages2 = await generalChannel2.getUserMessages(joiningUserUsername2) - const text2 = await messages2[0].getText() - expect(text2).toEqual(joiningUserMessages[1]) + await generalChannel2.waitForUserMessage(joiningUserUsername2, joiningUserMessages[1]) + // const messages2 = await generalChannel2.getUserMessages(joiningUserUsername2) + // const text2 = await messages2[0].getText() + // expect(text2).toEqual(joiningUserMessages[1]) }) - it('Owner close app', async () => { + it('Owner closes app', async () => { await ownerApp.close({ forceSaveState: true }) await new Promise(resolve => setTimeout(() => resolve(), 20000)) }) - it('Guest close app', async () => { + it('Guest closes app', async () => { console.log('TEST 9') await guestApp?.close() }) - it('Owner re-open app', async () => { + it('Owner re-opens app', async () => { await ownerApp?.open() await new Promise(resolve => setTimeout(() => resolve(), 10000)) }) - it('Guest close app - Owner send another message after guest leave app', async () => { + it('Guest closes app - Owner sends another message after guest left the app', async () => { console.log('TEST 10') ownerGeneralChannel = new Channel(ownerApp.driver, 'general') const isMessageInput = await ownerGeneralChannel.messageInput.isDisplayed() expect(isMessageInput).toBeTruthy() await ownerGeneralChannel.sendMessage(ownerMessages[2]) }) - it('Guest close app - Check if message is visible for owner', async () => { + it('Guest closes app - Check if message is visible for owner', async () => { console.log('TEST 11') - const messages = await ownerGeneralChannel.getUserMessages(ownerUsername) - const text = await messages[messages.length - 1].getText() - expect(text).toEqual(ownerMessages[2]) + await ownerGeneralChannel.waitForUserMessage(ownerUsername, ownerMessages[2]) + + // const messages = await ownerGeneralChannel.getUserMessages(ownerUsername) + // const text = await messages[messages.length - 1].getText() + // expect(text).toEqual(ownerMessages[2]) }) } }) From 9658700a6b056dfb52a2b5e1af00355c8abbdef2 Mon Sep 17 00:00:00 2001 From: Emi Date: Fri, 22 Sep 2023 16:40:00 +0200 Subject: [PATCH 09/17] Finish e2e test for unregistered user; Remove dupliated sortPeers function --- packages/e2e-tests/src/selectors.ts | 33 ++++++------- .../e2e-tests/src/tests/twoClients.test.ts | 36 +++----------- packages/state-manager/src/index.ts | 2 - .../appConnection/connection.selectors.ts | 2 +- .../src/sagas/users/users.selectors.ts | 4 ++ .../utils/functions/sortPeers/sortPeers.ts | 48 ------------------- 6 files changed, 28 insertions(+), 97 deletions(-) delete mode 100644 packages/state-manager/src/utils/functions/sortPeers/sortPeers.ts diff --git a/packages/e2e-tests/src/selectors.ts b/packages/e2e-tests/src/selectors.ts index b1b2401ea8..dc8fbe34b2 100644 --- a/packages/e2e-tests/src/selectors.ts +++ b/packages/e2e-tests/src/selectors.ts @@ -278,23 +278,24 @@ export class Channel { ) } - async getUserLabels(username: string) { - const messages = await this.getUserMessagesWrapper(username) - console.log(`getUserLabels, wrappers for ${username}`, messages.length) - const labelsElements = messages.filter(async msg => { - return (await msg.findElements(By.xpath(`//*[contains(@data-testid, "userLabel-${username}")]`))).length > 0 + async waitForLabel(username: string, label: string) { + console.log(`Waiting for user's "${username}" label "${label}" label`) + await this.driver.wait(async () => { + const labels = await this.driver.findElements(By.xpath(`//*[contains(@data-testid, "userLabel-${username}")]`)) + const properLabels = labels.filter(async labelElement => { + const labelText = await labelElement.getText() + return labelText === label + }) + return properLabels.length > 0 + }) + } + + async waitForLabelsNotPresent(username: string) { + console.log(`Waiting for user's "${username}" label to not be present`) + await this.driver.wait(async () => { + const labels = await this.driver.findElements(By.xpath(`//*[contains(@data-testid, "userLabel-${username}")]`)) + return labels.length === 0 }) - console.log(`getUserLabels, elements for ${username}`, labelsElements.length) - // console.log('get user labels', username) - // const labels = await this.driver.wait( - // until.elementsLocated(By.xpath(`//*[contains(@data-testid, "userLabel-${username}")]`)) - // ) - // console.log('labels', labels.length) - const labelsText = await Promise.all( - labelsElements.map(async labelElement => labelElement.findElement(By.css('span')).getText()) - ) - console.log(`getUserLabels, labelsText for ${username}`, labelsText) - return labelsText } async getMessage(text: string) { diff --git a/packages/e2e-tests/src/tests/twoClients.test.ts b/packages/e2e-tests/src/tests/twoClients.test.ts index a7f0077ab9..47dd24cb16 100644 --- a/packages/e2e-tests/src/tests/twoClients.test.ts +++ b/packages/e2e-tests/src/tests/twoClients.test.ts @@ -46,12 +46,13 @@ describe('Multiple Clients', () => { const joiningUserMessages = ['Nice to meet you all', 'Nice to meet you again', 'Hi everyone'] const newChannelName = 'mid-night-club' - const sleep = async (time = 1000) => + const sleep = async (time = 1000) => { await new Promise(resolve => setTimeout(() => { resolve() }, time) ) + } beforeAll(async () => { ownerApp = new App() @@ -216,7 +217,6 @@ describe('Multiple Clients', () => { }) it('Second guest starts to register when owner is offline', async () => { - // console.log('new user - 3') const joinCommunityModal = new JoinCommunityModal(secondGuestApp.driver) const isJoinCommunityModal = await joinCommunityModal.element.isDisplayed() expect(isJoinCommunityModal).toBeTruthy() @@ -244,7 +244,7 @@ describe('Multiple Clients', () => { }) it('Second guest can send a message, they see their message tagged as "unregistered"', async () => { - console.log('FETCHING CHANNEL MESSAGES!') + console.log('Second guest FETCHING CHANNEL MESSAGES!') await new Promise(resolve => setTimeout(() => { resolve() @@ -252,20 +252,11 @@ describe('Multiple Clients', () => { ) await secondGuestGeneralChannel.sendMessage(joiningUserMessages[2]) secondGuestGeneralChannel = new Channel(secondGuestApp.driver, 'general') - const guestlabels = await ownerGeneralChannel.getUserLabels(joiningUserUsername3) - expect(guestlabels.length).toEqual(1) - for (const label of guestlabels) { - expect(label).toEqual('Unregistered') - } + await secondGuestGeneralChannel.waitForLabel(joiningUserUsername3, 'Unregistered') }) - // TODO: check if other user also sees unregistered user marked as "registered" it('First user sees that unregistered user messages are marked as "unregistered"', async () => { - const guestlabels = await generalChannel2.getUserLabels(joiningUserUsername3) - expect(guestlabels.length).toEqual(1) - for (const label of guestlabels) { - expect(label).toEqual('Unregistered') - } + await generalChannel2.waitForLabel(joiningUserUsername3, 'Unregistered') }) it('Owner goes back online', async () => { @@ -283,11 +274,9 @@ describe('Multiple Clients', () => { it('"Unregistered" label is removed', async () => { ownerGeneralChannel = new Channel(ownerApp.driver, 'general') - const ownerAppLabels = await ownerGeneralChannel.getUserLabels(joiningUserUsername3) - expect(ownerAppLabels.length).toEqual(0) + await ownerGeneralChannel.waitForLabelsNotPresent(joiningUserUsername3) }) - // TODO: maybe add extra "it" with "channel creation"? it('Channel creation - Owner creates second channel', async () => { sidebar = new Sidebar(ownerApp.driver) await sidebar.addNewChannel(newChannelName) @@ -394,12 +383,6 @@ describe('Multiple Clients', () => { await generalChannel2.waitForUserMessage(ownerUsername, `@${ownerUsername} deleted all messages in #general`) await generalChannel2.waitForUserMessage(ownerUsername, `@${joiningUserUsername2} has joined Testcommunity! 🎉`) - // const messages = await generalChannel2.getUserMessages(ownerUsername) - // const text1 = await messages[0].getText() - // const text2 = await messages[1].getText() - // expect(messages.length).toEqual(2) - // expect(text1).toEqual(`@${ownerUsername} deleted all messages in #general`) - // expect(text2).toEqual(`@${joiningUserUsername2} has joined Testcommunity! 🎉`) }) it('Leave community - Guest sends a message', async () => { @@ -418,9 +401,6 @@ describe('Multiple Clients', () => { it('Leave community - Sent message is visible in a channel', async () => { console.log('TEST 8') await generalChannel2.waitForUserMessage(joiningUserUsername2, joiningUserMessages[1]) - // const messages2 = await generalChannel2.getUserMessages(joiningUserUsername2) - // const text2 = await messages2[0].getText() - // expect(text2).toEqual(joiningUserMessages[1]) }) it('Owner closes app', async () => { await ownerApp.close({ forceSaveState: true }) @@ -447,10 +427,6 @@ describe('Multiple Clients', () => { it('Guest closes app - Check if message is visible for owner', async () => { console.log('TEST 11') await ownerGeneralChannel.waitForUserMessage(ownerUsername, ownerMessages[2]) - - // const messages = await ownerGeneralChannel.getUserMessages(ownerUsername) - // const text = await messages[messages.length - 1].getText() - // expect(text).toEqual(ownerMessages[2]) }) } }) diff --git a/packages/state-manager/src/index.ts b/packages/state-manager/src/index.ts index fc41960a33..697ae67bc1 100644 --- a/packages/state-manager/src/index.ts +++ b/packages/state-manager/src/index.ts @@ -82,8 +82,6 @@ export * from './constants' export { formatBytes } from './utils/functions/formatBytes/formatBytes' -export { sortPeers } from './utils/functions/sortPeers/sortPeers' - export { getInvitationCodes } from './utils/functions/invitationCode/invitationCode' export type { Socket } from './types' diff --git a/packages/state-manager/src/sagas/appConnection/connection.selectors.ts b/packages/state-manager/src/sagas/appConnection/connection.selectors.ts index 876d69b5dc..b0f7606fcf 100644 --- a/packages/state-manager/src/sagas/appConnection/connection.selectors.ts +++ b/packages/state-manager/src/sagas/appConnection/connection.selectors.ts @@ -5,9 +5,9 @@ import { allUsers } from '../users/users.selectors' import { communitiesSelectors } from '../communities/communities.selectors' import { peersStatsAdapter } from './connection.adapter' import { connectedPeers } from '../network/network.selectors' -import { sortPeers } from '../../utils/functions/sortPeers/sortPeers' import { type NetworkStats } from './connection.types' import { type User } from '../users/users.types' +import { sortPeers } from '@quiet/common' const connectionSlice: CreatedSelectors[StoreKeys.Connection] = (state: StoreState) => state[StoreKeys.Connection] diff --git a/packages/state-manager/src/sagas/users/users.selectors.ts b/packages/state-manager/src/sagas/users/users.selectors.ts index 1371c6eaf0..44481aa8bb 100644 --- a/packages/state-manager/src/sagas/users/users.selectors.ts +++ b/packages/state-manager/src/sagas/users/users.selectors.ts @@ -82,6 +82,10 @@ export const allUsers = createSelector(csrsMapping, certificatesMapping, (csrs, const username = csrs[pubKey].username const isDuplicated = duplicateUsernames.includes(username) const isRegistered = Boolean(certs[pubKey]) + console.log('isRegistered', isRegistered) + console.log('certs[pubKey]', certs[pubKey]) + console.log('pubKey', pubKey) + console.log('-----') users[pubKey] = { ...csrs[pubKey], isRegistered, diff --git a/packages/state-manager/src/utils/functions/sortPeers/sortPeers.ts b/packages/state-manager/src/utils/functions/sortPeers/sortPeers.ts deleted file mode 100644 index c96c895203..0000000000 --- a/packages/state-manager/src/utils/functions/sortPeers/sortPeers.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { isDefined } from '@quiet/common' -import { type NetworkStats } from '@quiet/types' - -/** -This is the very simple algorithm for evaluating the most wanted peers. -1. It takes the peers stats list that contains statistics for every peer our node was ever connected to. -2. Two sorted arrays are created - one sorted by last seen and other by most uptime shared. -3. Arrays are merged taking one element from list one and one element from the second list. Duplicates are ommited -4. We end up with mix of last seen and most uptime descending array of peers, the it is enchanced to libp2p address. - */ -export const sortPeers = (peersAddresses: string[], stats: NetworkStats[]): string[] => { - const lastSeenSorted = [...stats].sort((a, b) => { - return b.lastSeen - a.lastSeen - }) - const mostUptimeSharedSorted = [...stats].sort((a, b) => { - return b.connectionTime - a.connectionTime - }) - - const mostWantedPeers: NetworkStats[] = [] - - for (let i = 0; i < stats.length; i++) { - const peerOne = lastSeenSorted[i] - const peerTwo = mostUptimeSharedSorted[i] - - if (!mostWantedPeers.includes(peerOne)) { - mostWantedPeers.push(peerOne) - } - - if (!mostWantedPeers.includes(peerTwo)) { - mostWantedPeers.push(peerTwo) - } - } - - const peerList = mostWantedPeers.map(peerId => { - return peersAddresses.find(peerAddress => { - const id = peerAddress.split('/')[7] - if (id === peerId.peerId) { - peersAddresses.splice(peersAddresses.indexOf(peerAddress), 1) - return true - } - }) - }) - - return peerList - .concat(peersAddresses) - .filter(address => address !== null) - .filter(isDefined) -} From 72dfe76736a074e23cca57eeb3ccb86d5e1844ed Mon Sep 17 00:00:00 2001 From: Emi Date: Mon, 25 Sep 2023 12:06:02 +0200 Subject: [PATCH 10/17] E2E test for multiple users - group users data --- packages/e2e-tests/src/selectors.ts | 2 +- .../e2e-tests/src/tests/twoClients.test.ts | 227 +++++++++--------- 2 files changed, 120 insertions(+), 109 deletions(-) diff --git a/packages/e2e-tests/src/selectors.ts b/packages/e2e-tests/src/selectors.ts index dc8fbe34b2..824f987afc 100644 --- a/packages/e2e-tests/src/selectors.ts +++ b/packages/e2e-tests/src/selectors.ts @@ -28,8 +28,8 @@ export class App { } async close(options?: { forceSaveState?: boolean }) { - console.log('Closing the app', this.buildSetup.dataDir) if (!this.isOpened) return + console.log('Closing the app', this.buildSetup.dataDir) if (options?.forceSaveState) { await this.saveState() // Selenium creates community and closes app so fast that redux state may not be saved properly await this.waitForSavedState() diff --git a/packages/e2e-tests/src/tests/twoClients.test.ts b/packages/e2e-tests/src/tests/twoClients.test.ts index 47dd24cb16..32eb4f1f27 100644 --- a/packages/e2e-tests/src/tests/twoClients.test.ts +++ b/packages/e2e-tests/src/tests/twoClients.test.ts @@ -5,22 +5,20 @@ import { CreateCommunityModal, DebugModeModal, JoinCommunityModal, - JoiningLoadingPanel, RegisterUsernameModal, Sidebar, } from '../selectors' import logger from '../logger' -const log = logger('Two Clients:') +const log = logger('ManyClients') + +interface UserTestData { + username: string + app: App + messages: string[] +} jest.setTimeout(900000) describe('Multiple Clients', () => { - let ownerApp: App - let guestApp: App - let secondGuestApp: App - - let registerModal2: RegisterUsernameModal - let registerModal3: RegisterUsernameModal - let ownerGeneralChannel: Channel let generalChannel2: Channel let secondGuestGeneralChannel: Channel @@ -35,15 +33,10 @@ describe('Multiple Clients', () => { let sidebar: Sidebar let sidebar2: Sidebar + let users: Record + const communityName = 'testcommunity' const displayedCommunityName = 'Testcommunity' - const ownerUsername = 'bob' - const ownerMessages = ['Hi', 'Hello', 'After guest leave app'] - const joiningUserUsername = 'alice-joining' - const joiningUserUsername2 = 'alice2' - const joiningUserUsername3 = 'alice-unregistered' - - const joiningUserMessages = ['Nice to meet you all', 'Nice to meet you again', 'Hi everyone'] const newChannelName = 'mid-night-club' const sleep = async (time = 1000) => { @@ -55,13 +48,35 @@ describe('Multiple Clients', () => { } beforeAll(async () => { - ownerApp = new App() + const commonApp = new App() + users = { + owner: { + username: 'owner', + messages: ['Hi', 'Hello', 'After guest left the app'], + app: new App(), + }, + user1: { + username: 'user-joining-1', + messages: ['Nice to meet you all'], + app: commonApp, + }, + user2: { + username: 'user-joining-1-1', + messages: ['Nice to meet you again'], + app: commonApp, + }, + user3: { + username: 'user-joining-2', + messages: ['Hi everyone'], + app: new App(), + }, + } }) afterAll(async () => { - await ownerApp?.close() - await guestApp?.close() - await secondGuestApp?.close() + for (const user of Object.values(users)) { + await user.app.close() + } }) beforeEach(async () => { @@ -70,36 +85,31 @@ describe('Multiple Clients', () => { describe('Stages:', () => { it('Owner opens the app', async () => { - await ownerApp.open() + await users.owner.app.open() }) it('JoinCommunityModal - owner switches to create community modal', async () => { - const joinModal = new JoinCommunityModal(ownerApp.driver) + const joinModal = new JoinCommunityModal(users.owner.app.driver) const isJoinModal = await joinModal.element.isDisplayed() expect(isJoinModal).toBeTruthy() await joinModal.switchToCreateCommunity() }) it('CreateCommunityModal - owner creates the community', async () => { - const createModal = new CreateCommunityModal(ownerApp.driver) + const createModal = new CreateCommunityModal(users.owner.app.driver) const isCreateModal = await createModal.element.isDisplayed() expect(isCreateModal).toBeTruthy() await createModal.typeCommunityName(communityName) await createModal.submit() }) it('RegisterUsernameModal - owner registers username', async () => { - const registerModal = new RegisterUsernameModal(ownerApp.driver) + const registerModal = new RegisterUsernameModal(users.owner.app.driver) const isRegisterModal = await registerModal.element.isDisplayed() expect(isRegisterModal).toBeTruthy() - await registerModal.typeUsername(ownerUsername) + await registerModal.typeUsername(users.owner.username) await registerModal.submit() }) - it.skip('Connecting to peers modal', async () => { - const loadingPanelCommunity = new JoiningLoadingPanel(ownerApp.driver) - const isLoadingPanelCommunity = await loadingPanelCommunity.element.isDisplayed() - expect(isLoadingPanelCommunity).toBeTruthy() - }) it('Owner sees general channel', async () => { - ownerGeneralChannel = new Channel(ownerApp.driver, 'general') + ownerGeneralChannel = new Channel(users.owner.app.driver, 'general') const isGeneralChannel = await ownerGeneralChannel.element.isDisplayed() const generalChannelText = await ownerGeneralChannel.element.getText() expect(isGeneralChannel).toBeTruthy() @@ -108,15 +118,15 @@ describe('Multiple Clients', () => { it('Owner sends a message', async () => { const isMessageInput = await ownerGeneralChannel.messageInput.isDisplayed() expect(isMessageInput).toBeTruthy() - await ownerGeneralChannel.sendMessage(ownerMessages[0]) + await ownerGeneralChannel.sendMessage(users.owner.messages[0]) }) it("Owner's message is visible on channel", async () => { - const messages = await ownerGeneralChannel.getUserMessages(ownerUsername) + const messages = await ownerGeneralChannel.getUserMessages(users.owner.username) const text = await messages[1].getText() - expect(text).toEqual(ownerMessages[0]) + expect(text).toEqual(users.owner.messages[0]) }) it('Owner opens the settings tab and gets an invitation code', async () => { - const settingsModal = await new Sidebar(ownerApp.driver).openSettings() + const settingsModal = await new Sidebar(users.owner.app.driver).openSettings() const isSettingsModal = await settingsModal.element.isDisplayed() expect(isSettingsModal).toBeTruthy() await sleep(2000) @@ -134,13 +144,12 @@ describe('Multiple Clients', () => { it('Guest opens the app', async () => { console.log('Second client') - guestApp = new App() - await guestApp.open() + await users.user1.app.open() }) it('Guest joins the new community successfully', async () => { console.log('new user - 3') - const joinCommunityModal = new JoinCommunityModal(guestApp.driver) + const joinCommunityModal = new JoinCommunityModal(users.user1.app.driver) const isJoinCommunityModal = await joinCommunityModal.element.isDisplayed() expect(isJoinCommunityModal).toBeTruthy() console.log({ invitationCode }) @@ -150,23 +159,17 @@ describe('Multiple Clients', () => { it('RegisterUsernameModal - Guest submits the username', async () => { console.log('new user - 5') - registerModal2 = new RegisterUsernameModal(guestApp.driver) - const isRegisterModal = await registerModal2.element.isDisplayed() + const registerModal = new RegisterUsernameModal(users.user1.app.driver) + const isRegisterModal = await registerModal.element.isDisplayed() expect(isRegisterModal).toBeTruthy() - await registerModal2.clearInput() - await registerModal2.typeUsername(joiningUserUsername) - await registerModal2.submit() + await registerModal.clearInput() + await registerModal.typeUsername(users.user1.username) + await registerModal.submit() }) - it.skip('JoiningLoadingPanel', async () => { - console.log('new user - 6') - const loadingPanelCommunity2 = new JoiningLoadingPanel(ownerApp.driver) - const isLoadingPanelCommunity2 = await loadingPanelCommunity2.element.isDisplayed() - expect(isLoadingPanelCommunity2).toBeTruthy() - }) it('Guest sees general channel and sends a message', async () => { console.log('new user - 7') - generalChannel2 = new Channel(guestApp.driver, 'general') + generalChannel2 = new Channel(users.user1.app.driver, 'general') await generalChannel2.element.isDisplayed() const isMessageInput2 = await generalChannel2.messageInput.isDisplayed() expect(isMessageInput2).toBeTruthy() @@ -176,19 +179,18 @@ describe('Multiple Clients', () => { resolve() }, 15000) ) - await generalChannel2.sendMessage(joiningUserMessages[0]) + await generalChannel2.sendMessage(users.user1.messages[0]) }) it('Sent message is visible in a channel', async () => { - const messages2 = await generalChannel2.getUserMessages(joiningUserUsername) - const messages1 = await generalChannel2.getUserMessages(ownerUsername) - + const messages2 = await generalChannel2.getUserMessages(users.user1.username) + const messages1 = await generalChannel2.getUserMessages(users.owner.username) console.log({ messages1, messages2 }) const text2 = await messages2[0].getText() - expect(text2).toEqual(joiningUserMessages[0]) + expect(text2).toEqual(users.user1.messages[0]) }) it('Guest opens the settings tab and gets an updated invitation code', async () => { - const settingsModal = await new Sidebar(guestApp.driver).openSettings() + const settingsModal = await new Sidebar(users.user1.app.driver).openSettings() const isSettingsModal = await settingsModal.element.isDisplayed() expect(isSettingsModal).toBeTruthy() await sleep(2000) @@ -198,26 +200,25 @@ describe('Multiple Clients', () => { await sleep(2000) invitationCode = await invitationCodeElement.getText() await sleep(2000) - console.log(`${invitationCode} copied from first user`) + console.log(`${invitationCode} copied from non owner`) expect(invitationCode).not.toBeUndefined() await settingsModal.close() }) - // third user joins when owner is offline. Does not use duplicated username + // Third user joins when owner is offline. Does not use duplicated username it('Owner goes offline', async () => { - await ownerApp.close() + await users.owner.app.close() }) it('Second guest opens the app', async () => { console.log('Third client') - secondGuestApp = new App() - await secondGuestApp.open() - const debugModal = new DebugModeModal(secondGuestApp.driver) + await users.user3.app.open() + const debugModal = new DebugModeModal(users.user3.app.driver) await debugModal.close() }) it('Second guest starts to register when owner is offline', async () => { - const joinCommunityModal = new JoinCommunityModal(secondGuestApp.driver) + const joinCommunityModal = new JoinCommunityModal(users.user3.app.driver) const isJoinCommunityModal = await joinCommunityModal.element.isDisplayed() expect(isJoinCommunityModal).toBeTruthy() console.log({ invitationCode }) @@ -227,17 +228,17 @@ describe('Multiple Clients', () => { it('Second guest submits username that is not used by other user', async () => { console.log('nereeew user - 5') - registerModal3 = new RegisterUsernameModal(secondGuestApp.driver) - const isRegisterModal = await registerModal3.element.isDisplayed() + const registerModal = new RegisterUsernameModal(users.user3.app.driver) + const isRegisterModal = await registerModal.element.isDisplayed() expect(isRegisterModal).toBeTruthy() - await registerModal3.clearInput() - await registerModal3.typeUsername(joiningUserUsername3) - await registerModal3.submit() + await registerModal.clearInput() + await registerModal.typeUsername(users.user3.username) + await registerModal.submit() }) it('Second quest sees general channel', async () => { console.log('new user - 7') - secondGuestGeneralChannel = new Channel(secondGuestApp.driver, 'general') + secondGuestGeneralChannel = new Channel(users.user3.app.driver, 'general') await secondGuestGeneralChannel.element.isDisplayed() const isMessageInput = await secondGuestGeneralChannel.messageInput.isDisplayed() expect(isMessageInput).toBeTruthy() @@ -250,61 +251,62 @@ describe('Multiple Clients', () => { resolve() }, 15000) ) - await secondGuestGeneralChannel.sendMessage(joiningUserMessages[2]) - secondGuestGeneralChannel = new Channel(secondGuestApp.driver, 'general') - await secondGuestGeneralChannel.waitForLabel(joiningUserUsername3, 'Unregistered') + await secondGuestGeneralChannel.sendMessage(users.user3.messages[0]) + secondGuestGeneralChannel = new Channel(users.user3.app.driver, 'general') + await secondGuestGeneralChannel.waitForLabel(users.user3.username, 'Unregistered') }) it('First user sees that unregistered user messages are marked as "unregistered"', async () => { - await generalChannel2.waitForLabel(joiningUserUsername3, 'Unregistered') + await generalChannel2.waitForLabel(users.user3.username, 'Unregistered') }) it('Owner goes back online', async () => { - await ownerApp.open() - const debugModal = new DebugModeModal(ownerApp.driver) + await users.owner.app.open() + const debugModal = new DebugModeModal(users.owner.app.driver) await debugModal.close() }) it('Unregistered user receives certificate, they can see confirmation that they registered', async () => { await secondGuestGeneralChannel.waitForUserMessage( - ownerUsername, - `@${joiningUserUsername3} has joined ${displayedCommunityName}!` + users.owner.username, + `@${users.user3.username} has joined ${displayedCommunityName}!` ) }) it('"Unregistered" label is removed', async () => { - ownerGeneralChannel = new Channel(ownerApp.driver, 'general') - await ownerGeneralChannel.waitForLabelsNotPresent(joiningUserUsername3) + ownerGeneralChannel = new Channel(users.owner.app.driver, 'general') + await ownerGeneralChannel.waitForLabelsNotPresent(users.user3.username) }) it('Channel creation - Owner creates second channel', async () => { - sidebar = new Sidebar(ownerApp.driver) + sidebar = new Sidebar(users.owner.app.driver) await sidebar.addNewChannel(newChannelName) await sidebar.switchChannel(newChannelName) const channels = await sidebar.getChannelList() expect(channels.length).toEqual(2) }) it('Channel creation - Owner sends message in second channel', async () => { - secondChannel = new Channel(ownerApp.driver, newChannelName) + secondChannel = new Channel(users.owner.app.driver, newChannelName) const isMessageInput = await secondChannel.messageInput.isDisplayed() expect(isMessageInput).toBeTruthy() - await secondChannel.sendMessage(ownerMessages[1]) + await secondChannel.sendMessage(users.owner.messages[1]) }) it('Channel creation - User reads message in second channel', async () => { - sidebar2 = new Sidebar(guestApp.driver) + sidebar2 = new Sidebar(users.user1.app.driver) await sidebar2.switchChannel(newChannelName) - secondChannel2 = new Channel(guestApp.driver, newChannelName) + secondChannel2 = new Channel(users.user1.app.driver, newChannelName) await new Promise(resolve => setTimeout(() => { resolve() }, 2000) ) - const messages = await secondChannel2.getUserMessages(ownerUsername) - const text = await messages[1].getText() - expect(text).toEqual(ownerMessages[1]) + await secondChannel2.waitForUserMessage(users.owner.username, users.owner.messages[1]) + // const messages = await secondChannel2.getUserMessages(users.owner.username) + // const text = await messages[1].getText() + // expect(text).toEqual(users.owner.messages[1]) }) it('Channel deletion - Owner deletes second channel', async () => { - channelContextMenu = new ChannelContextMenu(ownerApp.driver) + channelContextMenu = new ChannelContextMenu(users.owner.app.driver) await channelContextMenu.openMenu() await channelContextMenu.openDeletionChannelModal() await channelContextMenu.deleteChannel() @@ -313,12 +315,15 @@ describe('Multiple Clients', () => { }) it('Channel deletion - User sees info about channel deletion in general channel', async () => { await sleep(5000) - await generalChannel2.waitForUserMessage(ownerUsername, `@${ownerUsername} deleted #${newChannelName}`) + await generalChannel2.waitForUserMessage( + users.owner.username, + `@${users.owner.username} deleted #${newChannelName}` + ) }) it('Channel deletion - User can create channel with the same name and is fresh channel', async () => { await sidebar2.addNewChannel(newChannelName) await sidebar2.switchChannel(newChannelName) - const messages = await secondChannel2.getUserMessages(joiningUserUsername) + const messages = await secondChannel2.getUserMessages(users.user1.username) expect(messages.length).toEqual(1) await new Promise(resolve => setTimeout(() => { @@ -332,7 +337,7 @@ describe('Multiple Clients', () => { if (process.platform !== 'win32') { it('Leave community', async () => { console.log('TEST 2') - const settingsModal = await new Sidebar(guestApp.driver).openSettings() + const settingsModal = await new Sidebar(users.user1.app.driver).openSettings() const isSettingsModal = await settingsModal.element.isDisplayed() expect(isSettingsModal).toBeTruthy() await settingsModal.openLeaveCommunityModal() @@ -353,9 +358,9 @@ describe('Multiple Clients', () => { it('Leave community - Guest re-join to community successfully', async () => { console.log('TEST 4') - const debugModal = new DebugModeModal(guestApp.driver) + const debugModal = new DebugModeModal(users.user1.app.driver) await debugModal.close() - const joinCommunityModal = new JoinCommunityModal(guestApp.driver) + const joinCommunityModal = new JoinCommunityModal(users.user1.app.driver) const isJoinCommunityModal = await joinCommunityModal.element.isDisplayed() expect(isJoinCommunityModal).toBeTruthy() await joinCommunityModal.typeCommunityCode(invitationCode) @@ -363,17 +368,17 @@ describe('Multiple Clients', () => { }) it('Leave community - Guest registers new username', async () => { console.log('TEST 5') - const registerModal2 = new RegisterUsernameModal(guestApp.driver) + const registerModal2 = new RegisterUsernameModal(users.user1.app.driver) const isRegisterModal2 = await registerModal2.element.isDisplayed() expect(isRegisterModal2).toBeTruthy() - await registerModal2.typeUsername(joiningUserUsername2) + await registerModal2.typeUsername(users.user2.username) await registerModal2.submit() }) // Check correct channels replication it('Channel deletion - User sees information about recreation general channel and see correct amount of messages', async () => { console.log('TEST 6') - generalChannel2 = new Channel(guestApp.driver, 'general') + generalChannel2 = new Channel(users.user1.app.driver, 'general') await generalChannel2.element.isDisplayed() await new Promise(resolve => setTimeout(() => { @@ -381,13 +386,19 @@ describe('Multiple Clients', () => { }, 10000) ) - await generalChannel2.waitForUserMessage(ownerUsername, `@${ownerUsername} deleted all messages in #general`) - await generalChannel2.waitForUserMessage(ownerUsername, `@${joiningUserUsername2} has joined Testcommunity! 🎉`) + await generalChannel2.waitForUserMessage( + users.owner.username, + `@${users.owner.username} deleted all messages in #general` + ) + await generalChannel2.waitForUserMessage( + users.owner.username, + `@${users.user2.username} has joined Testcommunity! 🎉` + ) }) - it('Leave community - Guest sends a message', async () => { + it('Leave community - Guest sends a message after rejoining community as a new user', async () => { console.log('TEST 7') - generalChannel2 = new Channel(guestApp.driver, 'general') + generalChannel2 = new Channel(users.user1.app.driver, 'general') await generalChannel2.element.isDisplayed() const isMessageInput2 = await generalChannel2.messageInput.isDisplayed() expect(isMessageInput2).toBeTruthy() @@ -396,37 +407,37 @@ describe('Multiple Clients', () => { resolve() }, 5000) ) - await generalChannel2.sendMessage(joiningUserMessages[1]) + await generalChannel2.sendMessage(users.user2.messages[0]) }) it('Leave community - Sent message is visible in a channel', async () => { console.log('TEST 8') - await generalChannel2.waitForUserMessage(joiningUserUsername2, joiningUserMessages[1]) + await generalChannel2.waitForUserMessage(users.user2.username, users.user2.messages[0]) }) it('Owner closes app', async () => { - await ownerApp.close({ forceSaveState: true }) + await users.owner.app.close({ forceSaveState: true }) await new Promise(resolve => setTimeout(() => resolve(), 20000)) }) it('Guest closes app', async () => { console.log('TEST 9') - await guestApp?.close() + await users.user1.app?.close() }) it('Owner re-opens app', async () => { - await ownerApp?.open() + await users.owner.app?.open() await new Promise(resolve => setTimeout(() => resolve(), 10000)) }) it('Guest closes app - Owner sends another message after guest left the app', async () => { console.log('TEST 10') - ownerGeneralChannel = new Channel(ownerApp.driver, 'general') + ownerGeneralChannel = new Channel(users.owner.app.driver, 'general') const isMessageInput = await ownerGeneralChannel.messageInput.isDisplayed() expect(isMessageInput).toBeTruthy() - await ownerGeneralChannel.sendMessage(ownerMessages[2]) + await ownerGeneralChannel.sendMessage(users.owner.messages[2]) }) it('Guest closes app - Check if message is visible for owner', async () => { console.log('TEST 11') - await ownerGeneralChannel.waitForUserMessage(ownerUsername, ownerMessages[2]) + await ownerGeneralChannel.waitForUserMessage(users.owner.username, users.owner.messages[2]) }) } }) From 8b78e9d4ab8367a4d35e17ac044a4dd3cdbd8e14 Mon Sep 17 00:00:00 2001 From: Emi Date: Mon, 25 Sep 2023 12:07:17 +0200 Subject: [PATCH 11/17] Rename twoClients to multipleClients e2e test --- .github/workflows/e2e-linux.yml | 4 ++-- .github/workflows/e2e-mac.yml | 4 ++-- .github/workflows/e2e-win.yml | 4 ++-- .../src/tests/{twoClients.test.ts => multipleClients.test.ts} | 0 4 files changed, 6 insertions(+), 6 deletions(-) rename packages/e2e-tests/src/tests/{twoClients.test.ts => multipleClients.test.ts} (100%) diff --git a/.github/workflows/e2e-linux.yml b/.github/workflows/e2e-linux.yml index e2dd29f39a..cb5e543278 100644 --- a/.github/workflows/e2e-linux.yml +++ b/.github/workflows/e2e-linux.yml @@ -53,12 +53,12 @@ jobs: max_attempts: 3 command: cd packages/e2e-tests && npm run test oneClient.test.ts - - name: Run two clients test + - name: Run multiple clients test uses: nick-fields/retry@v2 with: timeout_minutes: 25 max_attempts: 3 - command: cd packages/e2e-tests && npm run test twoClients.test.ts + command: cd packages/e2e-tests && npm run test multipleClients.test.ts - name: Run invitation link test - Includes 2 separate application clients uses: nick-fields/retry@v2 diff --git a/.github/workflows/e2e-mac.yml b/.github/workflows/e2e-mac.yml index 8e1b0c5e17..dde249026a 100644 --- a/.github/workflows/e2e-mac.yml +++ b/.github/workflows/e2e-mac.yml @@ -61,11 +61,11 @@ jobs: max_attempts: 3 command: cd packages/e2e-tests && npm run test oneClient.test.ts - - name: Run two clients test + - name: Run multiple clients test uses: nick-fields/retry@v2 with: timeout_minutes: 25 max_attempts: 3 - command: cd packages/e2e-tests && npm run test twoClients.test.ts + command: cd packages/e2e-tests && npm run test multipleClients.test.ts diff --git a/.github/workflows/e2e-win.yml b/.github/workflows/e2e-win.yml index 9f3fa52e37..2ec026f6f2 100644 --- a/.github/workflows/e2e-win.yml +++ b/.github/workflows/e2e-win.yml @@ -87,13 +87,13 @@ jobs: shell: bash command: cd packages/e2e-tests && npm run test oneClient.test.ts - - name: Run two clients test + - name: Run multiple clients test uses: nick-fields/retry@v2 with: timeout_minutes: 30 max_attempts: 3 shell: bash - command: cd packages/e2e-tests && npm run test twoClients.test.ts + command: cd packages/e2e-tests && npm run test multipleClients.test.ts - name: Run invitation link test - Includes 2 separate application clients uses: nick-fields/retry@v2 diff --git a/packages/e2e-tests/src/tests/twoClients.test.ts b/packages/e2e-tests/src/tests/multipleClients.test.ts similarity index 100% rename from packages/e2e-tests/src/tests/twoClients.test.ts rename to packages/e2e-tests/src/tests/multipleClients.test.ts From 287004bbbbd52a30a6668cc485d0577dcefe1a3c Mon Sep 17 00:00:00 2001 From: Emi Date: Mon, 25 Sep 2023 14:11:52 +0200 Subject: [PATCH 12/17] Clean up variables naming in e2e multiple clients test --- .github/workflows/e2e-win.yml | 2 + .../src/tests/multipleClients.test.ts | 140 +++++++++--------- 2 files changed, 70 insertions(+), 72 deletions(-) diff --git a/.github/workflows/e2e-win.yml b/.github/workflows/e2e-win.yml index 2ec026f6f2..15cf062f1c 100644 --- a/.github/workflows/e2e-win.yml +++ b/.github/workflows/e2e-win.yml @@ -74,10 +74,12 @@ jobs: - name: Kill tor run: Stop-Process -Name "tor" -Force shell: powershell + if: always() - name: Delay run: Start-Sleep -Seconds 10 shell: powershell + if: always() - name: Run one client test uses: nick-fields/retry@v2 diff --git a/packages/e2e-tests/src/tests/multipleClients.test.ts b/packages/e2e-tests/src/tests/multipleClients.test.ts index 32eb4f1f27..acc6d2e2cb 100644 --- a/packages/e2e-tests/src/tests/multipleClients.test.ts +++ b/packages/e2e-tests/src/tests/multipleClients.test.ts @@ -19,19 +19,18 @@ interface UserTestData { jest.setTimeout(900000) describe('Multiple Clients', () => { - let ownerGeneralChannel: Channel - let generalChannel2: Channel - let secondGuestGeneralChannel: Channel + let generalChannelOwner: Channel + let generalChannelUser1: Channel + let generalChannelUser3: Channel - let secondChannel: Channel - let secondChannel2: Channel + let secondChannelUser1: Channel - let channelContextMenu: ChannelContextMenu + let channelContextMenuOwner: ChannelContextMenu let invitationCode: string - let sidebar: Sidebar - let sidebar2: Sidebar + let sidebarOwner: Sidebar + let sidebarUser1: Sidebar let users: Record @@ -109,19 +108,19 @@ describe('Multiple Clients', () => { await registerModal.submit() }) it('Owner sees general channel', async () => { - ownerGeneralChannel = new Channel(users.owner.app.driver, 'general') - const isGeneralChannel = await ownerGeneralChannel.element.isDisplayed() - const generalChannelText = await ownerGeneralChannel.element.getText() + generalChannelOwner = new Channel(users.owner.app.driver, 'general') + const isGeneralChannel = await generalChannelOwner.element.isDisplayed() + const generalChannelText = await generalChannelOwner.element.getText() expect(isGeneralChannel).toBeTruthy() expect(generalChannelText).toEqual('# general') }) it('Owner sends a message', async () => { - const isMessageInput = await ownerGeneralChannel.messageInput.isDisplayed() + const isMessageInput = await generalChannelOwner.messageInput.isDisplayed() expect(isMessageInput).toBeTruthy() - await ownerGeneralChannel.sendMessage(users.owner.messages[0]) + await generalChannelOwner.sendMessage(users.owner.messages[0]) }) it("Owner's message is visible on channel", async () => { - const messages = await ownerGeneralChannel.getUserMessages(users.owner.username) + const messages = await generalChannelOwner.getUserMessages(users.owner.username) const text = await messages[1].getText() expect(text).toEqual(users.owner.messages[0]) }) @@ -169,9 +168,9 @@ describe('Multiple Clients', () => { it('Guest sees general channel and sends a message', async () => { console.log('new user - 7') - generalChannel2 = new Channel(users.user1.app.driver, 'general') - await generalChannel2.element.isDisplayed() - const isMessageInput2 = await generalChannel2.messageInput.isDisplayed() + generalChannelUser1 = new Channel(users.user1.app.driver, 'general') + await generalChannelUser1.element.isDisplayed() + const isMessageInput2 = await generalChannelUser1.messageInput.isDisplayed() expect(isMessageInput2).toBeTruthy() console.log('FETCHING CHANNEL MESSAGES!') await new Promise(resolve => @@ -179,11 +178,11 @@ describe('Multiple Clients', () => { resolve() }, 15000) ) - await generalChannel2.sendMessage(users.user1.messages[0]) + await generalChannelUser1.sendMessage(users.user1.messages[0]) }) it('Sent message is visible in a channel', async () => { - const messages2 = await generalChannel2.getUserMessages(users.user1.username) - const messages1 = await generalChannel2.getUserMessages(users.owner.username) + const messages2 = await generalChannelUser1.getUserMessages(users.user1.username) + const messages1 = await generalChannelUser1.getUserMessages(users.owner.username) console.log({ messages1, messages2 }) const text2 = await messages2[0].getText() expect(text2).toEqual(users.user1.messages[0]) @@ -238,9 +237,9 @@ describe('Multiple Clients', () => { it('Second quest sees general channel', async () => { console.log('new user - 7') - secondGuestGeneralChannel = new Channel(users.user3.app.driver, 'general') - await secondGuestGeneralChannel.element.isDisplayed() - const isMessageInput = await secondGuestGeneralChannel.messageInput.isDisplayed() + generalChannelUser3 = new Channel(users.user3.app.driver, 'general') + await generalChannelUser3.element.isDisplayed() + const isMessageInput = await generalChannelUser3.messageInput.isDisplayed() expect(isMessageInput).toBeTruthy() }) @@ -251,13 +250,13 @@ describe('Multiple Clients', () => { resolve() }, 15000) ) - await secondGuestGeneralChannel.sendMessage(users.user3.messages[0]) - secondGuestGeneralChannel = new Channel(users.user3.app.driver, 'general') - await secondGuestGeneralChannel.waitForLabel(users.user3.username, 'Unregistered') + await generalChannelUser3.sendMessage(users.user3.messages[0]) + generalChannelUser3 = new Channel(users.user3.app.driver, 'general') + await generalChannelUser3.waitForLabel(users.user3.username, 'Unregistered') }) it('First user sees that unregistered user messages are marked as "unregistered"', async () => { - await generalChannel2.waitForLabel(users.user3.username, 'Unregistered') + await generalChannelUser1.waitForLabel(users.user3.username, 'Unregistered') }) it('Owner goes back online', async () => { @@ -267,70 +266,67 @@ describe('Multiple Clients', () => { }) it('Unregistered user receives certificate, they can see confirmation that they registered', async () => { - await secondGuestGeneralChannel.waitForUserMessage( + await generalChannelUser3.waitForUserMessage( users.owner.username, `@${users.user3.username} has joined ${displayedCommunityName}!` ) }) it('"Unregistered" label is removed', async () => { - ownerGeneralChannel = new Channel(users.owner.app.driver, 'general') - await ownerGeneralChannel.waitForLabelsNotPresent(users.user3.username) + generalChannelOwner = new Channel(users.owner.app.driver, 'general') + await generalChannelOwner.waitForLabelsNotPresent(users.user3.username) }) it('Channel creation - Owner creates second channel', async () => { - sidebar = new Sidebar(users.owner.app.driver) - await sidebar.addNewChannel(newChannelName) - await sidebar.switchChannel(newChannelName) - const channels = await sidebar.getChannelList() + sidebarOwner = new Sidebar(users.owner.app.driver) + await sidebarOwner.addNewChannel(newChannelName) + await sidebarOwner.switchChannel(newChannelName) + const channels = await sidebarOwner.getChannelList() expect(channels.length).toEqual(2) }) it('Channel creation - Owner sends message in second channel', async () => { - secondChannel = new Channel(users.owner.app.driver, newChannelName) - const isMessageInput = await secondChannel.messageInput.isDisplayed() + const newChannel = new Channel(users.owner.app.driver, newChannelName) + const isMessageInput = await newChannel.messageInput.isDisplayed() expect(isMessageInput).toBeTruthy() - await secondChannel.sendMessage(users.owner.messages[1]) + await newChannel.sendMessage(users.owner.messages[1]) }) it('Channel creation - User reads message in second channel', async () => { - sidebar2 = new Sidebar(users.user1.app.driver) - await sidebar2.switchChannel(newChannelName) - secondChannel2 = new Channel(users.user1.app.driver, newChannelName) + sidebarUser1 = new Sidebar(users.user1.app.driver) + await sidebarUser1.switchChannel(newChannelName) + secondChannelUser1 = new Channel(users.user1.app.driver, newChannelName) await new Promise(resolve => setTimeout(() => { resolve() }, 2000) ) - await secondChannel2.waitForUserMessage(users.owner.username, users.owner.messages[1]) - // const messages = await secondChannel2.getUserMessages(users.owner.username) - // const text = await messages[1].getText() - // expect(text).toEqual(users.owner.messages[1]) + await secondChannelUser1.waitForUserMessage(users.owner.username, users.owner.messages[1]) }) it('Channel deletion - Owner deletes second channel', async () => { - channelContextMenu = new ChannelContextMenu(users.owner.app.driver) - await channelContextMenu.openMenu() - await channelContextMenu.openDeletionChannelModal() - await channelContextMenu.deleteChannel() - const channels = await sidebar.getChannelList() + channelContextMenuOwner = new ChannelContextMenu(users.owner.app.driver) + await channelContextMenuOwner.openMenu() + await channelContextMenuOwner.openDeletionChannelModal() + await channelContextMenuOwner.deleteChannel() + const channels = await sidebarOwner.getChannelList() expect(channels.length).toEqual(1) }) it('Channel deletion - User sees info about channel deletion in general channel', async () => { await sleep(5000) - await generalChannel2.waitForUserMessage( + await generalChannelUser1.waitForUserMessage( users.owner.username, `@${users.owner.username} deleted #${newChannelName}` ) }) it('Channel deletion - User can create channel with the same name and is fresh channel', async () => { - await sidebar2.addNewChannel(newChannelName) - await sidebar2.switchChannel(newChannelName) - const messages = await secondChannel2.getUserMessages(users.user1.username) + await sidebarUser1.addNewChannel(newChannelName) + await sidebarUser1.switchChannel(newChannelName) + const messages = await secondChannelUser1.getUserMessages(users.user1.username) expect(messages.length).toEqual(1) await new Promise(resolve => setTimeout(() => { resolve() }, 2000) ) - const channels = await sidebar.getChannelList() + const channels = await sidebarOwner.getChannelList() expect(channels.length).toEqual(2) }) // End of tests for Windows @@ -347,12 +343,12 @@ describe('Multiple Clients', () => { it('Channel deletion - Owner recreates general channel', async () => { console.log('TEST 3') await new Promise(resolve => setTimeout(() => resolve(), 10000)) - const isGeneralChannel = await ownerGeneralChannel.messageInput.isDisplayed() + const isGeneralChannel = await generalChannelOwner.messageInput.isDisplayed() expect(isGeneralChannel).toBeTruthy() - await channelContextMenu.openMenu() - await channelContextMenu.openDeletionChannelModal() - await channelContextMenu.deleteChannel() - const channels = await sidebar.getChannelList() + await channelContextMenuOwner.openMenu() + await channelContextMenuOwner.openDeletionChannelModal() + await channelContextMenuOwner.deleteChannel() + const channels = await sidebarOwner.getChannelList() expect(channels.length).toEqual(2) }) @@ -378,19 +374,19 @@ describe('Multiple Clients', () => { // Check correct channels replication it('Channel deletion - User sees information about recreation general channel and see correct amount of messages', async () => { console.log('TEST 6') - generalChannel2 = new Channel(users.user1.app.driver, 'general') - await generalChannel2.element.isDisplayed() + generalChannelUser1 = new Channel(users.user1.app.driver, 'general') + await generalChannelUser1.element.isDisplayed() await new Promise(resolve => setTimeout(() => { resolve() }, 10000) ) - await generalChannel2.waitForUserMessage( + await generalChannelUser1.waitForUserMessage( users.owner.username, `@${users.owner.username} deleted all messages in #general` ) - await generalChannel2.waitForUserMessage( + await generalChannelUser1.waitForUserMessage( users.owner.username, `@${users.user2.username} has joined Testcommunity! 🎉` ) @@ -398,20 +394,20 @@ describe('Multiple Clients', () => { it('Leave community - Guest sends a message after rejoining community as a new user', async () => { console.log('TEST 7') - generalChannel2 = new Channel(users.user1.app.driver, 'general') - await generalChannel2.element.isDisplayed() - const isMessageInput2 = await generalChannel2.messageInput.isDisplayed() + generalChannelUser1 = new Channel(users.user1.app.driver, 'general') + await generalChannelUser1.element.isDisplayed() + const isMessageInput2 = await generalChannelUser1.messageInput.isDisplayed() expect(isMessageInput2).toBeTruthy() await new Promise(resolve => setTimeout(() => { resolve() }, 5000) ) - await generalChannel2.sendMessage(users.user2.messages[0]) + await generalChannelUser1.sendMessage(users.user2.messages[0]) }) it('Leave community - Sent message is visible in a channel', async () => { console.log('TEST 8') - await generalChannel2.waitForUserMessage(users.user2.username, users.user2.messages[0]) + await generalChannelUser1.waitForUserMessage(users.user2.username, users.user2.messages[0]) }) it('Owner closes app', async () => { await users.owner.app.close({ forceSaveState: true }) @@ -430,14 +426,14 @@ describe('Multiple Clients', () => { it('Guest closes app - Owner sends another message after guest left the app', async () => { console.log('TEST 10') - ownerGeneralChannel = new Channel(users.owner.app.driver, 'general') - const isMessageInput = await ownerGeneralChannel.messageInput.isDisplayed() + generalChannelOwner = new Channel(users.owner.app.driver, 'general') + const isMessageInput = await generalChannelOwner.messageInput.isDisplayed() expect(isMessageInput).toBeTruthy() - await ownerGeneralChannel.sendMessage(users.owner.messages[2]) + await generalChannelOwner.sendMessage(users.owner.messages[2]) }) it('Guest closes app - Check if message is visible for owner', async () => { console.log('TEST 11') - await ownerGeneralChannel.waitForUserMessage(users.owner.username, users.owner.messages[2]) + await generalChannelOwner.waitForUserMessage(users.owner.username, users.owner.messages[2]) }) } }) From 5c59ecd498b2ad49fe20c34775d629e4665b30ef Mon Sep 17 00:00:00 2001 From: Emi Date: Mon, 25 Sep 2023 14:43:36 +0200 Subject: [PATCH 13/17] Make test steps in multiple clients e2e test more clear --- .../widgets/channels/BasicMessage.test.tsx | 4 ++ .../widgets/channels/ChannelMessages.test.tsx | 1 + .../src/tests/multipleClients.test.ts | 38 +++++++++---------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.test.tsx b/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.test.tsx index 5ea510e3df..d55f830c5e 100644 --- a/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.test.tsx +++ b/packages/desktop/src/renderer/components/widgets/channels/BasicMessage.test.tsx @@ -36,6 +36,7 @@ describe('BasicMessage', () => { >
    { >
    { >
    { >
    { >
    { await users.owner.app.open() }) - it('JoinCommunityModal - owner switches to create community modal', async () => { + it('Owner sees "join community" modal and switches to "create community" modal', async () => { const joinModal = new JoinCommunityModal(users.owner.app.driver) const isJoinModal = await joinModal.element.isDisplayed() expect(isJoinModal).toBeTruthy() await joinModal.switchToCreateCommunity() }) - it('CreateCommunityModal - owner creates the community', async () => { + it('Owner submits valid community name', async () => { const createModal = new CreateCommunityModal(users.owner.app.driver) const isCreateModal = await createModal.element.isDisplayed() expect(isCreateModal).toBeTruthy() await createModal.typeCommunityName(communityName) await createModal.submit() }) - it('RegisterUsernameModal - owner registers username', async () => { + it('Owner sees "register username" modal and submits valid username', async () => { const registerModal = new RegisterUsernameModal(users.owner.app.driver) const isRegisterModal = await registerModal.element.isDisplayed() expect(isRegisterModal).toBeTruthy() await registerModal.typeUsername(users.owner.username) await registerModal.submit() }) - it('Owner sees general channel', async () => { + it('Owner registers successfully and sees general channel', async () => { generalChannelOwner = new Channel(users.owner.app.driver, 'general') const isGeneralChannel = await generalChannelOwner.element.isDisplayed() const generalChannelText = await generalChannelOwner.element.getText() @@ -141,12 +141,12 @@ describe('Multiple Clients', () => { await settingsModal.close() }) - it('Guest opens the app', async () => { + it('First user opens the app', async () => { console.log('Second client') await users.user1.app.open() }) - it('Guest joins the new community successfully', async () => { + it('First user submits invitation code received from owner', async () => { console.log('new user - 3') const joinCommunityModal = new JoinCommunityModal(users.user1.app.driver) const isJoinCommunityModal = await joinCommunityModal.element.isDisplayed() @@ -156,7 +156,7 @@ describe('Multiple Clients', () => { await joinCommunityModal.submit() }) - it('RegisterUsernameModal - Guest submits the username', async () => { + it('First user submits valid username', async () => { console.log('new user - 5') const registerModal = new RegisterUsernameModal(users.user1.app.driver) const isRegisterModal = await registerModal.element.isDisplayed() @@ -166,7 +166,7 @@ describe('Multiple Clients', () => { await registerModal.submit() }) - it('Guest sees general channel and sends a message', async () => { + it('First user joins successfully sees general channel and sends a message', async () => { console.log('new user - 7') generalChannelUser1 = new Channel(users.user1.app.driver, 'general') await generalChannelUser1.element.isDisplayed() @@ -180,15 +180,14 @@ describe('Multiple Clients', () => { ) await generalChannelUser1.sendMessage(users.user1.messages[0]) }) - it('Sent message is visible in a channel', async () => { + it("First user's sent message is visible in a channel", async () => { const messages2 = await generalChannelUser1.getUserMessages(users.user1.username) const messages1 = await generalChannelUser1.getUserMessages(users.owner.username) console.log({ messages1, messages2 }) const text2 = await messages2[0].getText() expect(text2).toEqual(users.user1.messages[0]) }) - - it('Guest opens the settings tab and gets an updated invitation code', async () => { + it('First user opens the settings tab and copies updated invitation code', async () => { const settingsModal = await new Sidebar(users.user1.app.driver).openSettings() const isSettingsModal = await settingsModal.element.isDisplayed() expect(isSettingsModal).toBeTruthy() @@ -204,19 +203,18 @@ describe('Multiple Clients', () => { await settingsModal.close() }) - // Third user joins when owner is offline. Does not use duplicated username it('Owner goes offline', async () => { await users.owner.app.close() }) - it('Second guest opens the app', async () => { + it('Second user opens the app', async () => { console.log('Third client') await users.user3.app.open() const debugModal = new DebugModeModal(users.user3.app.driver) await debugModal.close() }) - it('Second guest starts to register when owner is offline', async () => { + it('Second user starts to join when owner is offline', async () => { const joinCommunityModal = new JoinCommunityModal(users.user3.app.driver) const isJoinCommunityModal = await joinCommunityModal.element.isDisplayed() expect(isJoinCommunityModal).toBeTruthy() @@ -225,7 +223,7 @@ describe('Multiple Clients', () => { await joinCommunityModal.submit() }) - it('Second guest submits username that is not used by other user', async () => { + it('Second user submits valid, not-duplicated username', async () => { console.log('nereeew user - 5') const registerModal = new RegisterUsernameModal(users.user3.app.driver) const isRegisterModal = await registerModal.element.isDisplayed() @@ -235,7 +233,7 @@ describe('Multiple Clients', () => { await registerModal.submit() }) - it('Second quest sees general channel', async () => { + it('Second user sees general channel', async () => { console.log('new user - 7') generalChannelUser3 = new Channel(users.user3.app.driver, 'general') await generalChannelUser3.element.isDisplayed() @@ -243,7 +241,7 @@ describe('Multiple Clients', () => { expect(isMessageInput).toBeTruthy() }) - it('Second guest can send a message, they see their message tagged as "unregistered"', async () => { + it('Second user can send a message, they see their message tagged as "unregistered"', async () => { console.log('Second guest FETCHING CHANNEL MESSAGES!') await new Promise(resolve => setTimeout(() => { @@ -255,7 +253,7 @@ describe('Multiple Clients', () => { await generalChannelUser3.waitForLabel(users.user3.username, 'Unregistered') }) - it('First user sees that unregistered user messages are marked as "unregistered"', async () => { + it('First user sees that unregistered user\'s messages are marked as "unregistered"', async () => { await generalChannelUser1.waitForLabel(users.user3.username, 'Unregistered') }) @@ -265,14 +263,14 @@ describe('Multiple Clients', () => { await debugModal.close() }) - it('Unregistered user receives certificate, they can see confirmation that they registered', async () => { + it('Second user receives certificate, they can see confirmation that they registered', async () => { await generalChannelUser3.waitForUserMessage( users.owner.username, `@${users.user3.username} has joined ${displayedCommunityName}!` ) }) - it('"Unregistered" label is removed', async () => { + it('"Unregistered" label is removed from second user\'s messages', async () => { generalChannelOwner = new Channel(users.owner.app.driver, 'general') await generalChannelOwner.waitForLabelsNotPresent(users.user3.username) }) From 8cee282c15abf70fa0a1456a36f5eb744ab42c69 Mon Sep 17 00:00:00 2001 From: Emi Date: Tue, 26 Sep 2023 13:11:33 +0200 Subject: [PATCH 14/17] Don't stop CI workflow if tor or quiet processes can't be found on windows --- .github/workflows/e2e-win.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-win.yml b/.github/workflows/e2e-win.yml index 15cf062f1c..b13e63444c 100644 --- a/.github/workflows/e2e-win.yml +++ b/.github/workflows/e2e-win.yml @@ -68,18 +68,16 @@ jobs: shell: powershell - name: Kill Quiet - run: Stop-Process -Name "Quiet" -Force + run: Get-Process -Name "Quiet" -ErrorAction SilentlyContinue | Stop-Process -Force shell: powershell - name: Kill tor - run: Stop-Process -Name "tor" -Force + run: Get-Process -Name "tor" -ErrorAction SilentlyContinue | Stop-Process -Force shell: powershell - if: always() - name: Delay run: Start-Sleep -Seconds 10 shell: powershell - if: always() - name: Run one client test uses: nick-fields/retry@v2 From 06c887cd5b5c0203e6f6f28120c641e0c440481f Mon Sep 17 00:00:00 2001 From: Emi Date: Tue, 26 Sep 2023 15:03:22 +0200 Subject: [PATCH 15/17] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa1dfc66ae..847786621e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ * Running Chromatic tests for forked PRs +* Added e2e test for user joining community when owner is offline. Improved e2e tests + [2.0.0-alpha.11] * Customize Launch Screen on iOS From 4af8ccdd43eea24951467820ce5edcbe3d785851 Mon Sep 17 00:00:00 2001 From: Emi Date: Wed, 4 Oct 2023 10:37:38 +0200 Subject: [PATCH 16/17] Remove unused code --- packages/e2e-tests/src/selectors.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/e2e-tests/src/selectors.ts b/packages/e2e-tests/src/selectors.ts index 824f987afc..dad7cd0bd9 100644 --- a/packages/e2e-tests/src/selectors.ts +++ b/packages/e2e-tests/src/selectors.ts @@ -272,12 +272,6 @@ export class Channel { ) } - async getUserMessagesWrapper(username: string) { - return await this.driver.wait( - until.elementsLocated(By.xpath(`//*[contains(@data-testid, "userMessagesWrapper-${username}")]`)) - ) - } - async waitForLabel(username: string, label: string) { console.log(`Waiting for user's "${username}" label "${label}" label`) await this.driver.wait(async () => { From 850514b4e0926262ef3dd0f9e653d914b5b17ed1 Mon Sep 17 00:00:00 2001 From: Emi Date: Thu, 5 Oct 2023 09:11:56 +0200 Subject: [PATCH 17/17] Remove test logs --- packages/state-manager/src/sagas/users/users.selectors.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/state-manager/src/sagas/users/users.selectors.ts b/packages/state-manager/src/sagas/users/users.selectors.ts index 44481aa8bb..1371c6eaf0 100644 --- a/packages/state-manager/src/sagas/users/users.selectors.ts +++ b/packages/state-manager/src/sagas/users/users.selectors.ts @@ -82,10 +82,6 @@ export const allUsers = createSelector(csrsMapping, certificatesMapping, (csrs, const username = csrs[pubKey].username const isDuplicated = duplicateUsernames.includes(username) const isRegistered = Boolean(certs[pubKey]) - console.log('isRegistered', isRegistered) - console.log('certs[pubKey]', certs[pubKey]) - console.log('pubKey', pubKey) - console.log('-----') users[pubKey] = { ...csrs[pubKey], isRegistered,