Skip to content

Commit 27478ff

Browse files
committed
test: add plan and task card tests to chat.postMessage
1 parent e2bcf05 commit 27478ff

1 file changed

Lines changed: 141 additions & 3 deletions

File tree

packages/web-api/test/types/methods/chat.test-d.ts

Lines changed: 141 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ expectAssignable<Parameters<typeof web.chat.appendStream>>([
4242
type: 'markdown_text',
4343
text: 'Hello world',
4444
},
45+
{
46+
type: 'plan_update',
47+
title: 'Hello world',
48+
},
4549
{
4650
type: 'task_update',
4751
id: 'task-1',
@@ -495,6 +499,131 @@ function wideBooleanTest(b: boolean) {
495499
wideBooleanTest(true);
496500
wideBooleanTest(false);
497501

502+
// TaskCardBlock with all properties
503+
expectAssignable<Parameters<typeof web.chat.postMessage>>([
504+
{
505+
channel: 'C1234',
506+
text: 'fallback',
507+
blocks: [
508+
{
509+
type: 'task_card',
510+
task_id: '000',
511+
title: 'Living life well...',
512+
status: 'error',
513+
details: {
514+
type: 'rich_text',
515+
elements: [
516+
{
517+
type: 'rich_text_section',
518+
elements: [
519+
{
520+
type: 'text',
521+
text: 'Dreamt of touching grass',
522+
},
523+
],
524+
},
525+
],
526+
},
527+
sources: [
528+
{
529+
type: 'url',
530+
text: 'An online encyclopedia',
531+
url: 'https://wikipedia.org',
532+
},
533+
],
534+
output: {
535+
type: 'rich_text',
536+
elements: [
537+
{
538+
type: 'rich_text_section',
539+
elements: [
540+
{
541+
type: 'text',
542+
text: 'Good things once happened',
543+
},
544+
],
545+
},
546+
],
547+
},
548+
},
549+
],
550+
},
551+
]);
552+
553+
// TaskCardBlock with minimal required properties
554+
expectAssignable<Parameters<typeof web.chat.postMessage>>([
555+
{
556+
channel: 'C1234',
557+
text: 'fallback',
558+
blocks: [
559+
{
560+
type: 'task_card',
561+
task_id: 'task-123',
562+
title: 'Simple task',
563+
status: 'pending',
564+
},
565+
],
566+
},
567+
]);
568+
569+
// PlanUpdateBlock with nested TaskCardBlocks
570+
expectAssignable<Parameters<typeof web.chat.postMessage>>([
571+
{
572+
channel: 'C1234',
573+
text: 'fallback',
574+
blocks: [
575+
{
576+
type: 'plan',
577+
plan_id: 'plan-001',
578+
title: 'My execution plan',
579+
tasks: [
580+
{
581+
type: 'task_card',
582+
task_id: 'task-1',
583+
title: 'First task',
584+
status: 'complete',
585+
},
586+
{
587+
type: 'task_card',
588+
task_id: 'task-2',
589+
title: 'Second task',
590+
status: 'in_progress',
591+
details: {
592+
type: 'rich_text',
593+
elements: [
594+
{
595+
type: 'rich_text_section',
596+
elements: [
597+
{
598+
type: 'text',
599+
text: 'Working on this...',
600+
},
601+
],
602+
},
603+
],
604+
},
605+
},
606+
],
607+
},
608+
],
609+
},
610+
]);
611+
612+
// PlanUpdateBlock with minimal required properties
613+
expectAssignable<Parameters<typeof web.chat.postMessage>>([
614+
{
615+
channel: 'C1234',
616+
text: 'fallback',
617+
blocks: [
618+
{
619+
type: 'plan',
620+
plan_id: 'plan-minimal',
621+
title: 'Empty plan',
622+
},
623+
],
624+
},
625+
]);
626+
498627
// chat.scheduleMessage
499628
// -- sad path
500629
expectError(web.chat.scheduleMessage()); // lacking argument
@@ -655,12 +784,15 @@ expectAssignable<Parameters<typeof web.chat.startStream>>([
655784
{
656785
channel: 'C1234',
657786
thread_ts: '1234.56',
658-
markdown_text: 'hello',
659787
chunks: [
660788
{
661789
type: 'markdown_text',
662790
text: 'Hello world',
663791
},
792+
{
793+
type: 'plan_update',
794+
title: 'Hello world',
795+
},
664796
{
665797
type: 'task_update',
666798
id: 'task-1',
@@ -675,12 +807,15 @@ expectAssignable<Parameters<typeof web.chat.startStream>>([
675807
{
676808
channel: 'C1234',
677809
thread_ts: '1234.56',
678-
markdown_text: 'hello',
679810
chunks: [
680811
{
681812
type: 'markdown_text',
682813
text: 'Hello world',
683814
},
815+
{
816+
type: 'plan_update',
817+
title: 'Hello world',
818+
},
684819
{
685820
type: 'task_update',
686821
id: 'task-1',
@@ -727,12 +862,15 @@ expectAssignable<Parameters<typeof web.chat.stopStream>>([
727862
{
728863
channel: 'C1234',
729864
ts: '1234.56',
730-
markdown_text: 'hello',
731865
chunks: [
732866
{
733867
type: 'markdown_text',
734868
text: 'Hello world',
735869
},
870+
{
871+
type: 'plan_update',
872+
title: 'Hello world',
873+
},
736874
{
737875
type: 'task_update',
738876
id: 'task-1',

0 commit comments

Comments
 (0)