From 159fde2fa657aac492e0df3b6a7574d367b8b23f Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Thu, 22 Oct 2026 15:10:49 +0300 Subject: [PATCH 01/13] Tests optimization --- test/source/buf.ts | 70 +- .../strategies/send-message-strategy.ts | 10 +- test/source/mock/wkd/wkd-endpoints.ts | 3 + .../tests/browser-unit-tests/unit-Wkd.js | 28 +- test/source/tests/compose.ts | 55 +- test/source/tests/decrypt.ts | 913 ++++++------------ test/source/tests/gmail.ts | 259 ++--- test/source/tests/setup.ts | 27 - test/source/tests/unit-browser.ts | 4 +- test/source/tests/unit-node.ts | 84 +- 10 files changed, 517 insertions(+), 936 deletions(-) diff --git a/test/source/buf.ts b/test/source/buf.ts index 507e925d4ee..cc7d569b18e 100644 --- a/test/source/buf.ts +++ b/test/source/buf.ts @@ -5,57 +5,55 @@ import test from 'ava'; import { Buf } from '../../extension/js/common/core/buf.js'; import { equals } from './tests/unit-node.js'; -const lousyRandomBytes = (len = 30): Uint8Array => { - const a = new Uint8Array(len); - for (let i = 0; i < len; i++) { - a[i] = Math.floor(Math.random() * 256); - } - return a; -}; - -const withThousandRandomInputs = (cb: (data: Uint8Array) => void) => { - for (let i = 0; i < 1000; i++) { - const input = lousyRandomBytes(); - cb(input); - } -}; +const BYTE_INPUTS = [ + new Uint8Array(), + new Uint8Array([255]), + new Uint8Array([251, 255]), + new Uint8Array([251, 255, 255]), + // Exercise every padding length, all byte values, and raw-string chunk boundaries. + ...[4, 5, 6, 7, 8, 9, 29, 30, 31, 255, 256, 257, 32767, 32768, 32769].map(length => Uint8Array.from({ length }, (_, i) => (i * 73 + 251) % 256)), +]; const UTF8 = `გამარჯობა.\nこんにちは。\nЗдравствуй.\nChào bạn.\nDobrý deň!\n여보세요?\n你好。\r\n\t。 `; const UTF8_AS_BYTES = Buffer.from(UTF8); const UTF8_AS_RAW_STRING = Buffer.from(UTF8).toString('binary'); -test(`1000x Buf.fromUint8(data).toBase64Str() = Buffer.from(data).toString('base64')`, async t => { - withThousandRandomInputs(data => { - equals(Buf.fromUint8(data).toBase64Str(), Buffer.from(data).toString('base64')); - }); - t.pass(); +test(`Buf.fromUint8(data).toBase64Str() = Buffer.from(data).toString('base64')`, t => { + for (const data of BYTE_INPUTS) { + t.is(Buf.fromUint8(data).toBase64Str(), Buffer.from(data).toString('base64'), `length ${data.length}`); + } }); -test(`1000x Buf.fromUint8(data).toRawBytesStr() = Buffer.from(data).toString('binary')`, async t => { - withThousandRandomInputs(data => { - equals(Buf.fromUint8(data).toRawBytesStr(), Buffer.from(data).toString('binary')); - }); - t.pass(); +test(`Buf.fromUint8(data).toRawBytesStr() = Buffer.from(data).toString('binary')`, t => { + for (const data of BYTE_INPUTS) { + t.is(Buf.fromUint8(data).toRawBytesStr(), Buffer.from(data).toString('binary'), `length ${data.length}`); + } }); -test('1000x Buf.fromBase64UrlStr(Buf.fromUint8(data).toBase64UrlStr()) = data', async t => { - withThousandRandomInputs(data => { - equals(Buf.fromBase64UrlStr(Buf.fromUint8(data).toBase64UrlStr()), data); - }); +test(`Buf.fromUint8(data).toBase64UrlStr() = Buffer.from(data).toString('base64url')`, t => { + for (const data of BYTE_INPUTS) { + t.is(Buf.fromUint8(data).toBase64UrlStr(), Buffer.from(data).toString('base64url'), `length ${data.length}`); + } +}); + +test(`Buf.fromBase64UrlStr(Buffer.from(data).toString('base64url')) = data`, t => { + for (const data of BYTE_INPUTS) { + equals(Buf.fromBase64UrlStr(Buffer.from(data).toString('base64url')), data); + } t.pass(); }); -test('1000x Buf.fromRawBytesStr(Buf.fromUint8(data).toRawBytesStr()) = data', async t => { - withThousandRandomInputs(data => { - equals(Buf.fromRawBytesStr(Buf.fromUint8(data).toRawBytesStr()), data); - }); +test(`Buf.fromRawBytesStr(Buffer.from(data).toString('binary')) = data`, t => { + for (const data of BYTE_INPUTS) { + equals(Buf.fromRawBytesStr(Buffer.from(data).toString('binary')), data); + } t.pass(); }); -test('1000x Buf.fromBase64Str(Buf.fromUint8(data).toBase64Str()) = data', async t => { - withThousandRandomInputs(data => { - equals(Buf.fromBase64Str(Buf.fromUint8(data).toBase64Str()), data); - }); +test(`Buf.fromBase64Str(Buffer.from(data).toString('base64')) = data`, t => { + for (const data of BYTE_INPUTS) { + equals(Buf.fromBase64Str(Buffer.from(data).toString('base64')), data); + } t.pass(); }); diff --git a/test/source/mock/google/strategies/send-message-strategy.ts b/test/source/mock/google/strategies/send-message-strategy.ts index 2c80c1d497d..30c3de54741 100644 --- a/test/source/mock/google/strategies/send-message-strategy.ts +++ b/test/source/mock/google/strategies/send-message-strategy.ts @@ -112,11 +112,13 @@ class PwdAndPubkeyEncryptedMessagesWithFlowCryptComApiTestStrategy implements IT }; } class PwdEncryptedMessageWithFlowCryptComApiTestStrategy implements ITestMsgStrategy { + public constructor(private expectedSenderEmail: string) {} + public test = async (parseResult: ParseMsgResult) => { await check7bitEncodedPgpMimeParts(parseResult, ['flowcrypt.compatibility.1pp1', 'ci.tests.gmail'], true); const mimeMsg = parseResult.mimeMsg; - const senderEmail = Str.parseEmail(mimeMsg.from!.text).email; - if (!mimeMsg.text?.includes(`${senderEmail} has sent you a password-encrypted email`)) { + expect(Str.parseEmail(mimeMsg.from!.text).email).to.equal(this.expectedSenderEmail); + if (!mimeMsg.text?.includes(`${this.expectedSenderEmail} has sent you a password-encrypted email`)) { throw new HttpClientErr(`Error checking sent text in:\n\n${mimeMsg.text}`); } checkPwdEncryptedMessage(mimeMsg.text); @@ -318,7 +320,6 @@ class PlainTextMessageTestStrategy implements ITestMsgStrategy { }; } - class NoopTestStrategy implements ITestMsgStrategy { // eslint-disable-next-line @typescript-eslint/no-empty-function public test = async () => {}; @@ -468,7 +469,8 @@ export class TestBySubjectStrategyContext { } else if (subject.includes('Test Footer (Mock Test)')) { this.strategy = new MessageWithFooterTestStrategy(); } else if (subject.includes('PWD encrypted message with flowcrypt.com/shared-tenant-fes')) { - this.strategy = new PwdEncryptedMessageWithFlowCryptComApiTestStrategy(); + // The attachment test uses the original subject and the primary compatibility address. + this.strategy = new PwdEncryptedMessageWithFlowCryptComApiTestStrategy(/ - from: (.+)$/.exec(subject)?.[1] ?? 'flowcrypt.compatibility@gmail.com'); } else if (subject.includes('PWD and pubkey encrypted messages with flowcrypt.com/shared-tenant-fes')) { this.strategy = new PwdAndPubkeyEncryptedMessagesWithFlowCryptComApiTestStrategy(); } else if (subject.includes('PWD encrypted message with FES - ID TOKEN')) { diff --git a/test/source/mock/wkd/wkd-endpoints.ts b/test/source/mock/wkd/wkd-endpoints.ts index 2f8fc9641b0..47584396f05 100644 --- a/test/source/mock/wkd/wkd-endpoints.ts +++ b/test/source/mock/wkd/wkd-endpoints.ts @@ -54,6 +54,9 @@ export const getMockWkdEndpoints = (config: WkdConfig | undefined): HandlersDefi '/.well-known/openpgpkey/localhost/policy': async () => { return ''; // allow advanced for localhost }, + '/.well-known/openpgpkey/example.com/policy': async () => { + throw new HttpClientErr('Advanced policy not found', Status.NOT_FOUND); // exercise direct fallback + }, '/.well-known/openpgpkey/policy': async () => { return ''; // allow direct for all }, diff --git a/test/source/tests/browser-unit-tests/unit-Wkd.js b/test/source/tests/browser-unit-tests/unit-Wkd.js index 444fa8c6cd3..079804033e6 100644 --- a/test/source/tests/browser-unit-tests/unit-Wkd.js +++ b/test/source/tests/browser-unit-tests/unit-Wkd.js @@ -20,17 +20,14 @@ * Do not put any code whatsoever outside of the async functions. */ -BROWSER_UNIT_TEST_NAME(`Wkd direct method`); +BROWSER_UNIT_TEST_NAME(`Wkd direct method when advanced policy is absent`); (async () => { const wkd = new Wkd(); - let email; - email = 'john.doe@localhost'; - if (!(await wkd.lookupEmail(email)).pubkeys.length) { - throw Error(`Wkd for ${email} didn't return a pubkey`); - } - email = 'John.Doe@localhost'; - if (!(await wkd.lookupEmail(email)).pubkeys.length) { - throw Error(`Wkd for ${email} didn't return a pubkey`); + for (const email of ['john.doe@example.com', 'John.Doe@example.com', 'John.Doe@EXAMPLE.com']) { + const { pubkeys } = await wkd.lookupEmail(email); + if (pubkeys.length !== 1 || (await KeyUtil.parse(pubkeys[0])).id.toUpperCase() !== '094C3CBA696FA009F6015C473B635D858A1DB5E0') { + throw Error(`Wkd for ${email} didn't return the expected direct pubkey`); + } } return 'pass'; })(); @@ -38,14 +35,11 @@ BROWSER_UNIT_TEST_NAME(`Wkd direct method`); BROWSER_UNIT_TEST_NAME(`Wkd advanced method`); (async () => { const wkd = new Wkd(); - let email; - email = 'john.doe@localhost'; - if (!(await wkd.lookupEmail(email)).pubkeys.length) { - throw Error(`Wkd for ${email} didn't return a pubkey`); - } - email = 'John.Doe@localHOST'; - if (!(await wkd.lookupEmail(email)).pubkeys.length) { - throw Error(`Wkd for ${email} didn't return a pubkey`); + for (const email of ['john.doe@localhost', 'John.Doe@localhost', 'John.Doe@localHOST']) { + const { pubkeys } = await wkd.lookupEmail(email); + if (pubkeys.length !== 1 || (await KeyUtil.parse(pubkeys[0])).id.toUpperCase() !== 'CB1B7A41BA7C1CBAA08A6166B902CB65C694D6B4') { + throw Error(`Wkd for ${email} didn't return the expected advanced pubkey`); + } } return 'pass'; })(); diff --git a/test/source/tests/compose.ts b/test/source/tests/compose.ts index e4af4745cc7..9c59bc31002 100644 --- a/test/source/tests/compose.ts +++ b/test/source/tests/compose.ts @@ -145,39 +145,26 @@ export const defineComposeTests = (testVariant: TestVariant, testWithBrowser: Te }) ); - test( - 'compose - check for sender [flowcrypt.compatibility@gmail.com] from a password-protected email', - testWithBrowser(async (t, browser) => { - const senderEmail = 'flowcrypt.compatibility@gmail.com'; - await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility', { - google: { acctAliases: flowcryptCompatibilityAliasList }, - }); - const msgPwd = 'super hard password for the message'; - const subject = 'PWD encrypted message with flowcrypt.com/shared-tenant-fes'; - const composePage = await ComposePageRecipe.openStandalone(t, browser, 'compatibility'); - await ComposePageRecipe.selectFromOption(composePage, senderEmail); - await ComposePageRecipe.fillMsg(composePage, { to: 'test@email.com' }, subject); - await ComposePageRecipe.sendAndClose(composePage, { password: msgPwd }); - // this test is using PwdEncryptedMessageWithFlowCryptComApiTestStrategy to check sent result based on subject "PWD encrypted message with flowcrypt.com/shared-tenant-fes" - }) - ); - - test( - 'compose - check for sender [flowcryptcompatibility@gmail.com] (alias) from a password-protected email', - testWithBrowser(async (t, browser) => { - const senderEmail = 'flowcrypt.compatibility@gmail.com'; - await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility', { - google: { acctAliases: flowcryptCompatibilityAliasList }, - }); - const msgPwd = 'super hard password for the message'; - const subject = 'PWD encrypted message with flowcrypt.com/shared-tenant-fes'; - const composePage = await ComposePageRecipe.openStandalone(t, browser, 'compatibility'); - await ComposePageRecipe.selectFromOption(composePage, senderEmail); - await ComposePageRecipe.fillMsg(composePage, { to: 'test@email.com' }, subject); - await ComposePageRecipe.sendAndClose(composePage, { password: msgPwd }); - // this test is using PwdEncryptedMessageWithFlowCryptComApiTestStrategy to check sent result based on subject "PWD encrypted message with flowcrypt.com/shared-tenant-fes" - }) - ); + for (const { senderEmail, aliasLabel } of [ + { senderEmail: 'flowcrypt.compatibility@gmail.com', aliasLabel: '' }, + { senderEmail: 'flowcryptcompatibility@gmail.com', aliasLabel: ' (alias)' }, + ]) { + test( + `compose - check for sender [${senderEmail}]${aliasLabel} from a password-protected email`, + testWithBrowser(async (t, browser) => { + await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility', { + google: { acctAliases: flowcryptCompatibilityAliasList }, + }); + const msgPwd = 'super hard password for the message'; + const subject = `PWD encrypted message with flowcrypt.com/shared-tenant-fes - from: ${senderEmail}`; + const composePage = await ComposePageRecipe.openStandalone(t, browser, 'compatibility'); + await ComposePageRecipe.selectFromOption(composePage, senderEmail); + await ComposePageRecipe.fillMsg(composePage, { to: 'test@email.com' }, subject); + await ComposePageRecipe.sendAndClose(composePage, { password: msgPwd }); + // PwdEncryptedMessageWithFlowCryptComApiTestStrategy checks the sender specified in the subject. + }) + ); + } test( 'compose - check for sender [ci.tests.gmail@flowcrypt.test] from a password-protected email', @@ -185,7 +172,7 @@ export const defineComposeTests = (testVariant: TestVariant, testWithBrowser: Te const senderEmail = 'ci.tests.gmail@flowcrypt.test'; await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'ci.tests.gmail'); const msgPwd = 'super hard password for the message'; - const subject = 'PWD encrypted message with flowcrypt.com/shared-tenant-fes'; + const subject = `PWD encrypted message with flowcrypt.com/shared-tenant-fes - from: ${senderEmail}`; const composePage = await ComposePageRecipe.openStandalone(t, browser, senderEmail); await ComposePageRecipe.fillMsg(composePage, { to: 'test@email.com' }, subject); await ComposePageRecipe.sendAndClose(composePage, { password: msgPwd }); diff --git a/test/source/tests/decrypt.ts b/test/source/tests/decrypt.ts index a3a2d7cebdf..e7acb9d4130 100644 --- a/test/source/tests/decrypt.ts +++ b/test/source/tests/decrypt.ts @@ -2,12 +2,12 @@ import test from 'ava'; -import { Config, TestVariant, Util } from './../util'; +import { Config, TestMessage, TestVariant, Util } from './../util'; import { testConstants } from './tooling/consts'; import { BrowserRecipe } from './tooling/browser-recipe'; import { InboxPageRecipe } from './page-recipe/inbox-page-recipe'; import { SettingsPageRecipe } from './page-recipe/settings-page-recipe'; -import { TestWithBrowser } from './../test'; +import { CommonAcct, TestWithBrowser } from './../test'; import { expect } from 'chai'; import { PageRecipe } from './page-recipe/abstract-page-recipe'; import { @@ -430,385 +430,328 @@ export const defineDecryptTests = (testVariant: TestVariant, testWithBrowser: Te }) ); - test( - `decrypt - without a subject`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '1600f39127880eed', - { - content: ['This is a compatibility test email'], - unexpectedContent: ['Encrypted Subject:', '(no subject)'], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [enigmail] encrypted iso-2022-jp pgp/mime`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '16f66f1da9d50d05', - { - content: ['ゾし逸現飲'], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [enigmail] encrypted iso-2022-jp, plain text`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '16f431a0b9056562', - { - content: ['ゾし逸現飲'], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); - - test( - `decrypt - iso-2022-jp, signed plain text`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '18024d53a24b19ff', - { - content: ['テストです\nテスト'], - encryption: 'not encrypted', - signature: 'could not verify signature: missing pubkey 73A5534E5887BBAA', - }, - authHdr - ); - }) - ); - - test( - `decrypt - quoted part parsing will not crash browser`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '16b7fce1c1589c0a', - { - content: ['point to them directly', 'free cert through', 'will honestly soon', 'dropped significantly'], - encryption: 'encrypted', - signature: 'not signed', - quoted: true, - }, - authHdr - ); - }) - ); - - test( - `decrypt - [flowcrypt] signed message inline`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '15f7f5e966792203', - { - content: ['Standard message', 'signed inline', 'should easily verify', 'This is email footer'], - encryption: 'not encrypted', - signature: 'could not verify signature: missing pubkey 06CA553EC2455D70', - }, - authHdr - ); - }) - ); - - test( - `decrypt - cleartext signed message detected in an attachment`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'ci.tests.gmail'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '1885ded59a2b5a8d', - { - content: ['Standard message', 'signed inline', 'should easily verify', 'This is email footer'], - encryption: 'not encrypted', - signature: 'could not verify signature: missing pubkey 06CA553EC2455D70', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [gpgmail] signed message will get parsed and rendered (though verification fails, enigmail does the same)`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '15f81b5e6ed91b20', - { - content: ['Hi this is a signed message.'], - encryption: 'not encrypted', - signature: 'could not verify signature: missing pubkey 21FC55064B1DDC75', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [gpg] signed fully armored message`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '1707b9c96c5d7893', - { - content: ['this was encrypted with gpg', 'gpg --sign --armor -r flowcrypt.compatibility@gmail.com ./text.txt'], - encryption: 'not encrypted', - signature: 'could not verify signature: signed by flowcrypt.compatibility@gmail.com but message is from sender@domain.com', - quoted: false, - }, - authHdr - ); - }) - ); - - test( - `decrypt - [flowcrypt] encrypted utf8`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '15f7f5f098d6bc36', - { - content: ['გამარჯობა.', 'こんにちは。', 'Здравствуй.', 'Chào bạn.', 'Dobrý deň!', '여보세요?', '你好。'], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [flowcrypt] encrypted thai utf8`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '1645e37647db32f8', - { - content: ['ทดสอบ', 'นี้เป็นการทดสอบ', 'ภาษาไทย'], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [facebook] encrypted utf8`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '16180866d0ae26c3', - { - content: ['Сергій Ткаченко'], - encryption: 'encrypted', - signature: 'could not verify signature: missing pubkey 6859679E2F20BEF4', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [gpgmail] encrypted utf8`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - const gmailPage = await browser.newPage(t, `${t.context.urls?.mockGmailUrl()}/161b2ac5a73d4097`, undefined, authHdr); - await gmailPage.waitAll('iframe'); - const pgpBlockFrame = await gmailPage.getFrame(['pgp_block.htm']); - await BrowserRecipe.pgpBlockCheck(t, pgpBlockFrame, { - content: ['Prozent => %', 'Scharf-S => ß', 'Ue => Ü', 'Ae => Ä'], + const decryptCases: { name: string; acct?: CommonAcct; msgId: string; expected: TestMessage }[] = [ + { + name: `decrypt - without a subject`, + msgId: '1600f39127880eed', + expected: { + content: ['This is a compatibility test email'], + unexpectedContent: ['Encrypted Subject:', '(no subject)'], encryption: 'encrypted', - signature: 'could not verify signature: missing pubkey 9BBE40BC1E8CE4A3', - }); - await gmailPage.waitForContent('.message_inner_body', '1io | Sales & Marketing'); - await gmailPage.waitForContent('.message_inner_body', '1io GmbH'); - await gmailPage.close(); - }) - ); - - test( - `decrypt - [enigmail] encrypted utf8`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '1639b8ceb6c44a4c', - { - content: ['TEST, ПРОВЕРКА', 'C увaжeниeм, Пaвлoвcкий Poмaн Oлeгoвич.'], - encryption: 'encrypted', - signature: 'not signed', - quoted: true, - }, - authHdr - ); - }) - ); - - test( - `decrypt - [enigmail] encrypted pgp/mime`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '15f7fcace2d72246', - { - content: ['This is an encrypted message.', 'Not much going on here.'], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [enigmail] encrypted inline`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '15f7fcb7fabc7511', - { - content: ['This is inline-encrypted message from Enigmail.', 'Yay.'], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [enigmail] encrypted+signed inline`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '15f7fd2fd072cff2', - { - content: ['This message is both encrypted + signed.'], - encryption: 'encrypted', - signature: 'could not verify signature: missing pubkey CBD1C3466E9C437F', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [enigmail] encrypted+signed pgp/mime`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '15f7fd3ba3f37cf3', - { - content: ['Message encrypted and signed using PGP/MIME.'], - encryption: 'encrypted', - signature: 'could not verify signature: missing pubkey CBD1C3466E9C437F', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [enigmail] encrypted+signed+file pgp/mime + load from gmail`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '15f7fd7fe45fc026', - { - content: ['Message encrypted and signed as a whole using PGP/MIME.', 'cape-town-central.jpg', '185.69 kB'], - encryption: 'encrypted', - signature: 'could not verify signature: missing pubkey CBD1C3466E9C437F', - }, - authHdr - ); - }) - ); - - test( - `decrypt - encrypted missing checksum`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '15f7ffbebc6ba296', - { - content: ['400 library systems in 177 countries worldwide'], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); + signature: 'not signed', + }, + }, + { + name: `decrypt - [enigmail] encrypted iso-2022-jp pgp/mime`, + msgId: '16f66f1da9d50d05', + expected: { + content: ['ゾし逸現飲'], + encryption: 'encrypted', + signature: 'not signed', + }, + }, + { + name: `decrypt - [enigmail] encrypted iso-2022-jp, plain text`, + msgId: '16f431a0b9056562', + expected: { + content: ['ゾし逸現飲'], + encryption: 'encrypted', + signature: 'not signed', + }, + }, + { + name: `decrypt - iso-2022-jp, signed plain text`, + msgId: '18024d53a24b19ff', + expected: { + content: ['テストです\nテスト'], + encryption: 'not encrypted', + signature: 'could not verify signature: missing pubkey 73A5534E5887BBAA', + }, + }, + { + name: `decrypt - quoted part parsing will not crash browser`, + msgId: '16b7fce1c1589c0a', + expected: { + content: ['point to them directly', 'free cert through', 'will honestly soon', 'dropped significantly'], + encryption: 'encrypted', + signature: 'not signed', + quoted: true, + }, + }, + { + name: `decrypt - [flowcrypt] signed message inline`, + msgId: '15f7f5e966792203', + expected: { + content: ['Standard message', 'signed inline', 'should easily verify', 'This is email footer'], + encryption: 'not encrypted', + signature: 'could not verify signature: missing pubkey 06CA553EC2455D70', + }, + }, + { + name: `decrypt - cleartext signed message detected in an attachment`, + acct: 'ci.tests.gmail', + msgId: '1885ded59a2b5a8d', + expected: { + content: ['Standard message', 'signed inline', 'should easily verify', 'This is email footer'], + encryption: 'not encrypted', + signature: 'could not verify signature: missing pubkey 06CA553EC2455D70', + }, + }, + { + name: `decrypt - [gpgmail] signed message will get parsed and rendered (though verification fails, enigmail does the same)`, + msgId: '15f81b5e6ed91b20', + expected: { + content: ['Hi this is a signed message.'], + encryption: 'not encrypted', + signature: 'could not verify signature: missing pubkey 21FC55064B1DDC75', + }, + }, + { + name: `decrypt - [gpg] signed fully armored message`, + msgId: '1707b9c96c5d7893', + expected: { + content: ['this was encrypted with gpg', 'gpg --sign --armor -r flowcrypt.compatibility@gmail.com ./text.txt'], + encryption: 'not encrypted', + signature: 'could not verify signature: signed by flowcrypt.compatibility@gmail.com but message is from sender@domain.com', + quoted: false, + }, + }, + { + name: `decrypt - [flowcrypt] encrypted utf8`, + msgId: '15f7f5f098d6bc36', + expected: { + content: ['გამარჯობა.', 'こんにちは。', 'Здравствуй.', 'Chào bạn.', 'Dobrý deň!', '여보세요?', '你好。'], + encryption: 'encrypted', + signature: 'not signed', + }, + }, + { + name: `decrypt - [flowcrypt] encrypted thai utf8`, + msgId: '1645e37647db32f8', + expected: { + content: ['ทดสอบ', 'นี้เป็นการทดสอบ', 'ภาษาไทย'], + encryption: 'encrypted', + signature: 'not signed', + }, + }, + { + name: `decrypt - [facebook] encrypted utf8`, + msgId: '16180866d0ae26c3', + expected: { + content: ['Сергій Ткаченко'], + encryption: 'encrypted', + signature: 'could not verify signature: missing pubkey 6859679E2F20BEF4', + }, + }, + { + name: `decrypt - [enigmail] encrypted utf8`, + msgId: '1639b8ceb6c44a4c', + expected: { + content: ['TEST, ПРОВЕРКА', 'C увaжeниeм, Пaвлoвcкий Poмaн Oлeгoвич.'], + encryption: 'encrypted', + signature: 'not signed', + quoted: true, + }, + }, + { + name: `decrypt - [enigmail] encrypted pgp/mime`, + msgId: '15f7fcace2d72246', + expected: { + content: ['This is an encrypted message.', 'Not much going on here.'], + encryption: 'encrypted', + signature: 'not signed', + }, + }, + { + name: `decrypt - [enigmail] encrypted inline`, + msgId: '15f7fcb7fabc7511', + expected: { + content: ['This is inline-encrypted message from Enigmail.', 'Yay.'], + encryption: 'encrypted', + signature: 'not signed', + }, + }, + { + name: `decrypt - [enigmail] encrypted+signed inline`, + msgId: '15f7fd2fd072cff2', + expected: { + content: ['This message is both encrypted + signed.'], + encryption: 'encrypted', + signature: 'could not verify signature: missing pubkey CBD1C3466E9C437F', + }, + }, + { + name: `decrypt - [enigmail] encrypted+signed pgp/mime`, + msgId: '15f7fd3ba3f37cf3', + expected: { + content: ['Message encrypted and signed using PGP/MIME.'], + encryption: 'encrypted', + signature: 'could not verify signature: missing pubkey CBD1C3466E9C437F', + }, + }, + { + name: `decrypt - [enigmail] encrypted+signed+file pgp/mime + load from gmail`, + msgId: '15f7fd7fe45fc026', + expected: { + content: ['Message encrypted and signed as a whole using PGP/MIME.', 'cape-town-central.jpg', '185.69 kB'], + encryption: 'encrypted', + signature: 'could not verify signature: missing pubkey CBD1C3466E9C437F', + }, + }, + { + name: `decrypt - encrypted missing checksum`, + msgId: '15f7ffbebc6ba296', + expected: { + content: ['400 library systems in 177 countries worldwide'], + encryption: 'encrypted', + signature: 'not signed', + }, + }, + { + name: `decrypt - pgp/mime with large attachment - mismatch`, + msgId: '162275c819bcbf9b', + expected: { + content: ['No decryption key packets found'], + error: 'decrypt error', + expectPercentageProgress: true, + }, + }, + { + name: `decrypt - pgp/mime with large attachment as message.asc`, + msgId: '1622eaa286f90737', + expected: { + content: ['This will will have a larger attachment below', 'image-large.jpg'], + encryption: 'encrypted', + signature: 'not signed', + expectPercentageProgress: true, + }, + }, + { + name: `decrypt - pgp/mime with small attachments as message.asc`, + msgId: '16224f57d26e038e', + expected: { + content: ['Can you confirm this works.', 'Senior Consultant, Security'], + encryption: 'encrypted', + signature: 'could not verify signature: missing pubkey 6FC39F2CDD104B3C', + }, + }, + { + name: `decrypt - [flowcrypt] escape and keep tags in plain text`, + msgId: '1663ac8b70e22517', + expected: { + content: ['thispasswordhasainit'], + encryption: 'encrypted', + signature: 'not signed', + }, + }, + { + name: `decrypt - [symantec] base64 german umlauts`, + msgId: '166117c082a73905', + expected: { + content: ['verspätet die gewünschte', 'Grüße', 'ä, ü, ö or ß'], + encryption: 'encrypted', + signature: 'not signed', + }, + }, + { + name: `decrypt - [gnupg v2] thai text`, + msgId: '166147ea9bb6669d', + expected: { + content: ['still can read your message ยังคงอ่านได้อยู่', "This is time I can't read ครั้งนี้อ่านไม่ได้แล้ว"], + encryption: 'encrypted', + signature: 'not signed', + }, + }, + { + name: `decrypt - [gnupg v2] thai text in html`, + msgId: '16613ff9c3735102', + expected: { + content: ['เทสไทย', 'Vulnerability Assessment'], + encryption: 'encrypted', + signature: 'not signed', + }, + }, + { + name: `decrypt - [enigmail] basic html`, + msgId: '1663a65bbd73ce1a', + expected: { + content: ['The following text is bold: this is bold'], + encryption: 'encrypted', + signature: 'could not verify signature: missing pubkey D97859FF68EA0F04', + }, + }, + { + name: `decrypt - [thunderbird] unicode chinese`, + msgId: '164563dc9e3a8549', + expected: { + content: ['這封信是用 Thunderbird 做加密與簽章所寄出。', '第四屆董事會成員、認證委員會委員'], + encryption: 'encrypted', + signature: 'could not verify signature: missing pubkey 0B38948F4CD565B5', + quoted: true, + }, + }, + { + name: `decrypt - [security] mdc - missing - error`, + msgId: '163df1bf12034b9d', + expected: { + error: 'decrypt error', + content: ['Security threat!', 'MDC', 'Display the message at your own risk.'], + unexpectedContent: ['As stated in subject', 'Shall not decrypt automatically', 'Has to show a warning'], + }, + }, + { + name: `decrypt - [security] mdc - modification detected - error`, + msgId: '163dee87a4bfed45', + expected: { + error: 'decrypt error', + content: ['Security threat - opening this message is dangerous because it was modified in transit.'], + }, + }, + { + name: `decrypt - [everdesk] message encrypted for sub but claims encryptedFor:primary,sub`, + msgId: '16d558cb71e8d510', + expected: { + content: ['this is a sample for FlowCrypt compatibility'], + encryption: 'encrypted', + signature: 'not signed', + }, + }, + { + name: `decrypt - [pep] pgp/mime message with text encoded as inline attachment`, + msgId: '16ff09b1baca2051', + expected: { + content: ['Subject: Re: Test from Tom iOS', 'test again', 'A message', 'Testing'], + encryption: 'encrypted', + signature: 'could not verify signature: missing pubkey A4556258EFD7EE07', + quoted: true, + }, + }, + ]; + for (const { name, acct = 'compatibility', msgId, expected } of decryptCases) { + test( + name, + testWithBrowser(async (t, browser) => { + const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, acct); + await BrowserRecipe.pgpBlockVerifyDecryptedContent(t, browser, msgId, expected, authHdr); + }) + ); + } test( - `decrypt - pgp/mime with large attachment - mismatch`, + `decrypt - [gpgmail] encrypted utf8`, testWithBrowser(async (t, browser) => { const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '162275c819bcbf9b', - { - content: ['No decryption key packets found'], - error: 'decrypt error', - expectPercentageProgress: true, - }, - authHdr - ); + const gmailPage = await browser.newPage(t, `${t.context.urls?.mockGmailUrl()}/161b2ac5a73d4097`, undefined, authHdr); + await gmailPage.waitAll('iframe'); + const pgpBlockFrame = await gmailPage.getFrame(['pgp_block.htm']); + await BrowserRecipe.pgpBlockCheck(t, pgpBlockFrame, { + content: ['Prozent => %', 'Scharf-S => ß', 'Ue => Ü', 'Ae => Ä'], + encryption: 'encrypted', + signature: 'could not verify signature: missing pubkey 9BBE40BC1E8CE4A3', + }); + await gmailPage.waitForContent('.message_inner_body', '1io | Sales & Marketing'); + await gmailPage.waitForContent('.message_inner_body', '1io GmbH'); + await gmailPage.close(); }) ); @@ -830,187 +773,6 @@ export const defineDecryptTests = (testVariant: TestVariant, testWithBrowser: Te }) ); - test( - `decrypt - pgp/mime with large attachment as message.asc`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '1622eaa286f90737', - { - content: ['This will will have a larger attachment below', 'image-large.jpg'], - encryption: 'encrypted', - signature: 'not signed', - expectPercentageProgress: true, - }, - authHdr - ); - }) - ); - - test( - `decrypt - pgp/mime with small attachments as message.asc`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '16224f57d26e038e', - { - content: ['Can you confirm this works.', 'Senior Consultant, Security'], - encryption: 'encrypted', - signature: 'could not verify signature: missing pubkey 6FC39F2CDD104B3C', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [flowcrypt] escape and keep tags in plain text`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '1663ac8b70e22517', - { - content: ['thispasswordhasainit'], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [symantec] base64 german umlauts`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '166117c082a73905', - { - content: ['verspätet die gewünschte', 'Grüße', 'ä, ü, ö or ß'], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [gnupg v2] thai text`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '166147ea9bb6669d', - { - content: ['still can read your message ยังคงอ่านได้อยู่', "This is time I can't read ครั้งนี้อ่านไม่ได้แล้ว"], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [gnupg v2] thai text in html`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '16613ff9c3735102', - { - content: ['เทสไทย', 'Vulnerability Assessment'], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [enigmail] basic html`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '1663a65bbd73ce1a', - { - content: ['The following text is bold: this is bold'], - encryption: 'encrypted', - signature: 'could not verify signature: missing pubkey D97859FF68EA0F04', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [thunderbird] unicode chinese`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '164563dc9e3a8549', - { - content: ['這封信是用 Thunderbird 做加密與簽章所寄出。', '第四屆董事會成員、認證委員會委員'], - encryption: 'encrypted', - signature: 'could not verify signature: missing pubkey 0B38948F4CD565B5', - quoted: true, - }, - authHdr - ); - }) - ); - - test( - `decrypt - [security] mdc - missing - error`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '163df1bf12034b9d', - { - error: 'decrypt error', - content: ['Security threat!', 'MDC', 'Display the message at your own risk.'], - unexpectedContent: ['As stated in subject', 'Shall not decrypt automatically', 'Has to show a warning'], - }, - authHdr - ); - }) - ); - - test( - `decrypt - [security] mdc - modification detected - error`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '163dee87a4bfed45', - { - error: 'decrypt error', - content: ['Security threat - opening this message is dangerous because it was modified in transit.'], - }, - authHdr - ); - }) - ); - test( `decrypt - [security] signed message - maliciously modified - should not pass`, testWithBrowser(async (t, browser) => { @@ -1093,43 +855,6 @@ XZ8r4OC6sguP/yozWlkG+7dDxsgKQVBENeG6Lw== }) ); - test( - `decrypt - [everdesk] message encrypted for sub but claims encryptedFor:primary,sub`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '16d558cb71e8d510', - { - content: ['this is a sample for FlowCrypt compatibility'], - encryption: 'encrypted', - signature: 'not signed', - }, - authHdr - ); - }) - ); - - test( - `decrypt - [pep] pgp/mime message with text encoded as inline attachment`, - testWithBrowser(async (t, browser) => { - const { authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); - await BrowserRecipe.pgpBlockVerifyDecryptedContent( - t, - browser, - '16ff09b1baca2051', - { - content: ['Subject: Re: Test from Tom iOS', 'test again', 'A message', 'Testing'], - encryption: 'encrypted', - signature: 'could not verify signature: missing pubkey A4556258EFD7EE07', - quoted: true, - }, - authHdr - ); - }) - ); - test( `compose - #5125 test passphrase anti brute force protection`, testWithBrowser(async (t, browser) => { diff --git a/test/source/tests/gmail.ts b/test/source/tests/gmail.ts index 01eaa2530f8..96365e39225 100644 --- a/test/source/tests/gmail.ts +++ b/test/source/tests/gmail.ts @@ -218,64 +218,37 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test ); test( - 'mail.google.com - Thunderbird signature [html] is recognized', + 'mail.google.com - Thunderbird HTML signed, plain signed, and signed + encrypted messages render correctly', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/FMfcgzGkbDZKPJrNLplXZhKfWwtgjrXt'); - // validate pgp_block.htm is rendered - const pgpBlockUrls = await gmailPage.getFramesUrls(['/chrome/elements/pgp_block.htm'], { - sleep: 10, - appearIn: 25, - }); - expect(pgpBlockUrls.length).to.equal(1); - const pgpBlockFrame = await gmailPage.getFrame([pgpBlockUrls[0]]); - await BrowserRecipe.pgpBlockCheck(t, pgpBlockFrame, { - content: ['1234'], - encryption: 'not encrypted', - signature: 'signed', - }); - await pageHasSecureReplyContainer(t, browser, gmailPage); - await testMinimumElementHeight(gmailPage, '.pgp_block.signedDetached', 80); - await testMinimumElementHeight(gmailPage, '.pgp_block.publicKey', 120); - const pubkeyPage = await gmailPage.getFrame(['/chrome/elements/pgp_pubkey.htm']); - await pubkeyPage.waitForContent('@container-pgp-pubkey', 'Fingerprint: 50B7 A032 B5E1 FBAB 24BA B205 B362 45FD AC2F BF3D'); - expect(await gmailPage.isElementVisible('.aQH')).to.equal(false); // original attachment container(s) should be hidden - }) - ); - - test( - 'mail.google.com - Thunderbird signature [plain] is recognized + correct height', - testWithBrowser(async (t, browser) => { - await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/FMfcgzGkbDZKPKzSnGtGKZrPZSbTBNnB'); - // validate pgp_block.htm is rendered - const pgpBlockUrls = await gmailPage.getFramesUrls(['/chrome/elements/pgp_block.htm'], { - sleep: 10, - appearIn: 25, - }); - expect(pgpBlockUrls.length).to.equal(1); - await testMinimumElementHeight(gmailPage, '.pgp_block.signedDetached', 80); - await testMinimumElementHeight(gmailPage, '.pgp_block.publicKey', 120); - const pgpBlockFrame = await gmailPage.getFrame([pgpBlockUrls[0]]); - await BrowserRecipe.pgpBlockCheck(t, pgpBlockFrame, { - content: ['1234'], - encryption: 'not encrypted', - signature: 'signed', - }); - await pageHasSecureReplyContainer(t, browser, gmailPage); - const pubkeyPage = await gmailPage.getFrame(['/chrome/elements/pgp_pubkey.htm']); - await pubkeyPage.waitForContent('@container-pgp-pubkey', 'Fingerprint: 50B7 A032 B5E1 FBAB 24BA B205 B362 45FD AC2F BF3D'); - expect(await gmailPage.isElementVisible('.aQH')).to.equal(false); // original attachment container(s) should be hidden - }) - ); + for (const [format, path] of [ + ['html', '/FMfcgzGkbDZKPJrNLplXZhKfWwtgjrXt'], + ['plain', '/FMfcgzGkbDZKPKzSnGtGKZrPZSbTBNnB'], + ]) { + t.log(`Thunderbird signed message: ${format}`); + await gotoGmailPage(gmailPage, path); + // validate pgp_block.htm is rendered + const pgpBlockUrls = await gmailPage.getFramesUrls(['/chrome/elements/pgp_block.htm'], { + sleep: 10, + appearIn: 25, + }); + expect(pgpBlockUrls.length).to.equal(1); + const pgpBlockFrame = await gmailPage.getFrame([pgpBlockUrls[0]]); + await BrowserRecipe.pgpBlockCheck(t, pgpBlockFrame, { + content: ['1234'], + encryption: 'not encrypted', + signature: 'signed', + }); + await pageHasSecureReplyContainer(t, browser, gmailPage); + await testMinimumElementHeight(gmailPage, '.pgp_block.signedDetached', 80); + await testMinimumElementHeight(gmailPage, '.pgp_block.publicKey', 120); + const pubkeyPage = await gmailPage.getFrame(['/chrome/elements/pgp_pubkey.htm']); + await pubkeyPage.waitForContent('@container-pgp-pubkey', 'Fingerprint: 50B7 A032 B5E1 FBAB 24BA B205 B362 45FD AC2F BF3D'); + expect(await gmailPage.isElementVisible('.aQH')).to.equal(false); // original attachment container(s) should be hidden + } - test( - 'mail.google.com - pubkey gets rendered with new signed and encrypted Thunderbird signature', - testWithBrowser(async (t, browser) => { - await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); + t.log('Thunderbird signed + encrypted message'); await gotoGmailPage(gmailPage, '/FMfcgzGkbDZKPLBqWFzbgWqCrplTQdNz'); const pgpBlockFrame = await gmailPage.getFrame(['pgp_block.htm'], { sleep: 10, timeout: 25 }); await BrowserRecipe.pgpBlockCheck(t, pgpBlockFrame, { @@ -430,63 +403,78 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test // https://github.com/FlowCrypt/flowcrypt-browser/issues/5906 test( - 'mail.google.com - Keep original reply message when switching to secure mode', + 'mail.google.com - older-message secure reply switching preserves quotes and expanded message menus show secure buttons', testWithBrowser( async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); const gmailPage = await openGmailPage(t, browser); await gotoGmailPage(gmailPage, '/FMfcgzGqRGfPBbNLWvfPvDbxnHBwkdGf'); // plain convo await Util.sleep(30); - await gmailPage.waitAndClick('[role="listitem"] .adf.ads', { delay: 1 }); // click first message of thread + for (const switchControl of ['#switch_to_encrypted_reply', '[data-tooltip="Secure Reply"]']) { + t.log(`Switch older-message reply using ${switchControl}`); + await gmailPage.waitAndClick('[role="listitem"] .adf.ads', { delay: 1 }); // click first message of thread + await Util.sleep(3); + const messages = await gmailPage.target.$$('[role="listitem"] .adn.ads'); + expect(messages.length).to.equal(2); + const plainReplyButton = await messages[0].$('[aria-label="Reply"]'); + expect(plainReplyButton).to.be.ok; + await Util.sleep(1); + await plainReplyButton!.click(); + await gmailPage.waitAll('[data-tooltip^="Send"]'); // The Send button from the Standard reply box + await gmailPage.waitForContent( + '.reply_message_evaluated .error_notification', + 'The last message was encrypted, but you are composing a reply without encryption.' + ); + + if (switchControl === '#switch_to_encrypted_reply') { + await gmailPage.waitAndClick(switchControl); + } else { + const secureReplyButton = await messages[0].$(switchControl); + expect(secureReplyButton).to.be.ok; + await secureReplyButton!.click(); + } + await Util.sleep(2); + await gmailPage.waitAll('.reply_message'); + await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true, composeFrameCount: 2 }); + const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&skipClickPrompt=___cu_true___'], { sleep: 5 }); + if (switchControl === '#switch_to_encrypted_reply') { + await replyBox.waitAll(['@action-expand-quoted-text']); + await replyBox.waitAndClick('@action-expand-quoted-text'); + // Check if quoted message doesn't contain last message + expect(await replyBox.read('@input-body')).to.not.contain(`Here's reply`); + } + + // Finish deleting the draft before resetting the conversation for the next scenario. + await replyBox.waitAndClick('.delete_draft'); + await replyBox.waitAll('@action-accept-reply-prompt'); + await gmailPage.reload({ timeout: TIMEOUT_PAGE_LOAD * 1000, waitUntil: 'load' }); + await gmailPage.waitAll('[role="listitem"] .adf.ads'); + } + + t.log('Secure reply buttons on newest and expanded older message menus'); await Util.sleep(3); - const messages = await gmailPage.target.$$('[role="listitem"] .adn.ads'); - const plainReplyButton = await messages[0].$('[aria-label="Reply"]'); - await Util.sleep(1); - await plainReplyButton!.click(); - await gmailPage.waitAndClick('#switch_to_encrypted_reply'); // Switch to encrypted compose + let messages = await gmailPage.target.$$('[role="listitem"] .adn.ads'); + const newestMessage = messages[messages.length - 1]; + const newestMenuBtn = await newestMessage.$('[aria-label="More message options"]'); + expect(newestMenuBtn).to.be.ok; + await newestMenuBtn!.click(); + await gmailPage.waitAll('.action_reply_message_button'); + await newestMenuBtn!.click(); // close the menu before expanding the older message + await gmailPage.waitTillGone('.action_reply_message_button'); + + await gmailPage.waitAndClick('[role="listitem"] .adf.ads', { delay: 1 }); await Util.sleep(2); - await gmailPage.waitAll('.reply_message'); - await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true, composeFrameCount: 2 }); - const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&skipClickPrompt=___cu_true___'], { sleep: 5 }); - await replyBox.waitAll(['@action-expand-quoted-text']); - await replyBox.waitAndClick('@action-expand-quoted-text'); - // Check if quoted message doesn't contain last message - expect(await replyBox.read('@input-body')).to.not.contain(`Here's reply`); + messages = await gmailPage.target.$$('[role="listitem"] .adn.ads'); + const olderMenuBtn = await messages[0].$('[aria-label="More message options"]'); + expect(olderMenuBtn).to.be.ok; + await olderMenuBtn!.click(); + await gmailPage.waitAll('.action_reply_message_button'); }, undefined, minutes(6) ) ); - test( - 'mail.google.com - switch to encrypted reply for middle message', - testWithBrowser(async (t, browser) => { - await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/FMfcgzGqRGfPBbNLWvfPvDbxnHBwkdGf'); // plain convo - await gmailPage.waitAndClick('[role="listitem"] .adf.ads', { delay: 1 }); // click first message of thread - await Util.sleep(3); - const messages = await gmailPage.target.$$('[role="listitem"] .adn.ads'); - expect(messages.length).to.equal(2); - - const plainReplyButton = await messages[0].$('[aria-label="Reply"]'); - expect(plainReplyButton).to.be.ok; - await Util.sleep(1); - await plainReplyButton!.click(); - await gmailPage.waitAll('[data-tooltip^="Send"]'); // The Send button from the Standard reply box - await gmailPage.waitForContent( - '.reply_message_evaluated .error_notification', - 'The last message was encrypted, but you are composing a reply without encryption.' - ); - - const secureReplyButton = await messages[0].$('[data-tooltip="Secure Reply"]'); - expect(secureReplyButton).to.be.ok; - await secureReplyButton!.click(); // Switch to encrypted reply - await gmailPage.waitAll('.reply_message'); - await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true, composeFrameCount: 2 }); - }) - ); - test( 'mail.google.com - plain reply with dot menu', testWithBrowser(async (t, browser) => { @@ -609,7 +597,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test ); test( - 'mail.google.com - Outlook encrypted message with attachment is recognized', + 'mail.google.com - compatibility-key attachments: Outlook message and encrypted "message" attachment are recognized', testWithBrowser(async (t, browser) => { const settingsPage = await BrowserRecipe.openSettingsLoginApprove(t, browser, 'ci.tests.gmail@flowcrypt.dev'); await SetupPageRecipe.manualEnter( @@ -619,27 +607,15 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test { isSavePassphraseChecked: false, isSavePassphraseHidden: false } ); const gmailPage = await openGmailPage(t, browser); + t.log('Outlook encrypted message with attachment'); await gotoGmailPage(gmailPage, '/FMfcgzGllVqqBbjHQQRDsSwcZBlMRzDr'); await Util.sleep(5); await gmailPage.waitAll('iframe'); expect(await gmailPage.isElementPresent('@container-attachments')).to.equal(false); await gmailPage.waitAll(['.pYTkkf-JX-ano'], { visible: false }); expect(await gmailPage.isElementVisible('.aQH')).to.equal(false); // original attachment container(s) should be hidden - await gmailPage.close(); - }) - ); - test( - `mail.google.com - encrypted text inside "message" attachment`, - testWithBrowser(async (t, browser) => { - const settingsPage = await BrowserRecipe.openSettingsLoginApprove(t, browser, 'ci.tests.gmail@flowcrypt.dev'); - await SetupPageRecipe.manualEnter( - settingsPage, - 'flowcrypt.compatibility.1pp1', - { submitPubkey: false, usedPgpBefore: true }, - { isSavePassphraseChecked: false, isSavePassphraseHidden: false } - ); - const gmailPage = await openGmailPage(t, browser); + t.log('Encrypted text inside "message" attachment'); await gotoGmailPage(gmailPage, '/FMfcgzGrbHprlHvtTJscCJQpZcqrKQbg'); await Util.sleep(5); await gmailPage.waitAll('iframe'); @@ -650,10 +626,11 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test ); test( - `mail.google.com - large clipped PGP/MIME encrypted message rendered correctly`, + `mail.google.com - large clipped PGP/MIME messages render correctly, including a text/plain attachment`, testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); const gmailPage = await openGmailPage(t, browser); + t.log('Regular clipped PGP/MIME message'); await gotoGmailPage(gmailPage, '/FMfcgzGtxKSjjzhRZRRzddjMvJnpDRQf'); const urls = await gmailPage.getFramesUrls(['/chrome/elements/pgp_block.htm'], { sleep: 10, appearIn: 25 }); expect(urls.length).to.equal(1); @@ -664,20 +641,14 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test signature: 'signed', }); await pageHasSecureReplyContainer(t, browser, gmailPage); - }) - ); - // https://github.com/FlowCrypt/flowcrypt-browser/issues/6171 - test( - `mail.google.com - large clipped PGP/MIME message with text/plain attachment decrypts`, - testWithBrowser(async (t, browser) => { - await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); + // https://github.com/FlowCrypt/flowcrypt-browser/issues/6171 + t.log('Clipped PGP/MIME message with text/plain attachment'); await gotoGmailPage(gmailPage, '/FMfcgzQfBspgLbfNnBHGtlBsFtcLGPsr'); - const urls = await gmailPage.getFramesUrls(['/chrome/elements/pgp_block.htm'], { sleep: 10, appearIn: 25 }); - expect(urls.length).to.equal(1); - const pgpBlockFrame = await gmailPage.getFrame(['pgp_block.htm']); - await BrowserRecipe.pgpBlockCheck(t, pgpBlockFrame, { + const attachmentUrls = await gmailPage.getFramesUrls(['/chrome/elements/pgp_block.htm'], { sleep: 10, appearIn: 25 }); + expect(attachmentUrls.length).to.equal(1); + const attachmentPgpBlockFrame = await gmailPage.getFrame(['pgp_block.htm']); + await BrowserRecipe.pgpBlockCheck(t, attachmentPgpBlockFrame, { content: ['Test large clipped message'], encryption: 'encrypted', signature: 'not signed', @@ -738,44 +709,6 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test // expect(content).to.contain('Fingerprint: 7A2E 4FFD 34BC 4AED 0F54 4199 D652 7AD6 65C3 B0DD'); // })); - test( - 'mail.google.com - verify secure reply buttons on expanded older message', - testWithBrowser(async (t, browser) => { - await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); - // Use a known thread with multiple messages. - await gotoGmailPage(gmailPage, '/FMfcgzGqRGfPBbNLWvfPvDbxnHBwkdGf'); - - // 1. Verify buttons on the newest message (usually expanded by default) - await Util.sleep(3); - let messages = await gmailPage.target.$$('[role="listitem"] .adn.ads'); - const newestMessage = messages[messages.length - 1]; - const newestMenuBtn = await newestMessage.$('[aria-label="More message options"]'); - await newestMenuBtn?.click(); - await Util.sleep(1); - - await gmailPage.waitAll('.action_reply_message_button'); - const collapsedMessage = await gmailPage.target.$('[role="listitem"] .adf.ads'); - if (collapsedMessage) { - await collapsedMessage.click(); - await Util.sleep(2); - } - - // Now find the 3-dot menu on this expanded older message. - // After expansion, it should have .adn.ads class active/visible. - - messages = await gmailPage.target.$$('[role="listitem"] .adn.ads'); - const olderExpandedMessage = messages[0]; - const olderMenuBtn = await olderExpandedMessage.$('[aria-label="More message options"]'); - expect(olderMenuBtn).to.be.ok; - await olderMenuBtn?.click(); - await Util.sleep(1); - - // Verify secure buttons exist in the open menu for the older message - await gmailPage.waitAll('.action_reply_message_button'); - }) - ); - const testMinimumElementHeight = async (page: ControllablePage, selector: string, min: number) => { // testing https://github.com/FlowCrypt/flowcrypt-browser/issues/3519 const elStyle = await page.target.$eval(selector, el => el.getAttribute('style')); // 'height: 289.162px;' diff --git a/test/source/tests/setup.ts b/test/source/tests/setup.ts index 69e033726a8..15d19142ecb 100644 --- a/test/source/tests/setup.ts +++ b/test/source/tests/setup.ts @@ -1006,33 +1006,6 @@ AN8G3r5Htj8olot+jm9mIa5XLXWzMNUZgg== // await Util.sleep(200); // })); - test( - 'setup - recover with a passphrase - no remaining', - testWithBrowser(async (t, browser) => { - const acctEmail = 'flowcrypt.test.key.recovered@gmail.com'; - t.context.mockApi!.configProvider = new ConfigurationProvider({ - attester: singlePubKeyAttesterConfig(acctEmail, somePubkey), - }); - const settingsPage = await BrowserRecipe.openSettingsLoginApprove(t, browser, acctEmail); - await SetupPageRecipe.recover(settingsPage, 'flowcrypt.test.key.recovered', { hasRecoverMore: false }); - }) - ); - - test( - 'setup - fail to recover with a wrong passphrase', - testWithBrowser(async (t, browser) => { - const acctEmail = 'flowcrypt.test.key.recovered@gmail.com'; - t.context.mockApi!.configProvider = new ConfigurationProvider({ - attester: singlePubKeyAttesterConfig(acctEmail, somePubkey), - }); - const settingsPage = await BrowserRecipe.openSettingsLoginApprove(t, browser, acctEmail); - await SetupPageRecipe.recover(settingsPage, 'flowcrypt.wrong.passphrase', { - hasRecoverMore: false, - wrongPp: true, - }); - }) - ); - test( 'setup - fail to recover with a wrong passphrase at first, then recover with good passphrase', testWithBrowser(async (t, browser) => { diff --git a/test/source/tests/unit-browser.ts b/test/source/tests/unit-browser.ts index 73dfcfbd48f..ad06a767bec 100644 --- a/test/source/tests/unit-browser.ts +++ b/test/source/tests/unit-browser.ts @@ -10,7 +10,7 @@ import { testConstants } from './tooling/consts'; import { BrowserRecipe } from './tooling/browser-recipe'; import { ConfigurationProvider, HttpClientErr, Status } from '../mock/lib/api'; import { somePubkey } from '../mock/attester/attester-key-constants'; -import { aliceKey, jackAdvancedKey, johnDoeDirectKey, johnDoeAdvancedKey } from '../mock/wkd/wkd-constants'; +import { aliceKey, jackAdvancedKey, johnDoeAdvancedKey } from '../mock/wkd/wkd-constants'; import { johnDoeExampleComKey } from '../mock/sks/sks-constants'; type UnitTest = { title: string; code: string; acct?: CommonAcct; only: boolean }; @@ -42,7 +42,7 @@ export const defineUnitBrowserTests = (testVariant: TestVariant, testWithBrowser t.context.mockApi!.configProvider = new ConfigurationProvider({ wkd: { directLookup: { - 'john.doe': { pubkeys: [johnDoeDirectKey] }, + 'john.doe': { pubkeys: [johnDoeExampleComKey] }, 'jack.advanced': { pubkeys: [jackAdvancedKey] }, }, advancedLookup: { diff --git a/test/source/tests/unit-node.ts b/test/source/tests/unit-node.ts index b83e9481e72..3a0b913ee27 100644 --- a/test/source/tests/unit-node.ts +++ b/test/source/tests/unit-node.ts @@ -57,34 +57,25 @@ export const defineUnitNodeTests = (testVariant: TestVariant) => { }); t.pass(); }); - test(`[unit][OpenPGPKey.parseMany] throws on invalid input`, async t => { - await t.throwsAsync( - () => - OpenPGPKey.parseMany(`-----BEGIN PGP PUBLIC KEY BLOCK----- + const malformedKey = `-----BEGIN PGP PUBLIC KEY BLOCK----- Version: FlowCrypt Email Encryption Comment: Seamlessly send and receive encrypted email -Something wrong with this key`), - { +Something wrong with this key`; + const malformedKeyParsers = [ + { name: 'OpenPGPKey.parseMany', parse: (input: string) => OpenPGPKey.parseMany(input) }, + { name: 'KeyUtil.parseMany', parse: (input: string) => KeyUtil.parseMany(input) }, + { name: 'OpenPGPKey.parse', parse: (input: string) => OpenPGPKey.parse(input) }, + { name: 'KeyUtil.parse', parse: (input: string) => KeyUtil.parse(input) }, + ]; + for (const { name, parse } of malformedKeyParsers) { + test(`[unit][${name}] throws on invalid input`, async t => { + await t.throwsAsync(() => parse(malformedKey), { instanceOf: Error, message: 'Misformed armored text', - } - ); - }); - test(`[unit][KeyUtil.parseMany] throws on invalid input`, async t => { - await t.throwsAsync( - () => - KeyUtil.parseMany(`-----BEGIN PGP PUBLIC KEY BLOCK----- -Version: FlowCrypt Email Encryption -Comment: Seamlessly send and receive encrypted email - -Something wrong with this key`), - { - instanceOf: Error, - message: 'Misformed armored text', - } - ); - }); + }); + }); + } test(`[unit][KeyUtil.isChecksumMismatch] detects only present checksum mismatches`, t => { const armoredWithValidChecksum = `-----BEGIN PGP MESSAGE----- @@ -102,34 +93,6 @@ bG8= expect(KeyUtil.isChecksumMismatch(armoredWithMalformedChecksum)).to.equal(false); t.pass(); }); - test(`[unit][OpenPGPKey.parse] throws on invalid input`, async t => { - await t.throwsAsync( - () => - OpenPGPKey.parse(`-----BEGIN PGP PUBLIC KEY BLOCK----- -Version: FlowCrypt Email Encryption -Comment: Seamlessly send and receive encrypted email - -Something wrong with this key`), - { - instanceOf: Error, - message: 'Misformed armored text', - } - ); - }); - test(`[unit][KeyUtil.parse] throws on invalid input`, async t => { - await t.throwsAsync( - () => - KeyUtil.parse(`-----BEGIN PGP PUBLIC KEY BLOCK----- -Version: FlowCrypt Email Encryption -Comment: Seamlessly send and receive encrypted email - -Something wrong with this key`), - { - instanceOf: Error, - message: 'Misformed armored text', - } - ); - }); test(`[unit][OpenPGPKey.getOrCreateRevocationCertificate] operations`, async t => { const stringData = 'hello'; const data = Buf.fromUtfStr(stringData); @@ -146,20 +109,20 @@ Something wrong with this key`), const expectNotRevoked = async (key: Key) => { expect(key.revoked).to.be.false; if (key.isPrivate) { - await MsgUtil.sign(originalPrv, stringData); + await MsgUtil.sign(key, stringData); } else { - await MsgUtil.encryptMessage({ pubkeys: [pubkey], data, armor: true }); + await MsgUtil.encryptMessage({ pubkeys: [key], data, armor: true }); } }; const expectRevoked = async (key: Key) => { expect(key.revoked).to.be.true; if (key.isPrivate) { - await t.throwsAsync(() => MsgUtil.sign(revokedPrv, stringData), { + await t.throwsAsync(() => MsgUtil.sign(key, stringData), { instanceOf: Error, message: 'Error signing message: Primary key is revoked', }); } else { - await t.throwsAsync(() => MsgUtil.encryptMessage({ pubkeys: [revokedPub], data, armor: true }), { + await t.throwsAsync(() => MsgUtil.encryptMessage({ pubkeys: [key], data, armor: true }), { instanceOf: Error, message: 'Error encrypting message: Primary key is revoked', }); @@ -2870,7 +2833,8 @@ AAAAAAAAAAAAAAAAzzzzzzzzzzzzzzzzzzzzzzzzzzzz.....`) expect(PgpArmor.clip(messageWithNoise)).to.equal(validMessage); // Test multiple messages (should return first) - const multipleMessages = validMessage + '\n\n' + validMessage; + const secondMessage = '-----BEGIN PGP MESSAGE-----\n\nsecond content\n-----END PGP MESSAGE-----'; + const multipleMessages = validMessage + '\n\n' + secondMessage; expect(PgpArmor.clip(multipleMessages)).to.equal(validMessage); // Test with different block types @@ -2885,9 +2849,11 @@ AAAAAAAAAAAAAAAAzzzzzzzzzzzzzzzzzzzzzzzzzzzz.....`) const mismatchedMessage = '-----BEGIN PGP MESSAGE-----\n\ntest\n-----END PGP SIGNATURE-----'; expect(PgpArmor.clip(mismatchedMessage)).to.be.an.undefined; - // Test with very large input (over 10MB limit) - const largeInput = 'a'.repeat(11 * 1024 * 1024); - expect(PgpArmor.clip(largeInput)).to.be.an.undefined; + // Test valid armor at the 10MB limit and one character over it + const maxLength = 10 * 1024 * 1024; + const inputAtLimit = 'a'.repeat(maxLength - validMessage.length - 1) + '\n' + validMessage; + expect(PgpArmor.clip(inputAtLimit)).to.equal(validMessage); + expect(PgpArmor.clip(inputAtLimit + 'a')).to.be.an.undefined; // Test with pathological input that would have caused stack overflow const pathologicalBase = '-----BEGIN PGP MESSAGE-----\n' + 'a'.repeat(1000); From 25a41e7bd0fae555f8c2274b0c3a75c0703ab295 Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Wed, 28 Oct 2026 13:59:07 +0200 Subject: [PATCH 02/13] live test fix --- extension/js/common/settings.ts | 10 +++++++-- package-lock.json | 36 ++++++++++++++++----------------- package.json | 6 +++--- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/extension/js/common/settings.ts b/extension/js/common/settings.ts index 5e726211bae..48110ea5e80 100644 --- a/extension/js/common/settings.ts +++ b/extension/js/common/settings.ts @@ -598,7 +598,13 @@ export class Settings { private static async fetchAcctAliasesFromGmail(acctEmail: string): Promise> { const response = await new Gmail(acctEmail).fetchAcctAliases(); - const namesRes = await Google.getNames(acctEmail); + const namesRes = await Google.getNames(acctEmail).catch((e: unknown) => { + if (!ApiErr.isRateLimit(e)) { + throw e; + } + // Profile names are optional: keep Gmail's display name if the People API quota is exhausted. + return undefined; + }); const validAliases = response.sendAs.filter(alias => alias.isPrimary || alias.verificationStatus === 'accepted'); const result: Dict = {}; for (const a of validAliases) { @@ -610,7 +616,7 @@ export class Settings { footer: a.signature, }; if (sendAsEmail === acctEmail.toLowerCase()) { - result[sendAsEmail].name = namesRes.names.find(name => name.metadata.primary ?? false)?.displayName; + result[sendAsEmail].name = namesRes?.names.find(name => name.metadata.primary ?? false)?.displayName ?? a.displayName; } } return result; diff --git a/package-lock.json b/package-lock.json index 848f7b5359c..60255247350 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "jquery": "4.0.0", "linkify-html": "4.4.0", "linkifyjs": "4.4.0", - "node-forge": "1.4.1", + "node-forge": "1.4.2", "squire-rte": "2.4.10", "sweetalert2": "11.26.25" }, @@ -32,13 +32,13 @@ "@tony.ganchev/eslint-plugin-header": "3.4.4", "@types/chai": "5.2.3", "@types/chai-as-promised": "8.0.2", - "@types/chrome": "0.3.6", + "@types/chrome": "0.3.7", "@types/fs-extra": "11.0.4", "@types/jquery": "4.0.1", "@types/mailparser": "3.9.0", "@types/thunderbird-webext-browser": "127.0.0", "@typescript/native": "npm:typescript@7.0.2", - "ava": "8.1.2", + "ava": "8.2.0", "chai": "6.3.0", "chai-as-promised": "8.0.2", "eslint": "10.13.0", @@ -1858,9 +1858,9 @@ } }, "node_modules/@types/chrome": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.3.6.tgz", - "integrity": "sha512-NXCrCBefCHCKMVbkaxfBQqyP766Wg85S2FQhixCCxq7AtjJwoEaja2y5NSqCzpihIi9mPqhaF5RuybTnrdYD2Q==", + "version": "0.3.7", + "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.3.7.tgz", + "integrity": "sha512-jWZgbHqWbTL1a5+PoyN0OJutNyejWgyZ5MdcvKo6iJE1TNRtXR3FxsC4WzNl52yZWPidfWC8NV/VUNZf+OFKcA==", "dev": true, "license": "MIT", "dependencies": { @@ -3894,9 +3894,9 @@ } }, "node_modules/ava": { - "version": "8.1.2", - "resolved": "https://registry.npmjs.org/ava/-/ava-8.1.2.tgz", - "integrity": "sha512-oJnF53liq0Sf5K0AzZ7GwkH6HxwgsqukGMIOb/hV9QnTKlzj3lV6EXLHJksvlBcHOop6cqdAWa00u8uzqwpxFg==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/ava/-/ava-8.2.0.tgz", + "integrity": "sha512-9THsZEBUhwvA3e1oVqyJx9o4cBaLSkxScfP0oPlA9I7TDga51UDLMQJRy6bMDqMl3eubFCqxlj12h5IHEsLO7g==", "dev": true, "license": "MIT", "dependencies": { @@ -3988,9 +3988,9 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.11.33", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.33.tgz", - "integrity": "sha512-yiVKDX+qCMRKBE084lXvq9EcwFUhKZ2nU8TK1EQQuOgPNR/lmbGxXOeDdlGUqC2Zz11Cs9rk1d/8NfgBmlkt0w==", + "version": "2.11.34", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.34.tgz", + "integrity": "sha512-Aqr8mA1kIvyJ3UY5YAY7ib8LSo1DmDMbMnVqGPtsKW1LxaFQFwn9Eb3yvq2fUKJsRvaXjnAV7R5osqETapzNiA==", "dev": true, "license": "Apache-2.0", "peer": true, @@ -5261,9 +5261,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.465", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.465.tgz", - "integrity": "sha512-zg4iUpbeGw7YNZsswc2xKr2uiBex2d8dELAXo92Icw3but1ULbrvK8USe6wVLaWjgJnKBARv0pchx9Owktx6wQ==", + "version": "1.5.467", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.467.tgz", + "integrity": "sha512-Nw9X371rtZmYcBSnEijnCDONILjs93biCZO34juC7MBOmK8E+GFnyD4T/WvyrlJkppul7oxg6TwvtKst9SODTw==", "dev": true, "license": "ISC", "peer": true @@ -8182,9 +8182,9 @@ } }, "node_modules/node-forge": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.4.1.tgz", - "integrity": "sha512-w5/MfWaeMrpR/5ba6fZyAUTLSuE6aYz7H/3cYrqwZEmf5eQS3IaaLgJt4MBv7HglGFWmV22K8h4U18RJQmw/ow==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.4.2.tgz", + "integrity": "sha512-rRtAR5XLJ8gCKd9du4qrKAsgCG1ObGP4gLeNJMa4vYSeq4bmBMOJk5IHkrviBV0q7uoAJlVd8HEQYQSVUb4FGQ==", "license": "(BSD-3-Clause OR GPL-2.0)", "engines": { "node": ">= 6.13.0" diff --git a/package.json b/package.json index c08c79d245f..307f3d23b83 100644 --- a/package.json +++ b/package.json @@ -16,13 +16,13 @@ "@tony.ganchev/eslint-plugin-header": "3.4.4", "@types/chai": "5.2.3", "@types/chai-as-promised": "8.0.2", - "@types/chrome": "0.3.6", + "@types/chrome": "0.3.7", "@types/fs-extra": "11.0.4", "@types/jquery": "4.0.1", "@types/mailparser": "3.9.0", "@typescript/native": "npm:typescript@7.0.2", "@types/thunderbird-webext-browser": "127.0.0", - "ava": "8.1.2", + "ava": "8.2.0", "chai": "6.3.0", "chai-as-promised": "8.0.2", "eslint": "10.13.0", @@ -63,7 +63,7 @@ "jquery": "4.0.0", "linkify-html": "4.4.0", "linkifyjs": "4.4.0", - "node-forge": "1.4.1", + "node-forge": "1.4.2", "squire-rte": "2.4.10", "sweetalert2": "11.26.25" }, From 7f9e683c2f682d8dcb4bd76bf440f8bda4a9aa32 Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Tue, 3 Nov 2026 13:13:33 +0200 Subject: [PATCH 03/13] optimize semaphore setup --- .semaphore/semaphore.yml | 43 ++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 008fad0c89f..f6e48465774 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -11,8 +11,30 @@ execution_time_limit: hours: 1 blocks: - - name: Mock UI Tests + - name: Build dependencies: [] + execution_time_limit: + minutes: 20 + task: + env_vars: + - &flowcrypt_git_dir + name: SEMAPHORE_GIT_DIR + value: /home/semaphore/git/flowcrypt-browser + jobs: + - name: Build extension and tests + commands: + - mkdir ~/git && checkout + - cd ~/git/flowcrypt-browser + - cache restore flowcrypt-browser-npm-$(checksum package-lock.json) || true + - cache restore flowcrypt-browser-puppeteer-ubuntu2404-$(uname -m)-$(checksum package-lock.json) || true + # postinstall builds the extension variants and compiles the tests. + - npm ci --cache ~/.npm --prefer-offline + - cache store flowcrypt-browser-npm-$(checksum package-lock.json) ~/.npm || true + - cache store flowcrypt-browser-puppeteer-ubuntu2404-$(uname -m)-$(checksum package-lock.json) ~/.cache/puppeteer || true + - cache store flowcrypt-browser-build-$SEMAPHORE_PIPELINE_ID build || true + + - name: Mock UI Tests + dependencies: [Build] execution_time_limit: minutes: 45 task: @@ -20,16 +42,20 @@ blocks: - &flowcrypt_ci_secrets name: flowcrypt-browser-ci-secrets env_vars: - - &flowcrypt_git_dir - name: SEMAPHORE_GIT_DIR - value: /home/semaphore/git/flowcrypt-browser + - *flowcrypt_git_dir prologue: commands: &flowcrypt_ci_prologue - mkdir ~/git && checkout && mv ~/test-secrets.json ~/git/flowcrypt-browser/test/test-secrets.json - cd ~/git/flowcrypt-browser - cache restore flowcrypt-browser-npm-$(checksum package-lock.json) || true - - npm ci --cache ~/.npm --prefer-offline - - cache store flowcrypt-browser-npm-$(checksum package-lock.json) ~/.npm || true + - cache restore flowcrypt-browser-puppeteer-ubuntu2404-$(uname -m)-$(checksum package-lock.json) || true + # Install dependencies without rebuilding the extension in postinstall. + - npm ci --ignore-scripts --cache ~/.npm --prefer-offline + - npm rebuild puppeteer + - npm run symlink-core + - cache restore flowcrypt-browser-build-$SEMAPHORE_PIPELINE_ID || true + # Cache misses (including fork PRs and job reruns) must still run a full build. + - 'if [[ ! -f build/test/test/source/test.js ]]; then npm run pretest; fi' - 'echo "NODE=$(node --version), NPM=$(npm --version), TSC=$( ./node_modules/typescript/bin/tsc --version)"' jobs: - name: consumer mock - standard test group @@ -63,7 +89,7 @@ blocks: done - name: Live UI Gmail tests - dependencies: [] + dependencies: [Build] run: when: branch = 'master' OR branch =~ 'live-test' OR branch =~ 'gmail-test' execution_time_limit: @@ -84,7 +110,7 @@ blocks: on_fail: *flowcrypt_ci_epilogue_on_fail - name: Other tests - dependencies: [] + dependencies: [Build] execution_time_limit: minutes: 20 task: @@ -124,4 +150,5 @@ after_pipeline: jobs: - name: Publish Results commands: + - cache delete flowcrypt-browser-build-$SEMAPHORE_PIPELINE_ID || true - test-results gen-pipeline-report From 5eff0d62657cf7a5b05f8c1f816de92fa87c1dda Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Wed, 4 Nov 2026 14:17:49 +0200 Subject: [PATCH 04/13] live test fix --- test/source/browser/browser-pool.ts | 3 + test/source/tests/gmail.ts | 74 ++++++++----------- .../tests/page-recipe/oauth-page-recipe.ts | 65 +++++++--------- test/source/tests/tooling/browser-recipe.ts | 4 +- 4 files changed, 62 insertions(+), 84 deletions(-) diff --git a/test/source/browser/browser-pool.ts b/test/source/browser/browser-pool.ts index 1367e0679bd..2e930d58918 100644 --- a/test/source/browser/browser-pool.ts +++ b/test/source/browser/browser-pool.ts @@ -51,6 +51,9 @@ export class BrowserPool { if (this.isMock) { args.push('--ignore-certificate-errors'); args.push('--allow-insecure-localhost'); + } else { + // Google SAML confirmation failed over both QUIC and HTTP/2. + args.push('--disable-quic', '--disable-http2'); } const slowMo = this.isMock ? 60 : 60; const browser = await launch({ diff --git a/test/source/tests/gmail.ts b/test/source/tests/gmail.ts index 96365e39225..e90dd09c8bc 100644 --- a/test/source/tests/gmail.ts +++ b/test/source/tests/gmail.ts @@ -219,48 +219,38 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test test( 'mail.google.com - Thunderbird HTML signed, plain signed, and signed + encrypted messages render correctly', - testWithBrowser(async (t, browser) => { - await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); - for (const [format, path] of [ - ['html', '/FMfcgzGkbDZKPJrNLplXZhKfWwtgjrXt'], - ['plain', '/FMfcgzGkbDZKPKzSnGtGKZrPZSbTBNnB'], - ]) { - t.log(`Thunderbird signed message: ${format}`); - await gotoGmailPage(gmailPage, path); - // validate pgp_block.htm is rendered - const pgpBlockUrls = await gmailPage.getFramesUrls(['/chrome/elements/pgp_block.htm'], { - sleep: 10, - appearIn: 25, - }); - expect(pgpBlockUrls.length).to.equal(1); - const pgpBlockFrame = await gmailPage.getFrame([pgpBlockUrls[0]]); - await BrowserRecipe.pgpBlockCheck(t, pgpBlockFrame, { - content: ['1234'], - encryption: 'not encrypted', - signature: 'signed', - }); - await pageHasSecureReplyContainer(t, browser, gmailPage); - await testMinimumElementHeight(gmailPage, '.pgp_block.signedDetached', 80); - await testMinimumElementHeight(gmailPage, '.pgp_block.publicKey', 120); - const pubkeyPage = await gmailPage.getFrame(['/chrome/elements/pgp_pubkey.htm']); - await pubkeyPage.waitForContent('@container-pgp-pubkey', 'Fingerprint: 50B7 A032 B5E1 FBAB 24BA B205 B362 45FD AC2F BF3D'); - expect(await gmailPage.isElementVisible('.aQH')).to.equal(false); // original attachment container(s) should be hidden - } - - t.log('Thunderbird signed + encrypted message'); - await gotoGmailPage(gmailPage, '/FMfcgzGkbDZKPLBqWFzbgWqCrplTQdNz'); - const pgpBlockFrame = await gmailPage.getFrame(['pgp_block.htm'], { sleep: 10, timeout: 25 }); - await BrowserRecipe.pgpBlockCheck(t, pgpBlockFrame, { - content: ['Encrypted Subject: [ci.test] Thunderbird html signed + encrypted', '1234'], - encryption: 'encrypted', - signature: 'signed', - }); - await pageHasSecureReplyContainer(t, browser, gmailPage); - const pubkeyPage = await gmailPage.getFrame(['/chrome/elements/pgp_pubkey.htm']); - await pubkeyPage.waitForContent('@container-pgp-pubkey', 'Fingerprint: 50B7 A032 B5E1 FBAB 24BA B205 B362 45FD AC2F BF3D'); - expect(await gmailPage.isElementVisible('.aQH')).to.equal(false); // original attachment container(s) should be hidden - }) + testWithBrowser( + async (t, browser) => { + t.timeout(minutes(6)); // allow time for account setup and all three messages + await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail', { cleanUpDrafts: false }); + for (const { format, path, encrypted } of [ + { format: 'HTML signed', path: '/FMfcgzGkbDZKPJrNLplXZhKfWwtgjrXt', encrypted: false }, + { format: 'plain signed', path: '/FMfcgzGkbDZKPKzSnGtGKZrPZSbTBNnB', encrypted: false }, + { format: 'signed + encrypted', path: '/FMfcgzGkbDZKPLBqWFzbgWqCrplTQdNz', encrypted: true }, + ]) { + t.log(`Thunderbird message: ${format}`); + const gmailPage = await openGmailPage(t, browser, path); + const pgpBlockFrame = await gmailPage.getFrame(['/chrome/elements/pgp_block.htm'], { sleep: 0, timeout: 35 }); + await BrowserRecipe.pgpBlockCheck(t, pgpBlockFrame, { + content: encrypted ? ['Encrypted Subject: [ci.test] Thunderbird html signed + encrypted', '1234'] : ['1234'], + encryption: encrypted ? 'encrypted' : 'not encrypted', + signature: 'signed', + }); + await pageHasSecureReplyContainer(t, browser, gmailPage); + const pubkeyPage = await gmailPage.getFrame(['/chrome/elements/pgp_pubkey.htm']); + await pubkeyPage.waitForContent('@container-pgp-pubkey', 'Fingerprint: 50B7 A032 B5E1 FBAB 24BA B205 B362 45FD AC2F BF3D'); + if (!encrypted) { + expect(await gmailPage.getFramesUrls(['/chrome/elements/pgp_block.htm'], { sleep: 0 })).to.have.length(1); + await testMinimumElementHeight(gmailPage, '.pgp_block.signedDetached', 80); + await testMinimumElementHeight(gmailPage, '.pgp_block.publicKey', 120); + } + expect(await gmailPage.isElementVisible('.aQH')).to.equal(false); // original attachment container(s) should be hidden + await gmailPage.close(); + } + }, + undefined, + minutes(6) + ) ); // draft-sensitive test diff --git a/test/source/tests/page-recipe/oauth-page-recipe.ts b/test/source/tests/page-recipe/oauth-page-recipe.ts index 7bf6d2f8d6b..fe17ffddc77 100644 --- a/test/source/tests/page-recipe/oauth-page-recipe.ts +++ b/test/source/tests/page-recipe/oauth-page-recipe.ts @@ -3,7 +3,6 @@ import { Config, Util } from '../../util'; import { AvaContext } from '../tooling/'; import { ControllablePage } from '../../browser/controllable'; -import { TIMEOUT_PAGE_LOAD } from '../../browser'; import { PageRecipe } from './abstract-page-recipe'; import { Url } from '../../core/common'; @@ -52,22 +51,12 @@ export class OauthPageRecipe extends PageRecipe { acctEmail: string, action: 'close' | 'deny' | 'approve' | 'login' | 'login_with_invalid_state' ): Promise => { - try { - const isMock = oauthPage.target.url().includes('localhost'); - if (isMock) { - await OauthPageRecipe.mock(t, oauthPage, acctEmail, action); - return; - } else { - await Promise.race([ - oauthPage.page.waitForNavigation({ waitUntil: 'domcontentloaded', timeout: TIMEOUT_PAGE_LOAD * 1000 }), - oauthPage.page.waitForNavigation({ waitUntil: 'load', timeout: TIMEOUT_PAGE_LOAD * 1000 }), - ]); - } - } catch (e) { - if (String(e).includes('page has been closed')) { - // the extension may close the auth page after success before we had a chance to evaluate it - return; // in this case the login was already successful - } + if (oauthPage.page.isClosed()) { + return; + } + if (oauthPage.target.url().includes('localhost')) { + await OauthPageRecipe.mock(t, oauthPage, acctEmail, action); + return; } const auth = Config.secrets().auth.google.find(a => a.email === acctEmail); const acctPassword = auth?.password; @@ -78,14 +67,19 @@ export class OauthPageRecipe extends PageRecipe { auth0password: '#password', auth0loginBtn: 'button[type=submit][name=action][value=default]', googleApproveBtn: '#submit_approve_access', + googleConfirmAccountBtn: 'button[formaction*="confirmaccount?"], form[action*="confirmaccount?"] button[type="submit"]', googleContinueAuthBtn: '.VfPpkd-LgbsSe', googleSignInWithGoogleContinueBtn: '//button[.//span[normalize-space(.)="Continue"]]', }; + const confirmationButtons = [selectors.googleConfirmAccountBtn, selectors.googleSignInWithGoogleContinueBtn]; try { const alreadyLoggedSelector = '.w6VTHd, .wLBAL, .yAlK0b'; const alreadyLoggedChooseOtherAccountSelector = '.bLzI3e, .BHzsHc'; await oauthPage.waitAny( - `#Email, ${selectors.googleApproveBtn}, ${selectors.googleEmailInput}, ${alreadyLoggedSelector}, #profileIdentifier, ${selectors.auth0username}, ${selectors.googleContinueAuthBtn}`, + [ + `#Email, ${selectors.googleApproveBtn}, ${selectors.googleEmailInput}, ${alreadyLoggedSelector}, #profileIdentifier, ${selectors.auth0username}, ${selectors.googleContinueAuthBtn}`, + ...confirmationButtons, + ], { timeout: 45 } ); @@ -125,18 +119,7 @@ export class OauthPageRecipe extends PageRecipe { const actionButtons = await oauthPage.target.$$(selectors.googleContinueAuthBtn); await oauthPage.waitForNavigationIfAny(() => actionButtons[actionButtons.length - 1].click()); } - if (await oauthPage.isElementPresent(selectors.googleSignInWithGoogleContinueBtn)) { - // "Sign in with Google" can show a re-auth confirmation before the OAuth approval screen. - await oauthPage.waitForNavigationIfAny( - () => oauthPage.waitAndClick(selectors.googleSignInWithGoogleContinueBtn, { delay: 1 }), - OauthPageRecipe.longTimeout - ); - await Util.sleep(2); - if (oauthPage.page.isClosed()) { - return; - } - } - await oauthPage.waitAny([selectors.googleApproveBtn, selectors.auth0username]); + await oauthPage.waitAny([selectors.googleApproveBtn, selectors.auth0username, ...confirmationButtons]); if (await oauthPage.isElementPresent(selectors.auth0username)) { await oauthPage.waitAndType(selectors.auth0username, acctEmail); if (acctPassword) { @@ -144,18 +127,17 @@ export class OauthPageRecipe extends PageRecipe { } const loginButtons = await oauthPage.target.$$(selectors.auth0loginBtn); await oauthPage.waitForNavigationIfAny(() => loginButtons[loginButtons.length - 1].click()); - await oauthPage.waitAndClick(alreadyLoggedSelector, { delay: 1 }); + const nextButton = await oauthPage.waitAny([selectors.googleApproveBtn, ...confirmationButtons, alreadyLoggedSelector]); + if (await nextButton.evaluate((button, selector) => button.matches(selector), alreadyLoggedSelector)) { + await nextButton.click(); + } } - await Util.sleep(1); - const button = await oauthPage.waitAny('button'); - const formAction = await button.evaluate(button => (button as HTMLButtonElement).formAction); - if (formAction?.includes('confirmaccount?')) { - // click on "Continue" on "Verify it's you" screen - await button.click(); - await Util.sleep(2); - return await OauthPageRecipe.google(t, oauthPage, acctEmail, action); // it should handle the list of accounts + const button = await oauthPage.waitAny([selectors.googleApproveBtn, ...confirmationButtons]); + if (!(await button.evaluate((button, selector) => button.matches(selector), selectors.googleApproveBtn))) { + // Account confirmation can appear before either account selection or OAuth consent. + await oauthPage.waitForNavigationIfAny(() => button.click()); + return await OauthPageRecipe.google(t, oauthPage, acctEmail, action); } - await oauthPage.waitAll(selectors.googleApproveBtn); // if succeeds, we are logged in and presented with approve/deny choice // since we are successfully logged in, we may save cookies to keep them fresh // no need to await the API call because it's not crucial to always save it, can mostly skip errors if (action === 'close') { @@ -166,6 +148,9 @@ export class OauthPageRecipe extends PageRecipe { await oauthPage.waitAndClick(selectors.googleApproveBtn, { delay: 1 }); } } catch (e) { + if (oauthPage.page.isClosed()) { + return; + } const eStr = String(e); if ( !eStr.includes('Execution context was destroyed') && diff --git a/test/source/tests/tooling/browser-recipe.ts b/test/source/tests/tooling/browser-recipe.ts index 7793d50831d..9526d01b99e 100644 --- a/test/source/tests/tooling/browser-recipe.ts +++ b/test/source/tests/tooling/browser-recipe.ts @@ -100,7 +100,7 @@ export class BrowserRecipe { return gmailPage; }; - public static setUpCommonAcct = async (t: AvaContext, browser: BrowserHandle, acct: TestAccount) => { + public static setUpCommonAcct = async (t: AvaContext, browser: BrowserHandle, acct: TestAccount, { cleanUpDrafts = true } = {}) => { let acctEmail: string | undefined; let settingsPage: ControllablePage | undefined; if (acct === 'compatibility') { @@ -129,7 +129,7 @@ export class BrowserRecipe { } const accessToken = await BrowserRecipe.getGoogleAccessToken(settingsPage, acctEmail); const cleanupTasks = [settingsPage.close()]; - if (testVariant === 'CONSUMER-LIVE-GMAIL') { + if (testVariant === 'CONSUMER-LIVE-GMAIL' && cleanUpDrafts) { // clean up drafts so that broken tests from the past don't affect this test run cleanupTasks.push(BrowserRecipe.deleteAllDraftsInGmailAccount(accessToken)); } From b3cb25f2cf4e42c11e031801e9566d3ea1f4ccf8 Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Fri, 6 Nov 2026 13:22:59 +0200 Subject: [PATCH 05/13] live tests fixes --- test/source/browser/browser-handle.ts | 19 +++++- test/source/browser/controllable.ts | 2 +- test/source/tests/gmail.ts | 13 ++-- .../tests/page-recipe/oauth-page-recipe.ts | 12 ++-- test/source/tests/setup.ts | 64 +++++++++++++++++++ test/source/util/index.ts | 12 ++++ 6 files changed, 108 insertions(+), 14 deletions(-) diff --git a/test/source/browser/browser-handle.ts b/test/source/browser/browser-handle.ts index 2b6ccfc7c6e..2030c945adb 100644 --- a/test/source/browser/browser-handle.ts +++ b/test/source/browser/browser-handle.ts @@ -5,7 +5,7 @@ import { Util } from '../util'; import { ControllablePage } from './controllable'; import { Semaphore } from './browser-pool'; import { TIMEOUT_ELEMENT_APPEAR } from '.'; -import { AvaContext } from '../tests/tooling'; +import { AvaContext, newTimeoutPromise } from '../tests/tooling'; export class BrowserHandle { public pages: ControllablePage[] = []; @@ -117,6 +117,8 @@ export class BrowserHandle { }; public debugPagesHtml = async (t: AvaContext, alsoLogToConsole: boolean) => { + // Capture extension frames before collecting console messages, which can take several seconds per page. + const composeFramesHtmls = await Promise.all(this.pages.map(async cPage => (cPage.page.isClosed() ? '' : await this.debugComposeFramesHtml(cPage.page)))); let html = ''; for (let i = 0; i < this.pages.length; i++) { const cPage = this.pages[i]; @@ -127,6 +129,7 @@ export class BrowserHandle { .join('\n'); html += '
'; html += `
Page ${i} (${cPage.page.isClosed() ? 'closed' : 'active'}) ${Util.htmlEscape(url)}
`; + html += composeFramesHtmls[i] ?? ''; html += `
${consoleMsgs || '(no console messages)'}
`; html += `
${alerts || '(no alerts)'}
`; if (url !== 'about:blank' && !cPage.page.isClosed()) { @@ -148,6 +151,20 @@ export class BrowserHandle { return html; }; + private debugComposeFramesHtml = async (page: Page): Promise => { + let html = ''; + for (const frame of page.frames().filter(frame => frame.url().includes('/chrome/elements/compose.htm'))) { + html += `
${Util.htmlEscape(frame.url())} (detached: ${frame.detached})
`; + try { + const frameHtml = await Promise.race([frame.content(), newTimeoutPromise('compose frame diagnostics', 5)]); + html += `
${Util.htmlEscape(frameHtml)}
`; + } catch (e) { + html += `
${Util.htmlEscape(String(e))}
`; + } + } + return html; + }; + private doAwaitTriggeredPage = (triggeringAction: () => Promise): Promise => { return new Promise((resolve, reject) => { setTimeout(() => reject(new Error('Action did not trigger a new page within timeout period')), TIMEOUT_ELEMENT_APPEAR * 1000); diff --git a/test/source/browser/controllable.ts b/test/source/browser/controllable.ts index 7a9871689a7..c19fc6363db 100644 --- a/test/source/browser/controllable.ts +++ b/test/source/browser/controllable.ts @@ -673,7 +673,7 @@ abstract class ControllableBase { } } } catch (e) { - if (e instanceof Error && !e.message.includes('Cannot find context with specified id undefined')) { + if (!Util.isTransientPageError(e)) { throw e; } } diff --git a/test/source/tests/gmail.ts b/test/source/tests/gmail.ts index e90dd09c8bc..559c9912822 100644 --- a/test/source/tests/gmail.ts +++ b/test/source/tests/gmail.ts @@ -86,10 +86,15 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test const pageHasSecureDraft = async (gmailPage: ControllablePage, expectedContent?: string) => { const secureDraftFrame = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&draftId='], { sleep: 2 }); await Util.sleep(3); - // Wait for the iframe content to load - @input-body must exist first - await secureDraftFrame.waitAll('@input-body'); - if (expectedContent) { - await secureDraftFrame.waitForContent('@input-body', expectedContent); + try { + // Wait for the iframe content to load - @input-body must exist first + await secureDraftFrame.waitAll('@input-body'); + if (expectedContent) { + await secureDraftFrame.waitForContent('@input-body', expectedContent); + } + } catch (e) { + gmailPage.t.log(`Selected draft frame at failure: ${secureDraftFrame.frame.url()} (detached: ${secureDraftFrame.frame.detached})`); + throw e; } return secureDraftFrame; }; diff --git a/test/source/tests/page-recipe/oauth-page-recipe.ts b/test/source/tests/page-recipe/oauth-page-recipe.ts index fe17ffddc77..f19c977b914 100644 --- a/test/source/tests/page-recipe/oauth-page-recipe.ts +++ b/test/source/tests/page-recipe/oauth-page-recipe.ts @@ -68,10 +68,12 @@ export class OauthPageRecipe extends PageRecipe { auth0loginBtn: 'button[type=submit][name=action][value=default]', googleApproveBtn: '#submit_approve_access', googleConfirmAccountBtn: 'button[formaction*="confirmaccount?"], form[action*="confirmaccount?"] button[type="submit"]', + googleSamlConfirmAccountBtn: '[data-view-id="AZBvBc"] [jsname="Njthtb"] button', googleContinueAuthBtn: '.VfPpkd-LgbsSe', googleSignInWithGoogleContinueBtn: '//button[.//span[normalize-space(.)="Continue"]]', }; - const confirmationButtons = [selectors.googleConfirmAccountBtn, selectors.googleSignInWithGoogleContinueBtn]; + // The SAML confirmation view uses JS buttons without form actions, and its labels are localized. + const confirmationButtons = [selectors.googleConfirmAccountBtn, selectors.googleSamlConfirmAccountBtn, selectors.googleSignInWithGoogleContinueBtn]; try { const alreadyLoggedSelector = '.w6VTHd, .wLBAL, .yAlK0b'; const alreadyLoggedChooseOtherAccountSelector = '.bLzI3e, .BHzsHc'; @@ -151,15 +153,9 @@ export class OauthPageRecipe extends PageRecipe { if (oauthPage.page.isClosed()) { return; } - const eStr = String(e); - if ( - !eStr.includes('Execution context was destroyed') && - !eStr.includes('Cannot find context with specified id') && - !eStr.includes('Argument should belong to the same JavaScript world as target object') - ) { + if (!Util.isTransientPageError(e)) { throw e; // not a known retriable error } - // t.log(`Attempting to retry google auth:${action} on the same window for ${email} because: ${eStr}`); return await OauthPageRecipe.google(t, oauthPage, acctEmail, action); // retry, it should pick up where it left off } }; diff --git a/test/source/tests/setup.ts b/test/source/tests/setup.ts index 15d19142ecb..75a0524c5e8 100644 --- a/test/source/tests/setup.ts +++ b/test/source/tests/setup.ts @@ -87,6 +87,70 @@ const openMockGmailPage = async (t: AvaContext, browser: BrowserHandle, acctEmai export const defineSetupTests = (testVariant: TestVariant, testWithBrowser: TestWithBrowser) => { if (testVariant !== 'CONSUMER-LIVE-GMAIL') { + test( + 'setup - Google OAuth confirmation handles English and German buttons', + testWithBrowser(async (t, browser) => { + for (const label of ['Continue', 'Weiter']) { + const oauthPage = await browser.newPage(t); + await oauthPage.page.setContent(` +
+
+
+
+ `); + await oauthPage.page.evaluate(() => { + document.querySelector('[jsname="Njthtb"] button')?.addEventListener('click', () => { + const approve = document.createElement('button'); + approve.id = 'submit_approve_access'; + approve.textContent = 'Allow'; + document.body.replaceChildren(approve); + }); + }); + await OauthPageRecipe.google(t, oauthPage, 'oauth-fixture@example.com', 'close'); + t.true(oauthPage.page.isClosed(), label); + } + }) + ); + + test( + 'setup - element polling recovers from stale queries and visibility checks within its deadline', + testWithBrowser(async (t, browser) => { + const page = await browser.newPage(t); + await page.page.setContent(''); + const query = page.page.$$.bind(page.page); + const staleNode = new Error('Protocol error (DOM.resolveNode): Node with given id does not belong to the document'); + let queries = 0; + page.page.$$ = async selector => { + queries++; + if (queries === 1) { + throw staleNode; + } + const elements = await query(selector); + if (queries === 2) { + elements[0].boundingBox = async () => { + throw staleNode; + }; + } + return elements; + }; + try { + const element = await page.waitAny('#target', { timeout: 2 }); + t.is(await element.evaluate(element => element.textContent), 'Ready'); + t.is(queries, 3); + page.page.$$ = async () => { + throw staleNode; + }; + await t.throwsAsync(() => page.waitAny('#target', { timeout: 0.1 }), { message: 'waiting failed: Elements did not appear: #target' }); + page.page.$$ = async () => { + throw new Error('Unexpected protocol failure'); + }; + await t.throwsAsync(() => page.waitAny('#target'), { message: 'Unexpected protocol failure' }); + } finally { + page.page.$$ = query; + } + }) + ); + // note - `SetupPageRecipe.createKey` tests are in `defineFlakyTests` - running serially // because the keygen CPU spike can cause trouble to other concurrent tests diff --git a/test/source/util/index.ts b/test/source/util/index.ts index d789b08eb60..22ca11d6dd1 100644 --- a/test/source/util/index.ts +++ b/test/source/util/index.ts @@ -149,6 +149,18 @@ export class Util { return (await element.boundingBox()) !== null; }; + public static isTransientPageError = (e: unknown): boolean => { + return ( + e instanceof Error && + [ + 'Execution context was destroyed', + 'Cannot find context with specified id', + 'Argument should belong to the same JavaScript world as target object', + 'Node with given id does not belong to the document', + ].some(message => e.message.includes(message)) + ); + }; + public static wipeGoogleTokensUsingExperimentalSettingsPage = async (t: AvaContext, browser: BrowserHandle, acct: string) => { for (const wipeTokenBtnSelector of ['@action-wipe-google-refresh-token', '@action-wipe-google-access-token']) { const settingsPage = await browser.newExtensionSettingsPage(t, acct); From b252f187bdebbb5a17e58f7c07fb115a9f04874d Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Fri, 6 Nov 2026 14:27:59 +0200 Subject: [PATCH 06/13] improve live tests --- test/source/browser/browser-handle.ts | 27 +++++++------ test/source/tests/gmail.ts | 55 ++++++++++++++++----------- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/test/source/browser/browser-handle.ts b/test/source/browser/browser-handle.ts index 2030c945adb..50d3512fc28 100644 --- a/test/source/browser/browser-handle.ts +++ b/test/source/browser/browser-handle.ts @@ -152,17 +152,22 @@ export class BrowserHandle { }; private debugComposeFramesHtml = async (page: Page): Promise => { - let html = ''; - for (const frame of page.frames().filter(frame => frame.url().includes('/chrome/elements/compose.htm'))) { - html += `
${Util.htmlEscape(frame.url())} (detached: ${frame.detached})
`; - try { - const frameHtml = await Promise.race([frame.content(), newTimeoutPromise('compose frame diagnostics', 5)]); - html += `
${Util.htmlEscape(frameHtml)}
`; - } catch (e) { - html += `
${Util.htmlEscape(String(e))}
`; - } - } - return html; + const framesHtml = await Promise.all( + page + .frames() + .filter(frame => frame.url().includes('/chrome/elements/compose.htm')) + .map(async frame => { + let html = `
${Util.htmlEscape(frame.url())} (detached: ${frame.detached})
`; + try { + const frameHtml = await Promise.race([frame.content(), newTimeoutPromise('compose frame diagnostics', 5)]); + html += `
${Util.htmlEscape(frameHtml)}
`; + } catch (e) { + html += `
${Util.htmlEscape(String(e))}
`; + } + return html; + }) + ); + return framesHtml.join(''); }; private doAwaitTriggeredPage = (triggeringAction: () => Promise): Promise => { diff --git a/test/source/tests/gmail.ts b/test/source/tests/gmail.ts index 559c9912822..66c95e735a6 100644 --- a/test/source/tests/gmail.ts +++ b/test/source/tests/gmail.ts @@ -5,7 +5,7 @@ import test from 'ava'; import { expect } from 'chai'; import { BrowserHandle } from './../browser/browser-handle'; import { Controllable, ControllablePage } from './../browser/controllable'; -import { TIMEOUT_PAGE_LOAD } from './../browser'; +import { TIMEOUT_ELEMENT_APPEAR, TIMEOUT_PAGE_LOAD } from './../browser'; import { TestUrls } from './../browser/test-urls'; import { TestWithBrowser } from './../test'; import { TestVariant, Util } from './../util'; @@ -402,18 +402,22 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test testWithBrowser( async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/FMfcgzGqRGfPBbNLWvfPvDbxnHBwkdGf'); // plain convo - await Util.sleep(30); + const gmailPage = await openGmailPage(t, browser, '/FMfcgzGqRGfPBbNLWvfPvDbxnHBwkdGf'); // plain convo + await gmailPage.waitAll('@action-secure-compose', { timeout: TIMEOUT_PAGE_LOAD }); + const messageSelector = '[role="listitem"] .adn.ads'; + const controlWaitOptions = { visible: true, timeout: TIMEOUT_ELEMENT_APPEAR * 1000 }; for (const switchControl of ['#switch_to_encrypted_reply', '[data-tooltip="Secure Reply"]']) { t.log(`Switch older-message reply using ${switchControl}`); - await gmailPage.waitAndClick('[role="listitem"] .adf.ads', { delay: 1 }); // click first message of thread - await Util.sleep(3); - const messages = await gmailPage.target.$$('[role="listitem"] .adn.ads'); + await gmailPage.waitAndClick('[role="listitem"] .adf.ads', { delay: 0 }); // click first message of thread + await gmailPage.target.waitForFunction( + selector => document.querySelectorAll(selector).length === 2, + { timeout: TIMEOUT_ELEMENT_APPEAR * 1000 }, + messageSelector + ); + const messages = await gmailPage.target.$$(messageSelector); expect(messages.length).to.equal(2); - const plainReplyButton = await messages[0].$('[aria-label="Reply"]'); + const plainReplyButton = await messages[0].waitForSelector('[aria-label="Reply"]', controlWaitOptions); expect(plainReplyButton).to.be.ok; - await Util.sleep(1); await plainReplyButton!.click(); await gmailPage.waitAll('[data-tooltip^="Send"]'); // The Send button from the Standard reply box await gmailPage.waitForContent( @@ -422,45 +426,52 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test ); if (switchControl === '#switch_to_encrypted_reply') { - await gmailPage.waitAndClick(switchControl); + await gmailPage.waitAndClick(switchControl, { delay: 0 }); } else { - const secureReplyButton = await messages[0].$(switchControl); + const secureReplyButton = await messages[0].waitForSelector(switchControl, controlWaitOptions); expect(secureReplyButton).to.be.ok; await secureReplyButton!.click(); } - await Util.sleep(2); await gmailPage.waitAll('.reply_message'); + const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&skipClickPrompt=___cu_true___'], { sleep: 0 }); + await replyBox.waitAll(['@input-body', '@action-send']); + await gmailPage.target.waitForFunction(() => document.querySelectorAll('iframe[src*="/chrome/elements/compose.htm"]').length === 2, { + timeout: TIMEOUT_ELEMENT_APPEAR * 1000, + }); await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true, composeFrameCount: 2 }); - const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&skipClickPrompt=___cu_true___'], { sleep: 5 }); if (switchControl === '#switch_to_encrypted_reply') { await replyBox.waitAll(['@action-expand-quoted-text']); - await replyBox.waitAndClick('@action-expand-quoted-text'); + await replyBox.waitAndClick('@action-expand-quoted-text', { delay: 0 }); // Check if quoted message doesn't contain last message expect(await replyBox.read('@input-body')).to.not.contain(`Here's reply`); } // Finish deleting the draft before resetting the conversation for the next scenario. - await replyBox.waitAndClick('.delete_draft'); + await replyBox.waitAndClick('.delete_draft', { delay: 0 }); await replyBox.waitAll('@action-accept-reply-prompt'); await gmailPage.reload({ timeout: TIMEOUT_PAGE_LOAD * 1000, waitUntil: 'load' }); await gmailPage.waitAll('[role="listitem"] .adf.ads'); } t.log('Secure reply buttons on newest and expanded older message menus'); - await Util.sleep(3); - let messages = await gmailPage.target.$$('[role="listitem"] .adn.ads'); + await gmailPage.waitAll(`${messageSelector} [aria-label="More message options"]`); + let messages = await gmailPage.target.$$(messageSelector); const newestMessage = messages[messages.length - 1]; - const newestMenuBtn = await newestMessage.$('[aria-label="More message options"]'); + const newestMenuBtn = await newestMessage.waitForSelector('[aria-label="More message options"]', controlWaitOptions); expect(newestMenuBtn).to.be.ok; await newestMenuBtn!.click(); await gmailPage.waitAll('.action_reply_message_button'); await newestMenuBtn!.click(); // close the menu before expanding the older message await gmailPage.waitTillGone('.action_reply_message_button'); - await gmailPage.waitAndClick('[role="listitem"] .adf.ads', { delay: 1 }); - await Util.sleep(2); - messages = await gmailPage.target.$$('[role="listitem"] .adn.ads'); - const olderMenuBtn = await messages[0].$('[aria-label="More message options"]'); + await gmailPage.waitAndClick('[role="listitem"] .adf.ads', { delay: 0 }); + await gmailPage.target.waitForFunction( + selector => document.querySelectorAll(selector).length === 2, + { timeout: TIMEOUT_ELEMENT_APPEAR * 1000 }, + messageSelector + ); + messages = await gmailPage.target.$$(messageSelector); + const olderMenuBtn = await messages[0].waitForSelector('[aria-label="More message options"]', controlWaitOptions); expect(olderMenuBtn).to.be.ok; await olderMenuBtn!.click(); await gmailPage.waitAll('.action_reply_message_button'); From 2db06ec2f6510420d017200f18bcc7ffc7ab0a49 Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Fri, 6 Nov 2026 15:47:51 +0200 Subject: [PATCH 07/13] live test fix --- test/source/tests/gmail.ts | 48 ++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/test/source/tests/gmail.ts b/test/source/tests/gmail.ts index 66c95e735a6..090deaff511 100644 --- a/test/source/tests/gmail.ts +++ b/test/source/tests/gmail.ts @@ -550,28 +550,36 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test 'mail.google.com - secure reply and forward in dot menu', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/FMfcgzGtwgfMhWTlgRwwKWzRhqNZzwXz'); // go to encrypted convo - const gmailContextMenu = '.adn [aria-label="More message options"]'; - await gmailPage.waitAndClick(gmailContextMenu); - await Util.sleep(1); - expect(await gmailPage.isElementPresent('@action-reply-message-button')); - await gmailPage.waitAndClick('@action-reply-message-button'); - const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm'], { sleep: 5 }); - await replyBox.waitForContent('@input-body', ''); - await gmailPage.waitAndClick(gmailContextMenu); - await Util.sleep(1); - expect(await gmailPage.isElementPresent('@action-reply-all-message-button')); - await gmailPage.waitAndClick('@action-reply-all-message-button'); - const replyBox2 = await gmailPage.getFrame(['/chrome/elements/compose.htm'], { sleep: 5 }); - await replyBox2.waitForContent('@input-body', ''); + const gmailPage = await openGmailPage(t, browser, '/FMfcgzGtwgfMhWTlgRwwKWzRhqNZzwXz'); // encrypted convo + await gmailPage.waitAll('@action-secure-compose', { timeout: TIMEOUT_PAGE_LOAD }); + const replyPrompt = await gmailPage.getFrame(['/chrome/elements/compose.htm'], { sleep: 0, timeout: TIMEOUT_ELEMENT_APPEAR }); + await replyPrompt.waitAll('@action-accept-reply-prompt'); + const gmailContextMenu = '[role="listitem"] .adn.ads [aria-label="More message options"]'; + // Locators wait for a stable, visible target and retry if Gmail re-renders it before the click. + const click = async (selector: string) => + await gmailPage.target + .locator(selector) + .setVisibility('visible') + .setTimeout(TIMEOUT_ELEMENT_APPEAR * 1000) + .click(); + await click(gmailContextMenu); + await click('[data-test="action-reply-message-button"]'); + const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&replyOption=a_reply', '&skipClickPrompt=___cu_true___'], { sleep: 0 }); + await replyBox.waitUntilViewLoaded(); + await replyBox.waitAll(['@input-body', '@action-send']); + await gmailPage.waitTillGone('@action-reply-message-button'); + await click(gmailContextMenu); + await click('[data-test="action-reply-all-message-button"]'); + const replyBox2 = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&replyOption=a_reply_all'], { sleep: 0 }); + await replyBox2.waitUntilViewLoaded(); + await replyBox2.waitForSelTestState('ready'); + await replyBox2.waitAll(['@input-body', '@action-send']); const recipientsCount = await replyBox2.target.$$eval('.email_address', elements => elements.length); expect(recipientsCount).to.equal(2); - await gmailPage.waitAndClick(gmailContextMenu); - await Util.sleep(1); - expect(await gmailPage.isElementPresent('@action-forward-message-button')); - await gmailPage.waitAndClick('@action-forward-message-button'); - const replyBox3 = await gmailPage.getFrame(['/chrome/elements/compose.htm'], { sleep: 5 }); + await gmailPage.waitTillGone('@action-reply-all-message-button'); + await click(gmailContextMenu); + await click('[data-test="action-forward-message-button"]'); + const replyBox3 = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&replyOption=a_forward'], { sleep: 0 }); await replyBox3.waitForContent('@input-body', '---------- Forwarded message ---------'); }) ); From f9adc11bca35e4318c6056762d88b0c02ab91b27 Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Mon, 9 Nov 2026 16:09:53 +0200 Subject: [PATCH 08/13] live tests improvements --- test/source/tests/gmail.ts | 229 ++++++++++++++++++++++--------------- 1 file changed, 134 insertions(+), 95 deletions(-) diff --git a/test/source/tests/gmail.ts b/test/source/tests/gmail.ts index 090deaff511..47213d1945b 100644 --- a/test/source/tests/gmail.ts +++ b/test/source/tests/gmail.ts @@ -4,7 +4,7 @@ import test from 'ava'; import { expect } from 'chai'; import { BrowserHandle } from './../browser/browser-handle'; -import { Controllable, ControllablePage } from './../browser/controllable'; +import { Controllable, ControllableFrame, ControllablePage } from './../browser/controllable'; import { TIMEOUT_ELEMENT_APPEAR, TIMEOUT_PAGE_LOAD } from './../browser'; import { TestUrls } from './../browser/test-urls'; import { TestWithBrowser } from './../test'; @@ -34,16 +34,18 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test composeFrameIndex, // Total compose frame count composeFrameCount, + replyFrame, }: { isReplyPromptAccepted?: boolean; composeFrameIndex?: number; composeFrameCount?: number; + replyFrame?: ControllableFrame; } = {} ) => { const urls = await gmailPage.getFramesUrls(['/chrome/elements/compose.htm'], { sleep: 0 }); expect(urls.length).to.equal(composeFrameCount ?? 1); if (typeof isReplyPromptAccepted !== 'undefined') { - const replyBox = await gmailPage.getFrame([urls[composeFrameIndex ?? 0]]); + const replyBox = replyFrame ?? (await gmailPage.getFrame([urls[composeFrameIndex ?? 0]])); if (isReplyPromptAccepted) { await replyBox.waitAll('@action-send'); await replyBox.notPresent('@action-accept-reply-prompt'); @@ -118,6 +120,32 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test await gmailPage.goto(url); }; + const replyAllConversation = { + path: '/FMfcgzGtwgfMhWTlgRwwKWzRhqNZzwXz', + subject: 'Encrypted message with 2 recipients for reply-all test', + }; + const gotoGmailConversation = async (gmailPage: ControllablePage, { path, subject }: { path: string; subject: string }) => { + await gmailPage.page.goto(TestUrls.gmail(0, path), { waitUntil: 'domcontentloaded', timeout: TIMEOUT_PAGE_LOAD * 1000 }); + await gmailPage.waitForContent('h2.hP', subject, TIMEOUT_PAGE_LOAD); + await gmailPage.waitAll('@action-secure-compose', { timeout: TIMEOUT_PAGE_LOAD }); + }; + + const replyIframe = 'iframe.reply_message[src*="/chrome/elements/compose.htm"]'; + const getEditableGmailReply = async (gmailPage: ControllablePage) => { + const skipPrompt = '&skipClickPrompt=___cu_true___'; + await gmailPage.waitAll(`${replyIframe}[src*="${skipPrompt}"]`); + return await gmailPage.getFrame(['/chrome/elements/compose.htm', skipPrompt], { sleep: 0 }); + }; + + const messageMenu = '[aria-label="More message options"]'; + const clickGmailControl = async (gmailPage: ControllablePage, selector: string) => { + await gmailPage.target + .locator(selector) + .setVisibility('visible') + .setTimeout(TIMEOUT_ELEMENT_APPEAR * 1000) + .click(); + }; + test( 'mail.google.com/chat', testWithBrowser(async (t, browser) => { @@ -159,7 +187,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test test( 'mail.google.com - back button works in offline mode', testWithBrowser(async (t, browser) => { - await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); + await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail', { cleanUpDrafts: false }); const gmailPage = await openGmailPage(t, browser); await gotoGmailPage(gmailPage, '/FMfcgzGkbDWztBnnCgRHzjrvmFqLtcJD'); const expectedMessage = { content: ['this should decrypt even offline'], signature: 'signed', encryption: 'encrypted' }; @@ -175,7 +203,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test test( 'mail.google.com - attachments rendered correctly', testWithBrowser(async (t, browser) => { - await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); + await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail', { cleanUpDrafts: false }); const gmailPage = await openGmailPage(t, browser); await gotoGmailPage(gmailPage, '/FMfcgzGkbDXBWBWBfVKHssLtMqvDQSWN'); // Check if rendering attachments coorectly @@ -362,7 +390,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test test( 'mail.google.com - plain message contains smart replies', testWithBrowser(async (t, browser) => { - await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); + await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail', { cleanUpDrafts: false }); const gmailPage = await openGmailPage(t, browser); await Util.sleep(1); await gotoGmailPage(gmailPage, '/FMfcgzGpHHKCrKRLptBSNwkpMxzkdcQc'); // plain convo with smart replies @@ -375,21 +403,22 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); let gmailPage = await openGmailPage(t, browser, '/FMfcgzGkbDRNgcQxLmkhBCKVSFwkfdvV'); // plain convo - await gmailPage.waitAndClick('div.adn [aria-label="Reply"]', { delay: 1 }); + await clickGmailControl(gmailPage, 'div.adn [aria-label="Reply"]'); + await gmailPage.waitAll('[data-tooltip^="Send"]'); await gmailPage.close(); gmailPage = await openGmailPage(t, browser, '/181d226b4e69f172'); // go to encrypted convo - await gmailPage.waitAndClick('div.adn [aria-label="Reply"]', { delay: 1 }); + await clickGmailControl(gmailPage, 'div.adn [aria-label="Reply"]'); await gmailPage.waitTillGone('.reply_message'); await gmailPage.waitAll('[data-tooltip^="Send"]'); // The Send button from the Standard reply box await gmailPage.waitForContent( '.reply_message_evaluated .error_notification', 'The last message was encrypted, but you are composing a reply without encryption.' ); - await gmailPage.waitAndClick('[data-tooltip="Secure Reply"]'); // Switch to encrypted reply + await clickGmailControl(gmailPage, '[data-tooltip="Secure Reply"]'); await gmailPage.waitAll('.reply_message'); await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true }); await gotoGmailPage(gmailPage, '/FMfcgzGkbDRNpjDdNvCrwzqvXspZZxvh'); // go to signed convo - await gmailPage.waitAndClick('div.adn [aria-label="Reply"]', { delay: 1 }); + await clickGmailControl(gmailPage, 'div.adn [aria-label="Reply"]'); await gmailPage.waitTillGone('.reply_message'); await gmailPage.waitAll('[data-tooltip^="Send"]'); // The Send button from the Standard reply box await gmailPage.notPresent('.reply_message_evaluated .error_notification'); // should not show the warning about switching to encrypted reply @@ -405,40 +434,37 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test const gmailPage = await openGmailPage(t, browser, '/FMfcgzGqRGfPBbNLWvfPvDbxnHBwkdGf'); // plain convo await gmailPage.waitAll('@action-secure-compose', { timeout: TIMEOUT_PAGE_LOAD }); const messageSelector = '[role="listitem"] .adn.ads'; - const controlWaitOptions = { visible: true, timeout: TIMEOUT_ELEMENT_APPEAR * 1000 }; + const expandedMessage = async (index: number) => { + const id = await gmailPage.target.$$eval(messageSelector, (messages, i) => messages.at(i)?.getAttribute('data-legacy-message-id'), index); + if (!id) { + throw new Error(`No Gmail message ID found at index ${index}`); + } + return `${messageSelector}[data-legacy-message-id="${id}"]`; + }; for (const switchControl of ['#switch_to_encrypted_reply', '[data-tooltip="Secure Reply"]']) { t.log(`Switch older-message reply using ${switchControl}`); - await gmailPage.waitAndClick('[role="listitem"] .adf.ads', { delay: 0 }); // click first message of thread + await clickGmailControl(gmailPage, '[role="listitem"] .adf.ads'); // expand first message of thread await gmailPage.target.waitForFunction( selector => document.querySelectorAll(selector).length === 2, { timeout: TIMEOUT_ELEMENT_APPEAR * 1000 }, messageSelector ); - const messages = await gmailPage.target.$$(messageSelector); - expect(messages.length).to.equal(2); - const plainReplyButton = await messages[0].waitForSelector('[aria-label="Reply"]', controlWaitOptions); - expect(plainReplyButton).to.be.ok; - await plainReplyButton!.click(); + const olderMessage = await expandedMessage(0); + await clickGmailControl(gmailPage, `${olderMessage} [aria-label="Reply"]`); await gmailPage.waitAll('[data-tooltip^="Send"]'); // The Send button from the Standard reply box await gmailPage.waitForContent( '.reply_message_evaluated .error_notification', 'The last message was encrypted, but you are composing a reply without encryption.' ); - if (switchControl === '#switch_to_encrypted_reply') { - await gmailPage.waitAndClick(switchControl, { delay: 0 }); - } else { - const secureReplyButton = await messages[0].waitForSelector(switchControl, controlWaitOptions); - expect(secureReplyButton).to.be.ok; - await secureReplyButton!.click(); - } + await clickGmailControl(gmailPage, switchControl.startsWith('#') ? switchControl : `${olderMessage} ${switchControl}`); await gmailPage.waitAll('.reply_message'); const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&skipClickPrompt=___cu_true___'], { sleep: 0 }); - await replyBox.waitAll(['@input-body', '@action-send']); + await replyBox.waitAll('@input-body'); await gmailPage.target.waitForFunction(() => document.querySelectorAll('iframe[src*="/chrome/elements/compose.htm"]').length === 2, { timeout: TIMEOUT_ELEMENT_APPEAR * 1000, }); - await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true, composeFrameCount: 2 }); + await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true, composeFrameCount: 2, replyFrame: replyBox }); if (switchControl === '#switch_to_encrypted_reply') { await replyBox.waitAll(['@action-expand-quoted-text']); await replyBox.waitAndClick('@action-expand-quoted-text', { delay: 0 }); @@ -454,26 +480,20 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test } t.log('Secure reply buttons on newest and expanded older message menus'); - await gmailPage.waitAll(`${messageSelector} [aria-label="More message options"]`); - let messages = await gmailPage.target.$$(messageSelector); - const newestMessage = messages[messages.length - 1]; - const newestMenuBtn = await newestMessage.waitForSelector('[aria-label="More message options"]', controlWaitOptions); - expect(newestMenuBtn).to.be.ok; - await newestMenuBtn!.click(); + await gmailPage.waitAll(`${messageSelector} ${messageMenu}`); + const newestMenu = `${await expandedMessage(-1)} ${messageMenu}`; + await clickGmailControl(gmailPage, newestMenu); await gmailPage.waitAll('.action_reply_message_button'); - await newestMenuBtn!.click(); // close the menu before expanding the older message + await clickGmailControl(gmailPage, newestMenu); // close the menu before expanding the older message await gmailPage.waitTillGone('.action_reply_message_button'); - await gmailPage.waitAndClick('[role="listitem"] .adf.ads', { delay: 0 }); + await clickGmailControl(gmailPage, '[role="listitem"] .adf.ads'); await gmailPage.target.waitForFunction( selector => document.querySelectorAll(selector).length === 2, { timeout: TIMEOUT_ELEMENT_APPEAR * 1000 }, messageSelector ); - messages = await gmailPage.target.$$(messageSelector); - const olderMenuBtn = await messages[0].waitForSelector('[aria-label="More message options"]', controlWaitOptions); - expect(olderMenuBtn).to.be.ok; - await olderMenuBtn!.click(); + await clickGmailControl(gmailPage, `${await expandedMessage(0)} ${messageMenu}`); await gmailPage.waitAll('.action_reply_message_button'); }, undefined, @@ -485,24 +505,23 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test 'mail.google.com - plain reply with dot menu', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/FMfcgzGkbDRNgcQxLmkhBCKVSFwkfdvV'); // plain convo - await gmailPage.waitAndClick('div.adn [aria-label="Reply"]', { delay: 1 }); - await gotoGmailPage(gmailPage, '/FMfcgzGtwgfMhWTlgRwwKWzRhqNZzwXz'); // go to encrypted convo - await Util.sleep(5); - await gmailPage.waitAndClick('.adn [aria-label="More message options"]', { delay: 1 }); - await gmailPage.waitAndClick('li[data-action-type="24"]', { delay: 1 }); // click reply-all - await Util.sleep(3); + const gmailPage = await browser.newPage(t); + await gotoGmailConversation(gmailPage, { path: '/FMfcgzGkbDRNgcQxLmkhBCKVSFwkfdvV', subject: '[ci.test] plain email' }); + await clickGmailControl(gmailPage, 'div.adn [aria-label="Reply"]'); + await gmailPage.waitAll('[data-tooltip^="Send"]'); + await gotoGmailConversation(gmailPage, replyAllConversation); + await gmailPage.waitAll('iframe.pgp_block'); + await clickGmailControl(gmailPage, `.adn ${messageMenu}`); + await clickGmailControl(gmailPage, 'li[data-action-type="24"]'); // click reply-all await gmailPage.waitAll('[data-tooltip^="Send"]'); // The Send button from the Standard reply box await gmailPage.waitForContent( '.reply_message_evaluated .error_notification', 'The last message was encrypted, but you are composing a reply without encryption.' ); - await gmailPage.waitAndClick('[data-tooltip="Secure Reply"]'); // Switch to encrypted reply - await gmailPage.waitAll('.reply_message'); - await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true }); - const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm'], { sleep: 5 }); - await Util.sleep(3); + await clickGmailControl(gmailPage, '[data-tooltip="Secure Reply"]'); + const replyBox = await getEditableGmailReply(gmailPage); + await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true, replyFrame: replyBox }); + await replyBox.waitForSelTestState('ready'); expect(await replyBox.read('@recipients-preview')).to.equal(['flowcrypt.compatibility@gmail.com', 'e2e.enterprise.test@flowcrypt.com'].join('')); }) ); @@ -511,10 +530,11 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test test( 'mail.google.com - test reply all for password protected message', testWithBrowser(async (t, browser) => { - await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); + await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail', { cleanUpDrafts: false }); const gmailPage = await openGmailPage(t, browser); await gotoGmailPage(gmailPage, '/FMfcgzQZTMHNLflWQjRcSvWlMsKbLhpr'); - await gmailPage.waitAndClick('.adn [aria-label="More message options"]', { delay: 1 }); + await gmailPage.waitAll('@action-secure-compose', { timeout: TIMEOUT_PAGE_LOAD }); + await clickGmailControl(gmailPage, `.adn ${messageMenu}`); await gmailPage.waitAll('.action_reply_all_message_button'); }) ); @@ -524,22 +544,19 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test testWithBrowser( async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/FMfcgzGtwgfMhWTlgRwwKWzRhqNZzwXz'); // go to encrypted convo - await Util.sleep(5); - await gmailPage.waitAndClick('.adn [aria-label="More message options"]', { delay: 1 }); - await gmailPage.waitAndClick('li[data-action-type="25"]', { delay: 1 }); // click forward - await Util.sleep(3); + const gmailPage = await browser.newPage(t); + await gotoGmailConversation(gmailPage, replyAllConversation); + await gmailPage.waitAll('iframe.pgp_block'); + await clickGmailControl(gmailPage, `.adn ${messageMenu}`); + await clickGmailControl(gmailPage, 'li[data-action-type="25"]'); // click forward await gmailPage.waitAll('[data-tooltip^="Send"]'); // The Send button from the Standard reply box await gmailPage.waitForContent( '.reply_message_evaluated .error_notification', 'The last message was encrypted, but you are composing a message without encryption. Switch to encrypted compose' ); - await gmailPage.waitAndClick('#switch_to_encrypted_reply'); // Switch to encrypted compose - await Util.sleep(3); - const replyBox2 = await gmailPage.getFrame(['/chrome/elements/compose.htm'], { sleep: 5 }); - await Util.sleep(3); - await replyBox2.waitForContent('@input-body', '---------- Forwarded message ---------'); + await clickGmailControl(gmailPage, '#switch_to_encrypted_reply'); + const replyBox = await getEditableGmailReply(gmailPage); + await replyBox.waitForContent('@input-body', '---------- Forwarded message ---------'); }, undefined, minutes(6) @@ -550,37 +567,59 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test 'mail.google.com - secure reply and forward in dot menu', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser, '/FMfcgzGtwgfMhWTlgRwwKWzRhqNZzwXz'); // encrypted convo - await gmailPage.waitAll('@action-secure-compose', { timeout: TIMEOUT_PAGE_LOAD }); - const replyPrompt = await gmailPage.getFrame(['/chrome/elements/compose.htm'], { sleep: 0, timeout: TIMEOUT_ELEMENT_APPEAR }); - await replyPrompt.waitAll('@action-accept-reply-prompt'); - const gmailContextMenu = '[role="listitem"] .adn.ads [aria-label="More message options"]'; - // Locators wait for a stable, visible target and retry if Gmail re-renders it before the click. - const click = async (selector: string) => - await gmailPage.target - .locator(selector) - .setVisibility('visible') - .setTimeout(TIMEOUT_ELEMENT_APPEAR * 1000) - .click(); - await click(gmailContextMenu); - await click('[data-test="action-reply-message-button"]'); - const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&replyOption=a_reply', '&skipClickPrompt=___cu_true___'], { sleep: 0 }); - await replyBox.waitUntilViewLoaded(); - await replyBox.waitAll(['@input-body', '@action-send']); - await gmailPage.waitTillGone('@action-reply-message-button'); - await click(gmailContextMenu); - await click('[data-test="action-reply-all-message-button"]'); - const replyBox2 = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&replyOption=a_reply_all'], { sleep: 0 }); - await replyBox2.waitUntilViewLoaded(); - await replyBox2.waitForSelTestState('ready'); - await replyBox2.waitAll(['@input-body', '@action-send']); - const recipientsCount = await replyBox2.target.$$eval('.email_address', elements => elements.length); - expect(recipientsCount).to.equal(2); - await gmailPage.waitTillGone('@action-reply-all-message-button'); - await click(gmailContextMenu); - await click('[data-test="action-forward-message-button"]'); - const replyBox3 = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&replyOption=a_forward'], { sleep: 0 }); - await replyBox3.waitForContent('@input-body', '---------- Forwarded message ---------'); + const gmailPage = await browser.newPage(t); + await gotoGmailConversation(gmailPage, replyAllConversation); + await gmailPage.waitAll(`${replyIframe}[src*="&skipClickPrompt=___cu_false___"]`); + const gmailContextMenu = `[role="listitem"] .adn.ads ${messageMenu}`; + for (const action of ['reply', 'reply-all', 'forward'] as const) { + t.log(`Opening secure ${action} from the message menu`); + const menuItem = `[data-test="action-${action}-message-button"]`; + await clickGmailControl(gmailPage, gmailContextMenu); + await clickGmailControl(gmailPage, menuItem); + const replyOption = `a_${action.replace('-', '_')}`; + const iframe = await gmailPage.waitAny(`${replyIframe}[src*="&skipClickPrompt=___cu_true___"][src*="&replyOption=${replyOption}&"]`); + let composerUrl: string; + try { + await gmailPage.waitTillGone(menuItem); + composerUrl = await iframe.evaluate(el => (el as HTMLIFrameElement).src); + } finally { + await iframe.dispose(); + } + + const embeddedComposer = await gmailPage.getFrame([composerUrl], { sleep: 0 }); + // Probe the frame independently of composer readiness. Only a stalled Puppeteer evaluation can trigger the workaround. + const canReadFrame = + !process.env.SEMAPHORE || + (await Promise.race([ + embeddedComposer.target.evaluate(() => true), + new Promise(resolve => setTimeout(() => resolve(false), TIMEOUT_ELEMENT_APPEAR * 1000).unref()), + ])); + if (!canReadFrame) { + console.warn(`Reduced coverage for secure ${action}: Puppeteer could not read the embedded Gmail composer. Checking a fresh instance instead.`); + } + + const fallbackPage = canReadFrame ? undefined : await browser.newPage(t, composerUrl); + const composer = fallbackPage ?? embeddedComposer; + try { + await composer.waitUntilViewLoaded(); + await composer.waitAll(['@input-body', '@action-send']); + if (action === 'reply-all') { + await composer.waitForSelTestState('ready'); + const visibleRecipients = await composer.target.$$eval( + '[data-test="recipients-preview"] .email_address', + elements => elements.filter(element => element.checkVisibility({ visibilityProperty: true })).length + ); + expect(visibleRecipients).to.equal(2); + } else if (action === 'forward') { + await composer.waitForContent('@input-body', '---------- Forwarded message ---------'); + } + } finally { + if (fallbackPage) { + await fallbackPage.close(); + await gmailPage.page.bringToFront(); + } + } + } }) ); @@ -673,7 +712,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test test( `mail.google.com - render plain text for "message" attachment (which has plain text)`, testWithBrowser(async (t, browser) => { - await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); + await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail', { cleanUpDrafts: false }); const gmailPage = await openGmailPage(t, browser); await gotoGmailPage(gmailPage, '/FMfcgzGrbHrBdFGBXqpFZvSkcQpKkvrM'); await Util.sleep(5); From 93c8493d407adda8423c5c5da8db55b5ef3c68b9 Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Tue, 10 Nov 2026 10:45:04 +0200 Subject: [PATCH 09/13] live test fix --- test/source/tests/gmail.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/source/tests/gmail.ts b/test/source/tests/gmail.ts index 47213d1945b..b2517b4fe95 100644 --- a/test/source/tests/gmail.ts +++ b/test/source/tests/gmail.ts @@ -417,8 +417,12 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test await clickGmailControl(gmailPage, '[data-tooltip="Secure Reply"]'); await gmailPage.waitAll('.reply_message'); await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true }); - await gotoGmailPage(gmailPage, '/FMfcgzGkbDRNpjDdNvCrwzqvXspZZxvh'); // go to signed convo - await clickGmailControl(gmailPage, 'div.adn [aria-label="Reply"]'); + await gmailPage.close(); + gmailPage = await browser.newPage(t); + await gotoGmailConversation(gmailPage, { path: '/FMfcgzGkbDRNpjDdNvCrwzqvXspZZxvh', subject: '[ci.test] signed email' }); + await gmailPage.waitAll('iframe.pgp_block.signedMsg'); + t.log('Opening Gmail Reply on the signed message'); + await clickGmailControl(gmailPage, 'div.adn button[aria-label="Reply"]'); await gmailPage.waitTillGone('.reply_message'); await gmailPage.waitAll('[data-tooltip^="Send"]'); // The Send button from the Standard reply box await gmailPage.notPresent('.reply_message_evaluated .error_notification'); // should not show the warning about switching to encrypted reply From f9d348ccb2c37f7e09ed412088c943e9cf29402e Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Tue, 10 Nov 2026 12:42:39 +0200 Subject: [PATCH 10/13] live test fix --- test/source/tests/gmail.ts | 59 ++++++++++++++----- .../tests/page-recipe/gmail-page-recipe.ts | 39 +++++++++--- 2 files changed, 73 insertions(+), 25 deletions(-) diff --git a/test/source/tests/gmail.ts b/test/source/tests/gmail.ts index b2517b4fe95..751325e4a61 100644 --- a/test/source/tests/gmail.ts +++ b/test/source/tests/gmail.ts @@ -2,6 +2,7 @@ import test from 'ava'; +import { connect } from 'puppeteer'; import { expect } from 'chai'; import { BrowserHandle } from './../browser/browser-handle'; import { Controllable, ControllableFrame, ControllablePage } from './../browser/controllable'; @@ -63,6 +64,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test content: string, params: { offline: boolean } = { offline: false } ) => { + await GmailPageRecipe.dismissMobileNotificationsPrompt(gmailPage); let composeBox: Controllable | undefined; if (params.offline) { // TODO(@limonte): for some reason iframe is able to save the draft to the cloud even @@ -111,13 +113,16 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test if (path) { url = TestUrls.gmail(0, path, 'inbox'); } - return await browser.newPage(t, url); + const gmailPage = await browser.newPage(t, url); + await GmailPageRecipe.dismissMobileNotificationsPrompt(gmailPage); + return gmailPage; }; const gotoGmailPage = async (gmailPage: ControllablePage, path: string, category: GmailCategory = 'inbox') => { const url = TestUrls.gmail(0, path, category); await Util.sleep(1); await gmailPage.goto(url); + await GmailPageRecipe.dismissMobileNotificationsPrompt(gmailPage); }; const replyAllConversation = { @@ -128,6 +133,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test await gmailPage.page.goto(TestUrls.gmail(0, path), { waitUntil: 'domcontentloaded', timeout: TIMEOUT_PAGE_LOAD * 1000 }); await gmailPage.waitForContent('h2.hP', subject, TIMEOUT_PAGE_LOAD); await gmailPage.waitAll('@action-secure-compose', { timeout: TIMEOUT_PAGE_LOAD }); + await GmailPageRecipe.dismissMobileNotificationsPrompt(gmailPage); }; const replyIframe = 'iframe.reply_message[src*="/chrome/elements/compose.htm"]'; @@ -139,6 +145,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test const messageMenu = '[aria-label="More message options"]'; const clickGmailControl = async (gmailPage: ControllablePage, selector: string) => { + await GmailPageRecipe.dismissMobileNotificationsPrompt(gmailPage); await gmailPage.target .locator(selector) .setVisibility('visible') @@ -332,18 +339,32 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test await gotoGmailPage(gmailPage, `/${threadId}`); // go to encrypted convo await GmailPageRecipe.trimConvo(gmailPage, threadId); await gmailPage.waitAndClick('@secure-reply-button'); - let replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm'], { sleep: 5 }); + const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm'], { sleep: 5 }); await Util.sleep(3); expect(await replyBox.read('@recipients-preview')).to.equal('e2e.enterprise.test@flowcrypt.com'); await createSecureDraft(t, browser, gmailPage, 'reply draft'); await createSecureDraft(t, browser, gmailPage, 'offline reply draft', { offline: true }); - await gmailPage.reload({ timeout: TIMEOUT_PAGE_LOAD * 1000, waitUntil: 'load' }, true); - // Wait for extension to re-inject iframes after reload - await gmailPage.waitForIframes(3, 25); // 3 attempts, 25s each - await Util.sleep(5); // Let Gmail settle after reload - replyBox = await pageHasSecureDraft(gmailPage, 'offline reply draft'); - await Util.sleep(2); - await replyBox.waitAndClick('@action-send', { confirmGone: true }); + await gmailPage.reload({ timeout: TIMEOUT_PAGE_LOAD * 1000, waitUntil: 'domcontentloaded' }, true); + await gmailPage.waitAll(`${replyIframe}[src*="&draftId="]`); + // Puppeteer can lose access to the extension frame's execution context during navigation. + // Attach after the draft iframe is present and keep all assertions and Send in the original Gmail tab. + const attachedBrowser = await connect({ + browserWSEndpoint: browser.browser.wsEndpoint(), + defaultViewport: gmailPage.page.viewport(), + protocolTimeout: TIMEOUT_PAGE_LOAD * 1000, + }); + try { + const attachedPage = (await attachedBrowser.pages()).find(page => page.url() === gmailPage.page.url()); + if (!attachedPage) { + throw new Error('Could not reattach to the Gmail tab with the restored reply draft'); + } + const attachedGmailPage = new ControllablePage(t, attachedPage); + const restoredReply = await pageHasSecureDraft(attachedGmailPage, 'offline reply draft'); + await GmailPageRecipe.dismissMobileNotificationsPrompt(attachedGmailPage); + await restoredReply.waitAndClick('@action-send', { confirmGone: true }); + } finally { + await attachedBrowser.disconnect(); + } await Util.sleep(2); await gmailPage.reload({ timeout: TIMEOUT_PAGE_LOAD * 1000, waitUntil: 'load' }, true); await gmailPage.waitAndClick('.h7:last-child .ajz', { delay: 1 }); // the small triangle which toggles the message details @@ -484,12 +505,19 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test } t.log('Secure reply buttons on newest and expanded older message menus'); + const checkSecureReplyMenu = async (message: string) => { + await gmailPage.waitAll(`${message} iframe.pgp_block.encryptedMsg`); + await GmailPageRecipe.dismissMobileNotificationsPrompt(gmailPage); + const menu = `${message} ${messageMenu}`; + await gmailPage.waitAndFocus(menu); + await gmailPage.press('Enter'); + await gmailPage.waitAll(`${menu}[aria-expanded="true"]`); + await gmailPage.waitAll('@action-reply-message-button'); + await gmailPage.press('Escape'); + await gmailPage.waitTillGone(`${menu}[aria-expanded="true"]`); + }; await gmailPage.waitAll(`${messageSelector} ${messageMenu}`); - const newestMenu = `${await expandedMessage(-1)} ${messageMenu}`; - await clickGmailControl(gmailPage, newestMenu); - await gmailPage.waitAll('.action_reply_message_button'); - await clickGmailControl(gmailPage, newestMenu); // close the menu before expanding the older message - await gmailPage.waitTillGone('.action_reply_message_button'); + await checkSecureReplyMenu(await expandedMessage(-1)); await clickGmailControl(gmailPage, '[role="listitem"] .adf.ads'); await gmailPage.target.waitForFunction( @@ -497,8 +525,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test { timeout: TIMEOUT_ELEMENT_APPEAR * 1000 }, messageSelector ); - await clickGmailControl(gmailPage, `${await expandedMessage(0)} ${messageMenu}`); - await gmailPage.waitAll('.action_reply_message_button'); + await checkSecureReplyMenu(await expandedMessage(0)); }, undefined, minutes(6) diff --git a/test/source/tests/page-recipe/gmail-page-recipe.ts b/test/source/tests/page-recipe/gmail-page-recipe.ts index 294b549c900..dabd525ad90 100644 --- a/test/source/tests/page-recipe/gmail-page-recipe.ts +++ b/test/source/tests/page-recipe/gmail-page-recipe.ts @@ -2,14 +2,32 @@ import { BrowserHandle } from '../../browser/browser-handle'; import { ControllablePage } from '../../browser/controllable'; -import { TIMEOUT_PAGE_LOAD } from '../../browser'; +import { TIMEOUT_ELEMENT_GONE } from '../../browser'; import { AvaContext } from '../tooling/'; import { PageRecipe } from './abstract-page-recipe'; import { expect } from 'chai'; -import { Util } from '../../util'; export class GmailPageRecipe extends PageRecipe { + public static dismissMobileNotificationsPrompt = async (gmailPage: ControllablePage) => { + const selector = + 'xpath/.//*[@role="dialog"][.//div[starts-with(normalize-space(text()), "Pause mobile notifications while")]]//button[@aria-label="Close"]'; + const closeButton = await gmailPage.page.$(selector); + if (!closeButton) { + return; + } + try { + if (await closeButton.isVisible()) { + await closeButton.press('Enter'); + const hiddenButton = await gmailPage.page.waitForSelector(selector, { hidden: true, timeout: TIMEOUT_ELEMENT_GONE * 1000 }); + await hiddenButton?.dispose(); + gmailPage.t.log('Dismissed Gmail’s pause mobile notifications prompt'); + } + } finally { + await closeButton.dispose(); + } + }; + public static openSecureComposeWithRichTextWorkaround = async ( t: AvaContext, gmailPage: ControllablePage, @@ -51,14 +69,17 @@ export class GmailPageRecipe extends PageRecipe { if (!lastMessageId || !lastMessageElement || lastMessageId === messageId) { break; } - await Util.sleep(3); - // deleting last reply - use waitAndClick for more reliable interaction with Gmail's dynamic UI - await gmailPage.waitAndClick(`[${messageIdAttrName}="${lastMessageId}"] [aria-label="More message options"]`, { delay: 2 }); - await Util.sleep(3); - await gmailPage.press('ArrowDown', 4); + const lastMessage = `[${messageIdAttrName}="${lastMessageId}"]`; + await this.dismissMobileNotificationsPrompt(gmailPage); + await gmailPage.waitAndFocus(`${lastMessage} [aria-label="More message options"]`); await gmailPage.press('Enter'); - await Util.sleep(3); - await gmailPage.page.reload({ timeout: TIMEOUT_PAGE_LOAD * 1000, waitUntil: 'networkidle2' }); + const deleteItem = await gmailPage.waitAny('li[data-action-type="11"]'); // Delete this message + try { + await deleteItem.press('Enter'); + } finally { + await deleteItem.dispose(); + } + await gmailPage.waitTillGone(lastMessage); } if (await gmailPage.isElementPresent('//*[text()="delete forever"]')) { From d52fa5b793dc7f24c93e9fe5e765b6c69e2b2c0d Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Tue, 10 Nov 2026 13:39:19 +0200 Subject: [PATCH 11/13] test fix --- test/source/tests/gmail.ts | 47 ++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/test/source/tests/gmail.ts b/test/source/tests/gmail.ts index 751325e4a61..a7c369c4a9d 100644 --- a/test/source/tests/gmail.ts +++ b/test/source/tests/gmail.ts @@ -136,6 +136,24 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test await GmailPageRecipe.dismissMobileNotificationsPrompt(gmailPage); }; + const withReattachedGmailPage = async (browser: BrowserHandle, gmailPage: ControllablePage, action: (page: ControllablePage) => Promise) => { + // Attach after the extension iframe is present so Puppeteer can see its execution context. + const attachedBrowser = await connect({ + browserWSEndpoint: browser.browser.wsEndpoint(), + defaultViewport: gmailPage.page.viewport(), + protocolTimeout: TIMEOUT_PAGE_LOAD * 1000, + }); + try { + const attachedPage = (await attachedBrowser.pages()).find(page => page.url() === gmailPage.page.url()); + if (!attachedPage) { + throw new Error('Could not reattach to the Gmail tab'); + } + await action(new ControllablePage(gmailPage.t, attachedPage)); + } finally { + await attachedBrowser.disconnect(); + } + }; + const replyIframe = 'iframe.reply_message[src*="/chrome/elements/compose.htm"]'; const getEditableGmailReply = async (gmailPage: ControllablePage) => { const skipPrompt = '&skipClickPrompt=___cu_true___'; @@ -277,8 +295,11 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test signature: 'signed', }); await pageHasSecureReplyContainer(t, browser, gmailPage); - const pubkeyPage = await gmailPage.getFrame(['/chrome/elements/pgp_pubkey.htm']); - await pubkeyPage.waitForContent('@container-pgp-pubkey', 'Fingerprint: 50B7 A032 B5E1 FBAB 24BA B205 B362 45FD AC2F BF3D'); + await gmailPage.waitAll('iframe.pgp_block.publicKey'); + await withReattachedGmailPage(browser, gmailPage, async attachedPage => { + const pubkeyFrame = await attachedPage.getFrame(['/chrome/elements/pgp_pubkey.htm'], { sleep: 0 }); + await pubkeyFrame.waitForContent('@container-pgp-pubkey', 'Fingerprint: 50B7 A032 B5E1 FBAB 24BA B205 B362 45FD AC2F BF3D'); + }); if (!encrypted) { expect(await gmailPage.getFramesUrls(['/chrome/elements/pgp_block.htm'], { sleep: 0 })).to.have.length(1); await testMinimumElementHeight(gmailPage, '.pgp_block.signedDetached', 80); @@ -346,25 +367,11 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test await createSecureDraft(t, browser, gmailPage, 'offline reply draft', { offline: true }); await gmailPage.reload({ timeout: TIMEOUT_PAGE_LOAD * 1000, waitUntil: 'domcontentloaded' }, true); await gmailPage.waitAll(`${replyIframe}[src*="&draftId="]`); - // Puppeteer can lose access to the extension frame's execution context during navigation. - // Attach after the draft iframe is present and keep all assertions and Send in the original Gmail tab. - const attachedBrowser = await connect({ - browserWSEndpoint: browser.browser.wsEndpoint(), - defaultViewport: gmailPage.page.viewport(), - protocolTimeout: TIMEOUT_PAGE_LOAD * 1000, - }); - try { - const attachedPage = (await attachedBrowser.pages()).find(page => page.url() === gmailPage.page.url()); - if (!attachedPage) { - throw new Error('Could not reattach to the Gmail tab with the restored reply draft'); - } - const attachedGmailPage = new ControllablePage(t, attachedPage); - const restoredReply = await pageHasSecureDraft(attachedGmailPage, 'offline reply draft'); - await GmailPageRecipe.dismissMobileNotificationsPrompt(attachedGmailPage); + await withReattachedGmailPage(browser, gmailPage, async attachedPage => { + const restoredReply = await pageHasSecureDraft(attachedPage, 'offline reply draft'); + await GmailPageRecipe.dismissMobileNotificationsPrompt(attachedPage); await restoredReply.waitAndClick('@action-send', { confirmGone: true }); - } finally { - await attachedBrowser.disconnect(); - } + }); await Util.sleep(2); await gmailPage.reload({ timeout: TIMEOUT_PAGE_LOAD * 1000, waitUntil: 'load' }, true); await gmailPage.waitAndClick('.h7:last-child .ajz', { delay: 1 }); // the small triangle which toggles the message details From b103260873d4d510adf5232c7d49c1e33bd7cc9c Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Tue, 10 Nov 2026 14:37:45 +0200 Subject: [PATCH 12/13] improve live tests --- test/source/tests/gmail.ts | 266 +++++++++++++++++-------------------- 1 file changed, 124 insertions(+), 142 deletions(-) diff --git a/test/source/tests/gmail.ts b/test/source/tests/gmail.ts index a7c369c4a9d..e4a382f435b 100644 --- a/test/source/tests/gmail.ts +++ b/test/source/tests/gmail.ts @@ -2,7 +2,7 @@ import test from 'ava'; -import { connect } from 'puppeteer'; +import { TimeoutError, connect } from 'puppeteer'; import { expect } from 'chai'; import { BrowserHandle } from './../browser/browser-handle'; import { Controllable, ControllableFrame, ControllablePage } from './../browser/controllable'; @@ -108,33 +108,26 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test expect(urls.length).to.equal(0); }; - const openGmailPage = async (t: AvaContext, browser: BrowserHandle, path?: string): Promise => { - let url = TestUrls.gmail(0); - if (path) { - url = TestUrls.gmail(0, path, 'inbox'); + const gotoGmailPage = async ( + gmailPage: ControllablePage, + { path = '', category = 'inbox', subject }: { path?: string; category?: GmailCategory; subject?: string } = {} + ) => { + await gmailPage.page.goto(TestUrls.gmail(0, path, category), { waitUntil: 'domcontentloaded', timeout: TIMEOUT_PAGE_LOAD * 1000 }); + if (subject !== undefined) { + await gmailPage.waitForContent('h2.hP', subject, TIMEOUT_PAGE_LOAD); + } else { + await gmailPage.waitAll(path ? 'h2.hP' : '[role="main"]', { timeout: TIMEOUT_PAGE_LOAD }); } - const gmailPage = await browser.newPage(t, url); + await gmailPage.waitAll('@action-secure-compose', { timeout: TIMEOUT_PAGE_LOAD }); await GmailPageRecipe.dismissMobileNotificationsPrompt(gmailPage); return gmailPage; }; - const gotoGmailPage = async (gmailPage: ControllablePage, path: string, category: GmailCategory = 'inbox') => { - const url = TestUrls.gmail(0, path, category); - await Util.sleep(1); - await gmailPage.goto(url); - await GmailPageRecipe.dismissMobileNotificationsPrompt(gmailPage); - }; - + const plainConversation = { path: '/FMfcgzGkbDRNgcQxLmkhBCKVSFwkfdvV', subject: '[ci.test] plain email' }; const replyAllConversation = { path: '/FMfcgzGtwgfMhWTlgRwwKWzRhqNZzwXz', subject: 'Encrypted message with 2 recipients for reply-all test', }; - const gotoGmailConversation = async (gmailPage: ControllablePage, { path, subject }: { path: string; subject: string }) => { - await gmailPage.page.goto(TestUrls.gmail(0, path), { waitUntil: 'domcontentloaded', timeout: TIMEOUT_PAGE_LOAD * 1000 }); - await gmailPage.waitForContent('h2.hP', subject, TIMEOUT_PAGE_LOAD); - await gmailPage.waitAll('@action-secure-compose', { timeout: TIMEOUT_PAGE_LOAD }); - await GmailPageRecipe.dismissMobileNotificationsPrompt(gmailPage); - }; const withReattachedGmailPage = async (browser: BrowserHandle, gmailPage: ControllablePage, action: (page: ControllablePage) => Promise) => { // Attach after the extension iframe is present so Puppeteer can see its execution context. @@ -163,7 +156,6 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test const messageMenu = '[aria-label="More message options"]'; const clickGmailControl = async (gmailPage: ControllablePage, selector: string) => { - await GmailPageRecipe.dismissMobileNotificationsPrompt(gmailPage); await gmailPage.target .locator(selector) .setVisibility('visible') @@ -189,7 +181,8 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test async (t, browser) => { const acctEmail = 'ci.tests.gmail@flowcrypt.dev'; await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await BrowserRecipe.openGmailPageAndVerifyComposeBtnPresent(t, browser); + const gmailPage = await gotoGmailPage(await browser.newPage(t)); + await GmailPageRecipe.closeInitialSetupNotif(gmailPage); const composePage = await GmailPageRecipe.openSecureComposeWithRichTextWorkaround(t, gmailPage, browser); const subject = `New Rich Text Message ${Util.lousyRandom()}`; await ComposePageRecipe.fillMsg(composePage, { to: acctEmail }, subject, undefined, { @@ -213,12 +206,12 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test 'mail.google.com - back button works in offline mode', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail', { cleanUpDrafts: false }); - const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/FMfcgzGkbDWztBnnCgRHzjrvmFqLtcJD'); + const gmailPage = await gotoGmailPage(await browser.newPage(t)); + await gotoGmailPage(gmailPage, { path: '/FMfcgzGkbDWztBnnCgRHzjrvmFqLtcJD' }); const expectedMessage = { content: ['this should decrypt even offline'], signature: 'signed', encryption: 'encrypted' }; await Util.sleep(5); await BrowserRecipe.pgpBlockCheck(t, await gmailPage.getFrame(['/chrome/elements/pgp_block.htm'], { sleep: 10, timeout: 25 }), expectedMessage); - await gotoGmailPage(gmailPage, '/FMfcgzGkbDRNgcQxLmkhBCKVSFwkfdvV'); // plain convo + await gotoGmailPage(gmailPage, plainConversation); await gmailPage.page.setOfflineMode(true); // go offline mode await gmailPage.page.goBack({ waitUntil: 'load' }); await BrowserRecipe.pgpBlockCheck(t, await gmailPage.getFrame(['/chrome/elements/pgp_block.htm']), expectedMessage); @@ -229,21 +222,20 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test 'mail.google.com - attachments rendered correctly', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail', { cleanUpDrafts: false }); - const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/FMfcgzGkbDXBWBWBfVKHssLtMqvDQSWN'); + const gmailPage = await gotoGmailPage(await browser.newPage(t), { path: '/FMfcgzGkbDXBWBWBfVKHssLtMqvDQSWN' }); // Check if rendering attachments coorectly await gmailPage.waitForContent('.aVW span:first-child', '36'); const urls = await gmailPage.getFramesUrls(['/chrome/elements/attachment.htm']); expect(urls.length).to.equal(36); // simple attachments triggering processAttachments() keep "download all" button visible - await gotoGmailPage(gmailPage, '/KtbxLvHkSWwbVHxgCbWNvXVKGjFgqMbGQq'); + await gotoGmailPage(gmailPage, { path: '/KtbxLvHkSWwbVHxgCbWNvXVKGjFgqMbGQq' }); await Util.sleep(5); await gmailPage.waitAll('iframe'); await gmailPage.waitAll(['.pYTkkf-JX-ano'], { visible: true }); // attachments which contain emoji in filename are rendered correctly - await gotoGmailPage(gmailPage, '/FMfcgzGtwqFGhMwWtLRjkPJlQlZHSlrW'); + await gotoGmailPage(gmailPage, { path: '/FMfcgzGtwqFGhMwWtLRjkPJlQlZHSlrW' }); await Util.sleep(5); await gmailPage.waitAll('iframe'); await gmailPage.waitAll(['.aZo'], { visible: false }); @@ -259,8 +251,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test 'mail.google.com - msg.asc message content renders', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/QgrcJHrtqfgLGKqwChjKsHKzZQpwRHMBqpG'); + const gmailPage = await gotoGmailPage(await browser.newPage(t), { path: '/QgrcJHrtqfgLGKqwChjKsHKzZQpwRHMBqpG' }); await gmailPage.waitAll('@action-show-original-conversation'); const urls = await gmailPage.getFramesUrls(['/chrome/elements/pgp_block.htm'], { sleep: 10, appearIn: 25 }); expect(urls.length).to.equal(1); @@ -287,7 +278,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test { format: 'signed + encrypted', path: '/FMfcgzGkbDZKPLBqWFzbgWqCrplTQdNz', encrypted: true }, ]) { t.log(`Thunderbird message: ${format}`); - const gmailPage = await openGmailPage(t, browser, path); + const gmailPage = await gotoGmailPage(await browser.newPage(t), { path }); const pgpBlockFrame = await gmailPage.getFrame(['/chrome/elements/pgp_block.htm'], { sleep: 0, timeout: 35 }); await BrowserRecipe.pgpBlockCheck(t, pgpBlockFrame, { content: encrypted ? ['Encrypted Subject: [ci.test] Thunderbird html signed + encrypted', '1234'] : ['1234'], @@ -321,7 +312,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); t.timeout(minutes(6)); // extend ava's timeout - const gmailPage = await openGmailPage(t, browser); + const gmailPage = await gotoGmailPage(await browser.newPage(t)); // create compose draft await gmailPage.waitAndClick('@action-secure-compose', { delay: 1 }); await createSecureDraft(t, browser, gmailPage, 'compose draft 1', { offline: true }); @@ -355,9 +346,8 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test testWithBrowser( async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); const threadId = '19ae97b85fe4f50e'; // 1st message -- thread id - await gotoGmailPage(gmailPage, `/${threadId}`); // go to encrypted convo + const gmailPage = await gotoGmailPage(await browser.newPage(t), { path: `/${threadId}` }); await GmailPageRecipe.trimConvo(gmailPage, threadId); await gmailPage.waitAndClick('@secure-reply-button'); const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm'], { sleep: 5 }); @@ -390,13 +380,13 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); t.timeout(minutes(4)); // extend ava's timeout - const gmailPage = await openGmailPage(t, browser); + const gmailPage = await gotoGmailPage(await browser.newPage(t)); // create compose draft await gmailPage.waitAndClick('@action-secure-compose', { delay: 1 }); await createSecureDraft(t, browser, gmailPage, 'a compose draft'); await gmailPage.reload({ timeout: TIMEOUT_PAGE_LOAD * 1000, waitUntil: 'load' }); t.timeout(minutes(4)); // extend ava's timeout - await gotoGmailPage(gmailPage, '', 'drafts'); // to go drafts section + await gotoGmailPage(gmailPage, { category: 'drafts' }); // open new compose window and saved draft await gmailPage.waitAndClick('@action-secure-compose', { delay: 1 }); await gmailPage.waitAndClick('//*[text()="Draft"]'); @@ -419,9 +409,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test 'mail.google.com - plain message contains smart replies', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail', { cleanUpDrafts: false }); - const gmailPage = await openGmailPage(t, browser); - await Util.sleep(1); - await gotoGmailPage(gmailPage, '/FMfcgzGpHHKCrKRLptBSNwkpMxzkdcQc'); // plain convo with smart replies + const gmailPage = await gotoGmailPage(await browser.newPage(t), { path: '/FMfcgzGpHHKCrKRLptBSNwkpMxzkdcQc' }); await gmailPage.waitForContent('.brb', 'Yes'); }) ); @@ -430,11 +418,11 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test 'mail.google.com - plain reply to encrypted and signed messages', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - let gmailPage = await openGmailPage(t, browser, '/FMfcgzGkbDRNgcQxLmkhBCKVSFwkfdvV'); // plain convo + let gmailPage = await gotoGmailPage(await browser.newPage(t), plainConversation); await clickGmailControl(gmailPage, 'div.adn [aria-label="Reply"]'); await gmailPage.waitAll('[data-tooltip^="Send"]'); await gmailPage.close(); - gmailPage = await openGmailPage(t, browser, '/181d226b4e69f172'); // go to encrypted convo + gmailPage = await gotoGmailPage(await browser.newPage(t), { path: '/181d226b4e69f172' }); await clickGmailControl(gmailPage, 'div.adn [aria-label="Reply"]'); await gmailPage.waitTillGone('.reply_message'); await gmailPage.waitAll('[data-tooltip^="Send"]'); // The Send button from the Standard reply box @@ -446,8 +434,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test await gmailPage.waitAll('.reply_message'); await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true }); await gmailPage.close(); - gmailPage = await browser.newPage(t); - await gotoGmailConversation(gmailPage, { path: '/FMfcgzGkbDRNpjDdNvCrwzqvXspZZxvh', subject: '[ci.test] signed email' }); + gmailPage = await gotoGmailPage(await browser.newPage(t), { path: '/FMfcgzGkbDRNpjDdNvCrwzqvXspZZxvh', subject: '[ci.test] signed email' }); await gmailPage.waitAll('iframe.pgp_block.signedMsg'); t.log('Opening Gmail Reply on the signed message'); await clickGmailControl(gmailPage, 'div.adn button[aria-label="Reply"]'); @@ -458,30 +445,40 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test ); // https://github.com/FlowCrypt/flowcrypt-browser/issues/5906 - test( - 'mail.google.com - older-message secure reply switching preserves quotes and expanded message menus show secure buttons', - testWithBrowser( - async (t, browser) => { - await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser, '/FMfcgzGqRGfPBbNLWvfPvDbxnHBwkdGf'); // plain convo - await gmailPage.waitAll('@action-secure-compose', { timeout: TIMEOUT_PAGE_LOAD }); - const messageSelector = '[role="listitem"] .adn.ads'; - const expandedMessage = async (index: number) => { - const id = await gmailPage.target.$$eval(messageSelector, (messages, i) => messages.at(i)?.getAttribute('data-legacy-message-id'), index); - if (!id) { - throw new Error(`No Gmail message ID found at index ${index}`); - } - return `${messageSelector}[data-legacy-message-id="${id}"]`; - }; - for (const switchControl of ['#switch_to_encrypted_reply', '[data-tooltip="Secure Reply"]']) { - t.log(`Switch older-message reply using ${switchControl}`); - await clickGmailControl(gmailPage, '[role="listitem"] .adf.ads'); // expand first message of thread - await gmailPage.target.waitForFunction( - selector => document.querySelectorAll(selector).length === 2, - { timeout: TIMEOUT_ELEMENT_APPEAR * 1000 }, - messageSelector - ); - const olderMessage = await expandedMessage(0); + const openOlderReplyConversation = async (t: AvaContext, browser: BrowserHandle) => { + await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); + return await gotoGmailPage(await browser.newPage(t), { path: '/FMfcgzGqRGfPBbNLWvfPvDbxnHBwkdGf' }); + }; + const expandedMessageSelector = '[role="listitem"] .adn.ads'; + const getExpandedMessage = async (gmailPage: ControllablePage, index: number) => { + const id = await gmailPage.target.$$eval(expandedMessageSelector, (messages, i) => messages.at(i)?.getAttribute('data-legacy-message-id'), index); + if (!id) { + throw new Error(`No Gmail message ID found at index ${index}`); + } + return `${expandedMessageSelector}[data-legacy-message-id="${id}"]`; + }; + const expandOlderMessage = async (gmailPage: ControllablePage) => { + await clickGmailControl(gmailPage, '[role="listitem"] .adf.ads'); // expand first message of thread + await gmailPage.target.waitForFunction( + selector => document.querySelectorAll(selector).length === 2, + { timeout: TIMEOUT_ELEMENT_APPEAR * 1000 }, + expandedMessageSelector + ); + return await getExpandedMessage(gmailPage, 0); + }; + + const olderReplyCases = [ + { control: 'warning link', selector: () => '#switch_to_encrypted_reply', checkQuotedText: true }, + { control: 'Secure Reply button', selector: (message: string) => `${message} [data-tooltip="Secure Reply"]`, checkQuotedText: false }, + ]; + // These tests share a live account and conversation. Account setup clears drafts before each case. + for (const { control, selector, checkQuotedText } of olderReplyCases) { + test.serial( + `mail.google.com - switch older-message reply to secure using the ${control}`, + testWithBrowser( + async (t, browser) => { + const gmailPage = await openOlderReplyConversation(t, browser); + const olderMessage = await expandOlderMessage(gmailPage); await clickGmailControl(gmailPage, `${olderMessage} [aria-label="Reply"]`); await gmailPage.waitAll('[data-tooltip^="Send"]'); // The Send button from the Standard reply box await gmailPage.waitForContent( @@ -489,65 +486,54 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test 'The last message was encrypted, but you are composing a reply without encryption.' ); - await clickGmailControl(gmailPage, switchControl.startsWith('#') ? switchControl : `${olderMessage} ${switchControl}`); - await gmailPage.waitAll('.reply_message'); - const replyBox = await gmailPage.getFrame(['/chrome/elements/compose.htm', '&skipClickPrompt=___cu_true___'], { sleep: 0 }); + await clickGmailControl(gmailPage, selector(olderMessage)); + const replyBox = await getEditableGmailReply(gmailPage); await replyBox.waitAll('@input-body'); await gmailPage.target.waitForFunction(() => document.querySelectorAll('iframe[src*="/chrome/elements/compose.htm"]').length === 2, { timeout: TIMEOUT_ELEMENT_APPEAR * 1000, }); await pageHasSecureReplyContainer(t, browser, gmailPage, { isReplyPromptAccepted: true, composeFrameCount: 2, replyFrame: replyBox }); - if (switchControl === '#switch_to_encrypted_reply') { - await replyBox.waitAll(['@action-expand-quoted-text']); + if (checkQuotedText) { await replyBox.waitAndClick('@action-expand-quoted-text', { delay: 0 }); - // Check if quoted message doesn't contain last message + // The quote should exclude text from the newest message. expect(await replyBox.read('@input-body')).to.not.contain(`Here's reply`); } - - // Finish deleting the draft before resetting the conversation for the next scenario. - await replyBox.waitAndClick('.delete_draft', { delay: 0 }); - await replyBox.waitAll('@action-accept-reply-prompt'); - await gmailPage.reload({ timeout: TIMEOUT_PAGE_LOAD * 1000, waitUntil: 'load' }); - await gmailPage.waitAll('[role="listitem"] .adf.ads'); - } - - t.log('Secure reply buttons on newest and expanded older message menus'); - const checkSecureReplyMenu = async (message: string) => { + }, + undefined, + minutes(6) + ) + ); + } + + for (const messagePosition of ['newest', 'older']) { + test.serial( + `mail.google.com - ${messagePosition} message menu shows the secure reply button`, + testWithBrowser( + async (t, browser) => { + const gmailPage = await openOlderReplyConversation(t, browser); + await gmailPage.waitAll(`${expandedMessageSelector} ${messageMenu}`); + const message = messagePosition === 'older' ? await expandOlderMessage(gmailPage) : await getExpandedMessage(gmailPage, -1); await gmailPage.waitAll(`${message} iframe.pgp_block.encryptedMsg`); - await GmailPageRecipe.dismissMobileNotificationsPrompt(gmailPage); const menu = `${message} ${messageMenu}`; await gmailPage.waitAndFocus(menu); await gmailPage.press('Enter'); await gmailPage.waitAll(`${menu}[aria-expanded="true"]`); await gmailPage.waitAll('@action-reply-message-button'); - await gmailPage.press('Escape'); - await gmailPage.waitTillGone(`${menu}[aria-expanded="true"]`); - }; - await gmailPage.waitAll(`${messageSelector} ${messageMenu}`); - await checkSecureReplyMenu(await expandedMessage(-1)); - - await clickGmailControl(gmailPage, '[role="listitem"] .adf.ads'); - await gmailPage.target.waitForFunction( - selector => document.querySelectorAll(selector).length === 2, - { timeout: TIMEOUT_ELEMENT_APPEAR * 1000 }, - messageSelector - ); - await checkSecureReplyMenu(await expandedMessage(0)); - }, - undefined, - minutes(6) - ) - ); + }, + undefined, + minutes(6) + ) + ); + } test( 'mail.google.com - plain reply with dot menu', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await browser.newPage(t); - await gotoGmailConversation(gmailPage, { path: '/FMfcgzGkbDRNgcQxLmkhBCKVSFwkfdvV', subject: '[ci.test] plain email' }); + const gmailPage = await gotoGmailPage(await browser.newPage(t), plainConversation); await clickGmailControl(gmailPage, 'div.adn [aria-label="Reply"]'); await gmailPage.waitAll('[data-tooltip^="Send"]'); - await gotoGmailConversation(gmailPage, replyAllConversation); + await gotoGmailPage(gmailPage, replyAllConversation); await gmailPage.waitAll('iframe.pgp_block'); await clickGmailControl(gmailPage, `.adn ${messageMenu}`); await clickGmailControl(gmailPage, 'li[data-action-type="24"]'); // click reply-all @@ -569,9 +555,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test 'mail.google.com - test reply all for password protected message', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail', { cleanUpDrafts: false }); - const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/FMfcgzQZTMHNLflWQjRcSvWlMsKbLhpr'); - await gmailPage.waitAll('@action-secure-compose', { timeout: TIMEOUT_PAGE_LOAD }); + const gmailPage = await gotoGmailPage(await browser.newPage(t), { path: '/FMfcgzQZTMHNLflWQjRcSvWlMsKbLhpr' }); await clickGmailControl(gmailPage, `.adn ${messageMenu}`); await gmailPage.waitAll('.action_reply_all_message_button'); }) @@ -582,8 +566,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test testWithBrowser( async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await browser.newPage(t); - await gotoGmailConversation(gmailPage, replyAllConversation); + const gmailPage = await gotoGmailPage(await browser.newPage(t), replyAllConversation); await gmailPage.waitAll('iframe.pgp_block'); await clickGmailControl(gmailPage, `.adn ${messageMenu}`); await clickGmailControl(gmailPage, 'li[data-action-type="25"]'); // click forward @@ -605,8 +588,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test 'mail.google.com - secure reply and forward in dot menu', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await browser.newPage(t); - await gotoGmailConversation(gmailPage, replyAllConversation); + const gmailPage = await gotoGmailPage(await browser.newPage(t), replyAllConversation); await gmailPage.waitAll(`${replyIframe}[src*="&skipClickPrompt=___cu_false___"]`); const gmailContextMenu = `[role="listitem"] .adn.ads ${messageMenu}`; for (const action of ['reply', 'reply-all', 'forward'] as const) { @@ -624,21 +606,15 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test await iframe.dispose(); } - const embeddedComposer = await gmailPage.getFrame([composerUrl], { sleep: 0 }); - // Probe the frame independently of composer readiness. Only a stalled Puppeteer evaluation can trigger the workaround. - const canReadFrame = - !process.env.SEMAPHORE || - (await Promise.race([ - embeddedComposer.target.evaluate(() => true), - new Promise(resolve => setTimeout(() => resolve(false), TIMEOUT_ELEMENT_APPEAR * 1000).unref()), - ])); - if (!canReadFrame) { - console.warn(`Reduced coverage for secure ${action}: Puppeteer could not read the embedded Gmail composer. Checking a fresh instance instead.`); - } + const getReadableComposer = async (page: ControllablePage) => { + const composer = await page.getFrame([composerUrl], { sleep: 0 }); + // Check that Puppeteer can evaluate in the frame independently of composer readiness. + const probe = await composer.frame.waitForFunction(() => true, { timeout: TIMEOUT_ELEMENT_APPEAR * 1000 }); + await probe.dispose(); + return composer; + }; - const fallbackPage = canReadFrame ? undefined : await browser.newPage(t, composerUrl); - const composer = fallbackPage ?? embeddedComposer; - try { + const checkComposer = async (composer: ControllableFrame) => { await composer.waitUntilViewLoaded(); await composer.waitAll(['@input-body', '@action-send']); if (action === 'reply-all') { @@ -651,12 +627,22 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test } else if (action === 'forward') { await composer.waitForContent('@input-body', '---------- Forwarded message ---------'); } - } finally { - if (fallbackPage) { - await fallbackPage.close(); - await gmailPage.page.bringToFront(); + }; + + let composer: ControllableFrame; + try { + composer = await getReadableComposer(gmailPage); + } catch (e) { + if (!(e instanceof TimeoutError)) { + throw e; } + t.log(`Reattaching to the Gmail tab after the secure ${action} iframe evaluation timed out`); + await withReattachedGmailPage(browser, gmailPage, async attachedPage => { + await checkComposer(await getReadableComposer(attachedPage)); + }); + continue; } + await checkComposer(composer); } }) ); @@ -668,7 +654,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); const threadId = '181d226b4e69f172'; // 1st message -- thread id - const gmailPage = await openGmailPage(t, browser, `/${threadId}`); + const gmailPage = await gotoGmailPage(await browser.newPage(t), { path: `/${threadId}` }); await GmailPageRecipe.trimConvo(gmailPage, threadId); await gmailPage.waitAndClick('div.adn [aria-label="Reply"]', { delay: 5 }); t.timeout(minutes(2)); // extend ava's timeout @@ -697,9 +683,8 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test { submitPubkey: false, usedPgpBefore: true }, { isSavePassphraseChecked: false, isSavePassphraseHidden: false } ); - const gmailPage = await openGmailPage(t, browser); t.log('Outlook encrypted message with attachment'); - await gotoGmailPage(gmailPage, '/FMfcgzGllVqqBbjHQQRDsSwcZBlMRzDr'); + const gmailPage = await gotoGmailPage(await browser.newPage(t), { path: '/FMfcgzGllVqqBbjHQQRDsSwcZBlMRzDr' }); await Util.sleep(5); await gmailPage.waitAll('iframe'); expect(await gmailPage.isElementPresent('@container-attachments')).to.equal(false); @@ -707,7 +692,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test expect(await gmailPage.isElementVisible('.aQH')).to.equal(false); // original attachment container(s) should be hidden t.log('Encrypted text inside "message" attachment'); - await gotoGmailPage(gmailPage, '/FMfcgzGrbHprlHvtTJscCJQpZcqrKQbg'); + await gotoGmailPage(gmailPage, { path: '/FMfcgzGrbHprlHvtTJscCJQpZcqrKQbg' }); await Util.sleep(5); await gmailPage.waitAll('iframe'); expect(await gmailPage.isElementPresent('@container-attachments')).to.equal(false); @@ -720,9 +705,8 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test `mail.google.com - large clipped PGP/MIME messages render correctly, including a text/plain attachment`, testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); t.log('Regular clipped PGP/MIME message'); - await gotoGmailPage(gmailPage, '/FMfcgzGtxKSjjzhRZRRzddjMvJnpDRQf'); + const gmailPage = await gotoGmailPage(await browser.newPage(t), { path: '/FMfcgzGtxKSjjzhRZRRzddjMvJnpDRQf' }); const urls = await gmailPage.getFramesUrls(['/chrome/elements/pgp_block.htm'], { sleep: 10, appearIn: 25 }); expect(urls.length).to.equal(1); const pgpBlockFrame = await gmailPage.getFrame(['pgp_block.htm']); @@ -735,7 +719,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test // https://github.com/FlowCrypt/flowcrypt-browser/issues/6171 t.log('Clipped PGP/MIME message with text/plain attachment'); - await gotoGmailPage(gmailPage, '/FMfcgzQfBspgLbfNnBHGtlBsFtcLGPsr'); + await gotoGmailPage(gmailPage, { path: '/FMfcgzQfBspgLbfNnBHGtlBsFtcLGPsr' }); const attachmentUrls = await gmailPage.getFramesUrls(['/chrome/elements/pgp_block.htm'], { sleep: 10, appearIn: 25 }); expect(attachmentUrls.length).to.equal(1); const attachmentPgpBlockFrame = await gmailPage.getFrame(['pgp_block.htm']); @@ -751,8 +735,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test `mail.google.com - render plain text for "message" attachment (which has plain text)`, testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail', { cleanUpDrafts: false }); - const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/FMfcgzGrbHrBdFGBXqpFZvSkcQpKkvrM'); + const gmailPage = await gotoGmailPage(await browser.newPage(t), { path: '/FMfcgzGrbHrBdFGBXqpFZvSkcQpKkvrM' }); await Util.sleep(5); await gmailPage.waitForContent('.a3s', 'Plain message'); expect(await gmailPage.isElementPresent('.aQH')).to.equal(true); // gmail attachment container @@ -766,8 +749,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test 'mail.google.com - pubkey file gets rendered', testWithBrowser(async (t, browser) => { await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail'); - const gmailPage = await openGmailPage(t, browser); - await gotoGmailPage(gmailPage, '/FMfcgzGkbDXBWCgTcMJlmBtfNxrbzTTn'); + const gmailPage = await gotoGmailPage(await browser.newPage(t), { path: '/FMfcgzGkbDXBWCgTcMJlmBtfNxrbzTTn' }); const urls = await gmailPage.getFramesUrls(['/chrome/elements/pgp_pubkey.htm']); expect(urls.length).to.equal(1); await pageHasSecureReplyContainer(t, browser, gmailPage); @@ -791,7 +773,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test // todo - missing equivalent sample at ci.tests.gmail // test('mail.google.com - pubkey gets rendered when using quoted-printable mime', testWithBrowser('compatibility', async (t, browser) => { - // const gmailPage = await openGmailPage(t, browser, '/WhctKJVRFztXGwvSbwcrbDshGTnLWMFvhwJmhqllRWwvpKnlpblQMXVZLTsKfWdPWKhPFBV'); + // const gmailPage = await gotoGmailPage(await browser.newPage(t), { path: '/WhctKJVRFztXGwvSbwcrbDshGTnLWMFvhwJmhqllRWwvpKnlpblQMXVZLTsKfWdPWKhPFBV' }); // const urls = await gmailPage.getFramesUrls(['/chrome/elements/pgp_pubkey.htm'], { sleep: 10, appearIn: 20 }); // expect(urls.length).to.equal(1); // await pageHasSecureReplyContainer(t, browser, gmailPage); From f944ae6703a5f91bccf47e799b4674e9cb50ba30 Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Wed, 11 Nov 2026 11:16:40 +0200 Subject: [PATCH 13/13] remove johnDoeDirectKey --- test/source/mock/wkd/wkd-constants.ts | 28 --------------------------- 1 file changed, 28 deletions(-) diff --git a/test/source/mock/wkd/wkd-constants.ts b/test/source/mock/wkd/wkd-constants.ts index 2250cbe9d95..df276f68259 100644 --- a/test/source/mock/wkd/wkd-constants.ts +++ b/test/source/mock/wkd/wkd-constants.ts @@ -36,34 +36,6 @@ AwMwBxWpyLaH6xjb =mswb -----END PGP PUBLIC KEY BLOCK-----`; -export const johnDoeDirectKey = `-----BEGIN PGP PUBLIC KEY BLOCK----- - -xsBNBF+Jz04BCACYEg0Fkg4NLnTxzuyF3gnz2pMfp+BelG/IHvIg9mls4U8OJcjGyq3bVpPDKDDQ -4ZuhRtrMy5K0ZnyiGsmzMKXvVS3FUPQ5EJD2Laveo5ohtM6t49jlloQvv7aMUBVpjTskaY06lJuV -2f1CCCDteh3G8qNpKvziUc4a8PzeIItktHTCa0MNdDRxq19DUs2eQGGXqBDm/mQjVMZ1Zgt55Ymu -BpPLytJXOjRoDYsTj+OdOv+aQ4Td7JnicTDVQR4Uc9x02lMPsBF3K0N0cnITyiKCV/QdgdSQkL8N -zFVgvt5QPGhlGA0sAl1wiBFeNZrrd+VXg4FmuGrWd9YLS01AyRSJABEBAAHNEmpvaG4uZG9lQDEy -Ny4wLjAuMcLAiQQTAQgAMxYhBGWfN6kiReeNpwCbUy2oGOH1OKOdBQJfic9SAhsDBQsJCAcCBhUI -CQoLAgUWAgMBAAAKCRAtqBjh9TijnU1JB/wPcImnOmo42gu8YBKe18d9HyCQNs4q4pw/bYXshLe7 -aMjx+XgUvWHBcoTtz+4g2QjmhmL3ROkGs/vBriZZqhZz4636s7RAlyU0yyzcH4rvNq/ByNm+Ol7x -Bwo3EbaRh46Q4mbctslfQ/jd42cUzwEOnY2HSPH+tgfTjd8xciBL5tH0+YinCuqSi/sAOkBoNAkv -kgiA+cRH4scVsW2KwWuZPOJINO8nJVu0at64sZib8/UJ4Zku5w7i1dnmWu6C9aqz+Ddu/xcDUW8j -2GFXECJX0deXZmhEZ8wLt5P+ke3Wt1gttGCigVzPvpXHkpZpC7zlykcMeE2ywRBqypauZUjPzsBN -BF+Jz1IBCACjRVxKy2aU49H95g8LM1Dsqmc+KCSOl9/kC1pyzKl4xUEYQ+ok5OKHt9tf42a1z9SM -oUicFkSOwBMtjOhWjrghxVBHIc4NtDewFXY6IifG6BvewOiNat2mYzfLF852idBbhnN82p4NWd2g -oUwDcqOvZ3Z5qg4eKiH2l+UzlHuFXmSfFP3g7Pm3UTaYhOWRBwOO/u7JN9rMHBcLxfp7T745C8dT -UmrZEpfTEGgwhmYfBFyMZFxzgtZwt4UUTnyLFtqhROPx6ji4ecSDNAD7yVjd9uJSNbxIRV4SUPCG -/vR39Lm8dXiFEek47DYGPaPyid/zfFkfhLndQ70W2GkhGdLnABEBAAHCwHYEGAEIACAWIQRlnzep -IkXnjacAm1MtqBjh9TijnQUCX4nPVwIbDAAKCRAtqBjh9Tijna+wB/4tsj016eBsQGb3xGs/BBa6 -06VLL9tjrTV9TdZj3DfpE9xSPiNC+Jah09uW//VNRzNTDYctGXEGIYm2tx2q8QAX/rWBC/UYi16l -4lHnvlHa4NNA+O22uQpMlwmbTVSPTs4kVUSpNyuOtE6SXY6UyzcyvwTpffXiQkfICW7BXmykUXHx -HZ8Ddq/syp3eBitlmNZHGwRWKD5ihd96o5dCw/Dgpz/p6dxka1627j013wov65p1NbXiV1kM7G7s -ZccLrjYxOL/1Rc1ac9TdfXX7lVeZtbpSVhSl9Z1YMhth+oWVJ79iQQ8OPKEvt471Qwk1LH7k4a9O -nT5+WNnpAkcxrjMd -=fISM ------END PGP PUBLIC KEY BLOCK----- -`; - export const jackAdvancedKey = `-----BEGIN PGP PUBLIC KEY BLOCK----- xsBNBF+J56IBCADSvEei1mAEQCEXHxaOKzsxvM8Qvgjj0vr+zHE+hUFg1znRAyjQ9XSDGwJ4+dut