diff --git a/ts/components/conversation/message/message-item/ReadableMessage.tsx b/ts/components/conversation/message/message-item/ReadableMessage.tsx index a57cead51..40a0b0ada 100644 --- a/ts/components/conversation/message/message-item/ReadableMessage.tsx +++ b/ts/components/conversation/message/message-item/ReadableMessage.tsx @@ -186,7 +186,7 @@ export const ReadableMessage = (props: ReadableMessageProps) => { triggerOnce={false} trackVisibility={true} key={`inview-msg-${messageId}`} - data-testid="readable-message" + data-testid="control-message" > {props.children} diff --git a/ts/test/automation/change_avatar.spec.ts b/ts/test/automation/change_avatar.spec.ts index cb25d6b28..5772f57c3 100644 --- a/ts/test/automation/change_avatar.spec.ts +++ b/ts/test/automation/change_avatar.spec.ts @@ -2,7 +2,7 @@ import { _electron, expect, Page, test } from '@playwright/test'; import { openAppAndWait } from './setup/open'; import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { newUser } from './setup/new_user'; -import { clickOnTestIdWithText, waitForTestIdWithText } from './utils'; +import { clickOnTestIdWithText, waitForTestIdWithText } from './utilities/utils'; import { sleepFor } from '../../session/utils/Promise'; let window: Page | undefined; diff --git a/ts/test/automation/change_username.spec.ts b/ts/test/automation/change_username.spec.ts index 679aadcd2..73201fda3 100644 --- a/ts/test/automation/change_username.spec.ts +++ b/ts/test/automation/change_username.spec.ts @@ -2,7 +2,7 @@ import { _electron, expect, Page, test } from '@playwright/test'; import { newUser } from './setup/new_user'; import { openAppAndWait } from './setup/open'; import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; -import { clickOnTestIdWithText, typeIntoInput } from './utils'; +import { clickOnTestIdWithText, typeIntoInput } from './utilities/utils'; let window: Page | undefined; test.beforeEach(beforeAllClean); diff --git a/ts/test/automation/create_user.spec.ts b/ts/test/automation/create_user.spec.ts index 6f3b749d9..74663c99f 100644 --- a/ts/test/automation/create_user.spec.ts +++ b/ts/test/automation/create_user.spec.ts @@ -3,16 +3,20 @@ import { newUser } from './setup/new_user'; import { openAppAndWait } from './setup/open'; import { sleepFor } from '../../session/utils/Promise'; import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; -import { clickOnMatchingText, clickOnTestIdWithText, waitForTestIdWithText } from './utils'; +import { + clickOnMatchingText, + clickOnTestIdWithText, + waitForTestIdWithText, +} from './utilities/utils'; let window: Page | undefined; test.beforeEach(beforeAllClean); -test.afterEach(async () => { - if (window) { - await forceCloseAllWindows([window]); - } -}); +// test.afterEach(async () => { +// if (window) { +// await forceCloseAllWindows([window]); +// } +// }); test('Create User', async () => { // Launch Electron app. window = await openAppAndWait('1'); diff --git a/ts/test/automation/delete_account.spec.ts b/ts/test/automation/delete_account.spec.ts index 4fb920b30..8ab4a2b1e 100644 --- a/ts/test/automation/delete_account.spec.ts +++ b/ts/test/automation/delete_account.spec.ts @@ -1,8 +1,8 @@ import { _electron, Page, test } from '@playwright/test'; import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { openAppsAndNewUsers, openAppsNoNewUsers } from './setup/new_user'; -import { sendNewMessage } from './send_message'; -import { clickOnMatchingText, clickOnTestIdWithText, typeIntoInput } from './utils'; +import { sendNewMessage } from './utilities/send_message'; +import { clickOnMatchingText, clickOnTestIdWithText, typeIntoInput } from './utilities/utils'; import { sleepFor } from '../../session/utils/Promise'; // tslint:disable: no-console diff --git a/ts/test/automation/disappearing_messages.spec.ts b/ts/test/automation/disappearing_messages.spec.ts index 38fa84cdb..0417b0a81 100644 --- a/ts/test/automation/disappearing_messages.spec.ts +++ b/ts/test/automation/disappearing_messages.spec.ts @@ -1,15 +1,15 @@ import { _electron, Page, test } from '@playwright/test'; import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; -import { messageSent } from './message'; +import { messageSent } from './utilities/message'; import { openAppsAndNewUsers } from './setup/new_user'; -import { sendNewMessage } from './send_message'; +import { sendNewMessage } from './utilities/send_message'; import { clickOnMatchingText, clickOnTestIdWithText, waitForMatchingText, waitForReadableMessageWithText, waitForTestIdWithText, -} from './utils'; +} from './utilities/utils'; import { sleepFor } from '../../session/utils/Promise'; let windows: Array = []; diff --git a/ts/test/automation/group_creation.spec.ts b/ts/test/automation/group_creation.spec.ts index a582dd7e0..78ea89774 100644 --- a/ts/test/automation/group_creation.spec.ts +++ b/ts/test/automation/group_creation.spec.ts @@ -1,15 +1,15 @@ import { _electron, Page, test } from '@playwright/test'; import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; -import { messageSent } from './message'; +import { messageSent } from './utilities/message'; import { openAppsAndNewUsers } from './setup/new_user'; -import { sendNewMessage } from './send_message'; +import { sendNewMessage } from './utilities/send_message'; import { clickOnMatchingText, clickOnTestIdWithText, typeIntoInput, waitForReadableMessageWithText, waitForTestIdWithText, -} from './utils'; +} from './utilities/utils'; const testGroupName = 'Test Group Name'; diff --git a/ts/test/automation/group_testing.spec.ts b/ts/test/automation/group_testing.spec.ts index 046d6c3ff..f75dca10a 100644 --- a/ts/test/automation/group_testing.spec.ts +++ b/ts/test/automation/group_testing.spec.ts @@ -1,38 +1,63 @@ -import { _electron, expect, Page, test } from '@playwright/test'; -import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; -// import { recoverFromSeed } from './setup/recovery_using_seed'; +import { expect, test } from '@playwright/test'; +import { beforeAllClean } from './setup/beforeEach'; import { clickOnMatchingText, clickOnTestIdWithText, + waitForControlMessageWithText, waitForMatchingText, - // waitForTestIdWithText, -} from './utils'; -// import { testContact, testUser } from './setup/test_user'; -// import { openAppsNoNewUsers } from './setup/new_user'; -import { renameGroup } from './rename_group'; -import { leaveGroup } from './leave_group'; +} from './utilities/utils'; +import { renameGroup } from './utilities/rename_group'; import { createGroup } from './setup/create_group'; +// import { leaveGroup } from './utilities/leave_group'; +import { newUser, openApp } from './setup/new_user'; -let windows: Array = []; test.beforeEach(beforeAllClean); -test.afterEach(() => forceCloseAllWindows(windows)); +// test.afterEach(() => forceCloseAllWindows(windows)); -test('Group testing', async () => { +test('Create group', async () => { // Open Electron - const { windowA, windowB } = await createGroup('Test Group Name'); - windows = [windowA, windowB]; + const [windowA, windowB, windowC] = await openApp(3); + const [userA, userB, userC] = await Promise.all([ + newUser(windowA, 'Alice'), + newUser(windowB, 'Bob'), + newUser(windowC, 'Chloe'), + ]); + const testGroupName = 'Tiny Bubble Gang'; + await createGroup(testGroupName, userA, windowA, userB, windowB, userC, windowC); + // Check config messages in all windows + await waitForControlMessageWithText( + windowA, + `"${userC.userName}", "${userB.userName}", You joined the group.` + ); + await waitForControlMessageWithText( + windowB, + `"${userC.userName}", "${userA.userName}", You joined the group.` + ); + await waitForControlMessageWithText( + windowC, + `"${userB.userName}", "${userA.userName}", You joined the group.` + ); +}); + +test('Change group name', async () => { + const [windowA, windowB, windowC] = await openApp(3); + const [userA, userB, userC] = await Promise.all([ + newUser(windowA, 'Alice'), + newUser(windowB, 'Bob'), + newUser(windowC, 'Chloe'), + ]); + const testGroupName = 'Tiny Bubble Gang'; + const newGroupName = 'Otter lovers'; + const group = await createGroup(testGroupName, userA, windowA, userB, windowB, userC, windowC); // Change the name of the group and check that it syncs to all devices (config messages) // Click on already created group // Check that renaming a group is working - await renameGroup(windowA, 'Test Group Name', 'newGroupName'); + await renameGroup(windowA, group.userName, newGroupName); // Check config message in window B for group name change - await clickOnMatchingText(windowB, 'newGroupName'); - await waitForMatchingText(windowB, "Group name is now 'newGroupName'."); - // Change the group name back to original name + await clickOnMatchingText(windowB, newGroupName); + await waitForMatchingText(windowB, `Group name is now ${newGroupName}.`); // Click on conversation options - await renameGroup(windowA, 'newGroupName', 'Test Group Name'); - // Check to see that you can't change group name to empty string // Click on edit group name await clickOnMatchingText(windowA, 'Edit group name'); @@ -42,7 +67,4 @@ test('Group testing', async () => { await expect(errorMessage).toContainText('Please enter a group name'); await clickOnMatchingText(windowA, 'Cancel'); await clickOnTestIdWithText(windowA, 'back-button-conversation-options'); - - // Leave group and receive config confirmation - await leaveGroup(windowB); }); diff --git a/ts/test/automation/group_upkeep.spec.ts b/ts/test/automation/group_upkeep.spec.ts index a439b9a11..ec2d9f150 100644 --- a/ts/test/automation/group_upkeep.spec.ts +++ b/ts/test/automation/group_upkeep.spec.ts @@ -1,63 +1,71 @@ import { _electron, Page, test } from '@playwright/test'; -import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; -import { openAppsNoNewUsers } from './setup/new_user'; -import { sendNewMessage } from './send_message'; +import { beforeAllClean } from './setup/beforeEach'; +import { openApp } from './setup/new_user'; +import { sendNewMessage } from './utilities/send_message'; import { logIn } from './setup/log_in'; -import { - testContactFour, - testContactOne, - testContactThree, - testContactTwo, - testUser, -} from './setup/test_user'; +import { userA, userB, userC, userD, userE } from './setup/test_user'; let windows: Array = []; test.beforeEach(beforeAllClean); -test.afterEach(() => forceCloseAllWindows(windows)); - test.skip('Group upkeep', async () => { - const [windowA, windowB, windowC, windowD, windowE] = await openAppsNoNewUsers(5); + const [windowA, windowB, windowC, windowD, windowE] = await openApp(5); windows = [windowA, windowB, windowC, windowD, windowE]; await Promise.all([ - logIn(windowA, testUser.recoveryPhrase), - logIn(windowB, testContactOne.recoveryPhrase), - logIn(windowC, testContactTwo.recoveryPhrase), - logIn(windowD, testContactThree.recoveryPhrase), - logIn(windowE, testContactFour.recoveryPhrase), + logIn(windowA, userA.recoveryPhrase), + logIn(windowB, userB.recoveryPhrase), + logIn(windowC, userC.recoveryPhrase), + logIn(windowD, userD.recoveryPhrase), + logIn(windowE, userE.recoveryPhrase), ]); // Send message from test users to all of it's contacts to maintain contact status // Send message from user A to Whale(TC1) await sendNewMessage( windowA, - testContactOne.sessionid, - `Test user -> Whale (TC1): ${Date.now()}` + userB.sessionid, + `${userA.userName} -> ${userB.userName}: ${Date.now()}` ); // Send message from Whale to user A - await sendNewMessage(windowB, testUser.sessionid, `Whale (TC1) -> Test user : ${Date.now()}`); + await sendNewMessage( + windowB, + userA.sessionid, + `${userB.userName} -> ${userA.userName} : ${Date.now()}` + ); // Send message from user A to Dragon(TC2) await sendNewMessage( windowA, - testContactTwo.sessionid, - `Test user -> Dragon (TC2): ${Date.now()}` + userC.sessionid, + `${userA.userName} -> ${userC.userName}: ${Date.now()}` ); // Send message from Dragon to user A - await sendNewMessage(windowC, testUser.sessionid, `Dragon (TC2) -> Test user : ${Date.now()}`); + await sendNewMessage( + windowC, + userA.sessionid, + `${userC.userName} -> ${userA.userName} : ${Date.now()}` + ); // Send message from user A to Fish(TC3) await sendNewMessage( windowA, - testContactThree.sessionid, - `Test user -> Fish (TC3): ${Date.now()}` + userD.sessionid, + `${userA.userName} -> ${userD.userName}: ${Date.now()}` ); // Send message from Fish to user A - await sendNewMessage(windowD, testUser.sessionid, `Fish (TC3) -> Test user : ${Date.now()}`); + await sendNewMessage( + windowD, + userA.sessionid, + `${userD.userName} -> ${userA.userName} : ${Date.now()}` + ); // Send message from user A to Gopher(TC4) await sendNewMessage( windowA, - testContactFour.sessionid, - `Test user -> Gopher (TC4): ${Date.now()}` + userE.sessionid, + `${userA.userName} -> ${userD.userName}: ${Date.now()}` ); // Send message from Gopher to user A - await sendNewMessage(windowE, testUser.sessionid, `Gopher (TC4) -> Test user : ${Date.now()}`); + await sendNewMessage( + windowE, + userA.sessionid, + `${userD.userName} -> ${userA.userName} : ${Date.now()}` + ); }); diff --git a/ts/test/automation/linking_device.spec.ts b/ts/test/automation/linking_device.spec.ts index b72993a07..43262b6c6 100644 --- a/ts/test/automation/linking_device.spec.ts +++ b/ts/test/automation/linking_device.spec.ts @@ -1,7 +1,7 @@ import { _electron, Page, test } from '@playwright/test'; import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; -import { linkedDevice } from './setup/linked_device'; -import { clickOnTestIdWithText, typeIntoInput, waitForTestIdWithText } from './utils'; +import { linkedDevice } from './utilities/linked_device'; +import { clickOnTestIdWithText, typeIntoInput, waitForTestIdWithText } from './utilities/utils'; const windows: Array = []; test.beforeEach(beforeAllClean); diff --git a/ts/test/automation/mentions.spec.ts b/ts/test/automation/mentions.spec.ts index 36cd58be3..6d19176c7 100644 --- a/ts/test/automation/mentions.spec.ts +++ b/ts/test/automation/mentions.spec.ts @@ -1,6 +1,6 @@ import { _electron, Page, test } from '@playwright/test'; import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; -import { clickOnTestIdWithText, typeIntoInput, waitForTestIdWithText } from './utils'; +import { clickOnTestIdWithText, typeIntoInput, waitForTestIdWithText } from './utilities/utils'; import { createGroup } from './setup/create_group'; let windows: Array = []; diff --git a/ts/test/automation/message_requests.spec.ts b/ts/test/automation/message_requests.spec.ts index b1ba016d1..af9d5e083 100644 --- a/ts/test/automation/message_requests.spec.ts +++ b/ts/test/automation/message_requests.spec.ts @@ -1,8 +1,12 @@ import { _electron, Page, test } from '@playwright/test'; -import { sendNewMessage } from './send_message'; +import { sendNewMessage } from './utilities/send_message'; import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { openAppsAndNewUsers } from './setup/new_user'; -import { clickOnTestIdWithText, waitForMatchingText, waitForTestIdWithText } from './utils'; +import { + clickOnTestIdWithText, + waitForMatchingText, + waitForTestIdWithText, +} from './utilities/utils'; const testMessage = 'A -> B'; diff --git a/ts/test/automation/new_contact_test.spec.ts b/ts/test/automation/new_contact_test.spec.ts deleted file mode 100644 index 9644510cf..000000000 --- a/ts/test/automation/new_contact_test.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { _electron, Page, test } from '@playwright/test'; -import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; - -import { sendNewMessage } from './send_message'; -import { openAppsAndNewUsers } from './setup/new_user'; -import { clickOnTestIdWithText, waitForTestIdWithText } from './utils'; - -const testMessage = 'A -> B'; -const testReply = 'B -> A'; - -let windows: Array = []; -test.beforeEach(beforeAllClean); - -test.afterEach(() => forceCloseAllWindows(windows)); - -// Send message in one to one conversation with new contact -test('Send message to new contact', async () => { - const windowLoggedIn = await openAppsAndNewUsers(2); - windows = windowLoggedIn.windows; - const users = windowLoggedIn.users; - const [windowA, windowB] = windows; - const [userA, userB] = users; - // User A sends message to User B - await sendNewMessage(windowA, userB.sessionid, `${testMessage}${Date.now()}`); - // User B sends message to User B to USER A - await sendNewMessage(windowB, userA.sessionid, `${testReply}${Date.now()}`); - // Navigate to contacts tab in User B's window - - await clickOnTestIdWithText(windowA, 'new-conversation-button'); - await windowA.waitForTimeout(2000); - await waitForTestIdWithText(windowB, 'module-conversation__user__profile-name', userA.userName); - - // Navigate to contacts tab in User A's window - await clickOnTestIdWithText(windowA, 'new-conversation-button'); -}); diff --git a/ts/test/automation/password.spec.ts b/ts/test/automation/password.spec.ts index 17c9cf177..6eff8a297 100644 --- a/ts/test/automation/password.spec.ts +++ b/ts/test/automation/password.spec.ts @@ -9,7 +9,7 @@ import { typeIntoInput, waitForMatchingText, waitForTestIdWithText, -} from './utils'; +} from './utilities/utils'; let window: Page | undefined; test.beforeEach(beforeAllClean); diff --git a/ts/test/automation/setup/create_group.ts b/ts/test/automation/setup/create_group.ts index 3c4676535..3eb9aaf17 100644 --- a/ts/test/automation/setup/create_group.ts +++ b/ts/test/automation/setup/create_group.ts @@ -1,29 +1,41 @@ import { _electron, Page } from '@playwright/test'; -import { messageSent } from '../message'; -import { openAppsAndNewUsers } from '../setup/new_user'; -import { sendNewMessage } from '../send_message'; +import { messageSent } from '../utilities/message'; +import { sendNewMessage } from '../utilities/send_message'; import { clickOnMatchingText, clickOnTestIdWithText, typeIntoInput, - waitForReadableMessageWithText, + waitForControlMessageWithText, waitForTestIdWithText, -} from '../utils'; +} from '../utilities/utils'; +import { Group, User } from '../types/testing'; -let windows: Array = []; +// let windows: Array = []; -export const createGroup = async (groupName: string) => { - const windowLoggedIn = await openAppsAndNewUsers(3); - windows = windowLoggedIn.windows; - const users = windowLoggedIn.users; - const [windowA, windowB, windowC] = windows; - const [userA, userB, userC] = users; +export const createGroup = async ( + userName: string, + userOne: User, + windowA: Page, + userTwo: User, + windowB: Page, + userThree: User, + windowC: Page +): Promise => { + const group: Group = { userName, userOne, userTwo, userThree }; + + const messageAB = `${userOne.userName} to ${userTwo.userName}`; + const messageBA = `${userTwo.userName} to ${userOne.userName}`; + const messageCA = `${userThree.userName} to ${userOne.userName}`; + const messageAC = `${userOne.userName} to ${userThree.userName}`; + const msgAToGroup = `${userOne.userName} -> ${group.userName}`; + const msgBToGroup = `${userTwo.userName} -> ${group.userName}`; + const msgCToGroup = `${userThree.userName} -> ${group.userName}`; // Add contacts - await sendNewMessage(windowA, userC.sessionid, `A -> C: ${Date.now()}`); + await sendNewMessage(windowA, userThree.sessionid, `${messageAC} Time: ${Date.now()}`); await Promise.all([ - sendNewMessage(windowA, userB.sessionid, `A -> B: ${Date.now()}`), - sendNewMessage(windowB, userA.sessionid, `B -> A: ${Date.now()}`), - sendNewMessage(windowC, userA.sessionid, `C -> A: ${Date.now()}`), + sendNewMessage(windowA, userTwo.sessionid, `${messageAB} Time: ${Date.now()}`), + sendNewMessage(windowB, userOne.sessionid, `${messageBA} Time: ${Date.now()}`), + sendNewMessage(windowC, userOne.sessionid, `${messageCA} Time: ${Date.now()}`), ]); // Focus screen on window C to allow user C to become contact await clickOnTestIdWithText(windowC, 'messages-container'); @@ -33,18 +45,17 @@ export const createGroup = async (groupName: string) => { await clickOnTestIdWithText(windowA, 'new-conversation-button'); await clickOnTestIdWithText(windowA, 'chooser-new-group'); // Enter group name - await typeIntoInput(windowA, 'new-closed-group-name', groupName); + await typeIntoInput(windowA, 'new-closed-group-name', group.userName); // Select user B - await clickOnMatchingText(windowA, userB.userName); + await clickOnMatchingText(windowA, userTwo.userName); // Select user C - await clickOnMatchingText(windowA, userC.userName); + await clickOnMatchingText(windowA, userThree.userName); // Click Next await clickOnTestIdWithText(windowA, 'next-button'); // Check group was successfully created - await clickOnMatchingText(windowB, groupName); - await waitForTestIdWithText(windowB, 'header-conversation-name', groupName); + await clickOnMatchingText(windowB, group.userName); + await waitForTestIdWithText(windowB, 'header-conversation-name', group.userName); // Send message in group chat from user A - const msgAToGroup = 'A -> Group'; await messageSent(windowA, msgAToGroup); // Focus screen await clickOnMatchingText(windowA, msgAToGroup); @@ -52,11 +63,10 @@ export const createGroup = async (groupName: string) => { // Navigate to group in window B await clickOnTestIdWithText(windowB, 'message-section'); // Click on test group - await clickOnMatchingText(windowB, groupName); + await clickOnMatchingText(windowB, userName); // wait for selector 'test message' in chat window - await waitForReadableMessageWithText(windowB, msgAToGroup); + await waitForControlMessageWithText(windowB, msgAToGroup); // Send reply message - const msgBToGroup = 'B -> Group'; await messageSent(windowB, msgBToGroup); // Focus screen // await clickOnTestIdWithText(windowB, 'scroll-to-bottom-button'); @@ -64,16 +74,15 @@ export const createGroup = async (groupName: string) => { // Navigate to group in window C await clickOnTestIdWithText(windowC, 'message-section'); // Click on test group - await clickOnMatchingText(windowC, groupName); + await clickOnMatchingText(windowC, userName); // windowC must see the message from A and the message from B - await waitForReadableMessageWithText(windowC, msgAToGroup); - await waitForReadableMessageWithText(windowC, msgBToGroup); + await waitForControlMessageWithText(windowC, msgAToGroup); + await waitForControlMessageWithText(windowC, msgBToGroup); // Send message from C to the group - const msgCToGroup = 'C -> Group'; await messageSent(windowC, msgCToGroup); // windowA should see the message from B and the message from C - await waitForReadableMessageWithText(windowA, msgBToGroup); - await waitForReadableMessageWithText(windowA, msgCToGroup); + await waitForControlMessageWithText(windowA, msgBToGroup); + await waitForControlMessageWithText(windowA, msgCToGroup); - return { userA, userB, windowA, windowB, userC, windowC }; + return { userName, userOne, userTwo, userThree }; }; diff --git a/ts/test/automation/setup/log_in.ts b/ts/test/automation/setup/log_in.ts index 1593a8725..a0caebdc1 100644 --- a/ts/test/automation/setup/log_in.ts +++ b/ts/test/automation/setup/log_in.ts @@ -1,5 +1,5 @@ import { _electron, Page } from '@playwright/test'; -import { clickOnTestIdWithText, typeIntoInput } from '../utils'; +import { clickOnTestIdWithText, typeIntoInput } from '../utilities/utils'; export async function logIn(window: Page, recoveryPhrase: string) { await clickOnTestIdWithText(window, 'link-device'); diff --git a/ts/test/automation/setup/new_user.ts b/ts/test/automation/setup/new_user.ts index 5502da0ca..e29545da8 100644 --- a/ts/test/automation/setup/new_user.ts +++ b/ts/test/automation/setup/new_user.ts @@ -1,16 +1,11 @@ import { _electron, Page } from '@playwright/test'; import _ from 'lodash'; -import { clickOnMatchingText, typeIntoInput } from '../utils'; +import { User } from '../types/testing'; +import { clickOnMatchingText, typeIntoInput } from '../utilities/utils'; import { openAppAndWait } from './open'; const multisAvailable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; -export type UserLoggedInType = { - userName: string; - sessionid: string; - recoveryPhrase: string; -}; - -export const newUser = async (window: Page, userName: string): Promise => { +export const newUser = async (window: Page, userName: string): Promise => { // Create User await clickOnMatchingText(window, 'Create Session ID'); // Wait for animation for finish creating ID @@ -29,7 +24,7 @@ export const newUser = async (window: Page, userName: string): Promise => { +const openAppAndNewUser = async (multi: string): Promise => { const window = await openAppAndWait(multi); const userName = `${multi}-user`; @@ -56,12 +51,12 @@ export async function openAppsAndNewUsers(windowToCreate: number) { return { windows, users }; } -export async function openAppsNoNewUsers(windowToCreate: number) { - if (windowToCreate >= multisAvailable.length) { +export async function openApp(windowsToCreate: number) { + if (windowsToCreate >= multisAvailable.length) { throw new Error(`Do you really need ${multisAvailable.length} windows?!`); } // if windowToCreate = 3, this array will be ABC. If windowToCreate = 5, this array will be ABCDE - const multisToUse = multisAvailable.slice(0, windowToCreate); + const multisToUse = multisAvailable.slice(0, windowsToCreate); return Promise.all( [...multisToUse].map(async m => { return openAppAndWait(`${m}`); diff --git a/ts/test/automation/setup/recovery_using_seed.ts b/ts/test/automation/setup/recovery_using_seed.ts index c0e0db47d..34a1765eb 100644 --- a/ts/test/automation/setup/recovery_using_seed.ts +++ b/ts/test/automation/setup/recovery_using_seed.ts @@ -1,5 +1,5 @@ import { _electron, Page } from '@playwright/test'; -import { clickOnTestIdWithText, typeIntoInput } from '../utils'; +import { clickOnTestIdWithText, typeIntoInput } from '../utilities/utils'; export async function recoverFromSeed(window: Page, userName: string, recoveryPhrase: string) { await clickOnTestIdWithText(window, 'restore-using-recovery'); diff --git a/ts/test/automation/setup/test_user.ts b/ts/test/automation/setup/test_user.ts index f795fd663..1af13715d 100644 --- a/ts/test/automation/setup/test_user.ts +++ b/ts/test/automation/setup/test_user.ts @@ -1,36 +1,36 @@ import { _electron } from '@playwright/test'; -export const testUser = { - userName: 'testUser', - sessionid: '05560802be231abc2fbaa860f09da4c2f20dafa4e5f560f77d61c5f587ef2c741f', +export const userA = { + userName: 'Alice', + sessionid: '059e36f9bb03ac4e1ff9ff7d4aedd791d1f412770c6cd2796b855af12a7c7ea000', recoveryPhrase: - 'pinched total ongoing sushi etched rest gone long oilfield incur code grunt code', + 'tuition remedy sieve ivory wiggle gemstone hawk optical issued damp selfish fewest damp', }; -export const testContactOne = { - userName: 'Whale', - sessionid: '059c587e1e027368d4a0ebbf5982fe25e4129fdd79c2328616ceb394cbaf852c52', +export const userB = { + userName: 'Bob', + sessionid: '05ead902602c1f7b59aaa3932b9cdefe8ee4075c03b09811d31bc9b122cb292d0c', recoveryPhrase: - 'jeers apart cuffs mailed sleepless mystery dads tobacco elite lopped fudge arena mystery', + 'misery testing template jeopardy yahoo asylum kettle wise unveil wept bygones dice dice', }; -export const testContactTwo = { - userName: 'Dragon', - sessionid: '05c189b54cea50fa7a3e1fc3ddb6e9c5bcf34ffa7d17af5d8478a45d5a8f629e02', +export const userC = { + userName: 'Chloe', + sessionid: '055f4bcc665b94a0f4c2aa9c2d543ae015db167014aac316bc21f5d7c6fdb11025', recoveryPhrase: - 'gossip megabyte rogue pheasants rural romance opus grunt amidst runway erected unveil opus', + 'bakery broken circle ginger pistons deity deity degrees today insult fidget ouch deity', }; -export const testContactThree = { - userName: 'Fish', - sessionid: '058781e8f5845c22649c6c6e9fdb5c98e63e04832aec78fe6cacd62c3e71600464', +export const userD = { + userName: 'Doug', + sessionid: '0555274f98d9f681d37446797bdebfa0e53d872213450663141bedb58a8ca67675', recoveryPhrase: - 'hookup reinvest deepest waxing lukewarm aztec invoke fugitive aces onward hire tomorrow hire', + 'biscuit bomb hire update suede money balding rest fuming alchemy ridges deity update', }; -export const testContactFour = { - userName: 'Gopher', - sessionid: '0577ee81a6ac9c1a6f80daddcc22a85bd0dc9cfc3a513b5d2368e2da483886ca11', +export const userE = { + userName: 'Egbert', + sessionid: '058b523d3f00773c745c965cf9482dd2fd6ea7a67ec4643c187309e4bbf96a936a', recoveryPhrase: - 'odds annoyed maps apply diplomat custom boat iceberg extra kitchens adventure luggage maps', + 'dusted coffee hoisting ringing titans dangerous technical bomb bubble pancakes wipeout goldfish technical', }; diff --git a/ts/test/automation/switching_theme.spec.ts b/ts/test/automation/switching_theme.spec.ts index cfb0e3647..c391d3d2a 100644 --- a/ts/test/automation/switching_theme.spec.ts +++ b/ts/test/automation/switching_theme.spec.ts @@ -1,7 +1,7 @@ import { _electron, expect, Page, test } from '@playwright/test'; import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { openAppsAndNewUsers } from './setup/new_user'; -import { clickOnTestIdWithText } from './utils'; +import { clickOnTestIdWithText } from './utilities/utils'; let windows: Array = []; test.beforeEach(beforeAllClean); diff --git a/ts/test/automation/types/testing.ts b/ts/test/automation/types/testing.ts new file mode 100644 index 000000000..471f1f627 --- /dev/null +++ b/ts/test/automation/types/testing.ts @@ -0,0 +1,12 @@ +export type User = { + userName: string; + sessionid: string; + recoveryPhrase: string; +}; + +export type Group = { + userName: string; + userOne: User; + userTwo: User; + userThree: User; +}; diff --git a/ts/test/automation/unsend_message.spec.ts b/ts/test/automation/unsend_message.spec.ts index 085ff6d87..e0497ccf8 100644 --- a/ts/test/automation/unsend_message.spec.ts +++ b/ts/test/automation/unsend_message.spec.ts @@ -1,13 +1,13 @@ import { _electron, Page, test } from '@playwright/test'; import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { openAppsAndNewUsers } from './setup/new_user'; -import { sendNewMessage } from './send_message'; +import { sendNewMessage } from './utilities/send_message'; import { clickOnMatchingText, clickOnTestIdWithText, waitForMatchingText, waitForTestIdWithText, -} from './utils'; +} from './utilities/utils'; const testMessage = 'A -> B: '; const testReply = 'B -> A: '; diff --git a/ts/test/automation/blocking_user.spec.ts b/ts/test/automation/user_actions.spec.ts similarity index 57% rename from ts/test/automation/blocking_user.spec.ts rename to ts/test/automation/user_actions.spec.ts index 211db723b..7c3a33495 100644 --- a/ts/test/automation/blocking_user.spec.ts +++ b/ts/test/automation/user_actions.spec.ts @@ -1,18 +1,43 @@ import { _electron, Page, test } from '@playwright/test'; import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; + +import { sendNewMessage } from './utilities/send_message'; import { openAppsAndNewUsers } from './setup/new_user'; -import { sendNewMessage } from './send_message'; import { clickOnMatchingText, clickOnTestIdWithText, waitForMatchingText, waitForTestIdWithText, -} from './utils'; +} from './utilities/utils'; let windows: Array = []; test.beforeEach(beforeAllClean); -test.afterEach(() => forceCloseAllWindows(windows)); +// test.afterEach(() => forceCloseAllWindows(windows)); + +// Send message in one to one conversation with new contact +test('Create contact', async () => { + const windowLoggedIn = await openAppsAndNewUsers(2); + windows = windowLoggedIn.windows; + const users = windowLoggedIn.users; + const [windowA, windowB] = windows; + const [userA, userB] = users; + + const testMessage = `${userA.userName} to ${userB.userName}`; + const testReply = `${userB.userName} to ${userA.userName}`; + // User A sends message to User B + await sendNewMessage(windowA, userB.sessionid, `${testMessage} Time: '${Date.now()}'`); + // User B sends message to User B to USER A + await sendNewMessage(windowB, userA.sessionid, `${testReply} Time: '${Date.now()}'`); + // Navigate to contacts tab in User B's window + + await clickOnTestIdWithText(windowA, 'new-conversation-button'); + await windowA.waitForTimeout(2000); + await waitForTestIdWithText(windowB, 'module-conversation__user__profile-name', userA.userName); + + // Navigate to contacts tab in User A's window + await clickOnTestIdWithText(windowA, 'new-conversation-button'); +}); test('Block User', async () => { // Open app and create user @@ -21,14 +46,15 @@ test('Block User', async () => { const users = windowLoggedIn.users; const [windowA, windowB] = windows; const [userA, userB] = users; + const testMessage = `${userA.userName} to ${userB.userName}`; + const testReply = `${userB.userName} to ${userA.userName}`; // Create contact and send new message - await sendNewMessage(windowA, userB.sessionid, `A -> B: ${Date.now()}`); - await sendNewMessage(windowB, userA.sessionid, `B -> A: ${Date.now()}`); + await sendNewMessage(windowA, userB.sessionid, `${testMessage} Time: '${Date.now()}'`); + await sendNewMessage(windowB, userA.sessionid, `${testReply} Time: '${Date.now()}'`); // Check to see if User B is a contact await clickOnTestIdWithText(windowA, 'new-conversation-button'); await waitForTestIdWithText(windowA, 'module-conversation__user__profile-name', userB.userName); - //Click on three dots menu await clickOnTestIdWithText(windowA, 'message-section'); @@ -40,15 +66,12 @@ test('Block User', async () => { // Verify the user was moved to the blocked contact list // Click on settings tab await clickOnTestIdWithText(windowA, 'settings-section'); - // click on settings section 'conversation' await clickOnTestIdWithText(windowA, 'conversations-settings-menu-item'); - // Navigate to blocked users tab' await clickOnTestIdWithText(windowA, 'reveal-blocked-user-settings'); // select the contact to unblock by clicking on it by name await clickOnMatchingText(windowA, userB.userName); - // Unblock user by clicking on unblock await clickOnTestIdWithText(windowA, 'unblock-button-settings-screen'); // Verify toast notification says unblocked diff --git a/ts/test/automation/leave_group.ts b/ts/test/automation/utilities/leave_group.ts similarity index 100% rename from ts/test/automation/leave_group.ts rename to ts/test/automation/utilities/leave_group.ts diff --git a/ts/test/automation/setup/linked_device.ts b/ts/test/automation/utilities/linked_device.ts similarity index 84% rename from ts/test/automation/setup/linked_device.ts rename to ts/test/automation/utilities/linked_device.ts index ef93b0efb..b38ef0fb0 100644 --- a/ts/test/automation/setup/linked_device.ts +++ b/ts/test/automation/utilities/linked_device.ts @@ -1,5 +1,5 @@ import { _electron } from 'playwright-core'; -import { openAppsAndNewUsers, openAppsNoNewUsers } from './new_user'; +import { openAppsAndNewUsers, openAppsNoNewUsers } from '../setup/new_user'; import { logIn } from '../setup/log_in'; export async function linkedDevice() { diff --git a/ts/test/automation/message.ts b/ts/test/automation/utilities/message.ts similarity index 100% rename from ts/test/automation/message.ts rename to ts/test/automation/utilities/message.ts diff --git a/ts/test/automation/rename_group.ts b/ts/test/automation/utilities/rename_group.ts similarity index 100% rename from ts/test/automation/rename_group.ts rename to ts/test/automation/utilities/rename_group.ts diff --git a/ts/test/automation/send_message.ts b/ts/test/automation/utilities/send_message.ts similarity index 100% rename from ts/test/automation/send_message.ts rename to ts/test/automation/utilities/send_message.ts diff --git a/ts/test/automation/utils.ts b/ts/test/automation/utilities/utils.ts similarity index 92% rename from ts/test/automation/utils.ts rename to ts/test/automation/utilities/utils.ts index 8f3fe24c5..34886072a 100644 --- a/ts/test/automation/utils.ts +++ b/ts/test/automation/utilities/utils.ts @@ -14,8 +14,8 @@ export async function waitForTestIdWithText(window: Page, dataTestId: string, te return found; } -export async function waitForReadableMessageWithText(window: Page, text: string) { - return waitForTestIdWithText(window, 'readable-message', text); +export async function waitForControlMessageWithText(window: Page, text: string) { + return waitForTestIdWithText(window, 'control-message', text); } export async function waitForMatchingText(window: Page, text: string) {