Adding accessibility ids into types, fixing disappearing messages and deleting from swarm test

pull/2786/head
Emily 2 years ago
parent 088a1e1e74
commit cda3007702

@ -1,10 +1,11 @@
import { _electron, test } from '@playwright/test';
import { test } from '@playwright/test';
import { sleepFor } from '../../session/utils/Promise';
import { beforeAllClean, forceCloseAllWindows } from './setup/beforeEach';
import { newUser } from './setup/new_user';
import { sendNewMessage } from './utilities/send_message';
import { clickOnMatchingText, clickOnTestIdWithText, hasElementBeenDeleted, typeIntoInput } from './utilities/utils';
import { sleepFor } from '../../session/utils/Promise';
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';
// tslint:disable: no-console
test.beforeEach(beforeAllClean);
@ -29,7 +30,8 @@ test('Delete account from swarm', async () => {
// Confirm deletion by clicking Clear, twice
await clickOnMatchingText(windowA, 'Clear');
await clickOnMatchingText(windowA, 'Clear');
await windowA.waitForTimeout(7500);
await waitForLoadingAnimationToFinish(windowA, 'loading-spinner');
// await windowA.waitForTimeout(7500);
// Wait for window to close and reopen
await sleepFor(10000, true);
// await windowA.close();
@ -46,9 +48,49 @@ test('Delete account from swarm', async () => {
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)
await hasElementBeenDeleted(restoringWindow, "data-testid", 'module-conversation-list-item');
await clickOnTestIdWithText(restoringWindow, 'new-conversation-button'); // Expect contacts list to be empty
await hasElementBeenDeleted(restoringWindow, 'data-testid', 'module-conversation__user__profile-name');
await hasElementBeenDeleted(restoringWindow, 'data-testid', 'module-conversation__user__profile-name', 1000);
await clickOnElement(restoringWindow, 'data-testid', 'new-conversation-button'); // Expect contacts list to be empty
await hasElementBeenDeleted(restoringWindow, 'data-testid', 'module-conversation__user__profile-name', 1000);
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);
});

@ -60,6 +60,8 @@ test('Disappearing messages', async () => {
// Verify message is deleted
await hasTextElementBeenDeleted(windowA, sentMessage, 3000);
// focus window B
await windowA.close();
await windowB.bringToFront();
await clickOnTestIdWithText(windowB, "control-message", `${userA.userName} set the disappearing message timer to 5 seconds`);
await hasTextElementBeenDeleted(windowB, sentMessage, 4000);
await hasTextElementBeenDeleted(windowB, sentMessage, 5000);
});

@ -14,3 +14,63 @@ export type Group = {
export type Strategy = 'data-testid' | 'class' | ':has-text';
export type loaderType = 'loading-animation' | 'loading-spinner';
export type DataTestId =
'session-id-signup'
| 'display-name-input'
| 'recovery-phrase-seed-modal'
| "path-light-container"
| "new-conversation-button"
| 'chooser-new-conversation-button'
| 'new-session-conversation'
| 'next-new-conversation-button'
| "control-message"
| "disappearing-messages-indicator"
| "back-button-conversation-options"
| "conversation-options-avatar"
| "settings-section"
| "clear-data-settings-menu-item"
| "restore-using-recovery"
| "recovery-phrase-input"
| "continue-session-button"
| "label-device_and_network"
| "message-request-banner"
| "module-conversation__user__profile-name"
| "decline-message-request"
| "session-confirm-ok-button"
| "session-toast"
| "accept-message-request"
| "confirm-nickname"
| "nickname-input"
| "three-dots-conversation-options"
| "message-section"
| "conversations-settings-menu-item"
| "reveal-blocked-user-settings"
| "unblock-button-settings-screen"
| "leftpane-primary-avatar"
| "edit-profile-icon"
| "profile-name-input"
| "image-upload-section"
| "save-button-profile-update"
| "modal-close-button"
| "send-message-button"
| "message-input-text-area"
| "end-voice-message"
| "microphone-button"
| "enable-microphone"
| "theme-section"
| "call-button"
| "enable-calls"
| "end-call"
| "privacy-settings-menu-item"
| "set-password-button"
| "password-input"
| "password-input-confirm"
| "change-password-settings-button"
| "password-input-reconfirm"
| "messages-container"
| "chooser-new-group"
| "new-closed-group-name"
| "next-button"
| "link-device"
| "group-name-input"

@ -4,6 +4,7 @@ import { sleepFor } from '../../session/utils/Promise';
import { newUser } from './setup/new_user';
import { sendNewMessage } from './utilities/send_message';
import {
clickOnElement,
clickOnMatchingText,
clickOnTestIdWithText,
typeIntoInput,
@ -195,3 +196,11 @@ test('Set nickname', async () => {
const conversationListUsername = await conversationListUsernameText.innerText();
expect(conversationListUsername).toBe(nickname);
});
test('Read status', async () => {
const [windowA, windowB] = await openApp(2);
const [userA, userB] = await Promise.all([newUser(windowA, 'Alice'), newUser(windowB, 'Bob')]);
await createContact(windowA, windowB, userA, userB);
await clickOnElement(windowA, 'data-testid' , "setting-section")
});

@ -1,7 +1,7 @@
import { ElementHandle } from '@playwright/test';
import { Page } from 'playwright-core';
import { sleepFor } from '../../../session/utils/Promise';
import { loaderType, Strategy } from '../types/testing';
import { DataTestId, loaderType, Strategy } from '../types/testing';
// tslint:disable: no-console
// WAIT FOR FUNCTIONS
@ -29,9 +29,12 @@ export async function waitForElement(
window: Page,
strategy: Strategy,
selector: string,
maxWaitMs?: number
maxWaitMs?: number,
text?: string
) {
const builtSelector = `css=[${strategy}=${selector}]`;
const builtSelector = !text
? `css=[${strategy}=${selector}]`
: `css=[${strategy}=${selector}]:has-text("${text.replace(/"/g, '\\"')}")`;
return window.waitForSelector(builtSelector, { timeout: maxWaitMs });
}
@ -134,7 +137,7 @@ export async function clickOnMatchingText(window: Page, text: string, rightButto
export async function clickOnTestIdWithText(
window: Page,
dataTestId: string,
dataTestId: DataTestId,
text?: string,
rightButton?: boolean
) {
@ -152,13 +155,13 @@ export function getMessageTextContentNow() {
return `Test message timestamp: ${Date.now()}`;
}
export async function typeIntoInput(window: Page, dataTestId: string, text: string) {
export async function typeIntoInput(window: Page, dataTestId: DataTestId, text: string) {
console.info(`typeIntoInput testId: ${dataTestId} : "${text}"`);
const builtSelector = `css=[data-testid=${dataTestId}]`;
return window.fill(builtSelector, text);
}
export async function typeIntoInputSlow(window: Page, dataTestId: string, text: string) {
export async function typeIntoInputSlow(window: Page, dataTestId: DataTestId, text: string) {
console.info(`typeIntoInput testId: ${dataTestId} : "${text}"`);
const builtSelector = `css=[data-testid=${dataTestId}]`;
await window.waitForSelector(builtSelector);
@ -178,7 +181,7 @@ export async function hasTextElementBeenDeleted(window: Page, text: string, maxW
console.info('Element has not been found, congratulations', text);
}
export async function doesTextIncludeString(window: Page, dataTestId: string, text: string) {
export async function doesTextIncludeString(window: Page, dataTestId: DataTestId, text: string) {
const element = await waitForTestIdWithText(window, dataTestId);
const el = await element.innerText();

Loading…
Cancel
Save