Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extension/chrome/settings/modules/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ View.run(
substring: String($('.input-search-contacts').val()),
});
let lineActionsHtml =
'&nbsp;&nbsp;<a href="#" class="action_export_all">Export all</a>&nbsp;&nbsp;' +
'&nbsp;&nbsp;<a href="#" class="action_export_all" data-test="action-export-all-public-keys">Export all</a>&nbsp;&nbsp;' +
'&nbsp;&nbsp;<a href="#" class="action_view_bulk_import" data-test="action-show-import-public-keys-form">Import public keys</a>&nbsp;&nbsp;';
if (this.clientConfiguration.getCustomSksPubkeyServer()) {
lineActionsHtml +=
Expand Down
36 changes: 36 additions & 0 deletions test/source/tests/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,42 @@ export const defineSettingsTests = (testVariant: TestVariant, testWithBrowser: T
await SettingsPageRecipe.toggleScreen(settingsPage, 'basic');
})
);
test(
'settings - export all public keys from contacts',
testWithBrowser(async (t, browser) => {
const acct = 'flowcrypt.compatibility@gmail.com';
await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility', {
google: { acctAliases: flowcryptCompatibilityAliasList },
});
const settingsPage = await browser.newExtensionSettingsPage(t, acct);
await SettingsPageRecipe.toggleScreen(settingsPage, 'additional');
const contactsFrame = await SettingsPageRecipe.awaitNewPageFrame(settingsPage, '@action-open-contacts-page', ['contacts.htm', 'placement=settings']);
await contactsFrame.waitAll('@page-contacts');
await Util.sleep(1);

// Trigger the export and capture the downloaded file
const downloadedFiles = await contactsFrame.awaitDownloadTriggeredByClicking('@action-export-all-public-keys');
expect(downloadedFiles['public-keys-export.asc']).to.exist;

// Verify the file content is not empty
const fileContent = downloadedFiles['public-keys-export.asc'].toString();

// Verify the file contains PGP public key blocks
expect(fileContent).to.contain('-----BEGIN PGP PUBLIC KEY BLOCK-----');
expect(fileContent).to.contain('-----END PGP PUBLIC KEY BLOCK-----');

// Verify it contains the expected public keys (the account's own keys)
const { keys } = await KeyUtil.readMany(Buf.fromUtfStr(fileContent));

// Verify the keys can be parsed (they're valid PGP keys)
for (const key of keys) {
expect(key.id).to.not.be.empty;
}

await SettingsPageRecipe.closeDialog(settingsPage);
await SettingsPageRecipe.toggleScreen(settingsPage, 'basic');
})
);
test(
'settings - update contact public key',
testWithBrowser(async (t, browser) => {
Expand Down
Loading