@@ -332,98 +332,6 @@ describe('api', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getTask', () => {
|
||||
it('should return the task enriched with timestamps', async () => {
|
||||
const taskId = 'e4e4cb25-e743-4b79-8572-87e9d35aa998';
|
||||
server.use(
|
||||
rest.get(`${mockBaseUrl}/v2/tasks/:taskId`, (_req, res, ctx) => {
|
||||
return res(
|
||||
ctx.json({
|
||||
createdAt: '2023-10-16T08:21:32.038Z',
|
||||
id: taskId,
|
||||
lastHeartbeatAt: '2023-10-16T08:21:54.304Z',
|
||||
spec: {
|
||||
apiVersion: 'scaffolder.backstage.io/v1beta3',
|
||||
steps: [
|
||||
{
|
||||
action: 'fetch:template',
|
||||
id: 'fetch',
|
||||
},
|
||||
{
|
||||
action: 'debug:wait',
|
||||
id: 'mock-step-1',
|
||||
},
|
||||
{
|
||||
action: 'debug:wait',
|
||||
id: 'mock-step-2',
|
||||
},
|
||||
],
|
||||
templateInfo: {
|
||||
entityRef: 'template:default/docs-long-running-template',
|
||||
},
|
||||
},
|
||||
} as SerializedTask),
|
||||
);
|
||||
}),
|
||||
rest.get(`${mockBaseUrl}/v2/tasks/:taskId/events`, (_req, res, ctx) => {
|
||||
return res(
|
||||
ctx.json([
|
||||
{
|
||||
createdAt: '2023-10-16T08:21:32.062Z',
|
||||
body: {},
|
||||
id: 109,
|
||||
taskId,
|
||||
type: 'log',
|
||||
},
|
||||
{
|
||||
body: { stepId: 'fetch' },
|
||||
createdAt: '2023-10-16T08:21:32.062Z',
|
||||
id: 110,
|
||||
taskId,
|
||||
type: 'log',
|
||||
},
|
||||
{
|
||||
body: { stepId: 'fetch' },
|
||||
createdAt: '2023-10-16T08:21:33.062Z',
|
||||
id: 111,
|
||||
taskId,
|
||||
type: 'log',
|
||||
},
|
||||
{
|
||||
body: { stepId: 'fetch' },
|
||||
createdAt: '2023-10-16T08:21:34.062Z',
|
||||
id: 112,
|
||||
taskId,
|
||||
type: 'log',
|
||||
},
|
||||
{
|
||||
body: { stepId: 'mock-step-1' },
|
||||
createdAt: '2023-10-16T08:21:37.062Z',
|
||||
id: 120,
|
||||
taskId,
|
||||
type: 'log',
|
||||
},
|
||||
] as SerializedTaskEvent[]),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
const task = await apiClient.getTask(taskId);
|
||||
|
||||
const getStep = (stepId: string) =>
|
||||
task.spec.steps.find(
|
||||
step => step.id === stepId,
|
||||
) as unknown as ScaffolderStep;
|
||||
|
||||
expect(getStep('fetch').startedAt).toBe('2023-10-16T08:21:32.062Z');
|
||||
expect(getStep('fetch').endedAt).toBe('2023-10-16T08:21:34.062Z');
|
||||
expect(getStep('mock-step-1').startedAt).toBe('2023-10-16T08:21:37.062Z');
|
||||
expect(getStep('mock-step-1').endedAt).toBe('2023-10-16T08:21:37.062Z');
|
||||
expect(getStep('mock-step-2').startedAt).toBeUndefined();
|
||||
expect(getStep('mock-step-2').endedAt).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('listTasks', () => {
|
||||
it('should list all tasks', async () => {
|
||||
server.use(
|
||||
|
||||
Reference in New Issue
Block a user