diff --git a/ts/components/MemberListItem.tsx b/ts/components/MemberListItem.tsx index 3b06be785..693f08251 100644 --- a/ts/components/MemberListItem.tsx +++ b/ts/components/MemberListItem.tsx @@ -32,7 +32,7 @@ const StyledSessionMemberItem = styled.button<{ font-family: var(--font-default); padding: 0px var(--margins-sm); height: ${props => (props.inMentions ? '40px' : '50px')}; - + width: 100%; transition: var(--default-duration); opacity: ${props => (props.zombie ? 0.5 : 1)}; background-color: ${props => diff --git a/ts/components/leftpane/LeftPaneSettingSection.tsx b/ts/components/leftpane/LeftPaneSettingSection.tsx index 4eaa33e17..25f24e9ec 100644 --- a/ts/components/leftpane/LeftPaneSettingSection.tsx +++ b/ts/components/leftpane/LeftPaneSettingSection.tsx @@ -64,7 +64,7 @@ const LeftPaneSettingsCategoryRow = (props: { const dispatch = useDispatch(); const focusedSettingsSection = useSelector(getFocusedSettingsSection); - const dataTestId = `${title.toLowerCase()}-settings-menu-item`; + const dataTestId = `${title.toLowerCase().replace(' ', '-')}-settings-menu-item`; const isClearData = id === SessionSettingCategory.ClearData; diff --git a/ts/components/settings/BlockedList.tsx b/ts/components/settings/BlockedList.tsx index e32c80ace..8812cc985 100644 --- a/ts/components/settings/BlockedList.tsx +++ b/ts/components/settings/BlockedList.tsx @@ -133,6 +133,7 @@ export const BlockedContactsList = () => { buttonType={SessionButtonType.BrandOutline} text={window.i18n('unblockUser')} onClick={unBlockThoseUsers} + dataTestId="unblock-button-settings-screen" /> ) : null} @@ -141,6 +142,7 @@ export const BlockedContactsList = () => { iconType={'chevron'} onClick={toggleUnblockList} iconRotation={expanded ? 0 : 180} + dataTestId="reveal-blocked-user-settings" /> diff --git a/ts/session/types/PubKey.ts b/ts/session/types/PubKey.ts index bea9edbda..b4b1641aa 100644 --- a/ts/session/types/PubKey.ts +++ b/ts/session/types/PubKey.ts @@ -1,7 +1,6 @@ import { fromHexToArray } from '../utils/String'; -export const getStoragePubKey = (key: string) => - window.sessionFeatureFlags.useTestNet ? key.substring(2) : key; +export const getStoragePubKey = (key: string) => key; export enum KeyPrefixType { /** diff --git a/ts/test/automation/blocking_user.spec.ts b/ts/test/automation/blocking_user.spec.ts index d70c46b1c..211db723b 100644 --- a/ts/test/automation/blocking_user.spec.ts +++ b/ts/test/automation/blocking_user.spec.ts @@ -1,10 +1,17 @@ -import { _electron, expect, Page, test } from '@playwright/test'; -import { forceCloseAllWindows } from './setup/beforeEach'; +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 { clickOnMatchingText, clickOnTestIdWithText, waitForTestIdWithText } from './utils'; +import { + clickOnMatchingText, + clickOnTestIdWithText, + waitForMatchingText, + waitForTestIdWithText, +} from './utils'; let windows: Array = []; +test.beforeEach(beforeAllClean); + test.afterEach(() => forceCloseAllWindows(windows)); test('Block User', async () => { @@ -19,7 +26,6 @@ test('Block User', async () => { await sendNewMessage(windowA, userB.sessionid, `A -> B: ${Date.now()}`); await sendNewMessage(windowB, userA.sessionid, `B -> A: ${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); @@ -34,14 +40,18 @@ 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 clickOnMatchingText(windowA, 'Blocked contacts'); - // Check for user B's name - const blockedContact = windowA.locator('.session-settings-item__title'); + await clickOnTestIdWithText(windowA, 'reveal-blocked-user-settings'); + // select the contact to unblock by clicking on it by name + await clickOnMatchingText(windowA, userB.userName); - await expect(blockedContact).toContainText(userB.userName); - // Unblock user - await clickOnMatchingText(windowA, 'Unblock'); + // Unblock user by clicking on unblock + await clickOnTestIdWithText(windowA, 'unblock-button-settings-screen'); // Verify toast notification says unblocked await waitForTestIdWithText(windowA, 'session-toast', 'Unblocked'); + await waitForMatchingText(windowA, 'No blocked contacts'); }); diff --git a/ts/test/automation/change_avatar.spec.ts b/ts/test/automation/change_avatar.spec.ts index fdc09aed1..5dceda607 100644 --- a/ts/test/automation/change_avatar.spec.ts +++ b/ts/test/automation/change_avatar.spec.ts @@ -1,10 +1,11 @@ import { _electron, expect, Page, test } from '@playwright/test'; import { openAppAndWait } from './setup/open'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { newUser } from './setup/new_user'; import { clickOnTestIdWithText, waitForTestIdWithText } from './utils'; let window: Page | undefined; +test.beforeEach(beforeAllClean); test.afterEach(async () => { if (window) { @@ -29,10 +30,7 @@ test('Change profile picture/avatar', async () => { await waitForTestIdWithText(window, 'copy-button-profile-update', 'Copy'); await clickOnTestIdWithText(window, 'modal-close-button'); - const leftpaneAvatarContainer = await waitForTestIdWithText( - window, - 'img-leftpane-primary-avatar' - ); + const leftpaneAvatarContainer = await waitForTestIdWithText(window, 'leftpane-primary-avatar'); const screenshot = await leftpaneAvatarContainer.screenshot({ type: 'jpeg', // path: 'avatar-updated-blue', diff --git a/ts/test/automation/change_username.spec.ts b/ts/test/automation/change_username.spec.ts index 3a2d7d6a0..679aadcd2 100644 --- a/ts/test/automation/change_username.spec.ts +++ b/ts/test/automation/change_username.spec.ts @@ -1,10 +1,12 @@ import { _electron, expect, Page, test } from '@playwright/test'; import { newUser } from './setup/new_user'; import { openAppAndWait } from './setup/open'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { clickOnTestIdWithText, typeIntoInput } from './utils'; let window: Page | undefined; +test.beforeEach(beforeAllClean); + test.afterEach(async () => { if (window) { await forceCloseAllWindows([window]); diff --git a/ts/test/automation/create_user.spec.ts b/ts/test/automation/create_user.spec.ts index 130223348..6f3b749d9 100644 --- a/ts/test/automation/create_user.spec.ts +++ b/ts/test/automation/create_user.spec.ts @@ -2,10 +2,12 @@ import { _electron, Page, test } from '@playwright/test'; import { newUser } from './setup/new_user'; import { openAppAndWait } from './setup/open'; import { sleepFor } from '../../session/utils/Promise'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { clickOnMatchingText, clickOnTestIdWithText, waitForTestIdWithText } from './utils'; let window: Page | undefined; +test.beforeEach(beforeAllClean); + test.afterEach(async () => { if (window) { await forceCloseAllWindows([window]); diff --git a/ts/test/automation/delete_account.spec.ts b/ts/test/automation/delete_account.spec.ts index bbf9c8957..815c32f56 100644 --- a/ts/test/automation/delete_account.spec.ts +++ b/ts/test/automation/delete_account.spec.ts @@ -1,5 +1,5 @@ import { _electron, Page, test } from '@playwright/test'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { openAppsAndNewUsers, openAppsNoNewUsers } from './setup/new_user'; import { sendNewMessage } from './send_message'; import { clickOnMatchingText, clickOnTestIdWithText, typeIntoInput } from './utils'; @@ -7,6 +7,8 @@ import { sleepFor } from '../../session/utils/Promise'; // tslint:disable: no-console let windows: Array = []; +test.beforeEach(beforeAllClean); + test.afterEach(() => forceCloseAllWindows(windows)); test('Delete account from swarm', async () => { @@ -25,7 +27,7 @@ test('Delete account from swarm', async () => { // Click on settings tab await clickOnTestIdWithText(windowA, 'settings-section'); // Click on clear all data - await clickOnMatchingText(windowA, 'Clear All Data'); + await clickOnTestIdWithText(windowA, 'clear-data-settings-menu-item', 'Clear Data'); // Select entire account await clickOnMatchingText(windowA, 'Entire Account'); // Confirm deletion by clicking i am sure @@ -44,6 +46,8 @@ test('Delete account from swarm', async () => { await typeIntoInput(restoringWindow, 'display-name-input', userA.userName); // Click continue await clickOnTestIdWithText(restoringWindow, 'continue-session-button'); + console.log('sleeping for 20000ms'); + await sleepFor(20000); // just to allow any messages from our swarm to show up // Check if message from user B is restored (we don't want it to be) const errorDesc = 'Test Message should not be found'; try { diff --git a/ts/test/automation/disappearing_messages.spec.ts b/ts/test/automation/disappearing_messages.spec.ts index 58e1cf00f..5a2b554ec 100644 --- a/ts/test/automation/disappearing_messages.spec.ts +++ b/ts/test/automation/disappearing_messages.spec.ts @@ -1,5 +1,5 @@ import { _electron, Page, test } from '@playwright/test'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { messageSent } from './message'; import { openAppsAndNewUsers } from './setup/new_user'; import { sendNewMessage } from './send_message'; @@ -12,6 +12,8 @@ import { } from './utils'; let windows: Array = []; +test.beforeEach(beforeAllClean); + test.afterEach(() => forceCloseAllWindows(windows)); // tslint:disable: no-console diff --git a/ts/test/automation/group_creation.spec.ts b/ts/test/automation/group_creation.spec.ts index 49a4bab58..a582dd7e0 100644 --- a/ts/test/automation/group_creation.spec.ts +++ b/ts/test/automation/group_creation.spec.ts @@ -1,5 +1,5 @@ import { _electron, Page, test } from '@playwright/test'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { messageSent } from './message'; import { openAppsAndNewUsers } from './setup/new_user'; import { sendNewMessage } from './send_message'; @@ -14,6 +14,8 @@ import { const testGroupName = 'Test Group Name'; let windows: Array = []; +test.beforeEach(beforeAllClean); + test.afterEach(() => forceCloseAllWindows(windows)); test('Create group', async () => { @@ -39,7 +41,7 @@ test('Create group', async () => { // Select user C await clickOnMatchingText(windowA, userC.userName); // Click Done - await clickOnMatchingText(windowA, 'Done'); + await clickOnTestIdWithText(windowA, 'next-button'); // Check group was successfully created await clickOnMatchingText(windowB, testGroupName); await waitForTestIdWithText(windowB, 'header-conversation-name', testGroupName); diff --git a/ts/test/automation/group_testing.spec.ts b/ts/test/automation/group_testing.spec.ts index b6aa5a7a5..046d6c3ff 100644 --- a/ts/test/automation/group_testing.spec.ts +++ b/ts/test/automation/group_testing.spec.ts @@ -1,5 +1,5 @@ import { _electron, expect, Page, test } from '@playwright/test'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; // import { recoverFromSeed } from './setup/recovery_using_seed'; import { clickOnMatchingText, @@ -14,6 +14,8 @@ import { leaveGroup } from './leave_group'; import { createGroup } from './setup/create_group'; let windows: Array = []; +test.beforeEach(beforeAllClean); + test.afterEach(() => forceCloseAllWindows(windows)); test('Group testing', async () => { diff --git a/ts/test/automation/group_upkeep.spec.ts b/ts/test/automation/group_upkeep.spec.ts index 69e91873b..a439b9a11 100644 --- a/ts/test/automation/group_upkeep.spec.ts +++ b/ts/test/automation/group_upkeep.spec.ts @@ -1,5 +1,5 @@ import { _electron, Page, test } from '@playwright/test'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { openAppsNoNewUsers } from './setup/new_user'; import { sendNewMessage } from './send_message'; import { logIn } from './setup/log_in'; @@ -12,6 +12,8 @@ import { } from './setup/test_user'; let windows: Array = []; +test.beforeEach(beforeAllClean); + test.afterEach(() => forceCloseAllWindows(windows)); test.skip('Group upkeep', async () => { diff --git a/ts/test/automation/linking_device.spec.ts b/ts/test/automation/linking_device.spec.ts index a46f371d0..b72993a07 100644 --- a/ts/test/automation/linking_device.spec.ts +++ b/ts/test/automation/linking_device.spec.ts @@ -1,9 +1,11 @@ import { _electron, Page, test } from '@playwright/test'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { linkedDevice } from './setup/linked_device'; import { clickOnTestIdWithText, typeIntoInput, waitForTestIdWithText } from './utils'; const windows: Array = []; +test.beforeEach(beforeAllClean); + test.afterEach(() => forceCloseAllWindows(windows)); // tslint:disable: no-console diff --git a/ts/test/automation/mentions.spec.ts b/ts/test/automation/mentions.spec.ts index e89131796..36cd58be3 100644 --- a/ts/test/automation/mentions.spec.ts +++ b/ts/test/automation/mentions.spec.ts @@ -1,9 +1,11 @@ import { _electron, Page, test } from '@playwright/test'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { clickOnTestIdWithText, typeIntoInput, waitForTestIdWithText } from './utils'; import { createGroup } from './setup/create_group'; let windows: Array = []; +test.beforeEach(beforeAllClean); + test.afterEach(() => forceCloseAllWindows(windows)); test('Mentions', async () => { diff --git a/ts/test/automation/message_requests.spec.ts b/ts/test/automation/message_requests.spec.ts index 385020320..b1ba016d1 100644 --- a/ts/test/automation/message_requests.spec.ts +++ b/ts/test/automation/message_requests.spec.ts @@ -1,12 +1,14 @@ import { _electron, Page, test } from '@playwright/test'; import { sendNewMessage } from './send_message'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { openAppsAndNewUsers } from './setup/new_user'; import { clickOnTestIdWithText, waitForMatchingText, waitForTestIdWithText } from './utils'; const testMessage = 'A -> B'; let windows: Array = []; +test.beforeEach(beforeAllClean); + test.afterEach(() => forceCloseAllWindows(windows)); // Open two windows and log into 2 separate accounts test.describe('Message requests', () => { diff --git a/ts/test/automation/new_contact_test.spec.ts b/ts/test/automation/new_contact_test.spec.ts index 52be8e8c9..9644510cf 100644 --- a/ts/test/automation/new_contact_test.spec.ts +++ b/ts/test/automation/new_contact_test.spec.ts @@ -1,5 +1,5 @@ import { _electron, Page, test } from '@playwright/test'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { sendNewMessage } from './send_message'; import { openAppsAndNewUsers } from './setup/new_user'; @@ -9,6 +9,8 @@ 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 diff --git a/ts/test/automation/password.spec.ts b/ts/test/automation/password.spec.ts index 308d29690..f4506ec7c 100644 --- a/ts/test/automation/password.spec.ts +++ b/ts/test/automation/password.spec.ts @@ -1,5 +1,5 @@ import { _electron, Page, test } from '@playwright/test'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { newUser } from './setup/new_user'; import { openAppAndWait } from './setup/open'; import { @@ -11,6 +11,8 @@ import { } from './utils'; let window: Page | undefined; +test.beforeEach(beforeAllClean); + test.afterEach(async () => { if (window) { await forceCloseAllWindows([window]); diff --git a/ts/test/automation/setup/beforeEach.ts b/ts/test/automation/setup/beforeEach.ts index 725efab7f..6cada0449 100644 --- a/ts/test/automation/setup/beforeEach.ts +++ b/ts/test/automation/setup/beforeEach.ts @@ -7,16 +7,20 @@ import { MULTI_PREFIX, NODE_ENV, openElectronAppOnly } from './open'; const getDirectoriesOfSessionDataPath = (source: string) => readdirSync(source, { withFileTypes: true }) .filter(dirent => dirent.isDirectory()) - .map(dirent => dirent.name) - .filter(n => n.startsWith(`Session-${NODE_ENV}-${MULTI_PREFIX}`)); + .map(dirent => { + return dirent.name; + }) + .filter(n => n.includes(`${NODE_ENV}-${MULTI_PREFIX}`)); let alreadyCleaned = false; +let alreadyCleanedWaiting = false; -export const cleanUpOtherTest = async () => { - if (alreadyCleaned) { +const cleanUpOtherTest = async () => { + if (alreadyCleaned || alreadyCleanedWaiting) { return; } alreadyCleaned = true; + const electronApp = await openElectronAppOnly('start'); const appPath = await electronApp.evaluate(async ({ app }) => { @@ -24,23 +28,25 @@ export const cleanUpOtherTest = async () => { }); const window = await electronApp.firstWindow(); await window.close(); - if (alreadyCleaned) { + if (alreadyCleaned && alreadyCleanedWaiting) { return; } + alreadyCleanedWaiting = true; + if (!appPath.length) { throw new Error('appDataPath unset'); } + const parentFolderOfAllDataPath = dirname(appPath); if (!parentFolderOfAllDataPath || parentFolderOfAllDataPath.length < 20) { throw new Error('parentFolderOfAllDataPath not found or invalid'); } - console.info('cleaning other tests leftovers...'); + console.info('cleaning other tests leftovers...', parentFolderOfAllDataPath); - if (alreadyCleaned) { - return; - } const allAppDataPath = getDirectoriesOfSessionDataPath(parentFolderOfAllDataPath); + console.info('allAppDataPath', allAppDataPath); + allAppDataPath.map(folder => { if (!appPath) { throw new Error('parentFolderOfAllDataPath unset'); @@ -51,6 +57,8 @@ export const cleanUpOtherTest = async () => { console.info('...done'); }; +export const beforeAllClean = cleanUpOtherTest; + export const forceCloseAllWindows = async (windows: Array) => { return Promise.all(windows.map(w => w.close())); }; diff --git a/ts/test/automation/setup/create_group.ts b/ts/test/automation/setup/create_group.ts index 60d0ac221..3c4676535 100644 --- a/ts/test/automation/setup/create_group.ts +++ b/ts/test/automation/setup/create_group.ts @@ -38,8 +38,8 @@ export const createGroup = async (groupName: string) => { await clickOnMatchingText(windowA, userB.userName); // Select user C await clickOnMatchingText(windowA, userC.userName); - // Click Done - await clickOnMatchingText(windowA, 'Done'); + // Click Next + await clickOnTestIdWithText(windowA, 'next-button'); // Check group was successfully created await clickOnMatchingText(windowB, groupName); await waitForTestIdWithText(windowB, 'header-conversation-name', groupName); diff --git a/ts/test/automation/setup/new_user.ts b/ts/test/automation/setup/new_user.ts index 3aca163f1..5502da0ca 100644 --- a/ts/test/automation/setup/new_user.ts +++ b/ts/test/automation/setup/new_user.ts @@ -1,7 +1,6 @@ -import { _electron, Page, test } from '@playwright/test'; +import { _electron, Page } from '@playwright/test'; import _ from 'lodash'; import { clickOnMatchingText, typeIntoInput } from '../utils'; -import { cleanUpOtherTest } from './beforeEach'; import { openAppAndWait } from './open'; const multisAvailable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; @@ -11,9 +10,6 @@ export type UserLoggedInType = { recoveryPhrase: string; }; -test.beforeAll(cleanUpOtherTest); -test.afterAll(cleanUpOtherTest); - export const newUser = async (window: Page, userName: string): Promise => { // Create User await clickOnMatchingText(window, 'Create Session ID'); diff --git a/ts/test/automation/switching_theme.spec.ts b/ts/test/automation/switching_theme.spec.ts index 4a510e8d6..26f0a7025 100644 --- a/ts/test/automation/switching_theme.spec.ts +++ b/ts/test/automation/switching_theme.spec.ts @@ -1,9 +1,11 @@ import { _electron, expect, Page, test } from '@playwright/test'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { openAppsAndNewUsers } from './setup/new_user'; import { clickOnTestIdWithText } from './utils'; let windows: Array = []; +test.beforeEach(beforeAllClean); + test.afterEach(() => forceCloseAllWindows(windows)); test('Switch themes', async () => { diff --git a/ts/test/automation/unsend_message.spec.ts b/ts/test/automation/unsend_message.spec.ts index 60b2b74d2..085ff6d87 100644 --- a/ts/test/automation/unsend_message.spec.ts +++ b/ts/test/automation/unsend_message.spec.ts @@ -1,5 +1,5 @@ import { _electron, Page, test } from '@playwright/test'; -import { forceCloseAllWindows } from './setup/beforeEach'; +import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach'; import { openAppsAndNewUsers } from './setup/new_user'; import { sendNewMessage } from './send_message'; import { @@ -13,6 +13,8 @@ const testMessage = 'A -> B: '; const testReply = 'B -> A: '; let windows: Array = []; +test.beforeEach(beforeAllClean); + test.afterEach(() => forceCloseAllWindows(windows)); test('Unsend message', async () => {