diff --git a/tests/automation/call_checks.spec.ts b/tests/automation/call_checks.spec.ts index 7e712f6..9c77e6a 100644 --- a/tests/automation/call_checks.spec.ts +++ b/tests/automation/call_checks.spec.ts @@ -1,4 +1,4 @@ -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { Global, HomeScreen } from './locators'; import { test_Alice_1W_Bob_1W } from './setup/sessionTest'; import { createContact } from './utilities/create_contact'; @@ -22,13 +22,13 @@ test_Alice_1W_Bob_1W( await waitForTestIdWithText( bobWindow1, 'call-notification-answered-a-call', - englishStrippedStr('callsInProgress').toString(), + tStripped('callsInProgress'), ); // Control message should be '{callerName} called you' // await waitForTestIdWithText( // bobWindow1, // 'call-notification-answered-a-call', - // englishStrippedStr('callsCalledYou') + // tStripped('callsCalledYou') // .withArgs({ name: caller.userName }) // .toString(), // ); @@ -36,9 +36,7 @@ test_Alice_1W_Bob_1W( await waitForTestIdWithText( aliceWindow1, 'call-notification-started-call', - englishStrippedStr('callsYouCalled') - .withArgs({ name: bob.userName }) - .toString(), + tStripped('callsYouCalled', { name: bob.userName }), ); }, ); diff --git a/tests/automation/community_tests.spec.ts b/tests/automation/community_tests.spec.ts index c1adceb..2dc1edb 100644 --- a/tests/automation/community_tests.spec.ts +++ b/tests/automation/community_tests.spec.ts @@ -1,4 +1,4 @@ -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { testCommunityName } from './constants/community'; import { Conversation, Global, HomeScreen } from './locators'; import { newUser } from './setup/new_user'; @@ -26,8 +26,8 @@ import { waitForTestIdWithText, } from './utilities/utils'; -const banUserString = englishStrippedStr('banUser').toString(); -const unbanUserString = englishStrippedStr('banUnbanUser').toString(); +const banUserString = tStripped('banUser'); +const unbanUserString = tStripped('banUnbanUser'); test_Alice_2W( 'Join community and sync', diff --git a/tests/automation/cta_donations.spec.ts b/tests/automation/cta_donations.spec.ts index 23f31d4..3db3df6 100644 --- a/tests/automation/cta_donations.spec.ts +++ b/tests/automation/cta_donations.spec.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test'; -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { CTA, Global } from './locators'; import { test_Alice_1W } from './setup/sessionTest'; import { mockDBCreationTime } from './utilities/time_travel'; @@ -15,12 +15,9 @@ import { async function verifyDonateCTAShows(window: Page) { await checkCTAStrings( window, - englishStrippedStr('donateSessionHelp').toString(), - englishStrippedStr('donateSessionDescription').toString(), - [ - englishStrippedStr('donate').toString(), - englishStrippedStr('maybeLater').toString(), - ], + tStripped('donateSessionHelp'), + tStripped('donateSessionDescription'), + [tStripped('donate'), tStripped('maybeLater')], ); } @@ -63,8 +60,8 @@ urlModalButtons.forEach(({ button, name }) => { await clickOn(aliceWindow1, CTA.confirmButton); await checkModalStrings( aliceWindow1, - englishStrippedStr('urlOpen').toString(), - englishStrippedStr('urlOpenDescription').withArgs({ url }).toString(), + tStripped('urlOpen'), + tStripped('urlOpenDescription', { url }), 'openUrlModal', ); diff --git a/tests/automation/delete_account.spec.ts b/tests/automation/delete_account.spec.ts index d56da62..630ecdb 100644 --- a/tests/automation/delete_account.spec.ts +++ b/tests/automation/delete_account.spec.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test'; -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { sleepFor } from '../promise_utils'; import { Global, HomeScreen, LeftPane, Onboarding, Settings } from './locators'; import { forceCloseAllWindows } from './setup/closeWindows'; @@ -43,23 +43,17 @@ sessionTestTwoWindows( await clickOnWithText( windowA, Settings.clearDataMenuItem, - englishStrippedStr('sessionClearData').toString(), + tStripped('sessionClearData'), ); // Select entire account await clickOnWithText( windowA, Settings.clearDeviceAndNetworkRadial, - englishStrippedStr('clearDeviceAndNetwork').toString(), + tStripped('clearDeviceAndNetwork'), ); // Confirm deletion by clicking Clear, twice - await clickOnMatchingText( - windowA, - englishStrippedStr('clear').toString(), - ); - await clickOnMatchingText( - windowA, - englishStrippedStr('clear').toString(), - ); + await clickOnMatchingText(windowA, tStripped('clear')); + await clickOnMatchingText(windowA, tStripped('clear')); await waitForLoadingAnimationToFinish( windowA, Global.loadingSpinner.selector, @@ -136,18 +130,12 @@ sessionTestTwoWindows( await clickOnWithText( windowA, Settings.clearDataMenuItem, - englishStrippedStr('sessionClearData').toString(), + tStripped('sessionClearData'), ); // Keep 'Clear Device only' selection // Confirm deletion by clicking Clear, twice - await clickOnMatchingText( - windowA, - englishStrippedStr('clear').toString(), - ); - await clickOnMatchingText( - windowA, - englishStrippedStr('clear').toString(), - ); + await clickOnMatchingText(windowA, tStripped('clear')); + await clickOnMatchingText(windowA, tStripped('clear')); restoringWindows = await openApp(1); const [restoringWindow] = restoringWindows; // Sign in with deleted account and check that nothing restores diff --git a/tests/automation/disappearing_message_checks.spec.ts b/tests/automation/disappearing_message_checks.spec.ts index 4305e12..ee33f76 100644 --- a/tests/automation/disappearing_message_checks.spec.ts +++ b/tests/automation/disappearing_message_checks.spec.ts @@ -1,4 +1,4 @@ -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { sleepFor } from '../promise_utils'; import { testCommunityName } from './constants/community'; import { @@ -60,23 +60,19 @@ mediaArray.forEach( waitForTestIdWithText( aliceWindow1, Conversation.disappearingControlMessage.selector, - englishStrippedStr('disappearingMessagesSetYou') - .withArgs({ - time: formattedTime, - disappearing_messages_type: disappearAction, - }) - .toString(), + tStripped('disappearingMessagesSetYou', { + time: formattedTime, + disappearing_messages_type: disappearAction, + }), ), waitForTestIdWithText( bobWindow1, Conversation.disappearingControlMessage.selector, - englishStrippedStr('disappearingMessagesSet') - .withArgs({ - time: formattedTime, - disappearing_messages_type: disappearAction, - name: alice.userName, - }) - .toString(), + tStripped('disappearingMessagesSet', { + time: formattedTime, + disappearing_messages_type: disappearAction, + name: alice.userName, + }), ), ]); // Send media @@ -128,23 +124,19 @@ test_Alice_1W_Bob_1W( waitForTestIdWithText( aliceWindow1, Conversation.disappearingControlMessage.selector, - englishStrippedStr('disappearingMessagesSetYou') - .withArgs({ - time: formattedTime, - disappearing_messages_type: disappearAction, - }) - .toString(), + tStripped('disappearingMessagesSetYou', { + time: formattedTime, + disappearing_messages_type: disappearAction, + }), ), waitForTestIdWithText( bobWindow1, Conversation.disappearingControlMessage.selector, - englishStrippedStr('disappearingMessagesSet') - .withArgs({ - time: formattedTime, - disappearing_messages_type: disappearAction, - name: alice.userName, - }) - .toString(), + tStripped('disappearingMessagesSet', { + time: formattedTime, + disappearing_messages_type: disappearAction, + name: alice.userName, + }), ), ]); await typeIntoInput(aliceWindow1, 'message-input-text-area', longText); @@ -173,23 +165,19 @@ test_Alice_1W_Bob_1W( waitForTestIdWithText( aliceWindow1, Conversation.disappearingControlMessage.selector, - englishStrippedStr('disappearingMessagesSetYou') - .withArgs({ - time: formattedTime, - disappearing_messages_type: disappearAction, - }) - .toString(), + tStripped('disappearingMessagesSetYou', { + time: formattedTime, + disappearing_messages_type: disappearAction, + }), ), waitForTestIdWithText( bobWindow1, Conversation.disappearingControlMessage.selector, - englishStrippedStr('disappearingMessagesSet') - .withArgs({ - time: formattedTime, - disappearing_messages_type: disappearAction, - name: alice.userName, - }) - .toString(), + tStripped('disappearingMessagesSet', { + time: formattedTime, + disappearing_messages_type: disappearAction, + name: alice.userName, + }), ), ]); await sendLinkPreview(aliceWindow1, testLink); @@ -227,23 +215,19 @@ test_Alice_1W_Bob_1W( waitForTestIdWithText( aliceWindow1, Conversation.disappearingControlMessage.selector, - englishStrippedStr('disappearingMessagesSetYou') - .withArgs({ - time: formattedTime, - disappearing_messages_type: disappearAction, - }) - .toString(), + tStripped('disappearingMessagesSetYou', { + time: formattedTime, + disappearing_messages_type: disappearAction, + }), ), waitForTestIdWithText( bobWindow1, Conversation.disappearingControlMessage.selector, - englishStrippedStr('disappearingMessagesSet') - .withArgs({ - time: formattedTime, - disappearing_messages_type: disappearAction, - name: alice.userName, - }) - .toString(), + tStripped('disappearingMessagesSet', { + time: formattedTime, + disappearing_messages_type: disappearAction, + name: alice.userName, + }), ), ]); await joinCommunity(aliceWindow1); @@ -254,7 +238,7 @@ test_Alice_1W_Bob_1W( await waitForTestIdWithText( aliceWindow1, 'modal-heading', - englishStrippedStr('membersInvite').toString(), + tStripped('membersInvite'), ); await clickOnWithText(aliceWindow1, Global.contactItem, bob.userName); await clickOn(aliceWindow1, Global.confirmButton); @@ -321,23 +305,19 @@ test_Alice_1W_Bob_1W( waitForTestIdWithText( aliceWindow1, Conversation.disappearingControlMessage.selector, - englishStrippedStr('disappearingMessagesSetYou') - .withArgs({ - time: formattedTime, - disappearing_messages_type: disappearAction, - }) - .toString(), + tStripped('disappearingMessagesSetYou', { + time: formattedTime, + disappearing_messages_type: disappearAction, + }), ), waitForTestIdWithText( bobWindow1, Conversation.disappearingControlMessage.selector, - englishStrippedStr('disappearingMessagesSet') - .withArgs({ - time: formattedTime, - disappearing_messages_type: disappearAction, - name: alice.userName, - }) - .toString(), + tStripped('disappearingMessagesSet', { + time: formattedTime, + disappearing_messages_type: disappearAction, + name: alice.userName, + }), ), ]); await makeVoiceCall(aliceWindow1, bobWindow1); @@ -346,15 +326,13 @@ test_Alice_1W_Bob_1W( waitForTestIdWithText( bobWindow1, 'call-notification-answered-a-call', - englishStrippedStr('callsInProgress').toString(), + tStripped('callsInProgress'), ), // In the callers window, the message is 'You called {reciverName}' waitForTestIdWithText( aliceWindow1, 'call-notification-started-call', - englishStrippedStr('callsYouCalled') - .withArgs({ name: bob.userName }) - .toString(), + tStripped('callsYouCalled', { name: bob.userName }), ), ]); // Wait 30 seconds for call message to disappear @@ -365,16 +343,14 @@ test_Alice_1W_Bob_1W( 'data-testid', 'call-notification-answered-a-call', undefined, - englishStrippedStr('callsInProgress').toString(), + tStripped('callsInProgress'), ), hasElementBeenDeleted( aliceWindow1, 'data-testid', 'call-notification-started-call', undefined, - englishStrippedStr('callsYouCalled') - .withArgs({ name: bob.userName }) - .toString(), + tStripped('callsYouCalled', { name: bob.userName }), ), ]); }, diff --git a/tests/automation/disappearing_messages.spec.ts b/tests/automation/disappearing_messages.spec.ts index a173ac2..9d5abff 100644 --- a/tests/automation/disappearing_messages.spec.ts +++ b/tests/automation/disappearing_messages.spec.ts @@ -1,4 +1,4 @@ -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { sleepFor } from '../promise_utils'; import { defaultDisappearingOptions } from './constants/variables'; import { Conversation, HomeScreen } from './locators'; @@ -33,14 +33,10 @@ test_Alice_2W_Bob_1W( const formattedTime = formatTimeOption(timeOption); const testMessage = 'Testing disappearing messages timer is working correctly'; - const controlMessage = englishStrippedStr('disappearingMessagesSetYou') - .withArgs({ - time: formattedTime, - disappearing_messages_type: englishStrippedStr( - 'disappearingMessagesTypeRead', - ).toString(), - }) - .toString(); + const controlMessage = tStripped('disappearingMessagesSetYou', { + time: formattedTime, + disappearing_messages_type: tStripped('disappearingMessagesTypeRead'), + }); // Create Contact await createContact(aliceWindow1, bobWindow1, alice, bob); // Click on conversation in linked device @@ -92,14 +88,10 @@ test_Alice_2W_Bob_1W( const formattedTime = formatTimeOption(timeOption); const testMessage = 'Testing disappearing messages timer is working correctly'; - const controlMessage = englishStrippedStr('disappearingMessagesSetYou') - .withArgs({ - time: formattedTime, - disappearing_messages_type: englishStrippedStr( - 'disappearingMessagesTypeSent', - ).toString(), - }) - .toString(); + const controlMessage = tStripped('disappearingMessagesSetYou', { + time: formattedTime, + disappearing_messages_type: tStripped('disappearingMessagesTypeSent'), + }); // Create Contact await createContact(aliceWindow1, bobWindow1, alice, bob); @@ -148,14 +140,10 @@ test_group_Alice_2W_Bob_1W_Charlie_1W( const { timeOption, disappearingMessagesType, disappearAction } = defaultDisappearingOptions.group; const formattedTime = formatTimeOption(timeOption); - const controlMessage = englishStrippedStr('disappearingMessagesSetYou') - .withArgs({ - time: formattedTime, - disappearing_messages_type: englishStrippedStr( - 'disappearingMessagesTypeSent', - ).toString(), - }) - .toString(); + const controlMessage = tStripped('disappearingMessagesSetYou', { + time: formattedTime, + disappearing_messages_type: tStripped('disappearingMessagesTypeSent'), + }); const testMessage = 'Testing disappearing messages in groups'; await clickOnWithText( @@ -200,21 +188,17 @@ test_Alice_2W( const testMessage = 'Message to test note to self'; const testMessageDisappear = 'Message testing disappearing messages'; const formattedTime = formatTimeOption(timeOption); - const controlMessage = englishStrippedStr('disappearingMessagesSetYou') - .withArgs({ - time: formattedTime, - disappearing_messages_type: englishStrippedStr( - 'disappearingMessagesTypeSent', - ).toString(), - }) - .toString(); + const controlMessage = tStripped('disappearingMessagesSetYou', { + time: formattedTime, + disappearing_messages_type: tStripped('disappearingMessagesTypeSent'), + }); // Open Note to self conversation await sendNewMessage(aliceWindow1, alice.accountid, testMessage); // Check messages are syncing across linked devices await clickOnWithText( aliceWindow2, HomeScreen.conversationItemName, - englishStrippedStr('noteToSelf').toString(), + tStripped('noteToSelf'), ); await waitForTextMessage(aliceWindow2, testMessage); // Enable disappearing messages @@ -260,14 +244,10 @@ test_Alice_2W_Bob_1W( bobWindow1, ); // Check control message is visible and correct - const controlMessage = englishStrippedStr('disappearingMessagesSetYou') - .withArgs({ - time: formattedTime, - disappearing_messages_type: englishStrippedStr( - 'disappearingMessagesTypeSent', - ).toString(), - }) - .toString(); + const controlMessage = tStripped('disappearingMessagesSetYou', { + time: formattedTime, + disappearing_messages_type: tStripped('disappearingMessagesTypeSent'), + }); await Promise.all([ waitForTestIdWithText( aliceWindow1, @@ -282,15 +262,11 @@ test_Alice_2W_Bob_1W( waitForTestIdWithText( bobWindow1, 'disappear-control-message', - englishStrippedStr('disappearingMessagesSet') - .withArgs({ - name: alice.userName, - time: formattedTime, - disappearing_messages_type: englishStrippedStr( - 'disappearingMessagesTypeSent', - ).toString(), - }) - .toString(), + tStripped('disappearingMessagesSet', { + name: alice.userName, + time: formattedTime, + disappearing_messages_type: tStripped('disappearingMessagesTypeSent'), + }), ), ]); await sendMessage(aliceWindow1, testMessage); @@ -321,7 +297,7 @@ test_Alice_2W_Bob_1W( // Select Follow setting in Bob's window await clickOnMatchingText( bobWindow1, - englishStrippedStr('disappearingMessagesFollowSetting').toString(), + tStripped('disappearingMessagesFollowSetting'), ); await clickOnElement({ window: bobWindow1, @@ -334,38 +310,32 @@ test_Alice_2W_Bob_1W( waitForTestIdWithText( aliceWindow1, 'disappear-control-message', - englishStrippedStr('disappearingMessagesTurnedOffYou').toString(), + tStripped('disappearingMessagesTurnedOffYou'), ), waitForTestIdWithText( aliceWindow1, 'disappear-control-message', - englishStrippedStr('disappearingMessagesTurnedOff') - .withArgs({ name: bob.userName }) - .toString(), + tStripped('disappearingMessagesTurnedOff', { name: bob.userName }), ), waitForTestIdWithText( aliceWindow2, 'disappear-control-message', - englishStrippedStr('disappearingMessagesTurnedOffYou').toString(), + tStripped('disappearingMessagesTurnedOffYou'), ), waitForTestIdWithText( aliceWindow2, 'disappear-control-message', - englishStrippedStr('disappearingMessagesTurnedOff') - .withArgs({ name: bob.userName }) - .toString(), + tStripped('disappearingMessagesTurnedOff', { name: bob.userName }), ), waitForTestIdWithText( bobWindow1, 'disappear-control-message', - englishStrippedStr('disappearingMessagesTurnedOff') - .withArgs({ name: alice.userName }) - .toString(), + tStripped('disappearingMessagesTurnedOff', { name: alice.userName }), ), waitForTestIdWithText( bobWindow1, 'disappear-control-message', - englishStrippedStr('disappearingMessagesTurnedOffYou').toString(), + tStripped('disappearingMessagesTurnedOffYou'), ), ]); await Promise.all([ diff --git a/tests/automation/enforce_localized_str.spec.ts b/tests/automation/enforce_localized_str.spec.ts index 92a3e3a..187d98e 100644 --- a/tests/automation/enforce_localized_str.spec.ts +++ b/tests/automation/enforce_localized_str.spec.ts @@ -2,7 +2,7 @@ import { test } from '@playwright/test'; import * as fs from 'fs'; import * as path from 'path'; -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { isPluralToken, MergedLocalizerTokens, @@ -39,7 +39,7 @@ function readTsFiles(dir: string): Record { } function extractAllTokens(text: string) { - const pattern = /englishStrippedStr\(\s*'([^']*)'\s*\)/g; + const pattern = /tStripped\(\s*'([^']*)'\s*\)/g; const matches = [...text.matchAll(pattern)]; @@ -303,6 +303,18 @@ function getExpectedStringFromKey( return 'Ban User'; case 'banUnbanUser': return 'Unban User'; + case 'recoveryPasswordErrorMessageIncorrect': + return 'Some of the words in your Recovery Password are incorrect. Please check and try again.'; + case 'recoveryPasswordErrorMessageShort': + return 'The Recovery Password you entered is not long enough. Please check and try again.'; + case 'recoveryPasswordErrorMessageGeneric': + return 'Please check your recovery password and try again.'; + case 'displayNameErrorDescriptionShorter': + return 'Please enter a shorter display name'; + case 'proFeatureListLongerMessages': + return 'Messages up to 10,000 characters'; + case 'proFeatureListPinnedConversations': + return 'Pin unlimited conversations'; default: // returning null means we don't have an expected string yet for this key. // This will make the test fail @@ -335,9 +347,7 @@ test('Enforce localized strings return expected values', () => { const count = counts[countIndex]; const expectedStr = getExpectedStringFromKey({ key: token, count }); - const foundStr = englishStrippedStr(token) - .withArgs({ count }) - .toString(); + const foundStr = tStripped(token, { count }); if (!expectedStr) { unknownKeys.push(token); return; @@ -348,7 +358,7 @@ test('Enforce localized strings return expected values', () => { } } else { const expectedStr = getExpectedStringFromKey({ key: token }); - const foundStr = englishStrippedStr(token).toString(); + const foundStr = tStripped(token as TokenSimpleNoArgs); if (!expectedStr) { unknownKeys.push(token); continue; diff --git a/tests/automation/group_testing.spec.ts b/tests/automation/group_testing.spec.ts index 0557271..9a21278 100644 --- a/tests/automation/group_testing.spec.ts +++ b/tests/automation/group_testing.spec.ts @@ -1,4 +1,4 @@ -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { doForAll, sleepFor } from '../promise_utils'; import { Conversation, @@ -81,10 +81,7 @@ test_group_Alice_1W_Bob_1W_Charlie_1W_Dracula_1W( // Waiting for animation of right panel to appear await sleepFor(1000); await clickOnMatchingText(aliceWindow1, dracula.userName); - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('membersInviteTitle').toString(), - ); + await clickOnMatchingText(aliceWindow1, tStripped('membersInviteTitle')); // even if Bob and Charlie do not know Dracula's name, // Alice sets Dracula's name in the group members that every one will use as a fallback await doForAll( @@ -92,9 +89,7 @@ test_group_Alice_1W_Bob_1W_Charlie_1W_Dracula_1W( return waitForTestIdWithText( w, 'group-update-message', - englishStrippedStr('groupMemberNew') - .withArgs({ name: dracula.userName }) - .toString(), + tStripped('groupMemberNew', { name: dracula.userName }), ); }, [aliceWindow1, bobWindow1, charlieWindow1], @@ -112,7 +107,7 @@ test_group_Alice_1W_Bob_1W_Charlie_1W( 'Change group name', async ({ aliceWindow1, bobWindow1, charlieWindow1, groupCreated }) => { const newGroupName = 'New group name'; - const expectedError = englishStrippedStr('groupNameEnterPlease').toString(); + const expectedError = tStripped('groupNameEnterPlease'); // Change the name of the group and check that it syncs to all devices (config messages) // Click on already created group // Check that renaming a group is working @@ -121,16 +116,12 @@ test_group_Alice_1W_Bob_1W_Charlie_1W( await clickOnMatchingText(bobWindow1, newGroupName); await waitForMatchingText( bobWindow1, - englishStrippedStr('groupNameNew') - .withArgs({ group_name: newGroupName }) - .toString(), + tStripped('groupNameNew', { group_name: newGroupName }), ); await clickOnMatchingText(charlieWindow1, newGroupName); await waitForMatchingText( charlieWindow1, - englishStrippedStr('groupNameNew') - .withArgs({ group_name: newGroupName }) - .toString(), + tStripped('groupNameNew', { group_name: newGroupName }), ); // Click on conversation options // Check to see that you can't change group name to empty string @@ -149,10 +140,7 @@ test_group_Alice_1W_Bob_1W_Charlie_1W( `Expected error message: ${expectedError}, but got: ${actualError}`, ); } - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('cancel').toString(), - ); + await clickOnMatchingText(aliceWindow1, tStripped('cancel')); await clickOn(aliceWindow1, Global.modalCloseButton); }, ); @@ -238,16 +226,12 @@ test_group_Alice_1W_Bob_1W_Charlie_1W( waitForTestIdWithText( aliceWindow1, 'group-update-message', - englishStrippedStr('groupMemberLeft') - .withArgs({ name: charlie.userName }) - .toString(), + tStripped('groupMemberLeft', { name: charlie.userName }), ), waitForTestIdWithText( bobWindow1, 'group-update-message', - englishStrippedStr('groupMemberLeft') - .withArgs({ name: charlie.userName }) - .toString(), + tStripped('groupMemberLeft', { name: charlie.userName }), ), ]); }, diff --git a/tests/automation/input_validations.spec.ts b/tests/automation/input_validations.spec.ts index d8f7fd4..4eae49e 100644 --- a/tests/automation/input_validations.spec.ts +++ b/tests/automation/input_validations.spec.ts @@ -1,4 +1,4 @@ -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { Global, Onboarding } from './locators'; import { sessionTestOneWindow } from './setup/sessionTest'; import { @@ -14,25 +14,19 @@ import { // the word 'zork' is not on the mnemonic word list which triggers the expected error incorrectSeed: 'ruby bakery illness push rift reef nabbing bawled hope zork silk lobster hope', - expectedError: englishStrippedStr( - 'recoveryPasswordErrorMessageIncorrect', - ).toString(), + expectedError: tStripped('recoveryPasswordErrorMessageIncorrect'), }, { testName: 'Too short seed', incorrectSeed: 'zork', - expectedError: englishStrippedStr( - 'recoveryPasswordErrorMessageShort', - ).toString(), + expectedError: tStripped('recoveryPasswordErrorMessageShort'), }, { testName: 'Wrong seed', // the seed phrase is too long but contains only valid mnemonics which triggers the generic error incorrectSeed: 'ruby bakery illness push rift reef nabbing bawled hope ruby silk lobster hope ruby ruby ruby', - expectedError: englishStrippedStr( - 'recoveryPasswordErrorMessageGeneric', - ).toString(), + expectedError: tStripped('recoveryPasswordErrorMessageGeneric'), }, ].forEach(({ testName, incorrectSeed, expectedError }) => { sessionTestOneWindow(`Seed validation: "${testName}"`, async ([window]) => { @@ -58,15 +52,13 @@ import { testName: 'No name', // This currently fails - displays wrong error message displayName: ' ', - expectedError: englishStrippedStr('displayNameErrorDescription').toString(), + expectedError: tStripped('displayNameErrorDescription'), }, { testName: 'Too long name', displayName: 'One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed int', - expectedError: englishStrippedStr( - 'displayNameErrorDescriptionShorter', - ).toString(), + expectedError: tStripped('displayNameErrorDescriptionShorter'), }, ].forEach(({ testName, displayName, expectedError }) => { sessionTestOneWindow( diff --git a/tests/automation/landing_page.spec.ts b/tests/automation/landing_page.spec.ts index 9338ec4..a06c9bf 100644 --- a/tests/automation/landing_page.spec.ts +++ b/tests/automation/landing_page.spec.ts @@ -1,4 +1,4 @@ -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { test_Alice_2W } from './setup/sessionTest'; import { hasElementPoppedUpThatShouldnt, @@ -16,12 +16,12 @@ test_Alice_2W( // Check that the account created has all the required strings displayed await Promise.all( [ - englishStrippedStr('onboardingAccountCreated'), - englishStrippedStr('onboardingBubbleWelcomeToSession').withArgs({ + tStripped('onboardingAccountCreated'), + tStripped('onboardingBubbleWelcomeToSession', { emoji: '👋', }), - englishStrippedStr('conversationsNone'), - englishStrippedStr('onboardingHitThePlusButton'), + tStripped('conversationsNone'), + tStripped('onboardingHitThePlusButton'), ].map(async (builder) => waitForElement( aliceWindow1, @@ -36,8 +36,8 @@ test_Alice_2W( // Check that the account restored has all the required strings displayed await Promise.all( [ - englishStrippedStr('conversationsNone'), - englishStrippedStr('onboardingHitThePlusButton'), + tStripped('conversationsNone'), + tStripped('onboardingHitThePlusButton'), ].map(async (builder) => waitForElement( aliceWindow2, @@ -52,8 +52,8 @@ test_Alice_2W( // Make sure the "account created" part is not visible on the restored window await Promise.all( [ - englishStrippedStr('onboardingAccountCreated'), - englishStrippedStr('onboardingBubbleWelcomeToSession').withArgs({ + tStripped('onboardingAccountCreated'), + tStripped('onboardingBubbleWelcomeToSession', { emoji: '👋', }), ].map(async (builder) => diff --git a/tests/automation/linked_device_group.spec.ts b/tests/automation/linked_device_group.spec.ts index 1d14063..44aaf96 100644 --- a/tests/automation/linked_device_group.spec.ts +++ b/tests/automation/linked_device_group.spec.ts @@ -1,6 +1,6 @@ import type { Page } from '@playwright/test'; -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { Conversation, ConversationSettings, @@ -54,11 +54,9 @@ test_group_Alice_2W_Bob_1W_Charlie_1W( await waitForTestIdWithText( aliceWindow1, 'group-update-message', - englishStrippedStr('groupMemberLeft') - .withArgs({ - name: charlie.userName, - }) - .toString(), + tStripped('groupMemberLeft', { + name: charlie.userName, + }), ); // Check for linked device (userA) await clickOnWithText( @@ -69,21 +67,17 @@ test_group_Alice_2W_Bob_1W_Charlie_1W( await waitForTestIdWithText( aliceWindow2, 'group-update-message', - englishStrippedStr('groupMemberLeft') - .withArgs({ - name: charlie.userName, - }) - .toString(), + tStripped('groupMemberLeft', { + name: charlie.userName, + }), ); // Check for user B await waitForTestIdWithText( bobWindow1, 'group-update-message', - englishStrippedStr('groupMemberLeft') - .withArgs({ - name: charlie.userName, - }) - .toString(), + tStripped('groupMemberLeft', { + name: charlie.userName, + }), ); }, ); @@ -121,14 +115,14 @@ test_group_Alice_1W_Bob_1W_Charlie_1W( await waitForTestIdWithText( aliceWindow2, 'modal-heading', - englishStrippedStr('manageMembers').toString(), + tStripped('manageMembers'), ); // Check for You, Bob and Charlie await Promise.all([ waitForTestIdWithText( aliceWindow2, Global.contactItem.selector, - englishStrippedStr('you').toString(), + tStripped('you'), ), waitForTestIdWithText( aliceWindow2, @@ -150,26 +144,22 @@ async function clearDataOnWindow(window: Page) { await clickOnWithText( window, Settings.clearDataMenuItem, - englishStrippedStr('sessionClearData').toString(), + tStripped('sessionClearData'), ); await checkModalStrings( window, - englishStrippedStr('clearDataAll').toString(), - englishStrippedStr('clearDataAllDescription').toString(), + tStripped('clearDataAll'), + tStripped('clearDataAllDescription'), 'deleteAccountModal', ); - await clickOnWithText( - window, - Global.confirmButton, - englishStrippedStr('clear').toString(), - ); + await clickOnWithText(window, Global.confirmButton, tStripped('clear')); await checkModalStrings( window, - englishStrippedStr('clearDataAll').toString(), - englishStrippedStr('clearDeviceDescription').toString(), + tStripped('clearDataAll'), + tStripped('clearDeviceDescription'), 'deleteAccountModal', ); - await clickOnMatchingText(window, englishStrippedStr('clear').toString()); + await clickOnMatchingText(window, tStripped('clear')); } // Delete device data > Restore account @@ -206,7 +196,7 @@ test_group_Alice_1W_Bob_1W_Charlie_1W( waitForTestIdWithText( aliceWindow2, Global.contactItem.selector, - englishStrippedStr('you').toString(), + tStripped('you'), ), waitForTestIdWithText( aliceWindow2, @@ -251,7 +241,7 @@ test_group_Alice_1W_Bob_1W_Charlie_1W( waitForTestIdWithText( restoredWindow, Global.contactItem.selector, - englishStrippedStr('you').toString(), + tStripped('you'), ), waitForTestIdWithText( restoredWindow, @@ -297,7 +287,7 @@ test_group_Alice_1W_Bob_1W_Charlie_1W( waitForTestIdWithText( restoredWindow2, Global.contactItem.selector, - englishStrippedStr('you').toString(), + tStripped('you'), ), waitForTestIdWithText( restoredWindow2, @@ -326,10 +316,10 @@ test_group_Alice_2W_Bob_1W_Charlie_1W( await clickOn(aliceWindow1, ConversationSettings.leaveOrDeleteGroupOption); await checkModalStrings( aliceWindow1, - englishStrippedStr('groupDelete').toString(), - englishStrippedStr('groupDeleteDescription') - .withArgs({ group_name: groupCreated.userName }) - .toString(), + tStripped('groupDelete'), + tStripped('groupDeleteDescription', { + group_name: groupCreated.userName, + }), 'confirmModal', ); await clickOn(aliceWindow1, Global.confirmButton); @@ -338,9 +328,9 @@ test_group_Alice_2W_Bob_1W_Charlie_1W( await waitForTestIdWithText( w, 'empty-conversation-control-message', - englishStrippedStr('groupDeletedMemberDescription') - .withArgs({ group_name: groupCreated.userName }) - .toString(), + tStripped('groupDeletedMemberDescription', { + group_name: groupCreated.userName, + }), ); }), ); diff --git a/tests/automation/linked_device_requests.spec.ts b/tests/automation/linked_device_requests.spec.ts index 6284459..43e6418 100644 --- a/tests/automation/linked_device_requests.spec.ts +++ b/tests/automation/linked_device_requests.spec.ts @@ -1,4 +1,4 @@ -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { sleepFor } from '../promise_utils'; import { Conversation, @@ -37,19 +37,17 @@ test_Alice_2W_Bob_1W( await waitForTestIdWithText( aliceWindow1, Conversation.messageRequestAcceptControlMessage.selector, - englishStrippedStr('messageRequestYouHaveAccepted') - .withArgs({ - name: bob.userName, - }) - .toString(), + tStripped('messageRequestYouHaveAccepted', { + name: bob.userName, + }), ); await waitForMatchingText( aliceWindow1, - englishStrippedStr('messageRequestsNonePending').toString(), + tStripped('messageRequestsNonePending'), ); await waitForMatchingText( aliceWindow2, - englishStrippedStr('messageRequestsNonePending').toString(), + tStripped('messageRequestsNonePending'), ); await sendMessage(aliceWindow1, testReply); await waitForTextMessage(bobWindow1, testReply); @@ -85,20 +83,20 @@ test_Alice_2W_Bob_1W( await clickOnWithText( aliceWindow1, Conversation.deleteMessageRequestButton, - englishStrippedStr('delete').toString(), + tStripped('delete'), ); await clickOnWithText( aliceWindow1, Global.confirmButton, - englishStrippedStr('delete').toString(), + tStripped('delete'), ); await waitForMatchingText( aliceWindow1, - englishStrippedStr('messageRequestsNonePending').toString(), + tStripped('messageRequestsNonePending'), ); await waitForMatchingText( aliceWindow2, - englishStrippedStr('messageRequestsNonePending').toString(), + tStripped('messageRequestsNonePending'), ); }, ); @@ -122,10 +120,8 @@ test_Alice_2W_Bob_1W( // Check modal strings await checkModalStrings( aliceWindow1, - englishStrippedStr('block').toString(), - englishStrippedStr('blockDescription') - .withArgs({ name: bob.userName }) - .toString(), + tStripped('block'), + tStripped('blockDescription', { name: bob.userName }), ); // Confirm block await clickOn(aliceWindow1, Global.confirmButton); diff --git a/tests/automation/linked_device_user.spec.ts b/tests/automation/linked_device_user.spec.ts index f3edd07..de81d27 100644 --- a/tests/automation/linked_device_user.spec.ts +++ b/tests/automation/linked_device_user.spec.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test'; -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { sleepFor } from '../promise_utils'; import { Conversation, @@ -97,10 +97,7 @@ test_Alice_2W( newUsername, ); // Press enter to confirm change - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('save').toString(), - ); + await clickOnMatchingText(aliceWindow1, tStripped('save')); // Check username change in window B // Click on profile settings in window B @@ -150,10 +147,7 @@ test_Alice_2W( aliceWindow1, Global.loadingSpinner.selector, ); - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('save').toString(), - ); + await clickOnMatchingText(aliceWindow1, tStripped('save')); await clickOn(aliceWindow1, Global.modalCloseButton); const leftpaneAvatarContainer = await waitForTestIdWithText( @@ -200,21 +194,16 @@ test_Alice_2W_Bob_1W( waitForTextMessage(bobWindow1, messageToDelete), ]); await clickOnTextMessage(aliceWindow1, messageToDelete, true); - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('delete').toString(), - ); + await clickOnMatchingText(aliceWindow1, tStripped('delete')); await clickOnWithText( aliceWindow1, Global.confirmButton, - englishStrippedStr('delete').toString(), + tStripped('delete'), ); await waitForTestIdWithText( aliceWindow1, 'session-toast', - englishStrippedStr('deleteMessageDeleted') - .withArgs({ count: 1 }) - .toString(), + tStripped('deleteMessageDeleted', { count: 1 }), ); await hasTextMessageBeenDeleted(aliceWindow1, messageToDelete, 6_000); // linked device for deleted message @@ -243,13 +232,10 @@ test_Alice_2W_Bob_1W( waitForTextMessage(bobWindow1, unsentMessage), ]); await clickOnTextMessage(aliceWindow1, unsentMessage, true); + await clickOnMatchingText(aliceWindow1, tStripped('delete')); await clickOnMatchingText( aliceWindow1, - englishStrippedStr('delete').toString(), - ); - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('clearMessagesForEveryone').toString(), + tStripped('clearMessagesForEveryone'), ); await clickOnElement({ window: aliceWindow1, @@ -259,14 +245,12 @@ test_Alice_2W_Bob_1W( await waitForTestIdWithText( aliceWindow1, 'session-toast', - englishStrippedStr('deleteMessageDeleted') - .withArgs({ count: 1 }) - .toString(), + tStripped('deleteMessageDeleted', { count: 1 }), ); await hasTextMessageBeenDeleted(aliceWindow1, unsentMessage, 1000); await waitForMatchingText( bobWindow1, - englishStrippedStr('deleteMessageDeletedGlobally').toString(), + tStripped('deleteMessageDeletedGlobally'), ); // linked device for deleted message await hasTextMessageBeenDeleted(aliceWindow2, unsentMessage, 5_000); @@ -291,26 +275,24 @@ test_Alice_2W_Bob_1W( await clickOnWithText( aliceWindow2, Global.contextMenuItem, - englishStrippedStr('block').toString(), + tStripped('block'), ); // Check modal strings await checkModalStrings( aliceWindow2, - englishStrippedStr('block').toString(), - englishStrippedStr('blockDescription') - .withArgs({ name: bob.userName }) - .toString(), + tStripped('block'), + tStripped('blockDescription', { name: bob.userName }), ); await clickOnWithText( aliceWindow2, Global.confirmButton, - englishStrippedStr('block').toString(), + tStripped('block'), ); // Verify the user was moved to the blocked contact list await waitForMatchingPlaceholder( aliceWindow1, Conversation.messageInput.selector, - englishStrippedStr('blockBlockedDescription').toString(), + tStripped('blockBlockedDescription'), ); // Check linked device for blocked contact in settings screen // Click on settings tab @@ -376,19 +358,17 @@ test_Alice_2W_Bob_1W( await clickOnWithText( aliceWindow1, Global.contextMenuItem, - englishStrippedStr('conversationsDelete').toString(), + tStripped('conversationsDelete'), ); await checkModalStrings( aliceWindow1, - englishStrippedStr('conversationsDelete').toString(), - englishStrippedStr('deleteConversationDescription') - .withArgs({ name: bob.userName }) - .toString(), + tStripped('conversationsDelete'), + tStripped('deleteConversationDescription', { name: bob.userName }), ); await clickOnWithText( aliceWindow1, Global.confirmButton, - englishStrippedStr('delete').toString(), + tStripped('delete'), ); // Check if conversation is deleted // Need to wait for deletion to propagate to linked device @@ -420,7 +400,7 @@ test_Alice_2W( await waitForTestIdWithText( aliceWindow1, 'header-conversation-name', - englishStrippedStr('noteToSelf').toString(), + tStripped('noteToSelf'), ); await sendMessage(aliceWindow1, 'Testing note to self'); // Check if note to self is visible in linked device @@ -428,28 +408,28 @@ test_Alice_2W( await waitForTestIdWithText( aliceWindow2, HomeScreen.conversationItemName.selector, - englishStrippedStr('noteToSelf').toString(), + tStripped('noteToSelf'), ); await clickOnWithText( aliceWindow1, HomeScreen.conversationItemName, - englishStrippedStr('noteToSelf').toString(), + tStripped('noteToSelf'), { rightButton: true }, ); await clickOnWithText( aliceWindow1, Global.contextMenuItem, - englishStrippedStr('noteToSelfHide').toString(), + tStripped('noteToSelfHide'), ); await checkModalStrings( aliceWindow1, - englishStrippedStr('noteToSelfHide').toString(), - englishStrippedStr('noteToSelfHideDescription').toString(), + tStripped('noteToSelfHide'), + tStripped('noteToSelfHideDescription'), ); await clickOnWithText( aliceWindow1, Global.confirmButton, - englishStrippedStr('hide').toString(), + tStripped('hide'), ); // Check linked device for hidden note to self await sleepFor(1000); @@ -459,14 +439,14 @@ test_Alice_2W( 'data-testid', HomeScreen.conversationItemName.selector, 5000, - englishStrippedStr('noteToSelf').toString(), + tStripped('noteToSelf'), ), hasElementBeenDeleted( aliceWindow2, 'data-testid', HomeScreen.conversationItemName.selector, 15_000, - englishStrippedStr('noteToSelf').toString(), + tStripped('noteToSelf'), ), ]); }, diff --git a/tests/automation/message_checks.spec.ts b/tests/automation/message_checks.spec.ts index f576c22..88f330c 100644 --- a/tests/automation/message_checks.spec.ts +++ b/tests/automation/message_checks.spec.ts @@ -1,4 +1,4 @@ -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { sleepFor } from '../promise_utils'; import { testCommunityName } from './constants/community'; import { longText, mediaArray, testLink } from './constants/variables'; @@ -146,7 +146,7 @@ test_Alice_1W_Bob_1W( await waitForTestIdWithText( aliceWindow1, 'modal-heading', - englishStrippedStr('membersInvite').toString(), + tStripped('membersInvite'), ); await clickOnWithText(aliceWindow1, Global.contactItem, bob.userName); await clickOn(aliceWindow1, Global.confirmButton); @@ -190,13 +190,10 @@ test_Alice_1W_Bob_1W( await sendMessage(aliceWindow1, unsendMessage); await waitForTextMessage(bobWindow1, unsendMessage); await clickOnTextMessage(aliceWindow1, unsendMessage, true); + await clickOnMatchingText(aliceWindow1, tStripped('delete')); await clickOnMatchingText( aliceWindow1, - englishStrippedStr('delete').toString(), - ); - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('clearMessagesForEveryone').toString(), + tStripped('clearMessagesForEveryone'), ); await clickOnElement({ window: aliceWindow1, @@ -206,14 +203,12 @@ test_Alice_1W_Bob_1W( await waitForTestIdWithText( aliceWindow1, 'session-toast', - englishStrippedStr('deleteMessageDeleted') - .withArgs({ count: 1 }) - .toString(), + tStripped('deleteMessageDeleted', { count: 1 }), ); await sleepFor(1000); await waitForMatchingText( bobWindow1, - englishStrippedStr('deleteMessageDeletedGlobally').toString(), + tStripped('deleteMessageDeletedGlobally'), ); }, ); @@ -226,10 +221,7 @@ test_Alice_1W_Bob_1W( await sendMessage(aliceWindow1, deletedMessage); await waitForTextMessage(bobWindow1, deletedMessage); await clickOnTextMessage(aliceWindow1, deletedMessage, true); - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('delete').toString(), - ); + await clickOnMatchingText(aliceWindow1, tStripped('delete')); await clickOnElement({ window: aliceWindow1, strategy: 'data-testid', @@ -238,9 +230,7 @@ test_Alice_1W_Bob_1W( await waitForTestIdWithText( aliceWindow1, 'session-toast', - englishStrippedStr('deleteMessageDeleted') - .withArgs({ count: 1 }) - .toString(), + tStripped('deleteMessageDeleted', { count: 1 }), ); await hasTextMessageBeenDeleted(aliceWindow1, deletedMessage, 1000); // Still should exist in window B @@ -354,20 +344,13 @@ messageLengthTestCases.forEach((testCase) => { // Upgrade to pro await checkCTAStrings( aliceWindow1, - englishStrippedStr('upgradeTo').toString(), - englishStrippedStr('proCallToActionLongerMessages').toString(), - [ - englishStrippedStr('theContinue').toString(), - englishStrippedStr('cancel').toString(), - ], + tStripped('upgradeTo'), + tStripped('proCallToActionLongerMessages'), + [tStripped('theContinue'), tStripped('cancel')], [ - ` ${englishStrippedStr( - 'proFeatureListLongerMessages', - ).toString()}`, - ` ${englishStrippedStr( - 'proFeatureListPinnedConversations', - ).toString()}`, - englishStrippedStr('proFeatureListLoadsMore').toString(), + ` ${tStripped('proFeatureListLongerMessages')}`, + ` ${tStripped('proFeatureListPinnedConversations')}`, + tStripped('proFeatureListLoadsMore'), ], ); await clickOn(aliceWindow1, CTA.cancelButton); @@ -376,10 +359,10 @@ messageLengthTestCases.forEach((testCase) => { // Message Too Long modal await checkModalStrings( aliceWindow1, - englishStrippedStr('modalMessageTooLongTitle').toString(), - englishStrippedStr('modalMessageTooLongDescription') - .withArgs({ limit: maxChars.toLocaleString('en-AU') }) // Force "2,000" instead of "2000" - .toString(), + tStripped('modalMessageTooLongTitle'), + tStripped('modalMessageTooLongDescription', { + limit: maxChars.toLocaleString('en-AU'), + }), // Force "2,000" instead of "2000" ); await clickOn(aliceWindow1, Global.confirmButton); } diff --git a/tests/automation/message_checks_groups.spec.ts b/tests/automation/message_checks_groups.spec.ts index 6738751..bf07a93 100644 --- a/tests/automation/message_checks_groups.spec.ts +++ b/tests/automation/message_checks_groups.spec.ts @@ -1,4 +1,4 @@ -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { sleepFor } from '../promise_utils'; import { longText, mediaArray, testLink } from './constants/variables'; import { test_group_Alice_1W_Bob_1W_Charlie_1W } from './setup/sessionTest'; @@ -165,19 +165,16 @@ test_group_Alice_1W_Bob_1W_Charlie_1W( waitForTextMessage(charlieWindow1, unsendMessage), ]); await clickOnTextMessage(aliceWindow1, unsendMessage, true); + await clickOnMatchingText(aliceWindow1, tStripped('delete')); await clickOnMatchingText( aliceWindow1, - englishStrippedStr('delete').toString(), - ); - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('clearMessagesForEveryone').toString(), + tStripped('clearMessagesForEveryone'), ); // To be implemented in Standardise Message Deletion feature // await checkModalStrings( // aliceWindow1, - // englishStrippedStr('deleteMessage').withArgs({ count: 1 }).toString(), - // englishStrippedStr('deleteMessageConfirm').toString(), + // tStripped('deleteMessage', { count: 1 }), + // tStripped('deleteMessageConfirm'), // ); await clickOnElement({ window: aliceWindow1, @@ -187,18 +184,16 @@ test_group_Alice_1W_Bob_1W_Charlie_1W( await waitForTestIdWithText( aliceWindow1, 'session-toast', - englishStrippedStr('deleteMessageDeleted') - .withArgs({ count: 1 }) - .toString(), + tStripped('deleteMessageDeleted', { count: 1 }), ); await sleepFor(1000); await waitForMatchingText( bobWindow1, - englishStrippedStr('deleteMessageDeletedGlobally').toString(), + tStripped('deleteMessageDeletedGlobally'), ); await waitForMatchingText( charlieWindow1, - englishStrippedStr('deleteMessageDeletedGlobally').toString(), + tStripped('deleteMessageDeletedGlobally'), ); }, ); @@ -211,14 +206,8 @@ test_group_Alice_1W_Bob_1W_Charlie_1W( await waitForTextMessage(bobWindow1, deletedMessage); await waitForTextMessage(charlieWindow1, deletedMessage); await clickOnTextMessage(aliceWindow1, deletedMessage, true); - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('delete').toString(), - ); - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('clearMessagesForMe').toString(), - ); + await clickOnMatchingText(aliceWindow1, tStripped('delete')); + await clickOnMatchingText(aliceWindow1, tStripped('clearMessagesForMe')); await clickOnElement({ window: aliceWindow1, strategy: 'data-testid', @@ -227,14 +216,12 @@ test_group_Alice_1W_Bob_1W_Charlie_1W( await waitForTestIdWithText( aliceWindow1, 'session-toast', - englishStrippedStr('deleteMessageDeleted') - .withArgs({ count: 1 }) - .toString(), + tStripped('deleteMessageDeleted', { count: 1 }), ); await hasTextMessageBeenDeleted(aliceWindow1, deletedMessage, 5000); await waitForMatchingText( aliceWindow1, - englishStrippedStr('deleteMessageDeletedGlobally').toString(), + tStripped('deleteMessageDeletedGlobally'), ); // Should still be there for user B and C await waitForMatchingText(bobWindow1, deletedMessage); diff --git a/tests/automation/message_requests.spec.ts b/tests/automation/message_requests.spec.ts index 16bb2b4..f180168 100644 --- a/tests/automation/message_requests.spec.ts +++ b/tests/automation/message_requests.spec.ts @@ -1,6 +1,6 @@ import { expect } from '@playwright/test'; -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { Conversation, Global, @@ -43,15 +43,13 @@ test_Alice_1W_Bob_1W( await waitForTestIdWithText( bobWindow1, 'message-request-response-message', - englishStrippedStr('messageRequestYouHaveAccepted') - .withArgs({ - name: alice.userName, - }) - .toString(), + tStripped('messageRequestYouHaveAccepted', { + name: alice.userName, + }), ); await waitForMatchingText( bobWindow1, - englishStrippedStr('messageRequestsNonePending').toString(), + tStripped('messageRequestsNonePending'), ); }, ); @@ -77,15 +75,13 @@ test_Alice_1W_Bob_1W( await waitForTestIdWithText( bobWindow1, 'message-request-response-message', - englishStrippedStr('messageRequestYouHaveAccepted') - .withArgs({ - name: alice.userName, - }) - .toString(), + tStripped('messageRequestYouHaveAccepted', { + name: alice.userName, + }), ); await waitForMatchingText( bobWindow1, - englishStrippedStr('messageRequestsNonePending').toString(), + tStripped('messageRequestsNonePending'), ); }, ); @@ -108,23 +104,23 @@ test_Alice_1W_Bob_1W( await clickOnWithText( bobWindow1, Conversation.deleteMessageRequestButton, - englishStrippedStr('delete').toString(), + tStripped('delete'), ); // Confirm decline await checkModalStrings( bobWindow1, - englishStrippedStr('delete').toString(), - englishStrippedStr('messageRequestsDelete').toString(), + tStripped('delete'), + tStripped('messageRequestsDelete'), ); await clickOnWithText( bobWindow1, Global.confirmButton, - englishStrippedStr('delete').toString(), + tStripped('delete'), ); // Check config message of message request acceptance await waitForMatchingText( bobWindow1, - englishStrippedStr('messageRequestsNonePending').toString(), + tStripped('messageRequestsNonePending'), ); }, ); @@ -138,33 +134,26 @@ test_Alice_1W_Bob_1W( // Check the message request banner appears and click on it await clickOn(bobWindow1, HomeScreen.messageRequestBanner); // Select 'Clear All' button - await clickOnMatchingText( - bobWindow1, - englishStrippedStr('clearAll').toString(), - ); + await clickOnMatchingText(bobWindow1, tStripped('clearAll')); // Confirm decline await checkModalStrings( bobWindow1, - englishStrippedStr('clearAll').toString(), - englishStrippedStr('messageRequestsClearAllExplanation').toString(), - ); - await clickOnWithText( - bobWindow1, - Global.confirmButton, - englishStrippedStr('clear').toString(), + tStripped('clearAll'), + tStripped('messageRequestsClearAllExplanation'), ); + await clickOnWithText(bobWindow1, Global.confirmButton, tStripped('clear')); // Navigate back to message request folder to check await clickOn(bobWindow1, LeftPane.settingsButton); await clickOnWithText( bobWindow1, Settings.messageRequestsMenuItem, - englishStrippedStr('sessionMessageRequests').toString(), + tStripped('sessionMessageRequests'), ); // Check config message of message request acceptance await waitForMatchingText( bobWindow1, - englishStrippedStr('messageRequestsNonePending').toString(), + tStripped('messageRequestsNonePending'), ); }, ); @@ -213,11 +202,9 @@ test_Alice_1W_Bob_1W( await waitForTestIdWithText( bobWindow1, 'message-request-response-message', - englishStrippedStr('messageRequestYouHaveAccepted') - .withArgs({ - name: alice.userName, - }) - .toString(), + tStripped('messageRequestYouHaveAccepted', { + name: alice.userName, + }), ); }, ); diff --git a/tests/automation/network_page.spec.ts b/tests/automation/network_page.spec.ts index 7080632..283353c 100644 --- a/tests/automation/network_page.spec.ts +++ b/tests/automation/network_page.spec.ts @@ -1,4 +1,4 @@ -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { sleepFor } from '../promise_utils'; import { Global, LeftPane, Settings } from './locators'; import { test_Alice_1W } from './setup/sessionTest'; @@ -60,8 +60,8 @@ test_Alice_1W('Network page network link', async ({ aliceWindow1 }) => { await clickOn(aliceWindow1, Settings.learnMoreNetworkLink); await checkModalStrings( aliceWindow1, - englishStrippedStr('urlOpen').toString(), - englishStrippedStr('urlOpenDescription').withArgs({ url }).toString(), + tStripped('urlOpen'), + tStripped('urlOpenDescription', { url }), 'openUrlModal', ); await assertUrlIsReachable(url); @@ -74,20 +74,16 @@ test_Alice_1W('Network page staking link', async ({ aliceWindow1 }) => { await clickOn(aliceWindow1, Settings.learnMoreAboutStakingLink); await checkModalStrings( aliceWindow1, - englishStrippedStr('urlOpen').toString(), - englishStrippedStr('urlOpenDescription').withArgs({ url }).toString(), + tStripped('urlOpen'), + tStripped('urlOpenDescription', { url }), 'openUrlModal', ); await assertUrlIsReachable(url); }); test_Alice_1W('Network page refresh', async ({ aliceWindow1 }) => { - const zeroMinAgoText = englishStrippedStr('updated') - .withArgs({ relative_time: '0m' }) - .toString(); - const oneMinAgoText = englishStrippedStr('updated') - .withArgs({ relative_time: '1m' }) - .toString(); + const zeroMinAgoText = tStripped('updated', { relative_time: '0m' }); + const oneMinAgoText = tStripped('updated', { relative_time: '1m' }); await clickOn(aliceWindow1, LeftPane.settingsButton); await clickOn(aliceWindow1, Settings.networkPageMenuItem); await waitForLoadingAnimationToFinish( diff --git a/tests/automation/onboarding.spec.ts b/tests/automation/onboarding.spec.ts index a7213fb..bfdba95 100644 --- a/tests/automation/onboarding.spec.ts +++ b/tests/automation/onboarding.spec.ts @@ -1,4 +1,4 @@ -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { Global, Onboarding } from './locators'; import { sessionTestOneWindow } from './setup/sessionTest'; import { @@ -13,14 +13,14 @@ sessionTestOneWindow('Warning modal new account', async ([aliceWindow1]) => { await clickOn(aliceWindow1, Global.backButton); await checkModalStrings( aliceWindow1, - englishStrippedStr('warning').toString(), - englishStrippedStr('onboardingBackAccountCreation').toString(), + tStripped('warning'), + tStripped('onboardingBackAccountCreation'), 'confirmModal', ); await clickOnWithText( aliceWindow1, Global.confirmButton, - englishStrippedStr('quitButton').toString(), + tStripped('quitButton'), ); // Wait for window to close (confirms restart was triggered) await aliceWindow1.waitForEvent('close', { timeout: 5000 }); @@ -41,14 +41,14 @@ sessionTestOneWindow( await clickOn(aliceWindow1, Global.backButton); await checkModalStrings( aliceWindow1, - englishStrippedStr('warning').toString(), - englishStrippedStr('onboardingBackLoadAccount').toString(), + tStripped('warning'), + tStripped('onboardingBackLoadAccount'), 'confirmModal', ); await clickOnWithText( aliceWindow1, Global.confirmButton, - englishStrippedStr('quitButton').toString(), + tStripped('quitButton'), ); // Wait for window to close (confirms restart was triggered) await aliceWindow1.waitForEvent('close', { timeout: 5000 }); diff --git a/tests/automation/password.spec.ts b/tests/automation/password.spec.ts index 125326b..cc1990b 100644 --- a/tests/automation/password.spec.ts +++ b/tests/automation/password.spec.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test'; -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { sleepFor } from '../promise_utils'; import { Global, LeftPane, Settings } from './locators'; import { test_Alice_1W_no_network } from './setup/sessionTest'; @@ -51,7 +51,7 @@ test_Alice_1W_no_network('Set Password', async ({ alice, aliceWindow1 }) => { await waitForTestIdWithText( aliceWindow1, Global.toast.selector, - englishStrippedStr('passwordSetDescriptionToast').toString(), + tStripped('passwordSetDescriptionToast'), ); // Click on settings tab await sleepFor(300, true); @@ -67,10 +67,7 @@ test_Alice_1W_no_network('Set Password', async ({ alice, aliceWindow1 }) => { testPassword, ); // Click Done - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('enter').toString(), - ); + await clickOnMatchingText(aliceWindow1, tStripped('enter')); // check that the seed is visible now await expectRecoveryPhraseToBeVisible(aliceWindow1, alice.recoveryPassword); @@ -104,7 +101,7 @@ test_Alice_1W_no_network('Set Password', async ({ alice, aliceWindow1 }) => { await waitForTestIdWithText( aliceWindow1, Global.toast.selector, - englishStrippedStr('passwordChangedDescriptionToast').toString(), + tStripped('passwordChangedDescriptionToast'), ); }); @@ -171,7 +168,7 @@ test_Alice_1W_no_network( await waitForTestIdWithText( aliceWindow1, Global.errorMessage.selector, - englishStrippedStr('passwordIncorrect').toString(), + tStripped('passwordIncorrect'), ); await clickOn(aliceWindow1, Global.modalCloseButton); await sleepFor(100); @@ -183,7 +180,7 @@ test_Alice_1W_no_network( await waitForTestIdWithText( aliceWindow1, Global.errorMessage.selector, - englishStrippedStr('passwordIncorrect').toString(), + tStripped('passwordIncorrect'), ); }, ); diff --git a/tests/automation/setup/create_group.ts b/tests/automation/setup/create_group.ts index 898a991..581fed7 100644 --- a/tests/automation/setup/create_group.ts +++ b/tests/automation/setup/create_group.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test'; -import { englishStrippedStr } from '../../localization/englishStrippedStr'; +import { tStripped } from '../../localization/lib'; import { sortByPubkey } from '../../pubkey'; import { HomeScreen } from '../locators'; import { Group, User } from '../types/testing'; @@ -82,9 +82,7 @@ export const createGroup = async ( await waitForTestIdWithText( windowA, 'group-update-message', - englishStrippedStr('groupMemberNewTwo') - .withArgs({ name: firstUser, other_name: secondUser }) - .toString(), + tStripped('groupMemberNewTwo', { name: firstUser, other_name: secondUser }), ); // Click on test group await Promise.all( @@ -97,16 +95,14 @@ export const createGroup = async ( waitForTestIdWithText( windowB, 'group-update-message', - englishStrippedStr('groupInviteYouAndOtherNew') - .withArgs({ other_name: userThree.userName }) - .toString(), + tStripped('groupInviteYouAndOtherNew', { + other_name: userThree.userName, + }), ), waitForTestIdWithText( windowC, 'group-update-message', - englishStrippedStr('groupInviteYouAndOtherNew') - .withArgs({ other_name: userTwo.userName }) - .toString(), + tStripped('groupInviteYouAndOtherNew', { other_name: userTwo.userName }), ), ]); // Send message in group chat from user A diff --git a/tests/automation/user_actions.spec.ts b/tests/automation/user_actions.spec.ts index da4af45..eab030d 100644 --- a/tests/automation/user_actions.spec.ts +++ b/tests/automation/user_actions.spec.ts @@ -1,6 +1,6 @@ import { expect } from '@playwright/test'; -import { englishStrippedStr } from '../localization/englishStrippedStr'; +import { tStripped } from '../localization/lib'; import { sleepFor } from '../promise_utils'; import { Conversation, @@ -33,9 +33,9 @@ import { waitForTestIdWithText, } from './utilities/utils'; -const cancelString = englishStrippedStr('cancel').toString(); -const saveString = englishStrippedStr('save').toString(); -const removeString = englishStrippedStr('remove').toString(); +const cancelString = tStripped('cancel'); +const saveString = tStripped('save'); +const removeString = tStripped('remove'); // Send message in one to one conversation with new contact sessionTestTwoWindows('Create contact', async ([windowA, windowB]) => { @@ -49,11 +49,9 @@ sessionTestTwoWindows('Create contact', async ([windowA, windowB]) => { await waitForTestIdWithText( windowB, Conversation.messageRequestAcceptControlMessage.selector, - englishStrippedStr('messageRequestYouHaveAccepted') - .withArgs({ - name: userA.userName, - }) - .toString(), + tStripped('messageRequestYouHaveAccepted', { + name: userA.userName, + }), ); await clickOn(windowB, Global.backButton); await Promise.all([ @@ -99,20 +97,18 @@ test_Alice_1W_Bob_1W( await clickOnWithText( aliceWindow1, Global.contextMenuItem, - englishStrippedStr('block').toString(), + tStripped('block'), ); // Check modal strings await checkModalStrings( aliceWindow1, - englishStrippedStr('block').toString(), - englishStrippedStr('blockDescription') - .withArgs({ name: bob.userName }) - .toString(), + tStripped('block'), + tStripped('blockDescription', { name: bob.userName }), ); await clickOnWithText( aliceWindow1, Global.confirmButton, - englishStrippedStr('block').toString(), + tStripped('block'), ); // Verify the user was moved to the blocked contact list // Click on settings tab @@ -128,23 +124,18 @@ test_Alice_1W_Bob_1W( // make sure the confirm dialogs shows up await checkModalStrings( aliceWindow1, - englishStrippedStr('blockUnblock').toString(), - englishStrippedStr('blockUnblockName') - .withArgs({ name: bob.userName }) - .toString(), + tStripped('blockUnblock'), + tStripped('blockUnblockName', { name: bob.userName }), 'blockOrUnblockModal', ); // click on the unblock button await clickOnWithText( aliceWindow1, Global.confirmButton, - englishStrippedStr('blockUnblock').toString(), + tStripped('blockUnblock'), ); // make sure no blocked contacts are listed - await waitForMatchingText( - aliceWindow1, - englishStrippedStr('blockBlockedNone').toString(), - ); + await waitForMatchingText(aliceWindow1, tStripped('blockBlockedNone')); }, ); @@ -255,10 +246,7 @@ test_Alice_1W_Bob_1W( bob.userName, { rightButton: true }, ); - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('nicknameSet').toString(), - ); + await clickOnMatchingText(aliceWindow1, tStripped('nicknameSet')); await sleepFor(1000); await typeIntoInput(aliceWindow1, 'nickname-input', nickname); @@ -374,19 +362,17 @@ test_Alice_1W_Bob_1W( await clickOnWithText( aliceWindow1, Global.contextMenuItem, - englishStrippedStr('conversationsDelete').toString(), + tStripped('conversationsDelete'), ); await checkModalStrings( aliceWindow1, - englishStrippedStr('conversationsDelete').toString(), - englishStrippedStr('deleteConversationDescription') - .withArgs({ name: bob.userName }) - .toString(), + tStripped('conversationsDelete'), + tStripped('deleteConversationDescription', { name: bob.userName }), ); await clickOnWithText( aliceWindow1, Global.confirmButton, - englishStrippedStr('delete').toString(), + tStripped('delete'), ); // Check if conversation is deleted await hasElementBeenDeleted( @@ -408,31 +394,23 @@ test_Alice_2W( // Check first modal await checkModalStrings( aliceWindow1, - englishStrippedStr('recoveryPasswordHidePermanently').toString(), - englishStrippedStr( - 'recoveryPasswordHidePermanentlyDescription1', - ).toString(), + tStripped('recoveryPasswordHidePermanently'), + tStripped('recoveryPasswordHidePermanentlyDescription1'), 'hideRecoveryPasswordModal', ); await clickOnWithText( aliceWindow1, Global.confirmButton, - englishStrippedStr('theContinue').toString(), + tStripped('theContinue'), ); await checkModalStrings( aliceWindow1, - englishStrippedStr('recoveryPasswordHidePermanently').toString(), - englishStrippedStr( - 'recoveryPasswordHidePermanentlyDescription2', - ).toString(), + tStripped('recoveryPasswordHidePermanently'), + tStripped('recoveryPasswordHidePermanentlyDescription2'), 'hideRecoveryPasswordModal', ); // Click yes - await clickOnWithText( - aliceWindow1, - Global.confirmButton, - englishStrippedStr('yes').toString(), - ); + await clickOnWithText(aliceWindow1, Global.confirmButton, tStripped('yes')); await doesElementExist( aliceWindow1, 'data-testid', @@ -456,17 +434,14 @@ test_Alice_1W_no_network('Invite a friend', async ({ aliceWindow1, alice }) => { await waitForTestIdWithText( aliceWindow1, Global.toast.selector, - englishStrippedStr('copied').toString(), + tStripped('copied'), ); // Wait for copy to resolve await sleepFor(1000); + await waitForMatchingText(aliceWindow1, tStripped('accountIdCopied')); await waitForMatchingText( aliceWindow1, - englishStrippedStr('accountIdCopied').toString(), - ); - await waitForMatchingText( - aliceWindow1, - englishStrippedStr('shareAccountIdDescriptionCopied').toString(), + tStripped('shareAccountIdDescriptionCopied'), ); // To exit invite a friend await clickOn(aliceWindow1, Global.backButton); @@ -480,7 +455,7 @@ test_Alice_1W_no_network('Invite a friend', async ({ aliceWindow1, alice }) => { await waitForTestIdWithText( aliceWindow1, Conversation.conversationHeader.selector, - englishStrippedStr('noteToSelf').toString(), + tStripped('noteToSelf'), ); }); @@ -498,35 +473,35 @@ test_Alice_1W_no_network( await waitForTestIdWithText( aliceWindow1, Conversation.conversationHeader.selector, - englishStrippedStr('noteToSelf').toString(), + tStripped('noteToSelf'), ); await clickOnWithText( aliceWindow1, HomeScreen.conversationItemName, - englishStrippedStr('noteToSelf').toString(), + tStripped('noteToSelf'), { rightButton: true }, ); await clickOnWithText( aliceWindow1, Global.contextMenuItem, - englishStrippedStr('noteToSelfHide').toString(), + tStripped('noteToSelfHide'), ); await checkModalStrings( aliceWindow1, - englishStrippedStr('noteToSelfHide').toString(), - englishStrippedStr('noteToSelfHideDescription').toString(), + tStripped('noteToSelfHide'), + tStripped('noteToSelfHideDescription'), ); await clickOnWithText( aliceWindow1, Global.confirmButton, - englishStrippedStr('hide').toString(), + tStripped('hide'), ); await hasElementBeenDeleted( aliceWindow1, 'data-testid', 'module-conversation__user__profile-name', 5000, - englishStrippedStr('noteToSelf').toString(), + tStripped('noteToSelf'), ); }, ); @@ -538,20 +513,14 @@ test_Alice_1W_no_network('Toggle password', async ({ aliceWindow1 }) => { aliceWindow1, Settings.recoveryPasswordContainer.selector, ); - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('qrView').toString(), - ); + await clickOnMatchingText(aliceWindow1, tStripped('qrView')); // Wait for QR code to be visible await waitForTestIdWithText( aliceWindow1, Settings.recoveryPasswordQRCode.selector, ); // Then toggle back to text seed password - await clickOnMatchingText( - aliceWindow1, - englishStrippedStr('recoveryPasswordView').toString(), - ); + await clickOnMatchingText(aliceWindow1, tStripped('recoveryPasswordView')); await waitForTestIdWithText( aliceWindow1, Settings.recoveryPasswordContainer.selector, diff --git a/tests/automation/utilities/join_community.ts b/tests/automation/utilities/join_community.ts index 9a16c7d..092ae5f 100644 --- a/tests/automation/utilities/join_community.ts +++ b/tests/automation/utilities/join_community.ts @@ -1,6 +1,6 @@ import { type Page, test } from '@playwright/test'; -import { englishStrippedStr } from '../../localization/englishStrippedStr'; +import { tStripped } from '../../localization/lib'; import { type DefaultCommunity, testCommunityLink, @@ -81,7 +81,7 @@ export const joinOrOpenCommunity = async (window: Page) => { await waitForTestIdWithText( window, Global.errorMessage.selector, - englishStrippedStr('communityJoinedAlready').toString(), + tStripped('communityJoinedAlready'), ); await clickOn(window, Global.backButton); await clickOn(window, Global.backButton); diff --git a/tests/automation/utilities/leave_group.ts b/tests/automation/utilities/leave_group.ts index 4cd2750..2ec3d07 100644 --- a/tests/automation/utilities/leave_group.ts +++ b/tests/automation/utilities/leave_group.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test'; -import { englishStrippedStr } from '../../localization/englishStrippedStr'; +import { tStripped } from '../../localization/lib'; import { Conversation, Global } from '../locators'; import { Group } from '../types/testing'; import { @@ -14,16 +14,9 @@ export const leaveGroup = async (window: Page, group: Group) => { // go to three dots menu await clickOn(window, Conversation.conversationSettingsIcon); // Select Leave Group - await clickOnMatchingText( - window, - englishStrippedStr('groupLeave').toString(), - ); + await clickOnMatchingText(window, tStripped('groupLeave')); // Confirm leave group - await clickOnWithText( - window, - Global.confirmButton, - englishStrippedStr('leave').toString(), - ); + await clickOnWithText(window, Global.confirmButton, tStripped('leave')); // check config message await hasElementBeenDeleted( window, diff --git a/tests/automation/utilities/rename_group.ts b/tests/automation/utilities/rename_group.ts index 8aca644..1e778d8 100644 --- a/tests/automation/utilities/rename_group.ts +++ b/tests/automation/utilities/rename_group.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test'; -import { englishStrippedStr } from '../../localization/englishStrippedStr'; +import { tStripped } from '../../localization/lib'; import { Conversation, ConversationSettings, Global } from '../locators'; import { clickOn, @@ -20,14 +20,12 @@ export const renameGroup = async ( await clickOn(window, ConversationSettings.editGroupButton); await typeIntoInput(window, 'update-group-info-name-input', newGroupName); await window.keyboard.press('Enter'); - await clickOnMatchingText(window, englishStrippedStr('save').toString()); + await clickOnMatchingText(window, tStripped('save')); await waitForTestIdWithText(window, 'group-name', newGroupName); await clickOn(window, Global.modalCloseButton); // Check config message await waitForMatchingText( window, - englishStrippedStr('groupNameNew') - .withArgs({ group_name: newGroupName }) - .toString(), + tStripped('groupNameNew', { group_name: newGroupName }), ); }; diff --git a/tests/automation/utilities/reply_message.ts b/tests/automation/utilities/reply_message.ts index 48ca648..19cb3aa 100644 --- a/tests/automation/utilities/reply_message.ts +++ b/tests/automation/utilities/reply_message.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test'; -import { englishStrippedStr } from '../../localization/englishStrippedStr'; +import { tStripped } from '../../localization/lib'; import { sleepFor } from '../../promise_utils'; import { Strategy } from '../types/testing'; import { sendMessage } from './message'; @@ -49,12 +49,7 @@ export const replyTo = async ({ // Tried extending this as layout shift still happens sometimes await sleepFor(200, true); - await clickOnMatchingText( - senderWindow, - englishStrippedStr('reply').toString(), - false, - 1000, - ); + await clickOnMatchingText(senderWindow, tStripped('reply'), false, 1000); // Tried extending this as layout shift still happens sometimes await sleepFor(200, true); @@ -92,12 +87,7 @@ export const replyToMedia = async ({ try { await selc.click({ button: 'right' }); await sleepFor(200); - await clickOnMatchingText( - senderWindow, - englishStrippedStr('reply').toString(), - false, - 1000, - ); + await clickOnMatchingText(senderWindow, tStripped('reply'), false, 1000); break; } catch (_e) { console.info( diff --git a/tests/automation/utilities/send_media.ts b/tests/automation/utilities/send_media.ts index b96e1e1..d416d15 100644 --- a/tests/automation/utilities/send_media.ts +++ b/tests/automation/utilities/send_media.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test'; -import { englishStrippedStr } from '../../localization/englishStrippedStr'; +import { tStripped } from '../../localization/lib'; import { sleepFor } from '../../promise_utils'; import { Conversation, Global, Settings } from '../locators'; import { MediaType } from '../types/testing'; @@ -121,17 +121,13 @@ export const sendLinkPreview = async (window: Page, testLink: string) => { // doesn't pop up if manually typing link (needs to be pasted) // Need to have a nth(0) here to account for Copy Account ID, Appium was getting confused // Tried to use englishStripped here but Playwright doesn't like it - // const copyText = englishStrippedStr('copy').toString(); + // const copyText = tStripped('copy'); const firstCopyBtn = window .locator(`[data-testid=context-menu-item]:has-text("Copy")`) .nth(0); await firstCopyBtn.click(); - await waitForTestIdWithText( - window, - 'session-toast', - englishStrippedStr('copied').toString(), - ); + await waitForTestIdWithText(window, 'session-toast', tStripped('copied')); // click on the toast and wait for it to be closed to avoid the layout shift await clickOn(window, Global.toast); await sleepFor(1000); @@ -140,14 +136,10 @@ export const sendLinkPreview = async (window: Page, testLink: string) => { await window.keyboard.press(`${isMac ? 'Meta' : 'Control'}+V`); await checkModalStrings( window, - englishStrippedStr('linkPreviewsEnable').toString(), - englishStrippedStr('linkPreviewsFirstDescription').toString(), - ); - await clickOnWithText( - window, - Global.confirmButton, - englishStrippedStr('enable').toString(), + tStripped('linkPreviewsEnable'), + tStripped('linkPreviewsFirstDescription'), ); + await clickOnWithText(window, Global.confirmButton, tStripped('enable')); await waitForLoadingAnimationToFinish(window, Global.loadingSpinner.selector); await waitForTestIdWithText(window, 'link-preview-image'); await waitForTestIdWithText( @@ -171,24 +163,16 @@ export const trustUser = async ( ) => { await clickOnMatchingText( window, - englishStrippedStr('attachmentsClickToDownload') - .withArgs({ - file_type: englishStrippedStr(mediaType).toString().toLowerCase(), - }) - .toString(), + tStripped('attachmentsClickToDownload', { + file_type: tStripped(mediaType).toLowerCase(), + }), ); await checkModalStrings( window, - englishStrippedStr('attachmentsAutoDownloadModalTitle').toString(), - englishStrippedStr('attachmentsAutoDownloadModalDescription') - .withArgs({ - conversation_name: userName, - }) - .toString(), - ); - await clickOnWithText( - window, - Global.confirmButton, - englishStrippedStr('yes').toString(), + tStripped('attachmentsAutoDownloadModalTitle'), + tStripped('attachmentsAutoDownloadModalDescription', { + conversation_name: userName, + }), ); + await clickOnWithText(window, Global.confirmButton, tStripped('yes')); }; diff --git a/tests/automation/utilities/set_disappearing_messages.ts b/tests/automation/utilities/set_disappearing_messages.ts index 7f5b184..8dab2ff 100644 --- a/tests/automation/utilities/set_disappearing_messages.ts +++ b/tests/automation/utilities/set_disappearing_messages.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test'; -import { englishStrippedStr } from '../../localization/englishStrippedStr'; +import { tStripped } from '../../localization/lib'; import { Conversation, ConversationSettings } from '../locators'; import { ConversationType, @@ -92,27 +92,26 @@ export const setDisappearingMessages = async ( if (windowB) { await clickOnMatchingText( windowB, - englishStrippedStr('disappearingMessagesFollowSetting').toString(), + tStripped('disappearingMessagesFollowSetting'), ); let action; if (disappearAction === 'read') { - action = englishStrippedStr('disappearingMessagesTypeRead').toString(); + action = tStripped('disappearingMessagesTypeRead'); } else { - action = englishStrippedStr('disappearingMessagesTypeSent').toString(); + action = tStripped('disappearingMessagesTypeSent'); } const formattedTime = formatTimeOption(timerDuration); - const modalDescription = englishStrippedStr( - 'disappearingMessagesFollowSettingOn', - ) - .withArgs({ time: formattedTime, disappearing_messages_type: action }) - .toString(); + const modalDescription = tStripped('disappearingMessagesFollowSettingOn', { + time: formattedTime, + disappearing_messages_type: action, + }); await checkModalStrings( windowB, - englishStrippedStr('disappearingMessagesFollowSetting').toString(), + tStripped('disappearingMessagesFollowSetting'), modalDescription, ); await clickOnElement({ diff --git a/tests/automation/utilities/voice_call.ts b/tests/automation/utilities/voice_call.ts index af23ed4..6be987e 100644 --- a/tests/automation/utilities/voice_call.ts +++ b/tests/automation/utilities/voice_call.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test'; -import { englishStrippedStr } from '../../localization/englishStrippedStr'; +import { tStripped } from '../../localization/lib'; import { sleepFor } from '../../promise_utils'; import { Conversation, Global, Settings } from '../locators'; import { checkModalStrings, clickOn, clickOnMatchingText } from './utils'; @@ -14,8 +14,8 @@ export const makeVoiceCall = async ( await clickOn(callerWindow, Settings.enableCalls); await checkModalStrings( callerWindow, - englishStrippedStr('callsVoiceAndVideoBeta').toString(), - englishStrippedStr('callsVoiceAndVideoModalDescription').toString(), + tStripped('callsVoiceAndVideoBeta'), + tStripped('callsVoiceAndVideoModalDescription'), 'confirmModal', ); await clickOn(callerWindow, Global.confirmButton); @@ -26,15 +26,12 @@ export const makeVoiceCall = async ( await clickOn(receiverWindow, Settings.enableCalls); await checkModalStrings( receiverWindow, - englishStrippedStr('callsVoiceAndVideoBeta').toString(), - englishStrippedStr('callsVoiceAndVideoModalDescription').toString(), + tStripped('callsVoiceAndVideoBeta'), + tStripped('callsVoiceAndVideoModalDescription'), 'confirmModal', ); await clickOn(receiverWindow, Global.confirmButton); - await clickOnMatchingText( - receiverWindow, - englishStrippedStr('accept').toString(), - ); + await clickOnMatchingText(receiverWindow, tStripped('accept')); await clickOn(receiverWindow, Global.modalCloseButton); await sleepFor(5000); await clickOn(callerWindow, Conversation.endCallButton);