diff --git a/.env.sample b/.env.sample index 356e7c2..97d01c4 100644 --- a/.env.sample +++ b/.env.sample @@ -1,4 +1,11 @@ SESSION_DESKTOP_ROOT="" -PLAYWRIGHT_REPEAT_COUNT=0 -PLAYWRIGHT_RETRIES_COUNT=0 -PLAYWRIGHT_WORKERS_COUNT=1 \ No newline at end of file +PRINT_ONGOING_TEST_LOGS=0 # Print logs for tests as they log (should only be enabled when `PLAYWRIGHT_WORKERS_COUNT=1`) +PRINT_FAILED_TEST_LOGS=0 # Print logs for failed tests at the end of each tests (should only be enabled when `PLAYWRIGHT_WORKERS_COUNT=1`) +PLAYWRIGHT_REPEAT_COUNT=0 # Number of times to repeat each test, regardless of their last status (0 means no repeat) +PLAYWRIGHT_RETRIES_COUNT=0 # Number of times to retry each test, only if the last run failed (0 means no retry) +PLAYWRIGHT_WORKERS_COUNT=1 # Number of workers to use for running tests +SESSION_PRO= # Feature flag marking Pro as being released, set to 1 to enable +TEST_PRO_BACKEND= # If `SESSION_PRO` is set, this is the backend to use (the only working is the dev one, set to 1) +LOCAL_DEVNET_SEED_URL= # The local devnet seed url to use +SESSION_DEBUG= # Enable debug mode on session-desktop (set to 1 to enable) +# DEBUG="pw:*" # warning: this is very verbose and needs `PRINT_ONGOING_TEST_LOGS=1` set too diff --git a/tests/automation/cta_donations.spec.ts b/tests/automation/cta_donations.spec.ts index 351f328..7d39365 100644 --- a/tests/automation/cta_donations.spec.ts +++ b/tests/automation/cta_donations.spec.ts @@ -1,13 +1,13 @@ import { englishStrippedStr } from '../localization/englishStrippedStr'; import { CTA } from './locators'; -import { test_Alice_1W } from './setup/sessionTest'; +import { test_Alice_1W_no_network } from './setup/sessionTest'; import { mockDBCreationTime } from './utilities/time_travel'; import { checkCTAStrings, hasElementPoppedUpThatShouldnt, } from './utilities/utils'; -test_Alice_1W( +test_Alice_1W_no_network( 'Donate CTA, DB age >= 7 days', async ({ aliceWindow1 }) => { await checkCTAStrings( @@ -28,7 +28,7 @@ test_Alice_1W( }, ); -test_Alice_1W( +test_Alice_1W_no_network( 'Donate CTA, DB age < 7 days', async ({ aliceWindow1 }) => { await Promise.all([ diff --git a/tests/automation/enforce_localized_str.spec.ts b/tests/automation/enforce_localized_str.spec.ts index 447e479..25f5102 100644 --- a/tests/automation/enforce_localized_str.spec.ts +++ b/tests/automation/enforce_localized_str.spec.ts @@ -292,6 +292,12 @@ function getExpectedStringFromKey( return 'Donate'; case 'maybeLater': return 'Maybe Later'; + case 'upgradeTo': + return 'Upgrade to'; + case 'proCallToActionLongerMessages': + return 'Want to send longer messages? Send more text and unlock premium features with Session Pro Beta'; + case 'proFeatureListLoadsMore': + return 'Plus loads more exclusive features'; default: // returning null means we don't have an expected string yet for this key. // This will make the test fail diff --git a/tests/automation/message_checks.spec.ts b/tests/automation/message_checks.spec.ts index 2987bd6..f4ed83c 100644 --- a/tests/automation/message_checks.spec.ts +++ b/tests/automation/message_checks.spec.ts @@ -5,6 +5,7 @@ import { longText, mediaArray, testLink } from './constants/variables'; import { Conversation, ConversationSettings, + CTA, Global, HomeScreen, } from './locators'; @@ -24,6 +25,7 @@ import { trustUser, } from './utilities/send_media'; import { + checkCTAStrings, checkModalStrings, clickOn, clickOnElement, @@ -346,15 +348,40 @@ messageLengthTestCases.forEach((testCase) => { }), ); } else { - // 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(), - ); - await clickOn(aliceWindow1, Global.confirmButton); + if (process.env.SESSION_PRO) { + console.log('Session Pro detected, checking CTA'); + // Upgrade to pro + await checkCTAStrings( + aliceWindow1, + englishStrippedStr('upgradeTo').toString(), + englishStrippedStr('proCallToActionLongerMessages').toString(), + [ + englishStrippedStr('theContinue').toString(), + englishStrippedStr('cancel').toString(), + ], + [ + ` ${englishStrippedStr( + 'proFeatureListLongerMessages', + ).toString()}`, + ` ${englishStrippedStr( + 'proFeatureListPinnedConversations', + ).toString()}`, + englishStrippedStr('proFeatureListLoadsMore').toString(), + ], + ); + await clickOn(aliceWindow1, CTA.cancelButton); + } else { + console.log('Session Pro not detected, checking modal'); + // 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(), + ); + await clickOn(aliceWindow1, Global.confirmButton); + } // Verify message didn't send try { diff --git a/tests/automation/setup/new_user.ts b/tests/automation/setup/new_user.ts index c59bec5..b92c6b2 100644 --- a/tests/automation/setup/new_user.ts +++ b/tests/automation/setup/new_user.ts @@ -43,7 +43,6 @@ export const newUser = async ( // ); await clickOn(window, Global.modalCloseButton); await clickOn(window, LeftPane.profileButton); - // Save Account ID to a variable let accountid = await window.innerText( `[data-testid=${Settings.accountId.selector}]`, diff --git a/tests/automation/setup/open.ts b/tests/automation/setup/open.ts index e2d1302..219d6e7 100644 --- a/tests/automation/setup/open.ts +++ b/tests/automation/setup/open.ts @@ -28,9 +28,9 @@ const openElectronAppOnly = async (multi: string, context?: TestContext) => { const uniqueId = v4(); process.env.NODE_APP_INSTANCE = `${MULTI_PREFIX}-devprod-${uniqueId}-${process.env.MULTI}`; process.env.NODE_ENV = NODE_ENV; - process.env.SESSION_DEBUG = '1'; - process.env.LOCAL_DEVNET_SEED_URL = 'http://seed2.getsession.org:38157/'; - // process.env.LOCAL_DEVNET_SEED_URL = 'http://sesh-net:1280' + // process.env.SESSION_DEBUG = '1'; + // process.env.LOCAL_DEVNET_SEED_URL = process.env.LOCAL_DEVNET_SEED_URL ?? 'http://seed2.getsession.org:38157/'; + // process.env.LOCAL_DEVNET_SEED_URL = 'http://sesh-net.local:1280'; // Inject custom env vars if provided if (context?.dbCreationTimestampMs) { @@ -48,7 +48,9 @@ const openElectronAppOnly = async (multi: string, context?: TestContext) => { delete process.env.DB_CREATION_TIMESTAMP_MS; } - console.info(` ${process.env.LOCAL_DEVNET_SEED_URL}`); + console.info( + ` LOCAL_DEVNET_SEED_URL: ${process.env.LOCAL_DEVNET_SEED_URL}`, + ); console.info(` NON CI RUN`); console.info(' NODE_ENV', process.env.NODE_ENV); console.info(' NODE_APP_INSTANCE', process.env.NODE_APP_INSTANCE); diff --git a/tests/automation/utilities/utils.ts b/tests/automation/utilities/utils.ts index e2f3390..2cf631e 100644 --- a/tests/automation/utilities/utils.ts +++ b/tests/automation/utilities/utils.ts @@ -546,7 +546,7 @@ function assertTextMatches( if (sanitizedExpected !== sanitizedActual) { throw new Error( - `${fieldName} is incorrect.\nExpected: ${sanitizedExpected}\nActual: ${sanitizedActual}`, + `${fieldName} is incorrect.\nExpected: ${sanitizedExpected}\nActual: ${sanitizedActual}\n`, ); } }