diff --git a/test/source/tests/compose.ts b/test/source/tests/compose.ts index 312494b105e..9cc8f39343a 100644 --- a/test/source/tests/compose.ts +++ b/test/source/tests/compose.ts @@ -817,10 +817,10 @@ export const defineComposeTests = (testVariant: TestVariant, testWithBrowser: Te await composePage.waitAndClick('@action-send', { delay: 1 }); const attachment = await composePage.getFrame(['attachment.htm', `name=${attachmentFilename}`]); await attachment.waitForSelTestState('ready'); - const fileText = await composePage.awaitDownloadTriggeredByClicking(async () => { + const downloadedFiles = await composePage.awaitDownloadTriggeredByClicking(async () => { await attachment.click('#download'); }); - expect(Object.values(fileText).pop()!.toString()).to.equal(`small text file\nnot much here\nthis worked\n`); + expect(downloadedFiles[attachmentFilename]!.toString()).to.equal(`small text file\nnot much here\nthis worked\n`); await composePage.close(); })); @@ -1241,10 +1241,10 @@ export const defineComposeTests = (testVariant: TestVariant, testWithBrowser: Te const fileInput = await composeFrame.target.$('input[type=file]'); await fileInput!.uploadFile('test/samples/small.txt', 'test/samples/small.png', 'test/samples/small.pdf'); // attachments in composer can be downloaded - const fileText = await inboxPage.awaitDownloadTriggeredByClicking(async () => { + const downloadedFiles = await inboxPage.awaitDownloadTriggeredByClicking(async () => { await composeFrame.click('.qq-file-id-0'); }); - expect(Object.values(fileText).pop()!.toString()).to.equal(`small text file\nnot much here\nthis worked\n`); + expect(downloadedFiles['small.txt']!.toString()).to.equal(`small text file\nnot much here\nthis worked\n`); await composeFrame.waitAndClick('@action-send', { delay: 2 }); await inboxPage.waitTillGone('@container-new-message'); })); @@ -1261,10 +1261,10 @@ export const defineComposeTests = (testVariant: TestVariant, testWithBrowser: Te const fileInput = await composeFrame.target.$('input[type=file]'); await fileInput!.uploadFile('test/samples/small.txt', 'test/samples/small.png', 'test/samples/small.pdf'); // attachments in composer can be downloaded - const fileText = await inboxPage.awaitDownloadTriggeredByClicking(async () => { + const downloadedFiles = await inboxPage.awaitDownloadTriggeredByClicking(async () => { await composeFrame.click('.qq-file-id-0'); }); - expect(Object.values(fileText).pop()!.toString()).to.equal(`small text file\nnot much here\nthis worked\n`); + expect(downloadedFiles['small.txt']!.toString()).to.equal(`small text file\nnot much here\nthis worked\n`); await composeFrame.waitAndClick('@action-send', { delay: 2 }); await inboxPage.waitTillGone('@container-new-message'); })); diff --git a/test/source/tests/flaky.ts b/test/source/tests/flaky.ts index a93c5f21fa3..1eb51fc3b6e 100644 --- a/test/source/tests/flaky.ts +++ b/test/source/tests/flaky.ts @@ -107,8 +107,11 @@ export const defineFlakyTests = (testVariant: TestVariant, testWithBrowser: Test await SettingsPageRecipe.toggleScreen(settingsPage, 'additional'); const fingerprint = (await settingsPage.read('.good', true)).split(' ').join(''); const myKeyFrame = await browser.newPage(t, `chrome/settings/modules/my_key.htm?placement=settings&parentTabId=60%3A0&acctEmail=${acctEmail}&fingerprint=${fingerprint}`); - const files = await myKeyFrame.awaitDownloadTriggeredByClicking('@action-download-prv'); - const key = await KeyUtil.parse(Object.values(files).pop()!.toString()); + const downloadedFiles = await myKeyFrame.awaitDownloadTriggeredByClicking('@action-download-prv'); + // const longid = OpenPGPKey.fingerprintToLongid(fingerprint); + const longid = fingerprint.substring(fingerprint.length - 16); + const fileName = `flowcrypt-backup-usernosubmitorgruleflowcrypttest-0x${longid}.asc`; + const key = await KeyUtil.parse(downloadedFiles[fileName]!.toString()); expect(key.algo.bits).to.equal(3072); expect(key.algo.algorithm).to.equal('rsa_encrypt_sign'); await myKeyFrame.close(); diff --git a/test/source/tests/settings.ts b/test/source/tests/settings.ts index ec737940f0b..a29f9eaa212 100644 --- a/test/source/tests/settings.ts +++ b/test/source/tests/settings.ts @@ -594,7 +594,8 @@ export const defineSettingsTests = (testVariant: TestVariant, testWithBrowser: T await backupPage.waitAndClick('[data-id="CB0485FE44FC22FF09AF0DB31B383D0334E38B28"]'); // uncheck // backing up to file when only one key is checked const backupFileRawData1 = await backupPage.awaitDownloadTriggeredByClicking('@action-backup-step3manual-continue'); - const { keys: keys1 } = await KeyUtil.readMany(Buf.fromUtfStr(Object.values(backupFileRawData1).pop()!.toString())); + const { keys: keys1 } = await KeyUtil.readMany(Buf.fromUtfStr(backupFileRawData1['flowcrypt-backup-flowcrypttestkeymultiplegmailcom-515431151DDD3EA232B37A4C98ACFA1EADAB5B92.asc']! + .toString())); expect(keys1.length).to.equal(1); expect(keys1[0].id).to.equal("515431151DDD3EA232B37A4C98ACFA1EADAB5B92"); await backupPage.waitAndRespondToModal('info', 'confirm', 'Downloading private key backup file'); @@ -667,8 +668,13 @@ export const defineSettingsTests = (testVariant: TestVariant, testWithBrowser: T await backupPage.waitAndClick('@input-backup-step3manual-file'); // one passphrase is not known but successfully guessed const downloadedFiles = await backupPage.awaitDownloadTriggeredByClicking('@action-backup-step3manual-continue', 2); - const { keys } = await KeyUtil.readMany(Buf.fromUtfStr(Buffer.concat(Object.values(downloadedFiles)).toString())); - expect(keys.length).to.equal(2); + expect(Object.keys(downloadedFiles).length).to.equal(2); + const { keys: keys1 } = await KeyUtil.readMany(Buf.fromUtfStr(downloadedFiles['flowcrypt-backup-flowcrypttestkeymultiplegmailcom-515431151DDD3EA232B37A4C98ACFA1EADAB5B92.asc']! + .toString())); + expect(keys1.length).to.equal(1); + const { keys: keys2 } = await KeyUtil.readMany(Buf.fromUtfStr(downloadedFiles['flowcrypt-backup-flowcrypttestkeymultiplegmailcom-515431151DDD3EA232B37A4C98ACFA1EADAB5B92.asc']! + .toString())); + expect(keys2.length).to.equal(1); await backupPage.close(); })); @@ -776,7 +782,7 @@ export const defineSettingsTests = (testVariant: TestVariant, testWithBrowser: T '&type=openpgp&id=515431151DDD3EA232B37A4C98ACFA1EADAB5B92&idToken=fakeheader.01')); await backupPage.waitAndClick('@input-backup-step3manual-file'); const downloadedFiles = await backupPage.awaitDownloadTriggeredByClicking('@action-backup-step3manual-continue'); - const { keys } = await KeyUtil.readMany(Buf.fromUtfStr(Object.values(downloadedFiles).pop()!.toString())); + const { keys } = await KeyUtil.readMany(Buf.fromUtfStr(downloadedFiles['flowcrypt-backup-flowcrypttestkeymultiplegmailcom-515431151DDD3EA232B37A4C98ACFA1EADAB5B92.asc']!.toString())); expect(keys.length).to.equal(1); expect(keys[0].id).to.equal("515431151DDD3EA232B37A4C98ACFA1EADAB5B92"); await backupPage.waitAndRespondToModal('info', 'confirm', 'Downloading private key backup file');