|
|
|
import { expect, Page, test } from '@playwright/test';
|
|
|
|
import { sleepFor } from '../../session/utils/Promise';
|
|
|
|
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
2 years ago
|
|
|
import { newUser } from './setup/new_user';
|
|
|
|
import { openApp } from './setup/open';
|
|
|
|
import { createContact } from './utilities/create_contact';
|
|
|
|
import { linkedDevice } from './utilities/linked_device';
|
|
|
|
import { sendMessage } from './utilities/message';
|
|
|
|
import {
|
|
|
|
clickOnElement,
|
|
|
|
clickOnMatchingText,
|
|
|
|
clickOnTestIdWithText,
|
|
|
|
hasTextElementBeenDeleted,
|
|
|
|
typeIntoInput,
|
|
|
|
waitForLoadingAnimationToFinish,
|
|
|
|
waitForMatchingText,
|
|
|
|
waitForTestIdWithText,
|
|
|
|
waitForTextMessage,
|
|
|
|
} from './utilities/utils';
|
|
|
|
|
|
|
|
const windows: Array<Page> = [];
|
|
|
|
test.beforeEach(beforeAllClean);
|
|
|
|
|
|
|
|
test.afterEach(() => forceCloseAllWindows(windows));
|
|
|
|
// tslint:disable: no-console
|
|
|
|
|
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
2 years ago
|
|
|
test('Link a device', async () => {
|
|
|
|
const [windowA] = await openApp(1);
|
|
|
|
const userA = await newUser(windowA, 'Alice');
|
|
|
|
const [windowB] = await linkedDevice(userA.recoveryPhrase);
|
|
|
|
await clickOnTestIdWithText(windowA, 'leftpane-primary-avatar');
|
|
|
|
// Verify Username
|
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
2 years ago
|
|
|
await waitForTestIdWithText(windowA, 'your-profile-name', userA.userName);
|
|
|
|
// Verify Session ID
|
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
2 years ago
|
|
|
await waitForTestIdWithText(windowA, 'your-session-id', userA.sessionid);
|
|
|
|
// exit profile module
|
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
2 years ago
|
|
|
await clickOnTestIdWithText(windowA, 'modal-close-button');
|
|
|
|
// You're almost finished isn't displayed
|
|
|
|
const errorDesc = 'Should not be found';
|
|
|
|
try {
|
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
2 years ago
|
|
|
const elemShouldNotBeFound = windowB.locator('[data-testid=reveal-recovery-phrase]');
|
|
|
|
if (elemShouldNotBeFound) {
|
|
|
|
console.error('Continue to save recovery phrase not found, excellent news');
|
|
|
|
throw new Error(errorDesc);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
if (e.message !== errorDesc) {
|
|
|
|
// this is NOT ok
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Check changed username syncs', async () => {
|
|
|
|
const [windowA] = await openApp(1);
|
|
|
|
const userA = await newUser(windowA, 'Alice');
|
|
|
|
const [windowB] = await linkedDevice(userA.recoveryPhrase);
|
|
|
|
const newUsername = 'Tiny bubble';
|
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
2 years ago
|
|
|
await clickOnTestIdWithText(windowA, 'leftpane-primary-avatar');
|
|
|
|
// Click on pencil icon
|
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
2 years ago
|
|
|
await clickOnTestIdWithText(windowA, 'edit-profile-icon');
|
|
|
|
// Replace old username with new username
|
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
2 years ago
|
|
|
await typeIntoInput(windowA, 'profile-name-input', newUsername);
|
|
|
|
// Press enter to confirm change
|
|
|
|
await clickOnElement(windowA, 'data-testid', 'save-button-profile-update');
|
|
|
|
// Wait for loading animation
|
|
|
|
// Check username change in window B
|
|
|
|
// Click on profile settings in window B
|
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
2 years ago
|
|
|
await clickOnTestIdWithText(windowB, 'leftpane-primary-avatar');
|
|
|
|
// Verify username has changed to new username
|
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
2 years ago
|
|
|
await waitForTestIdWithText(windowB, 'your-profile-name', newUsername);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Check profile picture syncs', async () => {
|
|
|
|
const [windowA] = await openApp(1);
|
|
|
|
const userA = await newUser(windowA, 'Alice');
|
|
|
|
const [windowB] = await linkedDevice(userA.recoveryPhrase);
|
|
|
|
await clickOnTestIdWithText(windowA, 'leftpane-primary-avatar');
|
|
|
|
// Click on current profile picture
|
|
|
|
await waitForTestIdWithText(windowA, 'copy-button-profile-update', 'Copy');
|
|
|
|
|
|
|
|
await clickOnTestIdWithText(windowA, 'image-upload-section');
|
|
|
|
await clickOnTestIdWithText(windowA, 'save-button-profile-update');
|
|
|
|
await waitForTestIdWithText(windowA, 'loading-spinner');
|
|
|
|
|
|
|
|
await waitForTestIdWithText(windowA, 'copy-button-profile-update', 'Copy');
|
|
|
|
await clickOnTestIdWithText(windowA, 'modal-close-button');
|
|
|
|
|
|
|
|
await sleepFor(500);
|
|
|
|
const leftpaneAvatarContainer = await waitForTestIdWithText(windowB, 'leftpane-primary-avatar');
|
|
|
|
await sleepFor(500);
|
|
|
|
const screenshot = await leftpaneAvatarContainer.screenshot({
|
|
|
|
type: 'jpeg',
|
|
|
|
// path: 'avatar-updated-blue',
|
|
|
|
});
|
|
|
|
expect(screenshot).toMatchSnapshot({ name: 'avatar-updated-blue.jpeg' });
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Check contacts sync', async () => {
|
|
|
|
const [windowA, windowC] = await openApp(2);
|
|
|
|
const [userA, userB] = await Promise.all([newUser(windowA, 'Alice'), newUser(windowC, 'Bob')]);
|
|
|
|
const [windowB] = await linkedDevice(userA.recoveryPhrase);
|
|
|
|
// Waiting for linked device to finish loading
|
|
|
|
await waitForLoadingAnimationToFinish(windowB, 'loading-spinner');
|
|
|
|
await createContact(windowA, windowC, userA, userB);
|
|
|
|
// Check linked device (windowB)
|
|
|
|
await waitForTestIdWithText(windowB, 'module-conversation__user__profile-name', userB.userName);
|
|
|
|
console.info('Contacts correctly synced');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Check deleted message syncs', async () => {
|
|
|
|
const [windowA, windowC] = await openApp(2);
|
|
|
|
const [userA, userB] = await Promise.all([newUser(windowA, 'Alice'), newUser(windowC, 'Bob')]);
|
|
|
|
const [windowB] = await linkedDevice(userA.recoveryPhrase);
|
|
|
|
const deletedMessage = 'Testing deletion functionality for linked device';
|
|
|
|
await waitForLoadingAnimationToFinish(windowB, 'loading-spinner');
|
|
|
|
await createContact(windowA, windowC, userA, userB);
|
|
|
|
await sendMessage(windowA, deletedMessage);
|
|
|
|
// Navigate to conversation on linked device and check for message from user A to user B
|
|
|
|
await clickOnTestIdWithText(windowB, 'module-conversation__user__profile-name', userB.userName);
|
|
|
|
await waitForTextMessage(windowB, deletedMessage);
|
|
|
|
await waitForTextMessage(windowC, deletedMessage);
|
|
|
|
await clickOnTestIdWithText(windowA, 'control-message', deletedMessage, true);
|
|
|
|
await clickOnMatchingText(windowA, 'Delete just for me');
|
|
|
|
await clickOnMatchingText(windowA, 'Delete');
|
|
|
|
await waitForTestIdWithText(windowA, 'session-toast', 'Deleted');
|
|
|
|
await hasTextElementBeenDeleted(windowA, deletedMessage, 1000);
|
|
|
|
// Check linked device for deleted message
|
|
|
|
// Waiting for message to be removed
|
|
|
|
await sleepFor(5000);
|
|
|
|
await hasTextElementBeenDeleted(windowB, deletedMessage, 1000);
|
|
|
|
// Still should exist for user B
|
|
|
|
await waitForMatchingText(windowC, deletedMessage);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Check unsent message syncs', async () => {
|
|
|
|
const [windowA, windowC] = await openApp(2);
|
|
|
|
const [userA, userB] = await Promise.all([newUser(windowA, 'Alice'), newUser(windowC, 'Bob')]);
|
|
|
|
const [windowB] = await linkedDevice(userA.recoveryPhrase);
|
|
|
|
const unsentMessage = 'Testing unsending functionality for linked device';
|
|
|
|
await waitForLoadingAnimationToFinish(windowB, 'loading-spinner');
|
|
|
|
await createContact(windowA, windowC, userA, userB);
|
|
|
|
await sendMessage(windowA, unsentMessage);
|
|
|
|
// Navigate to conversation on linked device and check for message from user A to user B
|
|
|
|
await clickOnTestIdWithText(windowB, 'module-conversation__user__profile-name', userB.userName);
|
|
|
|
await waitForTextMessage(windowB, unsentMessage);
|
|
|
|
await waitForTextMessage(windowC, unsentMessage);
|
|
|
|
await clickOnTestIdWithText(windowA, 'control-message', unsentMessage, true);
|
|
|
|
await clickOnMatchingText(windowA, 'Delete for everyone');
|
|
|
|
await clickOnElement(windowA, 'data-testid', 'session-confirm-ok-button');
|
|
|
|
await waitForTestIdWithText(windowA, 'session-toast', 'Deleted');
|
|
|
|
await hasTextElementBeenDeleted(windowA, unsentMessage, 1000);
|
|
|
|
await waitForMatchingText(windowC, 'This message has been deleted');
|
|
|
|
// Check linked device for deleted message
|
|
|
|
await hasTextElementBeenDeleted(windowB, unsentMessage, 1000);
|
|
|
|
});
|
|
|
|
|
|
|
|
// test('Check blocked user syncs', async () => {
|
|
|
|
// const [windowA, windowC] = await openApp(2);
|
|
|
|
// const [userA, userB] = await Promise.all([newUser(windowA, 'Alice'), newUser(windowC, 'Bob')]);
|
|
|
|
// const [windowB] = await linkedDevice(userA.recoveryPhrase);
|
|
|
|
// const testMessage = 'Testing blocking functionality for linked device';
|
|
|
|
// await waitForLoadingAnimationToFinish(windowB, 'loading-spinner');
|
|
|
|
// await createContact(windowA, windowC, userA, userB);
|
|
|
|
// await sendMessage(windowA, testMessage);
|
|
|
|
// // Navigate to conversation on linked device and check for message from user A to user B
|
|
|
|
// await clickOnTestIdWithText(windowB, 'module-conversation__user__profile-name', userB.userName);
|
|
|
|
// await clickOnElement(windowA, 'data-testid', 'three-dots-conversation-options');
|
|
|
|
// await clickOnMatchingText(windowA, 'Block');
|
|
|
|
// await waitForTestIdWithText(windowA, 'session-toast', 'Blocked');
|
|
|
|
// await waitForMatchingText(windowA, 'Unblock this contact to send a message.');
|
|
|
|
// // Check linked device for blocked contact in settings screen
|
|
|
|
// await clickOnTestIdWithText(windowB, 'settings-section');
|
|
|
|
// await clickOnTestIdWithText(windowB, 'conversations-settings-menu-item');
|
|
|
|
// await clickOnTestIdWithText(windowB, 'reveal-blocked-user-settings');
|
|
|
|
// // Check if user B is in blocked contact list
|
|
|
|
// await waitForMatchingText(windowB, userB.userName);
|
|
|
|
// });
|