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
5 changes: 5 additions & 0 deletions .changeset/yummy-dolls-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": minor
---

Show latest instance by default on `workflows instances describe` command
41 changes: 40 additions & 1 deletion packages/wrangler/src/__tests__/workflows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe("wrangler workflows", () => {

COMMANDS
wrangler workflows instances list <name> Instance related commands (list, describe, terminate, pause, resume)
wrangler workflows instances describe <name> <id> Describe a workflow instance - see its logs, retries and errors
wrangler workflows instances describe <name> [id] Describe a workflow instance - see its logs, retries and errors
wrangler workflows instances terminate <name> <id> Terminate a workflow instance
wrangler workflows instances pause <name> <id> Pause a workflow instance
wrangler workflows instances resume <name> <id> Resume a workflow instance
Expand Down Expand Up @@ -380,6 +380,18 @@ describe("wrangler workflows", () => {
});
},
{ once: true }
),
http.get(
`*/accounts/:accountId/workflows/some-workflow/instances`,
async () => {
return HttpResponse.json({
success: true,
errors: [],
messages: [],
result: [mockResponse],
});
},
{ once: true }
)
);
};
Expand Down Expand Up @@ -410,6 +422,33 @@ describe("wrangler workflows", () => {
└─┴─┴─┴─┴─┘"
`);
});

it("should describe the latest instance if none is given", async () => {
writeWranglerConfig();
await mockDescribeInstances();

await runWrangler(`workflows instances describe some-workflow`);
expect(std.out).toMatchInlineSnapshot(`
" Name: event
Type: 👀 Waiting for event
Start: [mock-start-date]
End: [mock-end-date]
Duration: 4 years
Output: {}
Name: string
Type: 🎯 Step
Start: [mock-start-date]
End: [mock-end-date]
Duration: 4 years
Success: ✅ Yes
Output: {}
┌─┬─┬─┬─┬─┐
│ Start │ End │ Duration │ State │ Error │
├─┼─┼─┼─┼─┤
│ [mock-start-date] │ [mock-end-date] │ 4 years │ ✅ Success │ string: string │
└─┴─┴─┴─┴─┘"
`);
});
});

describe("instances pause", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export const workflowsInstancesDescribeCommand = createCommand({
describe:
"ID of the instance - instead of an UUID you can type 'latest' to get the latest instance and describe it",
type: "string",
demandOption: true,
demandOption: false,
default: "latest",
},
"step-output": {
describe:
Expand Down Expand Up @@ -78,6 +79,7 @@ export const workflowsInstancesDescribeCommand = createCommand({
return;
}

logRaw("Describing latest instance:");
id = instances[0].id;
}

Expand Down
Loading