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
4 changes: 4 additions & 0 deletions test/source/browser/controllable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,10 @@ abstract class ControllableBase {
return files;
};

public keyboard = () => {
return 'keyboard' in this.target ? this.target.keyboard : this.target.page().keyboard;
};

protected log = (msg: string) => {
if (this.debugNamespace) {
console.info(`[debug][controllable][${this.debugNamespace}] ${msg}`);
Expand Down
6 changes: 5 additions & 1 deletion test/source/mock/google/google-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ export const mockGoogleEndpoints: HandlersDefinition = {
// get msg or attachment
const acct = oauth.checkAuthorizationHeaderWithAccessToken(req.headers.authorization);
if (isGet(req)) {
const id = parseResourceId(req.url!); // eslint-disable-line @typescript-eslint/no-non-null-assertion
// temporary replacement for parseResourceId() until #5050 is fixed
const id = req.url!.match(/\/([a-zA-Z0-9\-_]+)(\?|$)/)?.[1]; // eslint-disable-line @typescript-eslint/no-non-null-assertion
if (!id) {
return {};
}
const data = await GoogleData.withInitializedData(acct);
if (req.url?.includes('/attachments/')) {
const attachment = data.getAttachment(id);
Expand Down
6 changes: 4 additions & 2 deletions test/source/tests/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2661,8 +2661,10 @@ export const defineComposeTests = (testVariant: TestVariant, testWithBrowser: Te
const settingsPage = await BrowserRecipe.openSettingsLoginApprove(t, browser, acct);
await SetupPageRecipe.autoSetupWithEKM(settingsPage);
const composePage = await ComposePageRecipe.openStandalone(t, browser, acct);
await ComposePageRecipe.fillMsg(composePage, { to: 'mock.only.pubkey@flowcrypt.com' }, 'no valid key');
await ComposePageRecipe.waitForToastToAppearAndDisappear(composePage, 'Draft not saved: Error: Your account keys are revoked');
await Promise.all([
ComposePageRecipe.fillMsg(composePage, { to: 'mock.only.pubkey@flowcrypt.com' }, 'no valid key'),
ComposePageRecipe.waitForToastToAppearAndDisappear(composePage, 'Draft not saved: Error: Your account keys are revoked'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This toast appears only once, doesn't reappear on further edits, is this behavior expected?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's expected behavior - we set disableSendingDrafts to true in case of such error (as there is no reason to retry draft saving)

https://github.com/FlowCrypt/flowcrypt-browser/blob/master/extension/chrome/elements/compose-modules/compose-draft-module.ts#L183

]);
await composePage.waitAndClick('@action-send', { delay: 1 });
await PageRecipe.waitForModalAndRespond(composePage, 'warning', {
contentToCheck: 'Failed to send message due to: Error: Your account keys are revoked',
Expand Down
22 changes: 14 additions & 8 deletions test/source/tests/page-recipe/compose-page-recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,28 @@ export class ComposePageRecipe extends PageRecipe {
body?: string | undefined,
sendingOpt: { encrypt?: boolean; sign?: boolean; richtext?: boolean } = {} // undefined means leave default
) {
await Util.sleep(0.5);
await ComposePageRecipe.fillRecipients(composePageOrFrame, recipients);
if (subject) {
await composePageOrFrame.click('@input-subject');
await Util.sleep(1);
await composePageOrFrame.type('@input-subject', subject?.match(/RTL/) ? subject : `Automated puppeteer test: ${subject}`);
}
const sendingOpts = sendingOpt as { [key: string]: boolean | undefined };
const keys = ['richtext', 'encrypt', 'sign'];
await composePageOrFrame.type('@input-body', body || subject || ''); // fall back to subject if body is not provided
for (const opt of keys) {
const shouldBeTicked = sendingOpts[opt];
if (typeof shouldBeTicked !== 'undefined') {
await ComposePageRecipe.setPopoverToggle(composePageOrFrame, opt as PopoverOpt, shouldBeTicked);
}
}
await Util.sleep(0.5); // todo: should we wait only if we didn't modify any sendingOpts?
await ComposePageRecipe.fillRecipients(composePageOrFrame, recipients);
if (subject) {
await composePageOrFrame.click('@input-subject');
await Util.sleep(1);
await composePageOrFrame.type('@input-subject', subject?.match(/RTL/) ? subject : `Automated puppeteer test: ${subject}`);
}
await composePageOrFrame.click('@input-body');
// bring cursor to the beginning of the multiline contenteditable
const keyboard = composePageOrFrame.keyboard();
await keyboard.down('Control');
await keyboard.press('Home');
await keyboard.up('Control');
await composePageOrFrame.type('@input-body', body || subject || ''); // fall back to subject if body is not provided
return { subject, body };
}

Expand Down