gogcli-mcp-gmail 2.0.12 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/index.js +327 -32
- package/manifest.json +57 -1
- package/package.json +1 -1
- package/src/tools/gmail-extra.ts +345 -16
- package/tests/tools/gmail-extra.test.ts +449 -0
|
@@ -223,6 +223,72 @@ describe('gog_gmail_thread_get', () => {
|
|
|
223
223
|
{ account: undefined },
|
|
224
224
|
);
|
|
225
225
|
});
|
|
226
|
+
|
|
227
|
+
const THREAD = JSON.stringify({
|
|
228
|
+
downloaded: false,
|
|
229
|
+
thread: {
|
|
230
|
+
id: 't1',
|
|
231
|
+
messages: [
|
|
232
|
+
{ id: 'm1', threadId: 't1', internalDate: '1', labelIds: ['INBOX'], snippet: 'first', payload: { headers: [{ name: 'From', value: 'a@x.com' }, { name: 'Subject', value: 'Hi' }, { name: 'X-Spam', value: 'no' }, { value: 'orphan-no-name' }], body: { data: 'AAAA' } } },
|
|
233
|
+
{ id: 'm2', threadId: 't1', internalDate: '2', labelIds: ['INBOX'], snippet: 'second', payload: { headers: [{ name: 'From', value: 'b@x.com' }] } },
|
|
234
|
+
{ id: 'm3', threadId: 't1', internalDate: '3', labelIds: ['SENT'], snippet: 'third' },
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('does not transform the output when no paging params are given', async () => {
|
|
240
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValueOnce(toText(THREAD));
|
|
241
|
+
const result = await handlers.get('gog_gmail_thread_get')!({ threadId: 't1' });
|
|
242
|
+
expect(result.content[0].text).toBe(THREAD);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('latestN returns only the last N messages', async () => {
|
|
246
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValueOnce(toText(THREAD));
|
|
247
|
+
const result = await handlers.get('gog_gmail_thread_get')!({ threadId: 't1', latestN: 2 });
|
|
248
|
+
// latestN is wrapper-side; no CLI flag is added
|
|
249
|
+
expect(vi.mocked(lib.runOrDiagnose).mock.calls[0]![0]).toEqual(['gmail', 'thread', 'get', 't1']);
|
|
250
|
+
const parsed = JSON.parse(result.content[0].text);
|
|
251
|
+
expect(parsed.thread.messages.map((m: { id: string }) => m.id)).toEqual(['m2', 'm3']);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('snippetsOnly returns per-message headers and snippet without bodies', async () => {
|
|
255
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValueOnce(toText(THREAD));
|
|
256
|
+
const result = await handlers.get('gog_gmail_thread_get')!({ threadId: 't1', snippetsOnly: true });
|
|
257
|
+
const parsed = JSON.parse(result.content[0].text);
|
|
258
|
+
expect(parsed.thread.messages).toHaveLength(3);
|
|
259
|
+
const m1 = parsed.thread.messages[0];
|
|
260
|
+
expect(m1.snippet).toBe('first');
|
|
261
|
+
expect(m1.headers).toEqual({ From: 'a@x.com', Subject: 'Hi' }); // X-Spam dropped
|
|
262
|
+
expect(m1.payload).toBeUndefined();
|
|
263
|
+
// a message with no payload yields empty headers without throwing
|
|
264
|
+
expect(parsed.thread.messages[2].headers).toEqual({});
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('combines latestN and snippetsOnly', async () => {
|
|
268
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValueOnce(toText(THREAD));
|
|
269
|
+
const result = await handlers.get('gog_gmail_thread_get')!({ threadId: 't1', latestN: 1, snippetsOnly: true });
|
|
270
|
+
const parsed = JSON.parse(result.content[0].text);
|
|
271
|
+
expect(parsed.thread.messages).toHaveLength(1);
|
|
272
|
+
expect(parsed.thread.messages[0].id).toBe('m3');
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it('returns the raw result when the payload is not JSON', async () => {
|
|
276
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValueOnce(toText('not json'));
|
|
277
|
+
const result = await handlers.get('gog_gmail_thread_get')!({ threadId: 't1', latestN: 2 });
|
|
278
|
+
expect(result.content[0].text).toBe('not json');
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('returns the raw result when there is no messages array', async () => {
|
|
282
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValueOnce(toText('{"thread":{}}'));
|
|
283
|
+
const result = await handlers.get('gog_gmail_thread_get')!({ threadId: 't1', snippetsOnly: true });
|
|
284
|
+
expect(result.content[0].text).toBe('{"thread":{}}');
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it('returns the raw result when there is no thread object', async () => {
|
|
288
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValueOnce(toText('{}'));
|
|
289
|
+
const result = await handlers.get('gog_gmail_thread_get')!({ threadId: 't1', latestN: 1 });
|
|
290
|
+
expect(result.content[0].text).toBe('{}');
|
|
291
|
+
});
|
|
226
292
|
});
|
|
227
293
|
|
|
228
294
|
describe('gog_gmail_thread_modify', () => {
|
|
@@ -430,6 +496,53 @@ describe('gog_gmail_drafts_create', () => {
|
|
|
430
496
|
{ account: undefined },
|
|
431
497
|
);
|
|
432
498
|
});
|
|
499
|
+
|
|
500
|
+
it('skips recipient flags when omitRecipients is true, even if to/cc/bcc are supplied', async () => {
|
|
501
|
+
await handlers.get('gog_gmail_drafts_create')!({
|
|
502
|
+
to: 'a@b.com', cc: 'cc@x.com', bcc: 'bcc@x.com',
|
|
503
|
+
subject: 'Hi', body: 'Hello', omitRecipients: true,
|
|
504
|
+
});
|
|
505
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
506
|
+
['gmail', 'drafts', 'create', '--subject=Hi', '--body=Hello'],
|
|
507
|
+
{ account: undefined },
|
|
508
|
+
);
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it('returnFull re-fetches and returns the full stored draft', async () => {
|
|
512
|
+
vi.mocked(lib.runOrDiagnose)
|
|
513
|
+
.mockResolvedValueOnce(toText('{"draftId":"d9","message":{"id":"m9"}}'))
|
|
514
|
+
.mockResolvedValueOnce(toText('{"id":"d9","message":{"subject":"Hi","body":"Hello"}}'));
|
|
515
|
+
const result = await handlers.get('gog_gmail_drafts_create')!({
|
|
516
|
+
subject: 'Hi', body: 'Hello', returnFull: true,
|
|
517
|
+
});
|
|
518
|
+
expect(lib.runOrDiagnose).toHaveBeenNthCalledWith(1,
|
|
519
|
+
['gmail', 'drafts', 'create', '--subject=Hi', '--body=Hello'], { account: undefined });
|
|
520
|
+
expect(lib.runOrDiagnose).toHaveBeenNthCalledWith(2,
|
|
521
|
+
['gmail', 'drafts', 'get', 'd9'], { account: undefined });
|
|
522
|
+
expect(result.content[0].text).toContain('"subject":"Hi"');
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
it('returnFull does not push --return-full to the CLI', async () => {
|
|
526
|
+
vi.mocked(lib.runOrDiagnose)
|
|
527
|
+
.mockResolvedValueOnce(toText('{"draftId":"d9"}'))
|
|
528
|
+
.mockResolvedValueOnce(toText('{}'));
|
|
529
|
+
await handlers.get('gog_gmail_drafts_create')!({ subject: 'Hi', body: 'Hello', returnFull: true });
|
|
530
|
+
expect(vi.mocked(lib.runOrDiagnose).mock.calls[0]![0]).not.toContain('--return-full');
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
it('returnFull returns the write result when output is not parseable JSON', async () => {
|
|
534
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValueOnce(toText('not json'));
|
|
535
|
+
const result = await handlers.get('gog_gmail_drafts_create')!({ subject: 'Hi', body: 'Hello', returnFull: true });
|
|
536
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledTimes(1);
|
|
537
|
+
expect(result.content[0].text).toBe('not json');
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
it('returnFull returns the write result when no draftId is present', async () => {
|
|
541
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValueOnce(toText('{"message":{"id":"m9"}}'));
|
|
542
|
+
const result = await handlers.get('gog_gmail_drafts_create')!({ subject: 'Hi', body: 'Hello', returnFull: true });
|
|
543
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledTimes(1);
|
|
544
|
+
expect(result.content[0].text).toBe('{"message":{"id":"m9"}}');
|
|
545
|
+
});
|
|
433
546
|
});
|
|
434
547
|
|
|
435
548
|
describe('gog_gmail_drafts_update', () => {
|
|
@@ -457,6 +570,38 @@ describe('gog_gmail_drafts_update', () => {
|
|
|
457
570
|
{ account: undefined },
|
|
458
571
|
);
|
|
459
572
|
});
|
|
573
|
+
|
|
574
|
+
it('skips recipient flags when omitRecipients is true', async () => {
|
|
575
|
+
await handlers.get('gog_gmail_drafts_update')!({
|
|
576
|
+
draftId: 'd1', to: 'a@b.com', subject: 'S', body: 'B', omitRecipients: true,
|
|
577
|
+
});
|
|
578
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
579
|
+
['gmail', 'drafts', 'update', 'd1', '--subject=S', '--body=B'],
|
|
580
|
+
{ account: undefined },
|
|
581
|
+
);
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
it('returnFull re-fetches the draft by its known id', async () => {
|
|
585
|
+
vi.mocked(lib.runOrDiagnose)
|
|
586
|
+
.mockResolvedValueOnce(toText('{"draftId":"d1"}'))
|
|
587
|
+
.mockResolvedValueOnce(toText('{"id":"d1","message":{"subject":"S"}}'));
|
|
588
|
+
const result = await handlers.get('gog_gmail_drafts_update')!({
|
|
589
|
+
draftId: 'd1', subject: 'S', body: 'B', returnFull: true,
|
|
590
|
+
});
|
|
591
|
+
expect(lib.runOrDiagnose).toHaveBeenNthCalledWith(2,
|
|
592
|
+
['gmail', 'drafts', 'get', 'd1'], { account: undefined });
|
|
593
|
+
expect(result.content[0].text).toContain('"subject":"S"');
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
it('returnFull surfaces a failed update instead of re-fetching a stale draft', async () => {
|
|
597
|
+
vi.mocked(lib.runOrDiagnose).mockResolvedValueOnce(toText('Error: update failed'));
|
|
598
|
+
const result = await handlers.get('gog_gmail_drafts_update')!({
|
|
599
|
+
draftId: 'd1', subject: 'S', body: 'B', returnFull: true,
|
|
600
|
+
});
|
|
601
|
+
// write failed (non-JSON) → no re-fetch; the error is surfaced
|
|
602
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledTimes(1);
|
|
603
|
+
expect(result.content[0].text).toBe('Error: update failed');
|
|
604
|
+
});
|
|
460
605
|
});
|
|
461
606
|
|
|
462
607
|
describe('gog_gmail_drafts_delete', () => {
|
|
@@ -467,6 +612,22 @@ describe('gog_gmail_drafts_delete', () => {
|
|
|
467
612
|
{ account: undefined },
|
|
468
613
|
);
|
|
469
614
|
});
|
|
615
|
+
|
|
616
|
+
it('appends --force when force is true', async () => {
|
|
617
|
+
await handlers.get('gog_gmail_drafts_delete')!({ draftId: 'd1', force: true });
|
|
618
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
619
|
+
['gmail', 'drafts', 'delete', 'd1', '--force'],
|
|
620
|
+
{ account: undefined },
|
|
621
|
+
);
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
it('omits --force when force is false', async () => {
|
|
625
|
+
await handlers.get('gog_gmail_drafts_delete')!({ draftId: 'd1', force: false });
|
|
626
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
627
|
+
['gmail', 'drafts', 'delete', 'd1'],
|
|
628
|
+
{ account: undefined },
|
|
629
|
+
);
|
|
630
|
+
});
|
|
470
631
|
});
|
|
471
632
|
|
|
472
633
|
describe('gog_gmail_drafts_send', () => {
|
|
@@ -587,3 +748,291 @@ describe('gog_gmail_autoreply', () => {
|
|
|
587
748
|
);
|
|
588
749
|
});
|
|
589
750
|
});
|
|
751
|
+
|
|
752
|
+
describe('gog_gmail_messages_search', () => {
|
|
753
|
+
it('calls runOrDiagnose with just the query', async () => {
|
|
754
|
+
await handlers.get('gog_gmail_messages_search')!({ query: 'from:alice' });
|
|
755
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
756
|
+
['gmail', 'messages', 'search', 'from:alice'],
|
|
757
|
+
{ account: undefined },
|
|
758
|
+
);
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
it('passes all flags when provided', async () => {
|
|
762
|
+
await handlers.get('gog_gmail_messages_search')!({
|
|
763
|
+
query: 'is:unread',
|
|
764
|
+
max: 10,
|
|
765
|
+
page: 'tok',
|
|
766
|
+
all: true,
|
|
767
|
+
includeBody: true,
|
|
768
|
+
full: true,
|
|
769
|
+
bodyFormat: 'html',
|
|
770
|
+
account: 'me@x.com',
|
|
771
|
+
});
|
|
772
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
773
|
+
['gmail', 'messages', 'search', 'is:unread', '--max=10', '--page=tok', '--all', '--include-body', '--full', '--body-format=html'],
|
|
774
|
+
{ account: 'me@x.com' },
|
|
775
|
+
);
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
it('omits flags when false/absent', async () => {
|
|
779
|
+
await handlers.get('gog_gmail_messages_search')!({ query: 'x', all: false, includeBody: false, full: false });
|
|
780
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
781
|
+
['gmail', 'messages', 'search', 'x'],
|
|
782
|
+
{ account: undefined },
|
|
783
|
+
);
|
|
784
|
+
});
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
describe('gog_gmail_labels_style', () => {
|
|
788
|
+
it('calls runOrDiagnose with just the label', async () => {
|
|
789
|
+
await handlers.get('gog_gmail_labels_style')!({ labelIdOrName: 'Work' });
|
|
790
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
791
|
+
['gmail', 'labels', 'style', 'Work'],
|
|
792
|
+
{ account: undefined },
|
|
793
|
+
);
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
it('passes all style flags when provided', async () => {
|
|
797
|
+
await handlers.get('gog_gmail_labels_style')!({
|
|
798
|
+
labelIdOrName: 'Work',
|
|
799
|
+
backgroundColor: '#000000',
|
|
800
|
+
textColor: '#ffffff',
|
|
801
|
+
labelListVisibility: 'labelHide',
|
|
802
|
+
messageListVisibility: 'hide',
|
|
803
|
+
});
|
|
804
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
805
|
+
['gmail', 'labels', 'style', 'Work', '--background-color=#000000', '--text-color=#ffffff', '--label-list-visibility=labelHide', '--message-list-visibility=hide'],
|
|
806
|
+
{ account: undefined },
|
|
807
|
+
);
|
|
808
|
+
});
|
|
809
|
+
});
|
|
810
|
+
|
|
811
|
+
describe('gog_gmail_vacation_get', () => {
|
|
812
|
+
it('calls runOrDiagnose', async () => {
|
|
813
|
+
await handlers.get('gog_gmail_vacation_get')!({ account: 'me@x.com' });
|
|
814
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
815
|
+
['gmail', 'settings', 'vacation', 'get'],
|
|
816
|
+
{ account: 'me@x.com' },
|
|
817
|
+
);
|
|
818
|
+
});
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
describe('gog_gmail_vacation_update', () => {
|
|
822
|
+
it('calls runOrDiagnose with no flags', async () => {
|
|
823
|
+
await handlers.get('gog_gmail_vacation_update')!({});
|
|
824
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
825
|
+
['gmail', 'settings', 'vacation', 'update'],
|
|
826
|
+
{ account: undefined },
|
|
827
|
+
);
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
it('enables with subject/body/start/end and scoping', async () => {
|
|
831
|
+
await handlers.get('gog_gmail_vacation_update')!({
|
|
832
|
+
enable: true,
|
|
833
|
+
subject: 'Away',
|
|
834
|
+
body: '<p>OOO</p>',
|
|
835
|
+
start: '2024-12-20T00:00:00Z',
|
|
836
|
+
end: '2024-12-31T23:59:59Z',
|
|
837
|
+
contactsOnly: true,
|
|
838
|
+
domainOnly: true,
|
|
839
|
+
});
|
|
840
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
841
|
+
['gmail', 'settings', 'vacation', 'update', '--enable', '--subject=Away', '--body=<p>OOO</p>', '--start=2024-12-20T00:00:00Z', '--end=2024-12-31T23:59:59Z', '--contacts-only', '--domain-only'],
|
|
842
|
+
{ account: undefined },
|
|
843
|
+
);
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
it('disables the responder', async () => {
|
|
847
|
+
await handlers.get('gog_gmail_vacation_update')!({ disable: true, enable: false, contactsOnly: false, domainOnly: false });
|
|
848
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
849
|
+
['gmail', 'settings', 'vacation', 'update', '--disable'],
|
|
850
|
+
{ account: undefined },
|
|
851
|
+
);
|
|
852
|
+
});
|
|
853
|
+
});
|
|
854
|
+
|
|
855
|
+
describe('gog_gmail_filters_list', () => {
|
|
856
|
+
it('calls runOrDiagnose', async () => {
|
|
857
|
+
await handlers.get('gog_gmail_filters_list')!({});
|
|
858
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
859
|
+
['gmail', 'settings', 'filters', 'list'],
|
|
860
|
+
{ account: undefined },
|
|
861
|
+
);
|
|
862
|
+
});
|
|
863
|
+
});
|
|
864
|
+
|
|
865
|
+
describe('gog_gmail_filters_get', () => {
|
|
866
|
+
it('calls runOrDiagnose with the filter ID', async () => {
|
|
867
|
+
await handlers.get('gog_gmail_filters_get')!({ filterId: 'f1' });
|
|
868
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
869
|
+
['gmail', 'settings', 'filters', 'get', 'f1'],
|
|
870
|
+
{ account: undefined },
|
|
871
|
+
);
|
|
872
|
+
});
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
describe('gog_gmail_filters_create', () => {
|
|
876
|
+
it('calls runOrDiagnose with no flags', async () => {
|
|
877
|
+
await handlers.get('gog_gmail_filters_create')!({});
|
|
878
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
879
|
+
['gmail', 'settings', 'filters', 'create'],
|
|
880
|
+
{ account: undefined },
|
|
881
|
+
);
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
it('passes all criteria and actions when provided', async () => {
|
|
885
|
+
await handlers.get('gog_gmail_filters_create')!({
|
|
886
|
+
from: 'alice@x.com',
|
|
887
|
+
to: 'me@x.com',
|
|
888
|
+
subject: 'Report',
|
|
889
|
+
query: 'has:attachment',
|
|
890
|
+
hasAttachment: true,
|
|
891
|
+
addLabel: 'Reports',
|
|
892
|
+
removeLabel: 'INBOX',
|
|
893
|
+
archive: true,
|
|
894
|
+
markRead: true,
|
|
895
|
+
star: true,
|
|
896
|
+
important: true,
|
|
897
|
+
trash: true,
|
|
898
|
+
neverSpam: true,
|
|
899
|
+
forward: 'fwd@x.com',
|
|
900
|
+
});
|
|
901
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
902
|
+
['gmail', 'settings', 'filters', 'create', '--from=alice@x.com', '--to=me@x.com', '--subject=Report', '--query=has:attachment', '--has-attachment', '--add-label=Reports', '--remove-label=INBOX', '--archive', '--mark-read', '--star', '--important', '--trash', '--never-spam', '--forward=fwd@x.com'],
|
|
903
|
+
{ account: undefined },
|
|
904
|
+
);
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
it('omits boolean flags when false', async () => {
|
|
908
|
+
await handlers.get('gog_gmail_filters_create')!({
|
|
909
|
+
from: 'a@x.com',
|
|
910
|
+
hasAttachment: false,
|
|
911
|
+
archive: false,
|
|
912
|
+
markRead: false,
|
|
913
|
+
star: false,
|
|
914
|
+
important: false,
|
|
915
|
+
trash: false,
|
|
916
|
+
neverSpam: false,
|
|
917
|
+
});
|
|
918
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
919
|
+
['gmail', 'settings', 'filters', 'create', '--from=a@x.com'],
|
|
920
|
+
{ account: undefined },
|
|
921
|
+
);
|
|
922
|
+
});
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
describe('gog_gmail_filters_delete', () => {
|
|
926
|
+
it('calls runOrDiagnose with the filter ID', async () => {
|
|
927
|
+
await handlers.get('gog_gmail_filters_delete')!({ filterId: 'f1' });
|
|
928
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
929
|
+
['gmail', 'settings', 'filters', 'delete', 'f1'],
|
|
930
|
+
{ account: undefined },
|
|
931
|
+
);
|
|
932
|
+
});
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
describe('gog_gmail_sendas_list', () => {
|
|
936
|
+
it('calls runOrDiagnose', async () => {
|
|
937
|
+
await handlers.get('gog_gmail_sendas_list')!({});
|
|
938
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
939
|
+
['gmail', 'settings', 'sendas', 'list'],
|
|
940
|
+
{ account: undefined },
|
|
941
|
+
);
|
|
942
|
+
});
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
describe('gog_gmail_sendas_get', () => {
|
|
946
|
+
it('calls runOrDiagnose with the email', async () => {
|
|
947
|
+
await handlers.get('gog_gmail_sendas_get')!({ email: 'alias@x.com' });
|
|
948
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
949
|
+
['gmail', 'settings', 'sendas', 'get', 'alias@x.com'],
|
|
950
|
+
{ account: undefined },
|
|
951
|
+
);
|
|
952
|
+
});
|
|
953
|
+
});
|
|
954
|
+
|
|
955
|
+
describe('gog_gmail_sendas_create', () => {
|
|
956
|
+
it('calls runOrDiagnose with just the email', async () => {
|
|
957
|
+
await handlers.get('gog_gmail_sendas_create')!({ email: 'alias@x.com' });
|
|
958
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
959
|
+
['gmail', 'settings', 'sendas', 'create', 'alias@x.com'],
|
|
960
|
+
{ account: undefined },
|
|
961
|
+
);
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
it('passes all flags when provided', async () => {
|
|
965
|
+
await handlers.get('gog_gmail_sendas_create')!({
|
|
966
|
+
email: 'alias@x.com',
|
|
967
|
+
displayName: 'Alias',
|
|
968
|
+
replyTo: 'reply@x.com',
|
|
969
|
+
signature: '<p>sig</p>',
|
|
970
|
+
treatAsAlias: true,
|
|
971
|
+
});
|
|
972
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
973
|
+
['gmail', 'settings', 'sendas', 'create', 'alias@x.com', '--display-name=Alias', '--reply-to=reply@x.com', '--signature=<p>sig</p>', '--treat-as-alias'],
|
|
974
|
+
{ account: undefined },
|
|
975
|
+
);
|
|
976
|
+
});
|
|
977
|
+
|
|
978
|
+
it('omits treatAsAlias when false', async () => {
|
|
979
|
+
await handlers.get('gog_gmail_sendas_create')!({ email: 'alias@x.com', treatAsAlias: false });
|
|
980
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
981
|
+
['gmail', 'settings', 'sendas', 'create', 'alias@x.com'],
|
|
982
|
+
{ account: undefined },
|
|
983
|
+
);
|
|
984
|
+
});
|
|
985
|
+
});
|
|
986
|
+
|
|
987
|
+
describe('gog_gmail_sendas_update', () => {
|
|
988
|
+
it('calls runOrDiagnose with just the email', async () => {
|
|
989
|
+
await handlers.get('gog_gmail_sendas_update')!({ email: 'alias@x.com' });
|
|
990
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
991
|
+
['gmail', 'settings', 'sendas', 'update', 'alias@x.com'],
|
|
992
|
+
{ account: undefined },
|
|
993
|
+
);
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
it('passes all flags when provided', async () => {
|
|
997
|
+
await handlers.get('gog_gmail_sendas_update')!({
|
|
998
|
+
email: 'alias@x.com',
|
|
999
|
+
displayName: 'Alias',
|
|
1000
|
+
replyTo: 'reply@x.com',
|
|
1001
|
+
signature: '<p>sig</p>',
|
|
1002
|
+
treatAsAlias: true,
|
|
1003
|
+
makeDefault: true,
|
|
1004
|
+
});
|
|
1005
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
1006
|
+
['gmail', 'settings', 'sendas', 'update', 'alias@x.com', '--display-name=Alias', '--reply-to=reply@x.com', '--signature=<p>sig</p>', '--treat-as-alias', '--make-default'],
|
|
1007
|
+
{ account: undefined },
|
|
1008
|
+
);
|
|
1009
|
+
});
|
|
1010
|
+
|
|
1011
|
+
it('omits boolean flags when false', async () => {
|
|
1012
|
+
await handlers.get('gog_gmail_sendas_update')!({ email: 'alias@x.com', treatAsAlias: false, makeDefault: false });
|
|
1013
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
1014
|
+
['gmail', 'settings', 'sendas', 'update', 'alias@x.com'],
|
|
1015
|
+
{ account: undefined },
|
|
1016
|
+
);
|
|
1017
|
+
});
|
|
1018
|
+
});
|
|
1019
|
+
|
|
1020
|
+
describe('gog_gmail_sendas_delete', () => {
|
|
1021
|
+
it('calls runOrDiagnose with the email', async () => {
|
|
1022
|
+
await handlers.get('gog_gmail_sendas_delete')!({ email: 'alias@x.com' });
|
|
1023
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
1024
|
+
['gmail', 'settings', 'sendas', 'delete', 'alias@x.com'],
|
|
1025
|
+
{ account: undefined },
|
|
1026
|
+
);
|
|
1027
|
+
});
|
|
1028
|
+
});
|
|
1029
|
+
|
|
1030
|
+
describe('gog_gmail_sendas_verify', () => {
|
|
1031
|
+
it('calls runOrDiagnose with the email', async () => {
|
|
1032
|
+
await handlers.get('gog_gmail_sendas_verify')!({ email: 'alias@x.com' });
|
|
1033
|
+
expect(lib.runOrDiagnose).toHaveBeenCalledWith(
|
|
1034
|
+
['gmail', 'settings', 'sendas', 'verify', 'alias@x.com'],
|
|
1035
|
+
{ account: undefined },
|
|
1036
|
+
);
|
|
1037
|
+
});
|
|
1038
|
+
});
|