Skip to content

Commit

Permalink
#5928 Fix secure reply-all issues in Gmail context menu (#5934)
Browse files Browse the repository at this point in the history
* fix: correct reply-all option invocation

* test: test updated

* test: update test

* refactor: display better label for "reply to all"

* test: debugging

* test: debugging

* test: debugging

* test: debugging

* test: skip tests that fails too often

* chore: add comment

---------

Co-authored-by: martgil <martroblesit@gmail.com>
  • Loading branch information
martgil and martgil authored Feb 18, 2025
1 parent ab59cca commit ac524c5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
13 changes: 7 additions & 6 deletions extension/js/common/xss-safe-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,15 @@ export class XssSafeFactory {
};

public btnSecureMenuBtn = (replyOption: ReplyOption) => {
const actionText = replyOption.replace('a_', '').replace('_', ' ');
const action = {
underscore: actionText.replace(' ', '_'),
hyphen: actionText.replace(' ', '-'),
const replyOptionText = replyOption.replace('a_', '').replace('_', ' ');
const htmlAttrib = {
className: replyOptionText.replace(' ', '_'),
testName: replyOptionText.replace(' ', '-'),
};
const displayText = replyOptionText === 'reply all' ? replyOptionText.replace('all', 'to all') : replyOptionText;
// * The action_${action.underscore}_message_button is used as an identifier in GmailElementReplacer.actionActivateSecureReplyHandler()
return `<div class="action_${action.underscore}_message_button action_menu_message_button" data-test="action-${action.hyphen}-message-button">
<img src="${this.srcImg(`svgs/${action.hyphen}-icon.svg`)}" /><span>secure ${actionText}</span>
return `<div class="action_${htmlAttrib.className}_message_button action_menu_message_button" data-test="action-${htmlAttrib.testName}-message-button">
<img src="${this.srcImg(`svgs/${htmlAttrib.testName}-icon.svg`)}" /><span>secure ${displayText}</span>
</div>`;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export class GmailElementReplacer extends WebmailElementReplacer {
event.stopImmediatePropagation();
const secureReplyInvokedFromMenu = btn.className.includes('action_menu_message_button');
let replyOption: ReplyOption;
if (btn.className.includes('reply-all')) {
if (btn.className.includes('reply_all')) {
replyOption = 'a_reply_all';
} else if (btn.className.includes('forward')) {
replyOption = 'a_forward';
Expand Down
13 changes: 9 additions & 4 deletions test/source/tests/gmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test
);

// convo-sensitive, draft-sensitive test
test.serial(
// skipped temporarily as per https://github.com/FlowCrypt/flowcrypt-browser/issues/5934#issuecomment-2664926769, originally uses test.serial
test.skip(
'mail.google.com - secure reply btn, reply draft',
testWithBrowser(
async (t, browser) => {
Expand Down Expand Up @@ -403,7 +404,8 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test
);

// https://github.com/FlowCrypt/flowcrypt-browser/issues/5906
test(
// skipped temporarily as per https://github.com/FlowCrypt/flowcrypt-browser/issues/5934#issuecomment-2664926769
test.skip(
'mail.google.com - Keep original reply message when switching to secure mode',
testWithBrowser(async (t, browser) => {
await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail');
Expand All @@ -421,7 +423,7 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test
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 Util.sleep(3);
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`);
Expand Down Expand Up @@ -495,7 +497,8 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test
})
);

test(
// skipped temporarily as per https://github.com/FlowCrypt/flowcrypt-browser/issues/5934#issuecomment-2664926769
test.skip(
'mail.google.com - switch to encrypted forward',
testWithBrowser(async (t, browser) => {
await BrowserRecipe.setUpCommonAcct(t, browser, 'ci.tests.gmail');
Expand Down Expand Up @@ -537,6 +540,8 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test
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 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'));
Expand Down

0 comments on commit ac524c5

Please sign in to comment.