Skip to content
Merged
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
4 changes: 3 additions & 1 deletion src/commands/cloudmanager/execution/get-step-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class GetExecutionStepDetails extends Command {

const buildStep = stepStates.find(stepState => stepState.action === 'build')
const codeQualityStep = stepStates.find(stepState => stepState.action === 'codeQuality')
codeQualityStep.startedAt = buildStep.finishedAt
if (buildStep.status === 'FINISHED') {
codeQualityStep.startedAt = buildStep.finishedAt
}

cli.table(stepStates, {
action: {
Expand Down
24 changes: 23 additions & 1 deletion test/commands/execution/get-step-details.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const { init, mockSdk } = require('@adobe/aio-lib-cloudmanager')
const { resetCurrentOrgId, setCurrentOrgId } = require('@adobe/aio-lib-ims')
const GetExecutionStepDetails = require('../../../src/commands/cloudmanager/execution/get-step-details')
const execution1010 = require('../../data/execution1010.json')
const execution1011 = require('../../data/execution1011.json')

beforeEach(() => {
resetCurrentOrgId()
Expand Down Expand Up @@ -55,7 +56,7 @@ test('get-execution-step-details - result', async () => {
setCurrentOrgId('good')
mockSdk.getExecution = jest.fn(() => execution1010)

expect.assertions(12)
expect.assertions(13)

const runResult = GetExecutionStepDetails.run(['5', '--programId', '5', '1002'])
await expect(runResult instanceof Promise).toBeTruthy()
Expand All @@ -67,9 +68,30 @@ test('get-execution-step-details - result', async () => {
await expect(mockSdk.getExecution).toHaveBeenCalledWith('5', '5', '1002')
await expect(cli.table.mock.calls).toHaveLength(1)

await expect(cli.table.mock.calls[0][0][2].startedAt).toBeTruthy()

await expect(cli.table.mock.calls[0][1].status.get({ status: 'RUNNING' })).toEqual('Running')
await expect(cli.table.mock.calls[0][1].action.get({ action: 'codeQuality' })).toEqual('Code Quality')
await expect(cli.table.mock.calls[0][1].action.get({ action: 'contentAudit' })).toEqual('Experience Audit')
await expect(cli.table.mock.calls[0][1].action.get({ action: 'deploy', environmentType: 'dev' })).toEqual('Dev Deploy')
await expect(cli.table.mock.calls[0][1].duration.get(execution1010._embedded.stepStates[1])).toEqual('7 minutes')
})

test('get-execution-step-details - cancelled build', async () => {
setCurrentOrgId('good')
mockSdk.getExecution = jest.fn(() => execution1011)

expect.assertions(8)

const runResult = GetExecutionStepDetails.run(['5', '--programId', '5', '1002'])
await expect(runResult instanceof Promise).toBeTruthy()

await expect(runResult).resolves.toBeTruthy()
await expect(init.mock.calls.length).toEqual(1)
await expect(init).toHaveBeenCalledWith('good', 'test-client-id', 'fake-token', 'https://cloudmanager.adobe.io')
await expect(mockSdk.getExecution.mock.calls.length).toEqual(1)
await expect(mockSdk.getExecution).toHaveBeenCalledWith('5', '5', '1002')
await expect(cli.table.mock.calls).toHaveLength(1)

await expect(cli.table.mock.calls[0][0][2].startedAt).toBeUndefined()
})
74 changes: 74 additions & 0 deletions test/data/execution1011.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"_embedded": {
"stepStates": [
{
"id": "2266443",
"stepId": "1001998",
"phaseId": "568199",
"executionId": "5",
"pipelineId": "4",
"programId": "5",
"action": "validate",
"startedAt": "2021-04-07T14:09:25.655+0000",
"finishedAt": "2021-04-07T14:09:32.273+0000",
"updatedAt": "2021-04-07T14:09:32.493+0000",
"status": "FINISHED"
},
{
"id": "2266444",
"stepId": "1001999",
"phaseId": "568200",
"executionId": "5",
"pipelineId": "4",
"programId": "5",
"action": "build",
"repository": "XXX",
"branch": "dev",
"startedAt": "2021-04-07T14:09:34.464+0000",
"finishedAt": "2021-04-07T14:10:42.448+0000",
"updatedAt": "2021-04-07T14:10:42.936+0000",
"status": "CANCELLED",
"statusString": "Pipeline execution cancelled"
},
{
"id": "2266445",
"stepId": "1002000",
"phaseId": "568200",
"executionId": "5",
"pipelineId": "4",
"programId": "5",
"action": "codeQuality",
"repository": "XXX",
"branch": "dev",
"updatedAt": "2021-04-07T14:09:18.875+0000",
"status": "NOT_STARTED"
},
{
"id": "2266446",
"stepId": "1002001",
"phaseId": "568201",
"executionId": "5",
"pipelineId": "4",
"programId": "5",
"action": "buildImage",
"updatedAt": "2021-04-07T14:09:18.875+0000",
"status": "NOT_STARTED",
"aemReleaseVersion": "2021.03.5026.1615324047792"
},
{
"id": "2266447",
"stepId": "1002052",
"phaseId": "568252",
"executionId": "5",
"pipelineId": "4",
"programId": "5",
"action": "deploy",
"environment": "YYY",
"environmentType": "dev",
"environmentId": "9",
"updatedAt": "2021-04-07T14:09:18.875+0000",
"status": "NOT_STARTED"
}
]
}
}