mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Merge pull request #2490 from Bilb/fix-integration-tests
fix integration tests
This commit is contained in:
commit
b008e9d792
23 changed files with 95 additions and 52 deletions
|
@ -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 =>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -133,6 +133,7 @@ export const BlockedContactsList = () => {
|
|||
buttonType={SessionButtonType.BrandOutline}
|
||||
text={window.i18n('unblockUser')}
|
||||
onClick={unBlockThoseUsers}
|
||||
dataTestId="unblock-button-settings-screen"
|
||||
/>
|
||||
) : null}
|
||||
<SpacerLG />
|
||||
|
@ -141,6 +142,7 @@ export const BlockedContactsList = () => {
|
|||
iconType={'chevron'}
|
||||
onClick={toggleUnblockList}
|
||||
iconRotation={expanded ? 0 : 180}
|
||||
dataTestId="reveal-blocked-user-settings"
|
||||
/>
|
||||
<SpacerLG />
|
||||
</BlockedContactListTitleButtons>
|
||||
|
|
|
@ -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 {
|
||||
/**
|
||||
|
|
|
@ -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<Page> = [];
|
||||
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');
|
||||
// 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 expect(blockedContact).toContainText(userB.userName);
|
||||
// Unblock user
|
||||
await clickOnMatchingText(windowA, 'Unblock');
|
||||
// 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
|
||||
await waitForTestIdWithText(windowA, 'session-toast', 'Unblocked');
|
||||
await waitForMatchingText(windowA, 'No blocked contacts');
|
||||
});
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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<Page> = [];
|
||||
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 {
|
||||
|
|
|
@ -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<Page> = [];
|
||||
test.beforeEach(beforeAllClean);
|
||||
|
||||
test.afterEach(() => forceCloseAllWindows(windows));
|
||||
// tslint:disable: no-console
|
||||
|
||||
|
|
|
@ -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<Page> = [];
|
||||
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);
|
||||
|
|
|
@ -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<Page> = [];
|
||||
test.beforeEach(beforeAllClean);
|
||||
|
||||
test.afterEach(() => forceCloseAllWindows(windows));
|
||||
|
||||
test('Group testing', async () => {
|
||||
|
|
|
@ -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<Page> = [];
|
||||
test.beforeEach(beforeAllClean);
|
||||
|
||||
test.afterEach(() => forceCloseAllWindows(windows));
|
||||
|
||||
test.skip('Group upkeep', async () => {
|
||||
|
|
|
@ -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<Page> = [];
|
||||
test.beforeEach(beforeAllClean);
|
||||
|
||||
test.afterEach(() => forceCloseAllWindows(windows));
|
||||
// tslint:disable: no-console
|
||||
|
||||
|
|
|
@ -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<Page> = [];
|
||||
test.beforeEach(beforeAllClean);
|
||||
|
||||
test.afterEach(() => forceCloseAllWindows(windows));
|
||||
|
||||
test('Mentions', async () => {
|
||||
|
|
|
@ -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<Page> = [];
|
||||
test.beforeEach(beforeAllClean);
|
||||
|
||||
test.afterEach(() => forceCloseAllWindows(windows));
|
||||
// Open two windows and log into 2 separate accounts
|
||||
test.describe('Message requests', () => {
|
||||
|
|
|
@ -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<Page> = [];
|
||||
test.beforeEach(beforeAllClean);
|
||||
|
||||
test.afterEach(() => forceCloseAllWindows(windows));
|
||||
|
||||
// Send message in one to one conversation with new contact
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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<Page>) => {
|
||||
return Promise.all(windows.map(w => w.close()));
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<UserLoggedInType> => {
|
||||
// Create User
|
||||
await clickOnMatchingText(window, 'Create Session ID');
|
||||
|
|
|
@ -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<Page> = [];
|
||||
test.beforeEach(beforeAllClean);
|
||||
|
||||
test.afterEach(() => forceCloseAllWindows(windows));
|
||||
|
||||
test('Switch themes', async () => {
|
||||
|
|
|
@ -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<Page> = [];
|
||||
test.beforeEach(beforeAllClean);
|
||||
|
||||
test.afterEach(() => forceCloseAllWindows(windows));
|
||||
|
||||
test('Unsend message', async () => {
|
||||
|
|
Loading…
Reference in a new issue