Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions __tests__/functions/deployment-confirmation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ beforeEach(() => {
data = {
deployment_confirmation_timeout: 60,
deploymentType: 'branch',
deploymentApiType: 'deploy',
environment: 'production',
environmentUrl: 'https://example.com',
log_url: 'https://github.com/corp/test/actions/runs/12345',
Expand Down Expand Up @@ -141,6 +142,56 @@ test('successfully prompts for deployment confirmation and gets confirmed by the
})
})

test('successfully prompts for destroy confirmation and gets confirmed by the original actor', async () => {
// Mock that the user adds a +1 reaction
octokit.rest.reactions.listForIssueComment.mockResolvedValueOnce({
data: [
{
user: {login: 'monalisa'},
content: '+1'
}
]
})

data.deploymentType = 'destroy'
data.deploymentApiType = 'destroy'

const result = await deploymentConfirmation(context, octokit, data)

expect(result).toBe(true)
expect(octokit.rest.issues.createComment).toHaveBeenCalledWith({
body: expect.stringContaining('Deployment Type: `destroy`'),
issue_number: 1,
owner: 'corp',
repo: 'test',
headers: API_HEADERS
})
expect(core.debug).toHaveBeenCalledWith(
'deployment confirmation comment id: 124'
)
expect(core.info).toHaveBeenCalledWith(
`🕒 waiting ${COLORS.highlight}60${COLORS.reset} seconds for deployment confirmation`
)
expect(core.info).toHaveBeenCalledWith(
`✅ deployment confirmed by ${COLORS.highlight}monalisa${COLORS.reset} - sha: ${COLORS.highlight}abc123${COLORS.reset}`
)

expect(octokit.rest.reactions.listForIssueComment).toHaveBeenCalledWith({
comment_id: 124,
owner: 'corp',
repo: 'test',
headers: API_HEADERS
})

expect(octokit.rest.issues.updateComment).toHaveBeenCalledWith({
body: expect.stringContaining('✅ Deployment confirmed by __monalisa__'),
comment_id: 124,
owner: 'corp',
repo: 'test',
headers: API_HEADERS
})
})

test('successfully prompts for deployment confirmation and gets confirmed by the original actor with some null data params in the issue comment', async () => {
data.params = null
data.parsed_params = null
Expand Down
Loading
Loading