Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disappearing messages call #16

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import { defineConfig } from '@playwright/test';
import { isEmpty, toNumber } from 'lodash';

import 'dotenv/config';
import dotenv from 'dotenv';

dotenv.config();

const useSessionReporter = !isEmpty(process.env.PLAYWRIGHT_CUSTOM_REPORTER);

Expand All @@ -23,7 +25,7 @@ export default defineConfig({
repeatEach: process.env.PLAYWRIGHT_REPEAT_COUNT
? toNumber(process.env.PLAYWRIGHT_REPEAT_COUNT)
: 0,
workers: toNumber(process.env.PLAYWRIGHT_WORKER_COUNT) || 1,
workers: toNumber(process.env.PLAYWRIGHT_WORKERS_COUNT) || 1,
reportSlowTests: null,
fullyParallel: true, // otherwise, tests in the same file are not run in parallel
globalSetup: './global.setup', // clean leftovers of previous test runs on start, runs only once
Expand Down
44 changes: 23 additions & 21 deletions tests/automation/call_checks.spec.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import { englishStrippedStr } from '../locale/localizedString';
import { sleepFor } from '../promise_utils';
import { test_Alice_1W_Bob_1W } from './setup/sessionTest';
import { createContact } from './utilities/create_contact';
import { clickOnMatchingText, clickOnTestIdWithText } from './utilities/utils';
import { waitForTestIdWithText } from './utilities/utils';
import { makeVoiceCall } from './utilities/voice_call';

test_Alice_1W_Bob_1W(
'Voice calls',
async ({ alice, aliceWindow1, bob, bobWindow1 }) => {
await createContact(aliceWindow1, bobWindow1, alice, bob);
await clickOnTestIdWithText(aliceWindow1, 'call-button');
await clickOnTestIdWithText(aliceWindow1, 'session-toast');
await clickOnTestIdWithText(aliceWindow1, 'enable-calls');
await clickOnTestIdWithText(aliceWindow1, 'session-confirm-ok-button');
await clickOnTestIdWithText(aliceWindow1, 'message-section');
await clickOnTestIdWithText(
aliceWindow1,
'module-conversation__user__profile-name',
bob.userName,
);
await clickOnTestIdWithText(aliceWindow1, 'call-button');
// Enable calls in window B
await clickOnTestIdWithText(bobWindow1, 'session-toast');
await clickOnTestIdWithText(bobWindow1, 'enable-calls');
await clickOnTestIdWithText(bobWindow1, 'session-confirm-ok-button');
await clickOnMatchingText(
await makeVoiceCall(aliceWindow1, bobWindow1, alice, bob);
// In the receivers window, the message is 'Call in progress'
await waitForTestIdWithText(
bobWindow1,
englishStrippedStr('accept').toString(),
'call-notification-answered-a-call',
englishStrippedStr('callsInProgress').toString(),
);
// Control message should be '{callerName} called you'
// await waitForTestIdWithText(
// bobWindow1,
// 'call-notification-answered-a-call',
// englishStrippedStr('callsCalledYou')
// .withArgs({ name: caller.userName })
// .toString(),
// );
// In the callers window, the message is 'You called {reciverName}'
await waitForTestIdWithText(
aliceWindow1,
'call-notification-started-call',
englishStrippedStr('callsYouCalled')
.withArgs({ name: bob.userName })
.toString(),
);
await sleepFor(5000);
await clickOnTestIdWithText(aliceWindow1, 'end-call');
},
);
74 changes: 74 additions & 0 deletions tests/automation/disappearing_message_checks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
waitForTestIdWithText,
waitForTextMessage,
} from './utilities/utils';
import { makeVoiceCall } from './utilities/voice_call';

// Disappearing time settings for all tests
const timeOption: DMTimeOption = 'time-option-30-seconds';
Expand Down Expand Up @@ -277,3 +278,76 @@ test_Alice_1W_Bob_1W(
]);
},
);

test_Alice_1W_Bob_1W(
`Send disappearing call message 1:1`,
async ({ alice, aliceWindow1, bob, bobWindow1 }) => {
await createContact(aliceWindow1, bobWindow1, alice, bob);
// Set disappearing messages
await setDisappearingMessages(
aliceWindow1,
['1:1', disappearingMessageType, timeOption, disappearAction],
bobWindow1,
);
await Promise.all([
waitForTestIdWithText(
aliceWindow1,
'disappear-control-message',
englishStrippedStr('disappearingMessagesSetYou')
.withArgs({
time: '30 seconds',
disappearing_messages_type: disappearAction,
})
.toString(),
),
waitForTestIdWithText(
bobWindow1,
'disappear-control-message',
englishStrippedStr('disappearingMessagesSet')
.withArgs({
time: '30 seconds',
disappearing_messages_type: disappearAction,
name: alice.userName,
})
.toString(),
),
]);
await makeVoiceCall(aliceWindow1, bobWindow1, alice, bob);
// In the receivers window, the message is 'Call in progress'
await Promise.all([
waitForTestIdWithText(
bobWindow1,
'call-notification-answered-a-call',
englishStrippedStr('callsInProgress').toString(),
),
// In the callers window, the message is 'You called {reciverName}'
waitForTestIdWithText(
aliceWindow1,
'call-notification-started-call',
englishStrippedStr('callsYouCalled')
.withArgs({ name: bob.userName })
.toString(),
),
]);
// Wait 30 seconds for call message to disappear
await sleepFor(30000);
await Promise.all([
hasElementBeenDeleted(
bobWindow1,
'data-testid',
'call-notification-answered-a-call',
undefined,
englishStrippedStr('callsInProgress').toString(),
),
hasElementBeenDeleted(
aliceWindow1,
'data-testid',
'call-notification-started-call',
undefined,
englishStrippedStr('callsYouCalled')
.withArgs({ name: bob.userName })
.toString(),
),
]);
},
);
63 changes: 0 additions & 63 deletions tests/automation/message_checks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,66 +245,3 @@ sessionTestTwoWindows(
console.log(timesArray);
},
);

test_Alice_1W_Bob_1W(
'Send link 1:1',
async ({ alice, aliceWindow1, bob, bobWindow1 }) => {
const testLink = 'https://getsession.org/';
const testReply = `${bob.userName} replying to link from ${alice.userName}`;

await createContact(aliceWindow1, bobWindow1, alice, bob);
await sendLinkPreview(aliceWindow1, testLink);
await waitForElement(
bobWindow1,
'class',
'module-message__link-preview__title',
undefined,
'Session | Send Messages, Not Metadata. | Private Messenger',
);
await replyTo({
senderWindow: bobWindow1,
textMessage: testLink,
replyText: testReply,
receiverWindow: aliceWindow1,
});
},
);

test_Alice_1W_Bob_1W(
'Send community invite',
async ({ alice, aliceWindow1, bob, bobWindow1 }) => {
await createContact(aliceWindow1, bobWindow1, alice, bob);
await joinCommunity(aliceWindow1);
await clickOnTestIdWithText(aliceWindow1, 'conversation-options-avatar');
await clickOnTestIdWithText(aliceWindow1, 'add-user-button');
await waitForTestIdWithText(
aliceWindow1,
'modal-heading',
englishStrippedStr('membersInvite').toString(),
);
await clickOnTestIdWithText(aliceWindow1, 'contact', bob.userName);
await clickOnTestIdWithText(aliceWindow1, 'session-confirm-ok-button');
await clickOnTestIdWithText(aliceWindow1, 'modal-close-button');
await clickOnTestIdWithText(
aliceWindow1,
'module-conversation__user__profile-name',
bob.userName,
);
await Promise.all([
waitForElement(
aliceWindow1,
'class',
'group-name',
undefined,
testCommunityName,
),
waitForElement(
bobWindow1,
'class',
'group-name',
undefined,
testCommunityName,
),
]);
},
);
4 changes: 3 additions & 1 deletion tests/automation/types/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,6 @@ export type DataTestId =
| 'copy-button-account-id'
| 'link-preview-title'
| 'link-preview-image'
| 'audio-player';
| 'audio-player'
| 'call-notification-answered-a-call'
| 'call-notification-started-call';
2 changes: 1 addition & 1 deletion tests/automation/utilities/reply_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const replyToMedia = async ({
for (let index = 0; index < 5; index++) {
try {
await selc.click({ button: 'right' });
await sleepFor(100);
await sleepFor(200);
await clickOnMatchingText(
senderWindow,
englishStrippedStr('reply').toString(),
Expand Down
54 changes: 54 additions & 0 deletions tests/automation/utilities/voice_call.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Page } from '@playwright/test';
import { englishStrippedStr } from '../../locale/localizedString';
import { sleepFor } from '../../promise_utils';
import { User } from '../types/testing';
import {
checkModalStrings,
clickOnMatchingText,
clickOnTestIdWithText,
} from './utils';

export const makeVoiceCall = async (
callerWindow: Page,
receiverWindow: Page,
caller: User,
receiver: User,
) => {
await clickOnTestIdWithText(callerWindow, 'call-button');
await clickOnTestIdWithText(callerWindow, 'session-toast');
await clickOnTestIdWithText(callerWindow, 'enable-calls');
await checkModalStrings(
callerWindow,
englishStrippedStr('callsVoiceAndVideoBeta').toString(),
englishStrippedStr('callsVoiceAndVideoModalDescription').toString(),
);
await clickOnTestIdWithText(callerWindow, 'session-confirm-ok-button');
await clickOnTestIdWithText(callerWindow, 'message-section');
await clickOnTestIdWithText(
callerWindow,
'module-conversation__user__profile-name',
receiver.userName,
);
await clickOnTestIdWithText(callerWindow, 'call-button');
// Enable calls in window B
await clickOnTestIdWithText(receiverWindow, 'session-toast');
await clickOnTestIdWithText(receiverWindow, 'enable-calls');
await checkModalStrings(
receiverWindow,
englishStrippedStr('callsVoiceAndVideoBeta').toString(),
englishStrippedStr('callsVoiceAndVideoModalDescription').toString(),
);
await clickOnTestIdWithText(receiverWindow, 'session-confirm-ok-button');
await clickOnMatchingText(
receiverWindow,
englishStrippedStr('accept').toString(),
);
await clickOnTestIdWithText(receiverWindow, 'message-section');
await clickOnTestIdWithText(
receiverWindow,
'module-conversation__user__profile-name',
caller.userName,
);
await sleepFor(5000);
await clickOnTestIdWithText(callerWindow, 'end-call');
};