Skip to content

Commit c0e8847

Browse files
committed
wip (going to abandon)
1 parent c9fcc36 commit c0e8847

File tree

8 files changed

+287
-2
lines changed

8 files changed

+287
-2
lines changed

__tests__/functions/deployment-confirmation.test.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ beforeEach(() => {
7575
data = {
7676
deployment_confirmation_timeout: 60,
7777
deploymentType: 'branch',
78+
deploymentApiType: 'deploy',
7879
environment: 'production',
7980
environmentUrl: 'https://example.com',
8081
log_url: 'https://github.com/corp/test/actions/runs/12345',
@@ -141,6 +142,56 @@ test('successfully prompts for deployment confirmation and gets confirmed by the
141142
})
142143
})
143144

145+
test('successfully prompts for destroy confirmation and gets confirmed by the original actor', async () => {
146+
// Mock that the user adds a +1 reaction
147+
octokit.rest.reactions.listForIssueComment.mockResolvedValueOnce({
148+
data: [
149+
{
150+
user: {login: 'monalisa'},
151+
content: '+1'
152+
}
153+
]
154+
})
155+
156+
data.deploymentType = 'destroy'
157+
data.deploymentApiType = 'destroy'
158+
159+
const result = await deploymentConfirmation(context, octokit, data)
160+
161+
expect(result).toBe(true)
162+
expect(octokit.rest.issues.createComment).toHaveBeenCalledWith({
163+
body: expect.stringContaining('Deployment Type: `destroy`'),
164+
issue_number: 1,
165+
owner: 'corp',
166+
repo: 'test',
167+
headers: API_HEADERS
168+
})
169+
expect(core.debug).toHaveBeenCalledWith(
170+
'deployment confirmation comment id: 124'
171+
)
172+
expect(core.info).toHaveBeenCalledWith(
173+
`🕒 waiting ${COLORS.highlight}60${COLORS.reset} seconds for deployment confirmation`
174+
)
175+
expect(core.info).toHaveBeenCalledWith(
176+
`✅ deployment confirmed by ${COLORS.highlight}monalisa${COLORS.reset} - sha: ${COLORS.highlight}abc123${COLORS.reset}`
177+
)
178+
179+
expect(octokit.rest.reactions.listForIssueComment).toHaveBeenCalledWith({
180+
comment_id: 124,
181+
owner: 'corp',
182+
repo: 'test',
183+
headers: API_HEADERS
184+
})
185+
186+
expect(octokit.rest.issues.updateComment).toHaveBeenCalledWith({
187+
body: expect.stringContaining('✅ Deployment confirmed by __monalisa__'),
188+
comment_id: 124,
189+
owner: 'corp',
190+
repo: 'test',
191+
headers: API_HEADERS
192+
})
193+
})
194+
144195
test('successfully prompts for deployment confirmation and gets confirmed by the original actor with some null data params in the issue comment', async () => {
145196
data.params = null
146197
data.parsed_params = null

0 commit comments

Comments
 (0)