diff --git a/playwright.config.ts b/playwright.config.ts index c7f1f5c..12c55cd 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -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); @@ -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 diff --git a/tests/automation/call_checks.spec.ts b/tests/automation/call_checks.spec.ts index 957c10a..ab38e22 100644 --- a/tests/automation/call_checks.spec.ts +++ b/tests/automation/call_checks.spec.ts @@ -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'); }, ); diff --git a/tests/automation/disappearing_message_checks.spec.ts b/tests/automation/disappearing_message_checks.spec.ts index fcad260..f18af71 100644 --- a/tests/automation/disappearing_message_checks.spec.ts +++ b/tests/automation/disappearing_message_checks.spec.ts @@ -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'; @@ -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(), + ), + ]); + }, +); diff --git a/tests/automation/message_checks.spec.ts b/tests/automation/message_checks.spec.ts index f472b55..82d96f7 100644 --- a/tests/automation/message_checks.spec.ts +++ b/tests/automation/message_checks.spec.ts @@ -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, - ), - ]); - }, -); diff --git a/tests/automation/types/testing.ts b/tests/automation/types/testing.ts index 8c1e5c6..c155e16 100644 --- a/tests/automation/types/testing.ts +++ b/tests/automation/types/testing.ts @@ -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'; diff --git a/tests/automation/utilities/reply_message.ts b/tests/automation/utilities/reply_message.ts index f6ed801..c3f827b 100644 --- a/tests/automation/utilities/reply_message.ts +++ b/tests/automation/utilities/reply_message.ts @@ -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(), diff --git a/tests/automation/utilities/voice_call.ts b/tests/automation/utilities/voice_call.ts new file mode 100644 index 0000000..7e9e6ba --- /dev/null +++ b/tests/automation/utilities/voice_call.ts @@ -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'); +};