2023-06-05 05:32:07 +02:00
|
|
|
import { test } from '@playwright/test';
|
|
|
|
import { sleepFor } from '../../session/utils/Promise';
|
2022-09-14 07:46:18 +02:00
|
|
|
import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach';
|
Adds data-testid to loading-animation, microphone recording button, recording permissions button, stop recording button, consolidates tests into user actions test, adds media to fixtures folder, updates linked device tests with avatar change, username change and group tests. Adds tests for messaging, sending image, video, document, gif and link with preview. Also updates reply message functionality to wait for loading animation
2023-05-01 05:43:19 +02:00
|
|
|
import { newUser } from './setup/new_user';
|
|
|
|
import { openApp } from './setup/open';
|
2023-06-05 05:32:07 +02:00
|
|
|
import { createContact } from './utilities/create_contact';
|
|
|
|
import { sendNewMessage } from './utilities/send_message';
|
2023-07-05 02:28:24 +02:00
|
|
|
import {
|
2023-08-07 08:13:01 +02:00
|
|
|
clickOnElement,
|
|
|
|
clickOnMatchingText,
|
|
|
|
clickOnTestIdWithText,
|
|
|
|
hasElementBeenDeleted,
|
|
|
|
hasTextElementBeenDeleted,
|
|
|
|
typeIntoInput,
|
|
|
|
waitForElement,
|
|
|
|
waitForLoadingAnimationToFinish,
|
2023-07-05 02:28:24 +02:00
|
|
|
} from './utilities/utils';
|
|
|
|
|
2022-09-14 07:46:18 +02:00
|
|
|
test.beforeEach(beforeAllClean);
|
|
|
|
|
2022-05-17 05:22:13 +02:00
|
|
|
test('Delete account from swarm', async () => {
|
2023-05-16 01:45:58 +02:00
|
|
|
const [windowA, windowB] = await openApp(2); // not using sessionTest here as we need to close and reopen one of the window
|
Adds data-testid to loading-animation, microphone recording button, recording permissions button, stop recording button, consolidates tests into user actions test, adds media to fixtures folder, updates linked device tests with avatar change, username change and group tests. Adds tests for messaging, sending image, video, document, gif and link with preview. Also updates reply message functionality to wait for loading animation
2023-05-01 05:43:19 +02:00
|
|
|
const [userA, userB] = await Promise.all([newUser(windowA, 'Alice'), newUser(windowB, 'Bob')]);
|
|
|
|
const testMessage = `${userA.userName} to ${userB.userName}`;
|
|
|
|
const testReply = `${userB.userName} to ${userA.userName}`;
|
2022-05-17 05:22:13 +02:00
|
|
|
// Create contact and send new message
|
|
|
|
await Promise.all([
|
|
|
|
sendNewMessage(windowA, userB.sessionid, testMessage),
|
|
|
|
sendNewMessage(windowB, userA.sessionid, testReply),
|
|
|
|
]);
|
|
|
|
// Delete all data from device
|
|
|
|
// Click on settings tab
|
|
|
|
await clickOnTestIdWithText(windowA, 'settings-section');
|
|
|
|
// Click on clear all data
|
2022-09-14 07:46:18 +02:00
|
|
|
await clickOnTestIdWithText(windowA, 'clear-data-settings-menu-item', 'Clear Data');
|
2022-05-17 05:22:13 +02:00
|
|
|
// Select entire account
|
2022-09-29 06:04:09 +02:00
|
|
|
await clickOnTestIdWithText(windowA, 'label-device_and_network', 'Clear Device and Network');
|
|
|
|
// Confirm deletion by clicking Clear, twice
|
|
|
|
await clickOnMatchingText(windowA, 'Clear');
|
|
|
|
await clickOnMatchingText(windowA, 'Clear');
|
2023-06-05 05:32:07 +02:00
|
|
|
await waitForLoadingAnimationToFinish(windowA, 'loading-spinner');
|
|
|
|
// await windowA.waitForTimeout(7500);
|
2022-05-17 05:22:13 +02:00
|
|
|
// Wait for window to close and reopen
|
|
|
|
await sleepFor(10000, true);
|
|
|
|
// await windowA.close();
|
2023-05-16 01:45:58 +02:00
|
|
|
const restoringWindows = await openApp(1); // not using sessionTest here as we need to close and reopen one of the window
|
2022-05-17 05:22:13 +02:00
|
|
|
const [restoringWindow] = restoringWindows;
|
|
|
|
// Sign in with deleted account and check that nothing restores
|
|
|
|
await clickOnTestIdWithText(restoringWindow, 'restore-using-recovery', 'Restore your account');
|
|
|
|
// Fill in recovery phrase
|
|
|
|
await typeIntoInput(restoringWindow, 'recovery-phrase-input', userA.recoveryPhrase);
|
|
|
|
// Enter display name
|
|
|
|
await typeIntoInput(restoringWindow, 'display-name-input', userA.userName);
|
|
|
|
// Click continue
|
|
|
|
await clickOnTestIdWithText(restoringWindow, 'continue-session-button');
|
2022-09-14 07:46:18 +02:00
|
|
|
console.log('sleeping for 20000ms');
|
|
|
|
await sleepFor(20000); // just to allow any messages from our swarm to show up
|
2023-07-05 02:28:24 +02:00
|
|
|
|
|
|
|
// Need to verify that no conversation is found at all
|
|
|
|
|
|
|
|
await hasElementBeenDeleted(restoringWindow, 'data-testid', 'conversation-list-item');
|
2023-06-05 05:32:07 +02:00
|
|
|
|
2023-06-30 03:23:51 +02:00
|
|
|
await clickOnTestIdWithText(restoringWindow, 'new-conversation-button'); // Expect contacts list to be empty
|
|
|
|
|
2023-07-05 02:28:24 +02:00
|
|
|
await hasTextElementBeenDeleted(restoringWindow, 'contact');
|
|
|
|
await forceCloseAllWindows(restoringWindows);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Delete account from device', async () => {
|
|
|
|
const [windowA, windowB] = await openApp(2);
|
|
|
|
const [userA, userB] = await Promise.all([newUser(windowA, 'Alice'), newUser(windowB, 'Bob')]);
|
|
|
|
// Create contact and send new message
|
|
|
|
await createContact(windowA, windowB, userA, userB);
|
|
|
|
// Delete all data from device
|
|
|
|
// Click on settings tab
|
|
|
|
await clickOnTestIdWithText(windowA, 'settings-section');
|
|
|
|
// Click on clear all data
|
|
|
|
await clickOnTestIdWithText(windowA, 'clear-data-settings-menu-item', 'Clear Data');
|
|
|
|
// Keep 'Clear Device only' selection
|
|
|
|
// Confirm deletion by clicking Clear, twice
|
|
|
|
await clickOnMatchingText(windowA, 'Clear');
|
|
|
|
await clickOnMatchingText(windowA, 'Clear');
|
|
|
|
await waitForLoadingAnimationToFinish(windowA, 'loading-spinner');
|
|
|
|
await windowA.waitForTimeout(7500);
|
|
|
|
// Wait for window to close and reopen
|
|
|
|
await sleepFor(10000, true);
|
|
|
|
// await windowA.close();
|
|
|
|
const restoringWindows = await openApp(1);
|
|
|
|
const [restoringWindow] = restoringWindows;
|
|
|
|
// Sign in with deleted account and check that nothing restores
|
|
|
|
await clickOnTestIdWithText(restoringWindow, 'restore-using-recovery', 'Restore your account');
|
|
|
|
// Fill in recovery phrase
|
|
|
|
await typeIntoInput(restoringWindow, 'recovery-phrase-input', userA.recoveryPhrase);
|
|
|
|
// Enter display name
|
|
|
|
await typeIntoInput(restoringWindow, 'display-name-input', userA.userName);
|
|
|
|
// Click continue
|
|
|
|
await clickOnTestIdWithText(restoringWindow, 'continue-session-button');
|
|
|
|
console.log('sleeping for 2000ms');
|
|
|
|
await sleepFor(2000); // just to allow any messages from our swarm to show up
|
|
|
|
// Check if message from user B is restored
|
|
|
|
await waitForElement(
|
|
|
|
restoringWindow,
|
|
|
|
'data-testid',
|
|
|
|
'module-conversation__user__profile-name',
|
|
|
|
1000,
|
|
|
|
userB.userName
|
|
|
|
);
|
|
|
|
// Check if contact is available in contacts section
|
|
|
|
await clickOnElement(restoringWindow, 'data-testid', 'new-conversation-button');
|
|
|
|
await waitForElement(
|
|
|
|
restoringWindow,
|
|
|
|
'data-testid',
|
|
|
|
'module-conversation__user__profile-name',
|
|
|
|
1000,
|
|
|
|
userB.userName
|
|
|
|
);
|
|
|
|
|
2023-08-07 08:13:01 +02:00
|
|
|
await hasElementBeenDeleted(restoringWindow, 'data-testid', 'conversation-list-item');
|
2023-07-11 07:34:28 +02:00
|
|
|
|
|
|
|
await clickOnTestIdWithText(restoringWindow, 'new-conversation-button'); // Expect contacts list to be empty
|
|
|
|
|
2023-08-07 08:13:01 +02:00
|
|
|
await hasTextElementBeenDeleted(restoringWindow, 'contact');
|
2023-06-05 05:32:07 +02:00
|
|
|
await forceCloseAllWindows(restoringWindows);
|
2023-06-30 03:23:51 +02:00
|
|
|
});
|