@shipfox/client-workflows 4.0.0 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +68 -0
- package/dist/components/workflow-run-list/types.d.ts +12 -0
- package/dist/components/workflow-run-list/types.d.ts.map +1 -1
- package/dist/components/workflow-run-list/types.js.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-list-view.d.ts +1 -1
- package/dist/components/workflow-run-list/workflow-run-list-view.d.ts.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-list-view.js +32 -11
- package/dist/components/workflow-run-list/workflow-run-list-view.js.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-list.d.ts +1 -1
- package/dist/components/workflow-run-list/workflow-run-list.d.ts.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-list.js +7 -2
- package/dist/components/workflow-run-list/workflow-run-list.js.map +1 -1
- package/dist/components/workflow-run-summary/workflow-run-summary.d.ts +2 -3
- package/dist/components/workflow-run-summary/workflow-run-summary.d.ts.map +1 -1
- package/dist/components/workflow-run-summary/workflow-run-summary.js.map +1 -1
- package/dist/components/workflow-run-view/job-card.d.ts.map +1 -1
- package/dist/components/workflow-run-view/job-card.js +9 -8
- package/dist/components/workflow-run-view/job-card.js.map +1 -1
- package/dist/components/workflow-run-view/workflow-run-view.js.map +1 -1
- package/dist/core/entities/job-execution.d.ts +11 -6
- package/dist/core/entities/job-execution.d.ts.map +1 -1
- package/dist/core/entities/job-execution.js +0 -19
- package/dist/core/entities/job-execution.js.map +1 -1
- package/dist/core/entities/job.d.ts +32 -10
- package/dist/core/entities/job.d.ts.map +1 -1
- package/dist/core/entities/job.js +0 -22
- package/dist/core/entities/job.js.map +1 -1
- package/dist/core/entities/step-attempt.d.ts +28 -3
- package/dist/core/entities/step-attempt.d.ts.map +1 -1
- package/dist/core/entities/step-attempt.js +0 -17
- package/dist/core/entities/step-attempt.js.map +1 -1
- package/dist/core/entities/step.d.ts +6 -6
- package/dist/core/entities/step.d.ts.map +1 -1
- package/dist/core/entities/step.js +19 -49
- package/dist/core/entities/step.js.map +1 -1
- package/dist/core/entities/workflow-run-attempt.d.ts +0 -2
- package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -1
- package/dist/core/entities/workflow-run-attempt.js +0 -12
- package/dist/core/entities/workflow-run-attempt.js.map +1 -1
- package/dist/core/entities/workflow-run.d.ts +6 -7
- package/dist/core/entities/workflow-run.d.ts.map +1 -1
- package/dist/core/entities/workflow-run.js +1 -67
- package/dist/core/entities/workflow-run.js.map +1 -1
- package/dist/core/workflow-run.d.ts +9 -9
- package/dist/core/workflow-run.d.ts.map +1 -1
- package/dist/core/workflow-run.js +6 -6
- package/dist/core/workflow-run.js.map +1 -1
- package/dist/feature.d.ts +23 -0
- package/dist/feature.d.ts.map +1 -1
- package/dist/feature.js +22 -9
- package/dist/feature.js.map +1 -1
- package/dist/hooks/api/workflow-run-mapper.d.ts +12 -0
- package/dist/hooks/api/workflow-run-mapper.d.ts.map +1 -0
- package/dist/hooks/api/workflow-run-mapper.js +207 -0
- package/dist/hooks/api/workflow-run-mapper.js.map +1 -0
- package/dist/hooks/api/workflow-runs.d.ts +25 -55
- package/dist/hooks/api/workflow-runs.d.ts.map +1 -1
- package/dist/hooks/api/workflow-runs.js +95 -51
- package/dist/hooks/api/workflow-runs.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/pages/project-workflows-page.d.ts +4 -0
- package/dist/pages/project-workflows-page.d.ts.map +1 -0
- package/dist/pages/project-workflows-page.js +479 -0
- package/dist/pages/project-workflows-page.js.map +1 -0
- package/dist/pages/workflow-run-page.d.ts +3 -1
- package/dist/pages/workflow-run-page.d.ts.map +1 -1
- package/dist/pages/workflow-run-page.js +21 -14
- package/dist/pages/workflow-run-page.js.map +1 -1
- package/dist/routes/inputs.d.ts +22 -0
- package/dist/routes/inputs.d.ts.map +1 -0
- package/dist/routes/inputs.js +76 -0
- package/dist/routes/inputs.js.map +1 -0
- package/dist/routes/run-detail.d.ts +2 -0
- package/dist/routes/run-detail.d.ts.map +1 -1
- package/dist/routes/run-detail.js +6 -6
- package/dist/routes/run-detail.js.map +1 -1
- package/dist/routes/runs.d.ts +2 -0
- package/dist/routes/runs.d.ts.map +1 -1
- package/dist/routes/runs.js +6 -6
- package/dist/routes/runs.js.map +1 -1
- package/dist/routes/workflows.d.ts +5 -0
- package/dist/routes/workflows.d.ts.map +1 -0
- package/dist/routes/workflows.js +14 -0
- package/dist/routes/workflows.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +13 -12
- package/src/components/workflow-run-list/types.ts +6 -0
- package/src/components/workflow-run-list/workflow-run-list-view.tsx +27 -11
- package/src/components/workflow-run-list/workflow-run-list.tsx +6 -0
- package/src/components/workflow-run-summary/workflow-run-attempt-switcher.test.tsx +5 -6
- package/src/components/workflow-run-summary/workflow-run-summary.tsx +3 -3
- package/src/components/workflow-run-view/job-card.tsx +20 -11
- package/src/components/workflow-run-view/workflow-run-view.test.tsx +3 -3
- package/src/components/workflow-run-view/workflow-run-view.tsx +2 -2
- package/src/core/entities/job-execution.ts +12 -28
- package/src/core/entities/job.ts +44 -45
- package/src/core/entities/step-attempt.ts +9 -20
- package/src/core/entities/step.ts +38 -66
- package/src/core/entities/workflow-run-attempt.ts +0 -14
- package/src/core/entities/workflow-run.ts +8 -86
- package/src/core/workflow-run.test.ts +13 -11
- package/src/core/workflow-run.ts +8 -13
- package/src/feature.ts +24 -10
- package/src/hooks/api/workflow-run-mapper.ts +246 -0
- package/src/hooks/api/workflow-runs.test.tsx +57 -59
- package/src/hooks/api/workflow-runs.ts +187 -88
- package/src/index.ts +5 -0
- package/src/page-harness-budget.test.ts +1 -0
- package/src/pages/project-workflows-page.test.tsx +247 -0
- package/src/pages/project-workflows-page.tsx +448 -0
- package/src/pages/workflow-run-page.test.tsx +4 -2
- package/src/pages/workflow-run-page.tsx +22 -17
- package/src/routes/inputs.test.ts +22 -0
- package/src/routes/inputs.ts +58 -0
- package/src/routes/run-detail.tsx +12 -8
- package/src/routes/runs.tsx +11 -4
- package/src/routes/workflows.tsx +10 -0
- package/test/fixtures/workflow-run.ts +9 -7
- package/test/pages.tsx +48 -6
- package/tsconfig.build.tsbuildinfo +1 -1
- package/vercel.json +5 -0
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type {
|
|
|
5
5
|
JobExecutionStatus,
|
|
6
6
|
JobExecutionTime,
|
|
7
7
|
JobStatus,
|
|
8
|
+
ManualWorkflowLaunch,
|
|
8
9
|
Step,
|
|
9
10
|
StepAttempt,
|
|
10
11
|
StepAttemptDisplayDuration,
|
|
@@ -40,6 +41,10 @@ export {
|
|
|
40
41
|
useWorkflowRunQuery,
|
|
41
42
|
useWorkflowRunsInfiniteQuery,
|
|
42
43
|
type WorkflowRunFilters,
|
|
44
|
+
workflowRunAttemptsQueryOptions,
|
|
45
|
+
workflowRunQueryOptions,
|
|
46
|
+
workflowRunsInfiniteQueryOptions,
|
|
43
47
|
workflowRunsQueryKeys,
|
|
44
48
|
} from './hooks/api/workflow-runs.js';
|
|
49
|
+
export {ProjectWorkflowsPage} from './pages/project-workflows-page.js';
|
|
45
50
|
export {WorkflowRunPage} from './pages/workflow-run-page.js';
|
|
@@ -7,6 +7,7 @@ import {fileURLToPath} from 'node:url';
|
|
|
7
7
|
const PAGE_HARNESS_ALLOWLIST = [
|
|
8
8
|
'src/components/workflow-run-summary/workflow-run-attempt-switcher.test.tsx',
|
|
9
9
|
'src/components/workflow-run-view/workflow-run-view.test.tsx',
|
|
10
|
+
'src/pages/project-workflows-page.test.tsx',
|
|
10
11
|
'src/pages/workflow-run-page.test.tsx',
|
|
11
12
|
];
|
|
12
13
|
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import {configureApiClient} from '@shipfox/client-api';
|
|
2
|
+
import {fireEvent, screen, waitFor} from '@testing-library/react';
|
|
3
|
+
import {jsonResponse, PROJECT_TEST_WID, renderProjectPage} from '#test/pages.js';
|
|
4
|
+
import {ProjectWorkflowsPage} from './project-workflows-page.js';
|
|
5
|
+
|
|
6
|
+
const PROJECT_ID = '44444444-4444-4444-8444-444444444444';
|
|
7
|
+
const CONNECTION_ID = '33333333-3333-4333-8333-333333333333';
|
|
8
|
+
|
|
9
|
+
describe('ProjectWorkflowsPage', () => {
|
|
10
|
+
test('renders workflow definitions and the source strip', async () => {
|
|
11
|
+
configureApiClient({fetchImpl: createProjectDetailFetch()});
|
|
12
|
+
|
|
13
|
+
renderWorkflowsPage();
|
|
14
|
+
|
|
15
|
+
expect(await screen.findByRole('heading', {name: 'Workflows'})).toBeInTheDocument();
|
|
16
|
+
expect(screen.getAllByText('Deploy production')[0]).toBeInTheDocument();
|
|
17
|
+
expect(screen.getAllByText('.shipfox/workflows/deploy.yml')[0]).toBeInTheDocument();
|
|
18
|
+
expect(screen.getByRole('region', {name: 'Project source'})).toBeInTheDocument();
|
|
19
|
+
// Source strip resolves connection display_name from the integrations
|
|
20
|
+
// workspace cache; external_repository_id renders as a Code chip.
|
|
21
|
+
expect(await screen.findByText('Acme GitHub')).toBeInTheDocument();
|
|
22
|
+
expect(screen.getAllByText('platform')[0]).toBeInTheDocument();
|
|
23
|
+
expect(screen.getAllByText('succeeded')[0]).toBeInTheDocument();
|
|
24
|
+
expect(screen.queryByRole('heading', {name: 'Source identity'})).not.toBeInTheDocument();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('shows definitions error while keeping the source strip visible', async () => {
|
|
28
|
+
configureApiClient({
|
|
29
|
+
fetchImpl: createProjectDetailFetch({
|
|
30
|
+
definitions: jsonResponse({code: 'server-error'}, {status: 500}),
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
renderWorkflowsPage();
|
|
35
|
+
|
|
36
|
+
expect(await screen.findByText("Couldn't load workflows")).toBeInTheDocument();
|
|
37
|
+
// SyncBadge in the strip falls back to Unavailable when sync is undefined
|
|
38
|
+
// (definitions errored before providing one).
|
|
39
|
+
expect(screen.getByText('Unavailable')).toBeInTheDocument();
|
|
40
|
+
expect(screen.getByRole('region', {name: 'Project source'})).toBeInTheDocument();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('shows failed sync empty state', async () => {
|
|
44
|
+
configureApiClient({
|
|
45
|
+
fetchImpl: createProjectDetailFetch({
|
|
46
|
+
definitions: jsonResponse(
|
|
47
|
+
definitionsDto({
|
|
48
|
+
definitions: [],
|
|
49
|
+
sync: {
|
|
50
|
+
ref: 'main',
|
|
51
|
+
status: 'failed',
|
|
52
|
+
last_sync_at: '2026-05-07T01:00:00.000Z',
|
|
53
|
+
started_at: '2026-05-07T01:00:00.000Z',
|
|
54
|
+
finished_at: null,
|
|
55
|
+
last_error_code: 'no-workflow-files',
|
|
56
|
+
last_error_message: 'No workflow files found',
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
),
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
renderWorkflowsPage();
|
|
64
|
+
|
|
65
|
+
expect(
|
|
66
|
+
await screen.findByText('No workflow files found under .shipfox/workflows/.'),
|
|
67
|
+
).toBeInTheDocument();
|
|
68
|
+
expect(screen.getByText('Workflow sync failed')).toBeInTheDocument();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('opens and closes the definition drawer by clicking the row', async () => {
|
|
72
|
+
configureApiClient({fetchImpl: createProjectDetailFetch()});
|
|
73
|
+
|
|
74
|
+
renderWorkflowsPage();
|
|
75
|
+
|
|
76
|
+
const workflowName = (await screen.findAllByText('Deploy production'))[0];
|
|
77
|
+
if (!workflowName) throw new Error('Workflow row was not rendered');
|
|
78
|
+
fireEvent.click(workflowName);
|
|
79
|
+
|
|
80
|
+
expect(await screen.findByText('Normalized definition')).toBeInTheDocument();
|
|
81
|
+
expect(screen.getByText((content) => content.includes('"deploy"'))).toBeInTheDocument();
|
|
82
|
+
|
|
83
|
+
fireEvent.keyDown(document, {key: 'Escape'});
|
|
84
|
+
|
|
85
|
+
await waitFor(() => {
|
|
86
|
+
expect(screen.queryByText('Normalized definition')).not.toBeInTheDocument();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('queues a run from a workflow definition', async () => {
|
|
91
|
+
configureApiClient({fetchImpl: createProjectDetailFetch()});
|
|
92
|
+
|
|
93
|
+
renderWorkflowsPage();
|
|
94
|
+
|
|
95
|
+
// Run button lives in the row's hover-reveal slot; getAllByRole still
|
|
96
|
+
// sees it (opacity-0, not display:none).
|
|
97
|
+
const [runButton] = await screen.findAllByRole('button', {name: 'Run'});
|
|
98
|
+
if (!runButton) throw new Error('Run button was not rendered');
|
|
99
|
+
|
|
100
|
+
fireEvent.click(runButton);
|
|
101
|
+
|
|
102
|
+
expect(await screen.findByText('Run queued')).toBeInTheDocument();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('renders not found state', async () => {
|
|
106
|
+
configureApiClient({
|
|
107
|
+
fetchImpl: vi.fn((input) => {
|
|
108
|
+
const url = new URL(requestInputUrl(input));
|
|
109
|
+
if (url.pathname === `/projects/${PROJECT_ID}`) {
|
|
110
|
+
return Promise.resolve(jsonResponse({code: 'not-found'}, {status: 404}));
|
|
111
|
+
}
|
|
112
|
+
if (url.pathname === '/integration-connections') {
|
|
113
|
+
return Promise.resolve(jsonResponse(connectionsDto()));
|
|
114
|
+
}
|
|
115
|
+
return Promise.resolve(jsonResponse(definitionsDto()));
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
renderWorkflowsPage();
|
|
120
|
+
|
|
121
|
+
expect(await screen.findByText('Project not found')).toBeInTheDocument();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
function renderWorkflowsPage() {
|
|
126
|
+
return renderProjectPage(
|
|
127
|
+
`/workspaces/${PROJECT_TEST_WID}/projects/${PROJECT_ID}/workflows`,
|
|
128
|
+
() => <ProjectWorkflowsPage projectId={PROJECT_ID} />,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function createProjectDetailFetch({
|
|
133
|
+
project = jsonResponse(projectDto()),
|
|
134
|
+
definitions = jsonResponse(definitionsDto()),
|
|
135
|
+
run = jsonResponse(runDto(), {status: 201}),
|
|
136
|
+
connections = jsonResponse(connectionsDto()),
|
|
137
|
+
}: {
|
|
138
|
+
project?: Response;
|
|
139
|
+
definitions?: Response;
|
|
140
|
+
run?: Response;
|
|
141
|
+
connections?: Response;
|
|
142
|
+
} = {}) {
|
|
143
|
+
return vi.fn((input: RequestInfo | URL, init?: RequestInit) => {
|
|
144
|
+
const url = new URL(requestInputUrl(input));
|
|
145
|
+
const method = init?.method ?? (input instanceof Request ? input.method : 'GET');
|
|
146
|
+
|
|
147
|
+
if (url.pathname === `/projects/${PROJECT_ID}`) {
|
|
148
|
+
return Promise.resolve(project.clone());
|
|
149
|
+
}
|
|
150
|
+
if (url.pathname === '/definitions') {
|
|
151
|
+
return Promise.resolve(definitions.clone());
|
|
152
|
+
}
|
|
153
|
+
if (url.pathname === '/integration-connections') {
|
|
154
|
+
return Promise.resolve(connections.clone());
|
|
155
|
+
}
|
|
156
|
+
if (
|
|
157
|
+
url.pathname.startsWith('/workflow-definitions/') &&
|
|
158
|
+
url.pathname.endsWith('/fire-manual') &&
|
|
159
|
+
method === 'POST'
|
|
160
|
+
) {
|
|
161
|
+
return Promise.resolve(run.clone());
|
|
162
|
+
}
|
|
163
|
+
return Promise.resolve(jsonResponse({code: 'not-found'}, {status: 404}));
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function requestInputUrl(input: RequestInfo | URL) {
|
|
168
|
+
if (input instanceof Request) return input.url;
|
|
169
|
+
return String(input);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function projectDto() {
|
|
173
|
+
return {
|
|
174
|
+
id: PROJECT_ID,
|
|
175
|
+
workspace_id: PROJECT_TEST_WID,
|
|
176
|
+
name: 'Platform',
|
|
177
|
+
source: {
|
|
178
|
+
connection_id: CONNECTION_ID,
|
|
179
|
+
external_repository_id: 'platform',
|
|
180
|
+
},
|
|
181
|
+
created_at: new Date().toISOString(),
|
|
182
|
+
updated_at: new Date().toISOString(),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function connectionsDto() {
|
|
187
|
+
return {
|
|
188
|
+
connections: [
|
|
189
|
+
{
|
|
190
|
+
id: CONNECTION_ID,
|
|
191
|
+
workspace_id: PROJECT_TEST_WID,
|
|
192
|
+
provider: 'github',
|
|
193
|
+
external_account_id: 'acme',
|
|
194
|
+
slug: 'github_acme',
|
|
195
|
+
display_name: 'Acme GitHub',
|
|
196
|
+
lifecycle_status: 'active',
|
|
197
|
+
capabilities: ['source_control'],
|
|
198
|
+
created_at: '2026-05-07T00:00:00.000Z',
|
|
199
|
+
updated_at: '2026-05-07T00:00:00.000Z',
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function definitionsDto(overrides: Partial<{definitions: unknown[]; sync: unknown}> = {}) {
|
|
206
|
+
return {...baseDefinitionsDto(), ...overrides};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function baseDefinitionsDto() {
|
|
210
|
+
return {
|
|
211
|
+
definitions: [
|
|
212
|
+
{
|
|
213
|
+
id: '55555555-5555-4555-8555-555555555555',
|
|
214
|
+
project_id: PROJECT_ID,
|
|
215
|
+
config_path: '.shipfox/workflows/deploy.yml',
|
|
216
|
+
source: 'vcs',
|
|
217
|
+
sha: 'abc123',
|
|
218
|
+
ref: 'main',
|
|
219
|
+
name: 'Deploy production',
|
|
220
|
+
workflow_document: {
|
|
221
|
+
name: 'Deploy production',
|
|
222
|
+
triggers: {on_demand: {source: 'manual', event: 'fire'}},
|
|
223
|
+
jobs: {deploy: {steps: [{run: './deploy.sh'}]}},
|
|
224
|
+
},
|
|
225
|
+
workflow_model: {kind: 'workflow', name: 'Deploy production'},
|
|
226
|
+
manual_trigger: {name: 'on_demand'},
|
|
227
|
+
fetched_at: '2026-05-07T01:00:00.000Z',
|
|
228
|
+
created_at: '2026-05-07T01:00:00.000Z',
|
|
229
|
+
updated_at: '2026-05-07T01:00:00.000Z',
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
next_cursor: null,
|
|
233
|
+
sync: {
|
|
234
|
+
ref: 'main',
|
|
235
|
+
status: 'succeeded',
|
|
236
|
+
last_sync_at: '2026-05-07T01:00:00.000Z',
|
|
237
|
+
started_at: '2026-05-07T00:59:55.000Z',
|
|
238
|
+
finished_at: '2026-05-07T01:00:00.000Z',
|
|
239
|
+
last_error_code: null,
|
|
240
|
+
last_error_message: null,
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function runDto() {
|
|
246
|
+
return {workflow_run_id: '66666666-6666-4666-8666-666666666666'};
|
|
247
|
+
}
|