From 15b53cab062e742ef517e71104b05053ea0a6fb3 Mon Sep 17 00:00:00 2001 From: Emily <92288602+burtonemily@users.noreply.github.com> Date: Wed, 5 Jul 2023 10:28:24 +1000 Subject: [PATCH] delete account --- ts/test/automation/delete_account.spec.ts | 94 ++++++++++++++++------- 1 file changed, 68 insertions(+), 26 deletions(-) diff --git a/ts/test/automation/delete_account.spec.ts b/ts/test/automation/delete_account.spec.ts index f3f0f13d4..60716aca6 100644 --- a/ts/test/automation/delete_account.spec.ts +++ b/ts/test/automation/delete_account.spec.ts @@ -5,7 +5,17 @@ import { newUser } from './setup/new_user'; import { openApp } from './setup/open'; import { createContact } from './utilities/create_contact'; import { sendNewMessage } from './utilities/send_message'; -import { clickOnElement, clickOnMatchingText, clickOnTestIdWithText, hasElementBeenDeleted, typeIntoInput, waitForElement, waitForLoadingAnimationToFinish } from './utilities/utils'; +import { + clickOnElement, + clickOnMatchingText, + clickOnTestIdWithText, + hasElementBeenDeleted, + hasTextElementBeenDeleted, + typeIntoInput, + waitForElement, + waitForLoadingAnimationToFinish, +} from './utilities/utils'; + // tslint:disable: no-console test.beforeEach(beforeAllClean); @@ -47,33 +57,65 @@ test('Delete account from swarm', async () => { 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 { - const elemShouldNotBeFound = restoringWindow.locator(testMessage); - if (elemShouldNotBeFound) { - console.error('Test message was not found'); - throw new Error(errorDesc); - } - } catch (e) { - if (e.message !== errorDesc) { - throw e; - } - } + + // Need to verify that no conversation is found at all + + await hasElementBeenDeleted(restoringWindow, 'data-testid', 'conversation-list-item'); await clickOnTestIdWithText(restoringWindow, 'new-conversation-button'); // Expect contacts list to be empty - const errorDesc2 = 'Should not be found'; - try { - const elemShouldNotBeFound = restoringWindow.locator(userB.userName); - if (elemShouldNotBeFound) { - console.error('Contact not found'); - throw new Error(errorDesc2); - } - } catch (e) { - if (e.message !== errorDesc2) { - throw e; - } - } + 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 + ); + await forceCloseAllWindows(restoringWindows); });