Skip to content

Commit 5c48fcf

Browse files
committed
test: confirm an array of accessorized options has templated variables replaced
1 parent 2d93133 commit 5c48fcf

1 file changed

Lines changed: 130 additions & 14 deletions

File tree

test/content.spec.js

Lines changed: 130 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,37 @@ describe("content", () => {
8888
mocks.core.getInput.withArgs("payload").returns(`
8989
channel: C0123456789
9090
reply_broadcast: false
91-
message: Served \${{ env.NUMBER }} from \${{ github.apiUrl }}
91+
message: Served \${{ env.NUMBER }} items
9292
blocks:
9393
- type: section
9494
text:
9595
type: mrkdwn
96-
text: "Served \${{ env.NUMBER }} on: \${{ env.DETAILS }}"
96+
text: "Served \${{ env.NUMBER }} items on: \${{ env.DETAILS }}"
9797
- type: divider
9898
- type: section
99+
block_id: selector
99100
text:
100101
type: mrkdwn
101-
text: "> From \${{ github.apiUrl }}"
102+
text: Send feedback
103+
accessory:
104+
action_id: response
105+
type: multi_static_select
106+
placeholder:
107+
type: plain_text
108+
text: Select URL
109+
options:
110+
- text:
111+
type: plain_text
112+
text: "\${{ github.apiUrl }}"
113+
value: api
114+
- text:
115+
type: plain_text
116+
text: "\${{ github.serverUrl }}"
117+
value: server
118+
- text:
119+
type: plain_text
120+
text: "\${{ github.graphqlUrl }}"
121+
value: graphql
102122
`);
103123
mocks.core.getBooleanInput.withArgs("payload-templated").returns(true);
104124
process.env.DETAILS = `
@@ -112,25 +132,57 @@ describe("content", () => {
112132
const expected = {
113133
channel: "C0123456789",
114134
reply_broadcast: false,
115-
message: "Served 12 from https://api.github.com",
135+
message: "Served 12 items",
116136
blocks: [
117137
{
118138
type: "section",
119139
text: {
120140
type: "mrkdwn",
121-
text: "Served 12 on: \n-fri\n-sat\n-sun",
141+
text: "Served 12 items on: \n-fri\n-sat\n-sun",
122142
},
123143
},
124144
{
125145
type: "divider",
126146
},
127147
{
128148
type: "section",
149+
block_id: "selector",
129150
text: {
130151
type: "mrkdwn",
131-
text: "> From https://api.github.com",
152+
text: "Send feedback"
132153
},
133-
},
154+
accessory: {
155+
action_id: "response",
156+
type: "multi_static_select",
157+
placeholder: {
158+
type: "plain_text",
159+
text: "Select URL"
160+
},
161+
options: [
162+
{
163+
text: {
164+
type: "plain_text",
165+
text: "https://api.github.com"
166+
},
167+
value: "api"
168+
},
169+
{
170+
text: {
171+
type: "plain_text",
172+
text: "https://github.com"
173+
},
174+
value: "server"
175+
},
176+
{
177+
text: {
178+
type: "plain_text",
179+
text: "https://api.github.com/graphql"
180+
},
181+
value: "graphql"
182+
}
183+
]
184+
}
185+
}
134186
],
135187
};
136188
assert.deepEqual(config.content.values, expected);
@@ -297,23 +349,55 @@ describe("content", () => {
297349
.returns(`{
298350
"channel": "C0123456789",
299351
"reply_broadcast": false,
300-
"message": "Served \${{ env.NUMBER }} from \${{ github.apiUrl }}",
352+
"message": "Served \${{ env.NUMBER }} items",
301353
"blocks": [
302354
{
303355
"type": "section",
304356
"text": {
305357
"type": "mrkdwn",
306-
"text": "Served \${{ env.NUMBER }} on: \${{ env.DETAILS }}"
358+
"text": "Served \${{ env.NUMBER }} items on: \${{ env.DETAILS }}"
307359
}
308360
},
309361
{
310362
"type": "divider"
311363
},
312364
{
313365
"type": "section",
366+
"block_id": "selector",
314367
"text": {
315368
"type": "mrkdwn",
316-
"text": "> From \${{ github.apiUrl }}"
369+
"text": "Send feedback"
370+
},
371+
"accessory": {
372+
"action_id": "response",
373+
"type": "multi_static_select",
374+
"placeholder": {
375+
"type": "plain_text",
376+
"text": "Select URL"
377+
},
378+
"options": [
379+
{
380+
"text": {
381+
"type": "plain_text",
382+
"text": "\${{ github.apiUrl }}"
383+
},
384+
"value": "api"
385+
},
386+
{
387+
"text": {
388+
"type": "plain_text",
389+
"text": "\${{ github.serverUrl }}"
390+
},
391+
"value": "server"
392+
},
393+
{
394+
"text": {
395+
"type": "plain_text",
396+
"text": "\${{ github.graphqlUrl }}"
397+
},
398+
"value": "graphql"
399+
}
400+
]
317401
}
318402
}
319403
]
@@ -330,25 +414,57 @@ describe("content", () => {
330414
const expected = {
331415
channel: "C0123456789",
332416
reply_broadcast: false,
333-
message: "Served 12 from https://api.github.com",
417+
message: "Served 12 items",
334418
blocks: [
335419
{
336420
type: "section",
337421
text: {
338422
type: "mrkdwn",
339-
text: "Served 12 on: \n-fri\n-sat\n-sun",
423+
text: "Served 12 items on: \n-fri\n-sat\n-sun",
340424
},
341425
},
342426
{
343427
type: "divider",
344428
},
345429
{
346430
type: "section",
431+
block_id: "selector",
347432
text: {
348433
type: "mrkdwn",
349-
text: "> From https://api.github.com",
434+
text: "Send feedback"
350435
},
351-
},
436+
accessory: {
437+
action_id: "response",
438+
type: "multi_static_select",
439+
placeholder: {
440+
type: "plain_text",
441+
text: "Select URL"
442+
},
443+
options: [
444+
{
445+
text: {
446+
type: "plain_text",
447+
text: "https://api.github.com"
448+
},
449+
value: "api"
450+
},
451+
{
452+
text: {
453+
type: "plain_text",
454+
text: "https://github.com"
455+
},
456+
value: "server"
457+
},
458+
{
459+
text: {
460+
type: "plain_text",
461+
text: "https://api.github.com/graphql"
462+
},
463+
value: "graphql"
464+
}
465+
]
466+
}
467+
}
352468
],
353469
};
354470
assert.deepEqual(config.content.values, expected);

0 commit comments

Comments
 (0)