|
|
|
@ -4,14 +4,13 @@ import { beforeAllClean } from './setup/beforeEach';
|
|
|
|
|
import { newUser } from './setup/new_user';
|
|
|
|
|
import { openApp } from './setup/open';
|
|
|
|
|
import { sendMessage } from './utilities/message';
|
|
|
|
|
import { sendNewMessage } from './utilities/send_message';
|
|
|
|
|
import {
|
|
|
|
|
clickOnMatchingText,
|
|
|
|
|
clickOnTestIdWithText,
|
|
|
|
|
waitForControlMessageWithText,
|
|
|
|
|
waitForMatchingText,
|
|
|
|
|
hasTextElementBeenDeleted,
|
|
|
|
|
waitForTestIdWithText,
|
|
|
|
|
} from './utilities/utils';
|
|
|
|
|
import { createContact } from './utilities/create_contact';
|
|
|
|
|
|
|
|
|
|
test.beforeEach(beforeAllClean);
|
|
|
|
|
|
|
|
|
@ -19,9 +18,9 @@ test.beforeEach(beforeAllClean);
|
|
|
|
|
// tslint:disable: no-console
|
|
|
|
|
|
|
|
|
|
const testMessage = 'Test-Message- (A -> B) ';
|
|
|
|
|
const testReply = 'Reply-Test-Message- (B -> A)';
|
|
|
|
|
// const testReply = 'Reply-Test-Message- (B -> A)';
|
|
|
|
|
const sentMessage = `${testMessage}${Date.now()}`;
|
|
|
|
|
const sentReplyMessage = `${testReply} :${Date.now()}`;
|
|
|
|
|
// const sentReplyMessage = `${testReply} :${Date.now()}`;
|
|
|
|
|
|
|
|
|
|
test('Disappearing messages', async () => {
|
|
|
|
|
// Open App
|
|
|
|
@ -29,11 +28,9 @@ test('Disappearing messages', async () => {
|
|
|
|
|
const [windowA, windowB] = await openApp(2);
|
|
|
|
|
const [userA, userB] = await Promise.all([newUser(windowA, 'Alice'), newUser(windowB, 'Bob')]);
|
|
|
|
|
// Create Contact
|
|
|
|
|
await sendNewMessage(windowA, userB.sessionid, sentMessage);
|
|
|
|
|
await sendNewMessage(windowB, userA.sessionid, sentReplyMessage);
|
|
|
|
|
await waitForControlMessageWithText(windowA, 'Your message request has been accepted');
|
|
|
|
|
// await waitForMatchingText(windowA, `You have accepted ${userA.userName}'s message request`);
|
|
|
|
|
// await waitForMatchingText(windowB, 'Your message request has been accepted');
|
|
|
|
|
await createContact(windowA, windowB, userA, userB);
|
|
|
|
|
// Need to wait for contact approval
|
|
|
|
|
await sleepFor(5000);
|
|
|
|
|
// Click on user's avatar to open conversation options
|
|
|
|
|
await clickOnTestIdWithText(windowA, 'conversation-options-avatar');
|
|
|
|
|
// Select disappearing messages drop down
|
|
|
|
@ -48,57 +45,21 @@ test('Disappearing messages', async () => {
|
|
|
|
|
'control-message',
|
|
|
|
|
'You set the disappearing message timer to 5 seconds'
|
|
|
|
|
);
|
|
|
|
|
await sleepFor(2000);
|
|
|
|
|
await waitForTestIdWithText(
|
|
|
|
|
windowB,
|
|
|
|
|
'control-message',
|
|
|
|
|
`${userA.userName} set the disappearing message timer to 5 seconds`
|
|
|
|
|
);
|
|
|
|
|
await sleepFor(500);
|
|
|
|
|
// Check top right hand corner indicator
|
|
|
|
|
|
|
|
|
|
await waitForTestIdWithText(windowA, 'disappearing-messages-indicator', '5 seconds');
|
|
|
|
|
// Send message
|
|
|
|
|
// Wait for tick of confirmation
|
|
|
|
|
await sendMessage(windowA, sentMessage);
|
|
|
|
|
// Check timer is functioning
|
|
|
|
|
|
|
|
|
|
await sleepFor(6000);
|
|
|
|
|
// Verify message is deleted
|
|
|
|
|
const errorDesc = 'Should not be found';
|
|
|
|
|
try {
|
|
|
|
|
const elemShouldNotBeFound = windowA.locator(sentMessage);
|
|
|
|
|
if (elemShouldNotBeFound) {
|
|
|
|
|
console.error('Sent message not found in window A');
|
|
|
|
|
throw new Error(errorDesc);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (e.message !== errorDesc) {
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Click on user's avatar for options
|
|
|
|
|
await clickOnTestIdWithText(windowA, 'conversation-options-avatar');
|
|
|
|
|
// Click on disappearing messages drop down
|
|
|
|
|
await clickOnMatchingText(windowA, 'Disappearing messages');
|
|
|
|
|
// Select off
|
|
|
|
|
await clickOnMatchingText(windowA, 'Off');
|
|
|
|
|
// Click chevron to close menu
|
|
|
|
|
await clickOnTestIdWithText(windowA, 'back-button-conversation-options');
|
|
|
|
|
// Check config message
|
|
|
|
|
await waitForTestIdWithText(windowA, 'control-message', 'You disabled disappearing messages.');
|
|
|
|
|
// Verify message is deleted in windowB for receiver user
|
|
|
|
|
// Check config message in windowB
|
|
|
|
|
await waitForMatchingText(
|
|
|
|
|
windowB,
|
|
|
|
|
`${userA.userName} set the disappearing message timer to 5 seconds`
|
|
|
|
|
);
|
|
|
|
|
// Wait 5 seconds
|
|
|
|
|
await waitForMatchingText(windowB, `${userA.userName} has turned off disappearing messages.`);
|
|
|
|
|
// verify message is deleted in windowB
|
|
|
|
|
const errorDesc2 = 'Should not be found';
|
|
|
|
|
try {
|
|
|
|
|
const elemShouldNotBeFound = windowA.locator(sentMessage);
|
|
|
|
|
if (elemShouldNotBeFound) {
|
|
|
|
|
console.error('Sent message not found in window B');
|
|
|
|
|
throw new Error(errorDesc2);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (e.message !== errorDesc2) {
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await hasTextElementBeenDeleted(windowA, sentMessage, 3000);
|
|
|
|
|
// focus window B
|
|
|
|
|
await clickOnTestIdWithText(windowB, "control-message", `${userA.userName} set the disappearing message timer to 5 seconds`);
|
|
|
|
|
await hasTextElementBeenDeleted(windowB, sentMessage, 4000);
|
|
|
|
|
});
|
|
|
|
|