Skip to content

Commit

Permalink
always delete local draft after sending
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed Nov 7, 2021
1 parent 09e0283 commit ac25d44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,10 @@ export class ComposeDraftModule extends ViewModule<ComposeView> {
await Ui.time.wait(() => !this.currentlySavingDraft ? true : undefined);
if (this.view.draftId) {
try {
if (this.isLocalDraftId(this.view.draftId)) {
await this.localDraftRemove();
} else {
if (!this.isLocalDraftId(this.view.draftId)) {
await this.view.emailProvider.draftDelete(this.view.draftId);
}
await this.localDraftRemove();
this.view.draftId = '';
} catch (e) {
if (ApiErr.isAuthErr(e)) {
Expand Down
9 changes: 4 additions & 5 deletions test/source/tests/gmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,27 +265,26 @@ export const defineGmailTests = (testVariant: TestVariant, testWithBrowser: Test
}));

ava.default('mail.google.com - secure reply btn, reply draft', testWithBrowser('ci.tests.gmail', async (t, browser) => {
const gmailPage = await openGmailPage(t, browser, '/');
await gotoGmailPage(gmailPage, '/FMfcgzGkbDRNgcPktjdSxpJVhZlZqpTr'); // to go encrypted convo
const gmailPage = await openGmailPage(t, browser, '/FMfcgzGlkjftvKTsGnTltMvmZdDzdPFB'); // to go encrypted convo
// Gmail has 100 emails per thread limit, so if there are 98 deleted messages + 1 initial message,
// the draft number 100 won't be saved. Therefore, we need to delete forever trashed messages from this thread.
if (await gmailPage.isElementPresent('//*[text()="delete forever"]')) {
await gmailPage.click('//*[text()="delete forever"]');
}
await gmailPage.waitAndClick('@secure-reply-button');
await createSecureDraft(t, browser, gmailPage, 'reply draft');
await gmailPage.page.reload();
await gmailPage.page.reload({ waitUntil: 'networkidle2' });
const urls = await gmailPage.getFramesUrls(['/chrome/elements/compose.htm']);
expect(urls.length).to.equal(1);
let replyBox = await pageHasSecureDraft(gmailPage, 'reply draft');
await createSecureDraft(t, browser, gmailPage, 'offline reply draft', { offline: true });
await gmailPage.page.reload();
await gmailPage.page.reload({ waitUntil: 'networkidle2' });
replyBox = await pageHasSecureDraft(gmailPage, 'offline reply draft');
// await replyBox.waitAndClick('@action-send'); doesn't work for some reason, use keyboard instead
await gmailPage.page.keyboard.press('Tab');
await gmailPage.page.keyboard.press('Enter');
await replyBox.waitTillGone('@action-send');
await gmailPage.page.reload();
await gmailPage.page.reload({ waitUntil: 'networkidle2' });
await gmailPage.waitAndClick('.h7:last-child .ajz', { delay: 1 }); // the small triangle which toggles the message details
await gmailPage.waitForContent('.h7:last-child .ajA', 'Re: [ci.test] encrypted email for reply render'); // make sure that the subject of the sent draft is corrent
await GmailPageRecipe.deleteLastReply(gmailPage);
Expand Down

0 comments on commit ac25d44

Please sign in to comment.