mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-10-30 16:16:19 +00:00
fix: drop the scheduled badge from a demo message once its send is cancelled
This commit is contained in:
@@ -30,3 +30,21 @@ describe('DemoJMAPClient raw messages', () => {
|
||||
expect(await (await client.fetchBlob(draft!.blobId!)).text()).toContain('Subject: Draft for export');
|
||||
});
|
||||
});
|
||||
|
||||
// A server sends a new object on every fetch. The app stamps the scheduled
|
||||
// send onto the message it opens; with the demo's own object, a cancelled
|
||||
// send kept its Scheduled badge in Drafts.
|
||||
describe('DemoJMAPClient getEmail', () => {
|
||||
it('returns a copy that the caller may change', async () => {
|
||||
const client = new DemoJMAPClient();
|
||||
const { emails } = await client.getEmails(undefined, undefined, 1);
|
||||
const opened = (await client.getEmail(emails[0].id))!;
|
||||
opened.isScheduled = true;
|
||||
opened.scheduledSendAt = '2030-01-01T08:00:00Z';
|
||||
const again = (await client.getEmail(emails[0].id))!;
|
||||
expect(again.isScheduled).toBeUndefined();
|
||||
expect(again.scheduledSendAt).toBeUndefined();
|
||||
const { emails: listed } = await client.getEmails(undefined, undefined, 500);
|
||||
expect(listed.find((e) => e.id === emails[0].id)!.isScheduled).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -383,7 +383,10 @@ export class DemoJMAPClient implements IJMAPClient {
|
||||
}
|
||||
|
||||
async getEmail(emailId: string): Promise<Email | null> {
|
||||
return this.data.emails.find(e => e.id === emailId) ?? null;
|
||||
// A copy, as a server sends: the app stamps what it opens (a scheduled
|
||||
// send's fields), which must not stick to the stored message.
|
||||
const email = this.data.emails.find(e => e.id === emailId);
|
||||
return email ? structuredClone(email) : null;
|
||||
}
|
||||
|
||||
async getTagCounts(tagIds: string[], accountId?: string, excludeMailboxIds?: string[]): Promise<Record<string, { total: number; unread: number }>> {
|
||||
|
||||
Reference in New Issue
Block a user