@bugbug-io/cli 14.3.1 → 14.3.5
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/dist/NavigatorApp-XRXZDTTA.js +11134 -0
- package/dist/{app-EAMEJJHZ.js → app-3N4QP7FQ.js} +12 -7
- package/dist/build-ASSKRVNB.js +51 -0
- package/dist/build-ER7UIJGW.js +44 -0
- package/dist/{chunk-BSHFIPEX.js → chunk-3PJ4ZE2N.js} +7 -4
- package/dist/{chunk-PR4QN5HX.js → chunk-4GQA3Z4V.js} +3 -1
- package/dist/chunk-6P445X23.js +27655 -0
- package/dist/chunk-EDZEGHXW.js +1437 -0
- package/dist/{chunk-WZXVS2EO.js → chunk-OM7HXLEF.js} +7 -4
- package/dist/{chunk-MSMINLHT.js → chunk-QAN5Q46C.js} +22 -11
- package/dist/chunk-WQDTXQDD.js +4138 -0
- package/dist/chunk-XLIBEETK.js +16 -0
- package/dist/devtools-YPXDFB7S.js +3693 -0
- package/dist/{getMachineId-bsd-QKL32ATF.js → getMachineId-bsd-WUTM4C2C.js} +8 -6
- package/dist/{getMachineId-darwin-MNPDTPSO.js → getMachineId-darwin-JTVFBJXK.js} +8 -6
- package/dist/{getMachineId-linux-6BBPG345.js → getMachineId-linux-OOJQHJT4.js} +7 -5
- package/dist/{getMachineId-unsupported-A7ZABDRN.js → getMachineId-unsupported-SXBHXUM4.js} +7 -5
- package/dist/{getMachineId-win-WYJ4B4CV.js → getMachineId-win-MDRAAXSI.js} +8 -6
- package/dist/index.js +3087 -66
- package/dist/react-U27HC6EG.js +11 -0
- package/dist/{render-U36YSDSA.js → render-CSMURV5U.js} +7 -5
- package/package.json +7 -9
- package/dist/NavigatorApp-FHG7FP7M.js +0 -3304
|
@@ -1,3304 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="20137d86-cd7e-5ca0-8a8c-3b405154dfa8")}catch(e){}}();
|
|
3
|
-
import {
|
|
4
|
-
analytics,
|
|
5
|
-
defaultJunitReportPath,
|
|
6
|
-
detectFormat,
|
|
7
|
-
exportProject,
|
|
8
|
-
exportTest,
|
|
9
|
-
formatCwd,
|
|
10
|
-
formatErrorMessage,
|
|
11
|
-
formatFinalResults,
|
|
12
|
-
formatRunStatus,
|
|
13
|
-
getCliConfig,
|
|
14
|
-
getIdentity,
|
|
15
|
-
getProjectById,
|
|
16
|
-
getRunErrorMessage,
|
|
17
|
-
getSuite,
|
|
18
|
-
getSuiteDetails,
|
|
19
|
-
getSuiteRunDetails,
|
|
20
|
-
getSuiteRunTestRuns,
|
|
21
|
-
getTest,
|
|
22
|
-
getTestDetails,
|
|
23
|
-
getTestRunDetails,
|
|
24
|
-
getTestRunJunitReport,
|
|
25
|
-
getVersion,
|
|
26
|
-
hasProjectConfigFile,
|
|
27
|
-
importProject,
|
|
28
|
-
importTest,
|
|
29
|
-
initProject,
|
|
30
|
-
isAuthenticationError,
|
|
31
|
-
isAuthorizationError,
|
|
32
|
-
isCompletedStatus,
|
|
33
|
-
isRunningStatus,
|
|
34
|
-
listProfiles,
|
|
35
|
-
listProjects,
|
|
36
|
-
listSuiteRuns,
|
|
37
|
-
listTestRunDebugArtifacts,
|
|
38
|
-
listTestRuns,
|
|
39
|
-
loadSuiteTableResources,
|
|
40
|
-
loadTestTableResources,
|
|
41
|
-
login,
|
|
42
|
-
logout,
|
|
43
|
-
openExternalUrl,
|
|
44
|
-
runSuite,
|
|
45
|
-
runTest,
|
|
46
|
-
switchProject,
|
|
47
|
-
updateSdkConfig,
|
|
48
|
-
userCwd,
|
|
49
|
-
waitForSuiteRun,
|
|
50
|
-
waitForTestRun,
|
|
51
|
-
writeReportXml
|
|
52
|
-
} from "./chunk-MSMINLHT.js";
|
|
53
|
-
import "./chunk-BSHFIPEX.js";
|
|
54
|
-
import "./chunk-PR4QN5HX.js";
|
|
55
|
-
|
|
56
|
-
// src/app/NavigatorApp.tsx
|
|
57
|
-
import { useState as useState21 } from "react";
|
|
58
|
-
import { RouterProvider } from "react-router";
|
|
59
|
-
|
|
60
|
-
// src/app/contexts/navigatorSession/NavigatorSessionContext.tsx
|
|
61
|
-
import { createContext, useCallback, useContext, useState } from "react";
|
|
62
|
-
import { jsx } from "react/jsx-runtime";
|
|
63
|
-
var applyAuthState = (config, authState) => ({
|
|
64
|
-
...config,
|
|
65
|
-
...authState.token !== void 0 ? { token: authState.token } : {},
|
|
66
|
-
...authState.projectId !== void 0 ? { projectId: authState.projectId } : {}
|
|
67
|
-
});
|
|
68
|
-
var getAuthStatus = (config, authState) => ({
|
|
69
|
-
kind: config.token && config.projectId ? "ready" : "prompt",
|
|
70
|
-
token: config.token,
|
|
71
|
-
projectId: config.projectId,
|
|
72
|
-
isUserToken: authState.isUserToken === true,
|
|
73
|
-
apiUrl: config.apiUrl
|
|
74
|
-
});
|
|
75
|
-
var syncInitialSdkConfig = () => {
|
|
76
|
-
const config = getCliConfig();
|
|
77
|
-
if (config.token) {
|
|
78
|
-
updateSdkConfig({
|
|
79
|
-
apiToken: config.token,
|
|
80
|
-
...config.projectId ? { projectId: config.projectId } : {}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
return {};
|
|
84
|
-
};
|
|
85
|
-
var NavigatorSessionContext = createContext(null);
|
|
86
|
-
var NavigatorSessionProvider = ({ children }) => {
|
|
87
|
-
const [authState, setAuthState] = useState(
|
|
88
|
-
() => syncInitialSdkConfig()
|
|
89
|
-
);
|
|
90
|
-
const [authError, setAuthError] = useState(null);
|
|
91
|
-
const config = applyAuthState(getCliConfig(), authState);
|
|
92
|
-
const auth = getAuthStatus(config, authState);
|
|
93
|
-
const completeSession = useCallback(
|
|
94
|
-
(token, projectId, options = {}) => {
|
|
95
|
-
try {
|
|
96
|
-
const trimmedToken = token.trim();
|
|
97
|
-
if (!trimmedToken) throw new Error("Token must not be empty.");
|
|
98
|
-
const trimmedProjectId = projectId.trim();
|
|
99
|
-
if (!trimmedProjectId) throw new Error("Project id must not be empty.");
|
|
100
|
-
const nextAuthState = {
|
|
101
|
-
token: trimmedToken,
|
|
102
|
-
projectId: trimmedProjectId,
|
|
103
|
-
isUserToken: options.isUserToken === true
|
|
104
|
-
};
|
|
105
|
-
updateSdkConfig({ apiToken: nextAuthState.token, projectId: nextAuthState.projectId });
|
|
106
|
-
analytics.refreshWithToken(trimmedToken);
|
|
107
|
-
analytics.trackEvent("cli_session_configured", { success: true });
|
|
108
|
-
if (config.projectId !== trimmedProjectId) {
|
|
109
|
-
analytics.trackEvent("cli_session_project_switched", { success: true });
|
|
110
|
-
}
|
|
111
|
-
analytics.trackEvent("cli_session_started");
|
|
112
|
-
setAuthState(nextAuthState);
|
|
113
|
-
setAuthError(null);
|
|
114
|
-
} catch (err) {
|
|
115
|
-
analytics.trackEvent("cli_session_configured", { success: false });
|
|
116
|
-
setAuthError(err instanceof Error ? err.message : String(err));
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
[config.projectId]
|
|
120
|
-
);
|
|
121
|
-
const clearSession = useCallback(() => {
|
|
122
|
-
setAuthState({});
|
|
123
|
-
setAuthError(null);
|
|
124
|
-
}, []);
|
|
125
|
-
const adoptTokenProject = useCallback((projectId) => {
|
|
126
|
-
const trimmedProjectId = projectId.trim();
|
|
127
|
-
if (!trimmedProjectId) return;
|
|
128
|
-
updateSdkConfig({ projectId: trimmedProjectId });
|
|
129
|
-
setAuthState(
|
|
130
|
-
(current) => current.projectId ? current : { ...current, projectId: trimmedProjectId }
|
|
131
|
-
);
|
|
132
|
-
}, []);
|
|
133
|
-
const setSessionProject = useCallback((projectId) => {
|
|
134
|
-
try {
|
|
135
|
-
const trimmedProjectId = projectId.trim();
|
|
136
|
-
if (!trimmedProjectId) throw new Error("Project id must not be empty.");
|
|
137
|
-
updateSdkConfig({ projectId: trimmedProjectId });
|
|
138
|
-
setAuthState((current) => ({ ...current, projectId: trimmedProjectId }));
|
|
139
|
-
setAuthError(null);
|
|
140
|
-
analytics.trackEvent("cli_session_project_switched", { success: true });
|
|
141
|
-
} catch (err) {
|
|
142
|
-
analytics.trackEvent("cli_session_project_switched", { success: false });
|
|
143
|
-
setAuthError(err instanceof Error ? err.message : String(err));
|
|
144
|
-
}
|
|
145
|
-
}, []);
|
|
146
|
-
return /* @__PURE__ */ jsx(
|
|
147
|
-
NavigatorSessionContext.Provider,
|
|
148
|
-
{
|
|
149
|
-
value: {
|
|
150
|
-
auth,
|
|
151
|
-
config,
|
|
152
|
-
authError,
|
|
153
|
-
completeSession,
|
|
154
|
-
clearSession,
|
|
155
|
-
setSessionProject,
|
|
156
|
-
adoptTokenProject
|
|
157
|
-
},
|
|
158
|
-
children
|
|
159
|
-
}
|
|
160
|
-
);
|
|
161
|
-
};
|
|
162
|
-
var useNavigatorSession = () => {
|
|
163
|
-
const ctx = useContext(NavigatorSessionContext);
|
|
164
|
-
if (!ctx) {
|
|
165
|
-
throw new Error("useNavigatorSession must be used within a NavigatorSessionProvider.");
|
|
166
|
-
}
|
|
167
|
-
return ctx;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
// src/app/router.tsx
|
|
171
|
-
import { createMemoryRouter, createRoutesFromElements, Route } from "react-router";
|
|
172
|
-
|
|
173
|
-
// src/app/Navigator.tsx
|
|
174
|
-
import { Box as Box4, useApp, useInput as useInput3 } from "ink";
|
|
175
|
-
import { useState as useState4 } from "react";
|
|
176
|
-
import { Outlet, useLocation as useLocation3, useNavigate as useNavigate2 } from "react-router";
|
|
177
|
-
|
|
178
|
-
// src/app/components/AuthGate/AuthGate.tsx
|
|
179
|
-
import { useEffect as useEffect2 } from "react";
|
|
180
|
-
import { useLocation, useNavigate } from "react-router";
|
|
181
|
-
|
|
182
|
-
// src/app/hooks/useConnectionStatus.ts
|
|
183
|
-
import { useEffect, useState as useState2 } from "react";
|
|
184
|
-
var PING_INTERVAL_MS = 15e3;
|
|
185
|
-
var getConnectionStatus = async () => {
|
|
186
|
-
try {
|
|
187
|
-
const identity = await getIdentity();
|
|
188
|
-
return { state: "ok", message: "API connectivity successful", identity };
|
|
189
|
-
} catch (err) {
|
|
190
|
-
if (isAuthenticationError(err) || isAuthorizationError(err)) {
|
|
191
|
-
return { state: "unauthenticated", message: "API token is invalid or missing" };
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
state: "error",
|
|
195
|
-
message: err instanceof Error ? err.message : "Unknown error"
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
var useConnectionStatus = (enabled) => {
|
|
200
|
-
const [status, setStatus] = useState2({ state: "checking" });
|
|
201
|
-
useEffect(() => {
|
|
202
|
-
if (!enabled) {
|
|
203
|
-
return void 0;
|
|
204
|
-
}
|
|
205
|
-
let cancelled = false;
|
|
206
|
-
const ping = async () => {
|
|
207
|
-
const nextStatus = await getConnectionStatus();
|
|
208
|
-
if (!cancelled) setStatus(nextStatus);
|
|
209
|
-
};
|
|
210
|
-
ping();
|
|
211
|
-
const interval = setInterval(() => {
|
|
212
|
-
ping();
|
|
213
|
-
}, PING_INTERVAL_MS);
|
|
214
|
-
return () => {
|
|
215
|
-
cancelled = true;
|
|
216
|
-
clearInterval(interval);
|
|
217
|
-
};
|
|
218
|
-
}, [enabled]);
|
|
219
|
-
return status;
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
// src/app/components/AuthGate/AuthGate.tsx
|
|
223
|
-
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
|
224
|
-
var INIT_ROUTE = "/init";
|
|
225
|
-
var AuthGate = ({ children }) => {
|
|
226
|
-
const { auth, adoptTokenProject } = useNavigatorSession();
|
|
227
|
-
const location = useLocation();
|
|
228
|
-
const navigate = useNavigate();
|
|
229
|
-
const onInitRoute = location.pathname === INIT_ROUTE;
|
|
230
|
-
const hasConfiguredAuth = Boolean(auth.token);
|
|
231
|
-
const connectionStatus = useConnectionStatus(hasConfiguredAuth);
|
|
232
|
-
const identity = connectionStatus.identity;
|
|
233
|
-
const tokenProjectId = identity?.tokenType === "project" ? identity.projectId : null;
|
|
234
|
-
const projectId = auth.projectId ?? tokenProjectId;
|
|
235
|
-
const authCheckPending = hasConfiguredAuth && connectionStatus.state === "checking";
|
|
236
|
-
const authRejected = hasConfiguredAuth && connectionStatus.state === "unauthenticated";
|
|
237
|
-
const authenticated = hasConfiguredAuth && !authRejected && Boolean(projectId);
|
|
238
|
-
useEffect2(() => {
|
|
239
|
-
if (tokenProjectId && !auth.projectId) adoptTokenProject(tokenProjectId);
|
|
240
|
-
}, [adoptTokenProject, auth.projectId, tokenProjectId]);
|
|
241
|
-
useEffect2(() => {
|
|
242
|
-
if (!authCheckPending && !authenticated && !onInitRoute) {
|
|
243
|
-
navigate(INIT_ROUTE, {
|
|
244
|
-
state: {
|
|
245
|
-
redirectUrl: location.pathname,
|
|
246
|
-
onlyThisSession: true,
|
|
247
|
-
...authRejected ? { ignoreConfiguredAuth: true } : {}
|
|
248
|
-
},
|
|
249
|
-
replace: true
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}, [authCheckPending, authenticated, authRejected, onInitRoute, location.pathname, navigate]);
|
|
253
|
-
if (authCheckPending) return null;
|
|
254
|
-
if (authenticated) return /* @__PURE__ */ jsx2(Fragment, { children: children(true) });
|
|
255
|
-
if (onInitRoute) return /* @__PURE__ */ jsx2(Fragment, { children: children(false) });
|
|
256
|
-
return null;
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
// src/app/components/Header/Header.tsx
|
|
260
|
-
import { Box, Text } from "ink";
|
|
261
|
-
|
|
262
|
-
// src/features/tui/theme.ts
|
|
263
|
-
var colors = {
|
|
264
|
-
brand: "#4c2b8b",
|
|
265
|
-
primary: "#521ec9",
|
|
266
|
-
primarySoft: "#8466CA",
|
|
267
|
-
accent: "#ffcd1c",
|
|
268
|
-
accentSoft: "#FFF8EA",
|
|
269
|
-
primaryActive: "#6029df",
|
|
270
|
-
primaryInactive: "#a489e2",
|
|
271
|
-
common: {
|
|
272
|
-
transparent: "transparent",
|
|
273
|
-
white: "#ffffff",
|
|
274
|
-
black: "#000000",
|
|
275
|
-
muted: "#f4f3fb"
|
|
276
|
-
},
|
|
277
|
-
background: {
|
|
278
|
-
primary: "#E8E9FF",
|
|
279
|
-
primary97: "#F4F3FB",
|
|
280
|
-
primary99: "#F9F9FF",
|
|
281
|
-
accent: "#FFF8EA",
|
|
282
|
-
surface: "#FFFFFF",
|
|
283
|
-
success: "#D1FBE2",
|
|
284
|
-
failure: "#FFF0F0",
|
|
285
|
-
neutral: "#FAFAFA",
|
|
286
|
-
highlight: "#F4F3FB",
|
|
287
|
-
highlightLight: "#F9F9FF"
|
|
288
|
-
},
|
|
289
|
-
text: {
|
|
290
|
-
normal: "#2b2b2b",
|
|
291
|
-
secondary: "#666666",
|
|
292
|
-
subtle: "#7A7F86",
|
|
293
|
-
lighter: "#8B8B8B",
|
|
294
|
-
secondaryAllCaps: "#A2A1A1",
|
|
295
|
-
emptyState: "#999999"
|
|
296
|
-
},
|
|
297
|
-
border: {
|
|
298
|
-
normal: "#2B2B2B",
|
|
299
|
-
dark: "#AAAAAA",
|
|
300
|
-
important: "#CCC9C9",
|
|
301
|
-
medium: "#E5E5E5",
|
|
302
|
-
semi: "#EBEBEB",
|
|
303
|
-
light: "#EFEFEF",
|
|
304
|
-
superLight: "#F1F1F3"
|
|
305
|
-
},
|
|
306
|
-
neutrals: {
|
|
307
|
-
"40": "#666666",
|
|
308
|
-
"80": "#CCCBCB",
|
|
309
|
-
"92": "#EAEAEA",
|
|
310
|
-
"94": "#EFEFEF",
|
|
311
|
-
"96": "#F5F5F5",
|
|
312
|
-
"97": "#F7F7F7"
|
|
313
|
-
},
|
|
314
|
-
status: {
|
|
315
|
-
success: "#4dbf8b",
|
|
316
|
-
success90: "#D1FBE2",
|
|
317
|
-
failure: "#e85b5b",
|
|
318
|
-
stopped: "#898989",
|
|
319
|
-
info: "blue",
|
|
320
|
-
debugging: "#ffcd1c",
|
|
321
|
-
warning: "#FFB100",
|
|
322
|
-
initialized: "#999999",
|
|
323
|
-
recording: "#EF2E51",
|
|
324
|
-
paused: "#ffcd1c",
|
|
325
|
-
skipped: "#8A8A8A"
|
|
326
|
-
},
|
|
327
|
-
code: {
|
|
328
|
-
blue: "#82aaff",
|
|
329
|
-
violet: "#c792ea",
|
|
330
|
-
yellow: "#d4c612",
|
|
331
|
-
red: "#ff5370",
|
|
332
|
-
ruby: "#f17c83"
|
|
333
|
-
},
|
|
334
|
-
block: {
|
|
335
|
-
if: {
|
|
336
|
-
background: "#f2f8fc",
|
|
337
|
-
marker: "#cfeeff"
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
var theme = {
|
|
342
|
-
colors
|
|
343
|
-
};
|
|
344
|
-
var useTheme = () => ({ theme });
|
|
345
|
-
|
|
346
|
-
// src/app/hooks/useFeatureQuery.ts
|
|
347
|
-
import { useCallback as useCallback2, useEffect as useEffect3, useState as useState3 } from "react";
|
|
348
|
-
var useFeatureQuery = (fn, deps) => {
|
|
349
|
-
const [data, setData] = useState3(void 0);
|
|
350
|
-
const [isFetching, setIsFetching] = useState3(true);
|
|
351
|
-
const [error, setError] = useState3(void 0);
|
|
352
|
-
const [refreshIndex, setRefreshIndex] = useState3(0);
|
|
353
|
-
useEffect3(() => {
|
|
354
|
-
let cancelled = false;
|
|
355
|
-
setIsFetching(true);
|
|
356
|
-
setError(void 0);
|
|
357
|
-
const run = async () => {
|
|
358
|
-
try {
|
|
359
|
-
const result = await fn();
|
|
360
|
-
if (!cancelled) setData(result);
|
|
361
|
-
} catch (err) {
|
|
362
|
-
if (!cancelled) setError(formatErrorMessage(err));
|
|
363
|
-
} finally {
|
|
364
|
-
if (!cancelled) setIsFetching(false);
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
run().catch((err) => {
|
|
368
|
-
if (!cancelled) {
|
|
369
|
-
setError(formatErrorMessage(err));
|
|
370
|
-
setIsFetching(false);
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
return () => {
|
|
374
|
-
cancelled = true;
|
|
375
|
-
};
|
|
376
|
-
}, [refreshIndex, ...deps]);
|
|
377
|
-
const refetch = useCallback2(() => {
|
|
378
|
-
setRefreshIndex((index) => index + 1);
|
|
379
|
-
}, []);
|
|
380
|
-
return {
|
|
381
|
-
data,
|
|
382
|
-
isLoading: isFetching && data === void 0,
|
|
383
|
-
isFetching,
|
|
384
|
-
isError: error !== void 0,
|
|
385
|
-
error,
|
|
386
|
-
refetch
|
|
387
|
-
};
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
// src/app/hooks/useCurrentProject.ts
|
|
391
|
-
var useCurrentProject = (enabled) => {
|
|
392
|
-
const { auth } = useNavigatorSession();
|
|
393
|
-
const projectId = enabled ? auth.projectId : void 0;
|
|
394
|
-
const query = useFeatureQuery(
|
|
395
|
-
() => projectId ? getProjectById(projectId) : Promise.resolve(null),
|
|
396
|
-
[projectId]
|
|
397
|
-
);
|
|
398
|
-
return query.data ?? void 0;
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
// src/app/components/Header/Header.constants.ts
|
|
402
|
-
var VERSION = getVersion();
|
|
403
|
-
var BUGBUG_LOGO_ASCII = [
|
|
404
|
-
"\u2584 \u2584 ",
|
|
405
|
-
"\u2588\u2588\u2588 \u2588\u2588\u2588 ",
|
|
406
|
-
"\u2580\u2580\u2580 \u2580\u2580\u2580 ",
|
|
407
|
-
"\u2584\u2584 \u2584\u2584 ",
|
|
408
|
-
" \u2580\u2580\u2580\u2580 "
|
|
409
|
-
].join("\n");
|
|
410
|
-
var STATUS_LABEL = {
|
|
411
|
-
checking: "Connecting...",
|
|
412
|
-
ok: "Authenticated",
|
|
413
|
-
unauthenticated: "Unauthenticated",
|
|
414
|
-
error: "Disconnected"
|
|
415
|
-
};
|
|
416
|
-
var STATUS_COLOR = {
|
|
417
|
-
checking: "yellow",
|
|
418
|
-
ok: void 0,
|
|
419
|
-
unauthenticated: "yellow",
|
|
420
|
-
error: "red"
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
// src/app/components/Header/Header.tsx
|
|
424
|
-
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
425
|
-
var Header = ({ authenticated }) => {
|
|
426
|
-
const { theme: theme2 } = useTheme();
|
|
427
|
-
const status = useConnectionStatus(authenticated);
|
|
428
|
-
const project = useCurrentProject(authenticated);
|
|
429
|
-
const identity = authenticated ? status.identity : void 0;
|
|
430
|
-
const state = authenticated ? status.state : "unauthenticated";
|
|
431
|
-
const showDetail = authenticated && (status.state === "error" || status.state === "unauthenticated") && !!status.message;
|
|
432
|
-
return /* @__PURE__ */ jsxs(Box, { marginBottom: 1, children: [
|
|
433
|
-
/* @__PURE__ */ jsx3(Box, { marginRight: 1, children: /* @__PURE__ */ jsx3(Text, { color: theme2.colors.brand, children: BUGBUG_LOGO_ASCII }) }),
|
|
434
|
-
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
435
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
436
|
-
/* @__PURE__ */ jsx3(Text, { bold: true, children: "BugBug" }),
|
|
437
|
-
" ",
|
|
438
|
-
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
439
|
-
"v",
|
|
440
|
-
VERSION
|
|
441
|
-
] })
|
|
442
|
-
] }),
|
|
443
|
-
/* @__PURE__ */ jsx3(Text, { dimColor: true, children: "Your interactive quality buddy" }),
|
|
444
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
445
|
-
/* @__PURE__ */ jsx3(Text, { dimColor: true, children: "Status: " }),
|
|
446
|
-
/* @__PURE__ */ jsx3(Text, { color: STATUS_COLOR[state], dimColor: state === "ok", children: STATUS_LABEL[state] }),
|
|
447
|
-
authenticated && identity && /* @__PURE__ */ jsx3(Text, { dimColor: true, children: identity.tokenType === "user" ? ` (logged in as ${identity.name})` : ` (via ${identity.tokenType} token)` }),
|
|
448
|
-
showDetail ? /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
449
|
-
" (",
|
|
450
|
-
status.message,
|
|
451
|
-
")"
|
|
452
|
-
] }) : null
|
|
453
|
-
] }),
|
|
454
|
-
authenticated && project ? /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
455
|
-
"Project: ",
|
|
456
|
-
project.name ?? "Untitled project",
|
|
457
|
-
" at ",
|
|
458
|
-
project.organizationName
|
|
459
|
-
] }) : /* @__PURE__ */ jsx3(Text, { dimColor: true, children: " " }),
|
|
460
|
-
/* @__PURE__ */ jsx3(Text, { dimColor: true, children: formatCwd(userCwd()) })
|
|
461
|
-
] })
|
|
462
|
-
] });
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
// src/features/tui/components/Breadcrumb/Breadcrumb.tsx
|
|
466
|
-
import { Box as Box2, Text as Text2 } from "ink";
|
|
467
|
-
import { useLocation as useLocation2 } from "react-router";
|
|
468
|
-
|
|
469
|
-
// src/app/routeLabels.ts
|
|
470
|
-
var CRUMB_LABELS = {
|
|
471
|
-
"/tests": "Tests",
|
|
472
|
-
"/tests/list": "List",
|
|
473
|
-
"/tests/import": "Import",
|
|
474
|
-
"/tests/run": "Run",
|
|
475
|
-
"/tests/:testId": "Details",
|
|
476
|
-
"/tests/:testId/run": "Run",
|
|
477
|
-
"/tests/:testId/lastRun": "Show last run",
|
|
478
|
-
"/tests/:testId/export": "Export",
|
|
479
|
-
"/tests/:testId/open": "Open in BugBug",
|
|
480
|
-
"/testruns": "Test runs",
|
|
481
|
-
"/testruns/list": "List",
|
|
482
|
-
"/testruns/:runId": "Details",
|
|
483
|
-
"/testruns/:runId/debugArtifacts": "Show run artifacts",
|
|
484
|
-
"/testruns/:runId/junitReport": "Download JUnit report",
|
|
485
|
-
"/testruns/:runId/open": "Open in BugBug",
|
|
486
|
-
"/suites": "Suites",
|
|
487
|
-
"/suites/list": "List",
|
|
488
|
-
"/suites/run": "Run",
|
|
489
|
-
"/suites/:suiteId": "Details",
|
|
490
|
-
"/suites/:suiteId/run": "Run",
|
|
491
|
-
"/suites/:suiteId/lastRun": "Show last run",
|
|
492
|
-
"/suites/:suiteId/open": "Open in BugBug",
|
|
493
|
-
"/suiteruns": "Suite runs",
|
|
494
|
-
"/suiteruns/list": "List",
|
|
495
|
-
"/suiteruns/:runId": "Details",
|
|
496
|
-
"/suiteruns/:runId/showTestRuns": "Show test runs",
|
|
497
|
-
"/suiteruns/:runId/open": "Open in BugBug",
|
|
498
|
-
"/profiles": "Profiles",
|
|
499
|
-
"/profiles/list": "List",
|
|
500
|
-
"/project": "Project",
|
|
501
|
-
"/project/export": "Export",
|
|
502
|
-
"/project/import": "Import",
|
|
503
|
-
"/settings": "Settings",
|
|
504
|
-
"/settings/setSessionToken": "Set session token",
|
|
505
|
-
"/logout": "Logout"
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
// src/features/tui/tui.utils.ts
|
|
509
|
-
var ROOT_LABEL = "Main menu";
|
|
510
|
-
var normalizePath = (pathname) => {
|
|
511
|
-
const trimmed = pathname.replace(/\/+$/, "");
|
|
512
|
-
return trimmed === "" ? "/" : trimmed;
|
|
513
|
-
};
|
|
514
|
-
var pathSegments = (pathname) => normalizePath(pathname).split("/").filter(Boolean);
|
|
515
|
-
var matchesPattern = (pattern, pathname) => {
|
|
516
|
-
const patternSegments = pathSegments(pattern);
|
|
517
|
-
const currentSegments = pathSegments(pathname);
|
|
518
|
-
if (patternSegments.length !== currentSegments.length) return false;
|
|
519
|
-
return patternSegments.every(
|
|
520
|
-
(segment, index) => segment.startsWith(":") || segment === currentSegments[index]
|
|
521
|
-
);
|
|
522
|
-
};
|
|
523
|
-
var findLabel = (pathname, labels) => {
|
|
524
|
-
const normalizedPath = normalizePath(pathname);
|
|
525
|
-
const exact = labels[normalizedPath];
|
|
526
|
-
if (exact) return exact;
|
|
527
|
-
const wildcard = Object.entries(labels).find(
|
|
528
|
-
([pattern]) => matchesPattern(pattern, normalizedPath)
|
|
529
|
-
);
|
|
530
|
-
return wildcard?.[1];
|
|
531
|
-
};
|
|
532
|
-
var buildBreadcrumb = (pathname, labels) => {
|
|
533
|
-
const parts = [ROOT_LABEL];
|
|
534
|
-
const segments = pathSegments(pathname);
|
|
535
|
-
for (let index = 0; index < segments.length; index += 1) {
|
|
536
|
-
const prefix = `/${segments.slice(0, index + 1).join("/")}`;
|
|
537
|
-
const label = findLabel(prefix, labels);
|
|
538
|
-
if (label && parts[parts.length - 1] !== label) parts.push(label);
|
|
539
|
-
}
|
|
540
|
-
return parts.join(" \u203A ");
|
|
541
|
-
};
|
|
542
|
-
|
|
543
|
-
// src/features/tui/components/Breadcrumb/Breadcrumb.tsx
|
|
544
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
545
|
-
var Breadcrumb = () => {
|
|
546
|
-
const { pathname } = useLocation2();
|
|
547
|
-
return /* @__PURE__ */ jsx4(Box2, { marginBottom: 1, children: /* @__PURE__ */ jsx4(Text2, { bold: true, color: "cyan", children: buildBreadcrumb(pathname, CRUMB_LABELS) }) });
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
// src/features/tui/components/ShortcutsGrid/ShortcutsGrid.tsx
|
|
551
|
-
import { Box as Box3, Text as Text3 } from "ink";
|
|
552
|
-
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
553
|
-
var GLOBAL_SHORTCUTS = [
|
|
554
|
-
{ shortcut: "t", label: "Tests" },
|
|
555
|
-
{ shortcut: "r", label: "Test runs" },
|
|
556
|
-
{ shortcut: "s", label: "Suites" },
|
|
557
|
-
{ shortcut: "u", label: "Suite runs" },
|
|
558
|
-
{ shortcut: "f", label: "Profiles" },
|
|
559
|
-
{ shortcut: "p", label: "Project" },
|
|
560
|
-
{ shortcut: ",", label: "Settings" },
|
|
561
|
-
{ shortcut: "Esc", label: "Back" },
|
|
562
|
-
{ shortcut: "q", label: "Close at main menu" },
|
|
563
|
-
{ shortcut: "Ctrl-C", label: "Exit" }
|
|
564
|
-
];
|
|
565
|
-
var ACTION_SHORTCUTS = [
|
|
566
|
-
{ shortcut: "Enter", label: "Select" },
|
|
567
|
-
{ shortcut: "/", label: "Search" },
|
|
568
|
-
{ shortcut: "l", label: "List or logs" },
|
|
569
|
-
{ shortcut: "r", label: "Run" },
|
|
570
|
-
{ shortcut: "i", label: "Import" },
|
|
571
|
-
{ shortcut: "e", label: "Export" },
|
|
572
|
-
{ shortcut: "o", label: "Open in BugBug" },
|
|
573
|
-
{ shortcut: "h", label: "Last run" },
|
|
574
|
-
{ shortcut: "a", label: "Artifacts" },
|
|
575
|
-
{ shortcut: "t", label: "Suite run tests" }
|
|
576
|
-
];
|
|
577
|
-
var ShortcutColumn = ({ title, items }) => /* @__PURE__ */ jsxs2(Box3, { flexDirection: "column", marginRight: 4, children: [
|
|
578
|
-
/* @__PURE__ */ jsx5(Text3, { bold: true, children: title }),
|
|
579
|
-
items.map(({ shortcut, label }) => /* @__PURE__ */ jsxs2(Text3, { children: [
|
|
580
|
-
/* @__PURE__ */ jsx5(Text3, { color: "cyan", children: shortcut.padEnd(7) }),
|
|
581
|
-
label
|
|
582
|
-
] }, `${shortcut}-${label}`))
|
|
583
|
-
] });
|
|
584
|
-
var ShortcutsGrid = () => /* @__PURE__ */ jsxs2(Box3, { marginTop: 1, borderStyle: "single", borderColor: "gray", paddingX: 1, children: [
|
|
585
|
-
/* @__PURE__ */ jsx5(ShortcutColumn, { title: "Global", items: GLOBAL_SHORTCUTS }),
|
|
586
|
-
/* @__PURE__ */ jsx5(ShortcutColumn, { title: "Actions", items: ACTION_SHORTCUTS })
|
|
587
|
-
] });
|
|
588
|
-
|
|
589
|
-
// src/features/tui/EscController.tsx
|
|
590
|
-
import { useInput } from "ink";
|
|
591
|
-
import { createContext as createContext2, useContext as useContext2, useEffect as useEffect4, useRef } from "react";
|
|
592
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
593
|
-
var EscContext = createContext2(null);
|
|
594
|
-
var EscProvider = ({
|
|
595
|
-
onUnhandled,
|
|
596
|
-
canGoBack = true,
|
|
597
|
-
children
|
|
598
|
-
}) => {
|
|
599
|
-
const handlersRef = useRef([]);
|
|
600
|
-
const register = (handler) => {
|
|
601
|
-
handlersRef.current.push(handler);
|
|
602
|
-
return () => {
|
|
603
|
-
handlersRef.current = handlersRef.current.filter((h) => h !== handler);
|
|
604
|
-
};
|
|
605
|
-
};
|
|
606
|
-
useInput((_input, key) => {
|
|
607
|
-
if (!key.escape) return;
|
|
608
|
-
for (let i = handlersRef.current.length - 1; i >= 0; i -= 1) {
|
|
609
|
-
if (handlersRef.current[i]()) return;
|
|
610
|
-
}
|
|
611
|
-
onUnhandled();
|
|
612
|
-
});
|
|
613
|
-
return /* @__PURE__ */ jsx6(EscContext.Provider, { value: { register, canGoBack }, children });
|
|
614
|
-
};
|
|
615
|
-
var useEscHandler = (handler) => {
|
|
616
|
-
const registry = useContext2(EscContext);
|
|
617
|
-
const handlerRef = useRef(handler);
|
|
618
|
-
handlerRef.current = handler;
|
|
619
|
-
useEffect4(() => {
|
|
620
|
-
if (!registry) return void 0;
|
|
621
|
-
return registry.register(() => handlerRef.current());
|
|
622
|
-
}, [registry]);
|
|
623
|
-
};
|
|
624
|
-
var useCanGoBack = () => {
|
|
625
|
-
const registry = useContext2(EscContext);
|
|
626
|
-
return registry?.canGoBack ?? false;
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
// src/features/tui/ShortcutController.tsx
|
|
630
|
-
import { useInput as useInput2 } from "ink";
|
|
631
|
-
import { createContext as createContext3, useContext as useContext3, useEffect as useEffect5, useRef as useRef2 } from "react";
|
|
632
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
633
|
-
var ShortcutContext = createContext3(null);
|
|
634
|
-
var ShortcutProvider = ({ children }) => {
|
|
635
|
-
const entriesRef = useRef2([]);
|
|
636
|
-
const blockerCountRef = useRef2(0);
|
|
637
|
-
const nextOrderRef = useRef2(0);
|
|
638
|
-
const register = (handler, options = {}) => {
|
|
639
|
-
const entry = {
|
|
640
|
-
handler,
|
|
641
|
-
priority: options.priority ?? 0,
|
|
642
|
-
order: nextOrderRef.current
|
|
643
|
-
};
|
|
644
|
-
nextOrderRef.current += 1;
|
|
645
|
-
entriesRef.current.push(entry);
|
|
646
|
-
return () => {
|
|
647
|
-
entriesRef.current = entriesRef.current.filter((current) => current !== entry);
|
|
648
|
-
};
|
|
649
|
-
};
|
|
650
|
-
const block = () => {
|
|
651
|
-
blockerCountRef.current += 1;
|
|
652
|
-
return () => {
|
|
653
|
-
blockerCountRef.current = Math.max(0, blockerCountRef.current - 1);
|
|
654
|
-
};
|
|
655
|
-
};
|
|
656
|
-
useInput2((input, key) => {
|
|
657
|
-
if (blockerCountRef.current > 0) return;
|
|
658
|
-
const entries = entriesRef.current.toSorted((a, b) => {
|
|
659
|
-
if (a.priority !== b.priority) return b.priority - a.priority;
|
|
660
|
-
return b.order - a.order;
|
|
661
|
-
});
|
|
662
|
-
for (const entry of entries) {
|
|
663
|
-
if (entry.handler({ input, key })) return;
|
|
664
|
-
}
|
|
665
|
-
});
|
|
666
|
-
return /* @__PURE__ */ jsx7(ShortcutContext.Provider, { value: { register, block }, children });
|
|
667
|
-
};
|
|
668
|
-
var useShortcutHandler = (handler, options = {}) => {
|
|
669
|
-
const registry = useContext3(ShortcutContext);
|
|
670
|
-
const handlerRef = useRef2(handler);
|
|
671
|
-
const priorityRef = useRef2(options.priority);
|
|
672
|
-
handlerRef.current = handler;
|
|
673
|
-
priorityRef.current = options.priority;
|
|
674
|
-
useEffect5(() => {
|
|
675
|
-
if (!registry) return void 0;
|
|
676
|
-
return registry.register((event) => handlerRef.current(event), {
|
|
677
|
-
priority: priorityRef.current
|
|
678
|
-
});
|
|
679
|
-
}, [registry]);
|
|
680
|
-
};
|
|
681
|
-
var useShortcutBlocker = (enabled = true) => {
|
|
682
|
-
const registry = useContext3(ShortcutContext);
|
|
683
|
-
useEffect5(() => {
|
|
684
|
-
if (!registry || !enabled) return void 0;
|
|
685
|
-
return registry.block();
|
|
686
|
-
}, [registry, enabled]);
|
|
687
|
-
};
|
|
688
|
-
|
|
689
|
-
// src/features/tui/ShortcutController.constants.ts
|
|
690
|
-
var GLOBAL_SHORTCUT_PRIORITY = -100;
|
|
691
|
-
var HELP_SHORTCUT_PRIORITY = 100;
|
|
692
|
-
|
|
693
|
-
// src/app/routes.ts
|
|
694
|
-
var ROUTES = {
|
|
695
|
-
root: () => "/",
|
|
696
|
-
view: (viewKey) => `/${viewKey}`,
|
|
697
|
-
action: (viewKey, actionKey) => `/${viewKey}/${actionKey}`,
|
|
698
|
-
tests: {
|
|
699
|
-
list: () => "/tests/list",
|
|
700
|
-
details: (testId) => `/tests/${testId}`,
|
|
701
|
-
run: (testId) => `/tests/${testId}/run`,
|
|
702
|
-
lastRun: (testId) => `/tests/${testId}/lastRun`,
|
|
703
|
-
export: (testId) => `/tests/${testId}/export`,
|
|
704
|
-
open: (testId) => `/tests/${testId}/open`
|
|
705
|
-
},
|
|
706
|
-
testRuns: {
|
|
707
|
-
root: () => "/testruns",
|
|
708
|
-
list: () => "/testruns/list",
|
|
709
|
-
details: (runId) => `/testruns/${runId}`,
|
|
710
|
-
debugArtifacts: (runId) => `/testruns/${runId}/debugArtifacts`,
|
|
711
|
-
junitReport: (runId) => `/testruns/${runId}/junitReport`,
|
|
712
|
-
open: (runId) => `/testruns/${runId}/open`
|
|
713
|
-
},
|
|
714
|
-
suites: {
|
|
715
|
-
list: () => "/suites/list",
|
|
716
|
-
details: (suiteId) => `/suites/${suiteId}`,
|
|
717
|
-
run: (suiteId) => `/suites/${suiteId}/run`,
|
|
718
|
-
lastRun: (suiteId) => `/suites/${suiteId}/lastRun`,
|
|
719
|
-
open: (suiteId) => `/suites/${suiteId}/open`
|
|
720
|
-
},
|
|
721
|
-
suiteRuns: {
|
|
722
|
-
root: () => "/suiteruns",
|
|
723
|
-
list: () => "/suiteruns/list",
|
|
724
|
-
details: (runId) => `/suiteruns/${runId}`,
|
|
725
|
-
showTestRuns: (runId) => `/suiteruns/${runId}/showTestRuns`,
|
|
726
|
-
open: (runId) => `/suiteruns/${runId}/open`
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
|
|
730
|
-
// src/app/Navigator.tsx
|
|
731
|
-
import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
732
|
-
var Navigator = () => {
|
|
733
|
-
const [shortcutsVisible, setShortcutsVisible] = useState4(false);
|
|
734
|
-
return /* @__PURE__ */ jsx8(ShortcutProvider, { children: /* @__PURE__ */ jsx8(
|
|
735
|
-
NavigatorShell,
|
|
736
|
-
{
|
|
737
|
-
shortcutsVisible,
|
|
738
|
-
onToggleShortcuts: () => setShortcutsVisible((visible) => !visible)
|
|
739
|
-
}
|
|
740
|
-
) });
|
|
741
|
-
};
|
|
742
|
-
var NavigatorShell = ({
|
|
743
|
-
shortcutsVisible,
|
|
744
|
-
onToggleShortcuts
|
|
745
|
-
}) => {
|
|
746
|
-
const { exit } = useApp();
|
|
747
|
-
const navigate = useNavigate2();
|
|
748
|
-
const location = useLocation3();
|
|
749
|
-
const atRoot = location.pathname === ROUTES.root();
|
|
750
|
-
useInput3((input, key) => {
|
|
751
|
-
if (key.ctrl && input === "c") {
|
|
752
|
-
exit();
|
|
753
|
-
return;
|
|
754
|
-
}
|
|
755
|
-
if (atRoot && (input === "q" || input === "Q")) {
|
|
756
|
-
exit();
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
useShortcutHandler(
|
|
760
|
-
({ input }) => {
|
|
761
|
-
if (input !== "?") return false;
|
|
762
|
-
onToggleShortcuts();
|
|
763
|
-
return true;
|
|
764
|
-
},
|
|
765
|
-
{ priority: HELP_SHORTCUT_PRIORITY }
|
|
766
|
-
);
|
|
767
|
-
useShortcutHandler(
|
|
768
|
-
({ input }) => {
|
|
769
|
-
const route = {
|
|
770
|
-
t: "/tests",
|
|
771
|
-
r: ROUTES.testRuns.list(),
|
|
772
|
-
s: "/suites",
|
|
773
|
-
u: ROUTES.suiteRuns.list(),
|
|
774
|
-
p: "/project",
|
|
775
|
-
",": "/settings"
|
|
776
|
-
}[input];
|
|
777
|
-
if (!route) return false;
|
|
778
|
-
navigate(route);
|
|
779
|
-
return true;
|
|
780
|
-
},
|
|
781
|
-
{ priority: GLOBAL_SHORTCUT_PRIORITY }
|
|
782
|
-
);
|
|
783
|
-
return /* @__PURE__ */ jsx8(Box4, { flexDirection: "column", padding: 1, children: /* @__PURE__ */ jsx8(AuthGate, { children: (authenticated) => /* @__PURE__ */ jsxs3(
|
|
784
|
-
EscProvider,
|
|
785
|
-
{
|
|
786
|
-
canGoBack: !atRoot,
|
|
787
|
-
onUnhandled: () => {
|
|
788
|
-
if (!atRoot) navigate(-1);
|
|
789
|
-
},
|
|
790
|
-
children: [
|
|
791
|
-
/* @__PURE__ */ jsx8(Header, { authenticated }),
|
|
792
|
-
authenticated && /* @__PURE__ */ jsx8(Breadcrumb, {}),
|
|
793
|
-
/* @__PURE__ */ jsx8(Outlet, {}),
|
|
794
|
-
shortcutsVisible && /* @__PURE__ */ jsx8(ShortcutsGrid, {})
|
|
795
|
-
]
|
|
796
|
-
}
|
|
797
|
-
) }) });
|
|
798
|
-
};
|
|
799
|
-
|
|
800
|
-
// src/app/views/logout/Logout.tsx
|
|
801
|
-
import { StatusMessage } from "@inkjs/ui";
|
|
802
|
-
import { useApp as useApp2 } from "ink";
|
|
803
|
-
import { useEffect as useEffect7, useState as useState6 } from "react";
|
|
804
|
-
|
|
805
|
-
// src/features/tui/layouts/ViewLayout/ViewLayout.tsx
|
|
806
|
-
import { Box as Box5, Text as Text4, useInput as useInput4 } from "ink";
|
|
807
|
-
import { useEffect as useEffect6, useState as useState5 } from "react";
|
|
808
|
-
|
|
809
|
-
// src/features/tui/layouts/ViewLayout/ViewLayout.constants.ts
|
|
810
|
-
var GO_BACK = "Esc to go back";
|
|
811
|
-
var CLOSE = "q to close";
|
|
812
|
-
var NAVIGATION = "\u2191/\u2193 to navigate";
|
|
813
|
-
var SELECT = "Enter to select";
|
|
814
|
-
var SEARCH = "/ search";
|
|
815
|
-
var HELP = "? for shortcuts";
|
|
816
|
-
var VIEW_HINTS = {
|
|
817
|
-
GO_BACK,
|
|
818
|
-
CLOSE,
|
|
819
|
-
SELECT,
|
|
820
|
-
SEARCH,
|
|
821
|
-
HELP,
|
|
822
|
-
SEARCH_MODE_DEFAULT: "type to search \xB7 Enter to search \xB7 Esc to clear",
|
|
823
|
-
NAVIGATION_SELECT: `${NAVIGATION} \xB7 ${SELECT}`,
|
|
824
|
-
CONFIRM: "Enter to confirm",
|
|
825
|
-
NAVIGATION_OPEN_SELECT: `${NAVIGATION} \xB7 Enter to open/select`
|
|
826
|
-
};
|
|
827
|
-
var HINT_TEXT = {
|
|
828
|
-
confirm: VIEW_HINTS.CONFIRM,
|
|
829
|
-
navigationOpenSelect: VIEW_HINTS.NAVIGATION_OPEN_SELECT,
|
|
830
|
-
navigationSelect: VIEW_HINTS.NAVIGATION_SELECT
|
|
831
|
-
};
|
|
832
|
-
|
|
833
|
-
// src/features/tui/layouts/ViewLayout/ViewLayout.tsx
|
|
834
|
-
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
835
|
-
var ViewLayout = ({
|
|
836
|
-
title,
|
|
837
|
-
hints: hintsOverride,
|
|
838
|
-
hintsHidden = false,
|
|
839
|
-
hintsPosition = "top",
|
|
840
|
-
searchable = false,
|
|
841
|
-
onSearch,
|
|
842
|
-
onSearchModeChange,
|
|
843
|
-
children
|
|
844
|
-
}) => {
|
|
845
|
-
const canGoBack = useCanGoBack();
|
|
846
|
-
const [searchMode, setSearchMode] = useState5(false);
|
|
847
|
-
const [searchText, setSearchText] = useState5("");
|
|
848
|
-
const defaultHints = [VIEW_HINTS.NAVIGATION_SELECT, searchable ? VIEW_HINTS.SEARCH : null];
|
|
849
|
-
const localHints = hintsOverride === "none" ? [] : hintsOverride !== void 0 ? [HINT_TEXT[hintsOverride]] : defaultHints;
|
|
850
|
-
const hintsParts = [
|
|
851
|
-
...hintsHidden ? [] : localHints,
|
|
852
|
-
VIEW_HINTS.HELP,
|
|
853
|
-
canGoBack ? VIEW_HINTS.GO_BACK : VIEW_HINTS.CLOSE
|
|
854
|
-
];
|
|
855
|
-
const hints = hintsHidden ? hintsParts.filter(Boolean).join(" \xB7 ") : searchMode ? VIEW_HINTS.SEARCH_MODE_DEFAULT : hintsParts.filter(Boolean).join(" \xB7 ");
|
|
856
|
-
const showSearch = searchable && (searchMode || searchText);
|
|
857
|
-
const showTopHints = hints && hintsPosition === "top";
|
|
858
|
-
const showBottomHints = hints && hintsPosition === "bottom";
|
|
859
|
-
useEffect6(() => {
|
|
860
|
-
onSearchModeChange?.(searchMode);
|
|
861
|
-
}, [onSearchModeChange, searchMode]);
|
|
862
|
-
useShortcutBlocker(searchMode);
|
|
863
|
-
useEscHandler(() => {
|
|
864
|
-
if (!searchable) return false;
|
|
865
|
-
if (searchMode) {
|
|
866
|
-
setSearchMode(false);
|
|
867
|
-
setSearchText("");
|
|
868
|
-
if (onSearch && searchText) onSearch("");
|
|
869
|
-
return true;
|
|
870
|
-
}
|
|
871
|
-
if (searchText) {
|
|
872
|
-
setSearchText("");
|
|
873
|
-
onSearch?.("");
|
|
874
|
-
return true;
|
|
875
|
-
}
|
|
876
|
-
return false;
|
|
877
|
-
});
|
|
878
|
-
useInput4((input, key) => {
|
|
879
|
-
if (!searchable) return;
|
|
880
|
-
if (searchMode) {
|
|
881
|
-
if (key.return) {
|
|
882
|
-
setSearchMode(false);
|
|
883
|
-
onSearch?.(searchText);
|
|
884
|
-
return;
|
|
885
|
-
}
|
|
886
|
-
if (key.backspace || key.delete) {
|
|
887
|
-
setSearchText((current) => current.slice(0, -1));
|
|
888
|
-
return;
|
|
889
|
-
}
|
|
890
|
-
if (input && !key.ctrl && !key.meta && !key.escape) {
|
|
891
|
-
setSearchText((current) => current + input);
|
|
892
|
-
}
|
|
893
|
-
return;
|
|
894
|
-
}
|
|
895
|
-
if (input === "/") setSearchMode(true);
|
|
896
|
-
});
|
|
897
|
-
return /* @__PURE__ */ jsxs4(Box5, { flexDirection: "column", children: [
|
|
898
|
-
title && /* @__PURE__ */ jsx9(Box5, { marginBottom: 1, children: /* @__PURE__ */ jsx9(Text4, { bold: true, children: title }) }),
|
|
899
|
-
showTopHints && /* @__PURE__ */ jsx9(Box5, { marginBottom: 1, children: /* @__PURE__ */ jsx9(Text4, { dimColor: true, children: hints }) }),
|
|
900
|
-
showSearch && /* @__PURE__ */ jsx9(Box5, { marginBottom: 1, children: /* @__PURE__ */ jsx9(Text4, { children: `Search: ${searchText}${searchMode ? "\u2588" : ""}` }) }),
|
|
901
|
-
/* @__PURE__ */ jsx9(Box5, { flexDirection: "column", children }),
|
|
902
|
-
showBottomHints && /* @__PURE__ */ jsx9(Box5, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text4, { dimColor: true, children: hints }) })
|
|
903
|
-
] });
|
|
904
|
-
};
|
|
905
|
-
|
|
906
|
-
// src/app/views/logout/Logout.tsx
|
|
907
|
-
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
908
|
-
var Logout = () => {
|
|
909
|
-
const { exit } = useApp2();
|
|
910
|
-
const [error, setError] = useState6(null);
|
|
911
|
-
useEffect7(() => {
|
|
912
|
-
let cleared;
|
|
913
|
-
try {
|
|
914
|
-
({ cleared } = logout());
|
|
915
|
-
} catch (err) {
|
|
916
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
917
|
-
return;
|
|
918
|
-
}
|
|
919
|
-
process.stdout.write(cleared ? "Logged out.\n" : "Already logged out.\n");
|
|
920
|
-
exit();
|
|
921
|
-
}, [exit]);
|
|
922
|
-
return /* @__PURE__ */ jsx10(ViewLayout, { title: "Logout", hintsHidden: true, children: error && /* @__PURE__ */ jsx10(StatusMessage, { variant: "error", children: `Error: ${error}` }) });
|
|
923
|
-
};
|
|
924
|
-
|
|
925
|
-
// src/app/hooks/useIsUserToken.ts
|
|
926
|
-
var useIsUserToken = () => {
|
|
927
|
-
const { auth } = useNavigatorSession();
|
|
928
|
-
const needsIdentity = auth.kind === "ready" && !auth.isUserToken;
|
|
929
|
-
const query = useFeatureQuery(
|
|
930
|
-
async () => needsIdentity ? (await getIdentity()).tokenType : null,
|
|
931
|
-
[needsIdentity, auth.token]
|
|
932
|
-
);
|
|
933
|
-
return auth.isUserToken || query.data === "user";
|
|
934
|
-
};
|
|
935
|
-
|
|
936
|
-
// src/features/tui/components/MenuList/MenuList.tsx
|
|
937
|
-
import { useNavigate as useNavigate3 } from "react-router";
|
|
938
|
-
|
|
939
|
-
// src/features/tui/components/VirtualizedList/VirtualizedList.tsx
|
|
940
|
-
import { Box as Box6, Text as Text5, useInput as useInput5, useStdout } from "ink";
|
|
941
|
-
import { useRef as useRef3, useState as useState7 } from "react";
|
|
942
|
-
|
|
943
|
-
// src/features/tui/components/VirtualizedList/VirtualizedList.constants.ts
|
|
944
|
-
var DEFAULT_RESERVED_TERMINAL_ROWS = 13;
|
|
945
|
-
var MIN_VIEWPORT_ROWS = 3;
|
|
946
|
-
var FALLBACK_TERMINAL_ROWS = 24;
|
|
947
|
-
|
|
948
|
-
// src/features/tui/components/VirtualizedList/VirtualizedList.utils.ts
|
|
949
|
-
var getVirtualizedListRange = ({
|
|
950
|
-
itemCount,
|
|
951
|
-
activeIndex,
|
|
952
|
-
viewportSize,
|
|
953
|
-
previousStart = 0
|
|
954
|
-
}) => {
|
|
955
|
-
const maxStart = Math.max(0, itemCount - viewportSize);
|
|
956
|
-
let start = Math.min(previousStart, maxStart);
|
|
957
|
-
if (activeIndex < start) start = activeIndex;
|
|
958
|
-
else if (activeIndex >= start + viewportSize) start = activeIndex - viewportSize + 1;
|
|
959
|
-
start = Math.max(0, Math.min(start, maxStart));
|
|
960
|
-
const end = Math.min(itemCount, start + viewportSize);
|
|
961
|
-
return {
|
|
962
|
-
start,
|
|
963
|
-
end,
|
|
964
|
-
hiddenAbove: start,
|
|
965
|
-
hiddenBelow: itemCount - end
|
|
966
|
-
};
|
|
967
|
-
};
|
|
968
|
-
|
|
969
|
-
// src/features/tui/components/VirtualizedList/VirtualizedList.tsx
|
|
970
|
-
import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
971
|
-
var VirtualizedList = ({
|
|
972
|
-
items,
|
|
973
|
-
initialSelectedIndex = 0,
|
|
974
|
-
getKey,
|
|
975
|
-
renderItem,
|
|
976
|
-
onSelect,
|
|
977
|
-
reservedTerminalRows = DEFAULT_RESERVED_TERMINAL_ROWS,
|
|
978
|
-
navigationDisabled = false
|
|
979
|
-
}) => {
|
|
980
|
-
const [internalIndex, setInternalIndex] = useState7(initialSelectedIndex);
|
|
981
|
-
const activeIndex = internalIndex;
|
|
982
|
-
useInput5((_input, key) => {
|
|
983
|
-
if (navigationDisabled) return;
|
|
984
|
-
if (key.upArrow) {
|
|
985
|
-
setInternalIndex((index) => Math.max(0, index - 1));
|
|
986
|
-
} else if (key.downArrow) {
|
|
987
|
-
setInternalIndex((index) => Math.min(Math.max(0, items.length - 1), index + 1));
|
|
988
|
-
} else if (key.return && onSelect) {
|
|
989
|
-
const item = items[activeIndex];
|
|
990
|
-
if (item) onSelect(item, activeIndex);
|
|
991
|
-
}
|
|
992
|
-
});
|
|
993
|
-
const { stdout } = useStdout();
|
|
994
|
-
const terminalRows = stdout?.rows ?? FALLBACK_TERMINAL_ROWS;
|
|
995
|
-
const viewportSize = Math.max(
|
|
996
|
-
MIN_VIEWPORT_ROWS,
|
|
997
|
-
Math.min(items.length, terminalRows - reservedTerminalRows)
|
|
998
|
-
);
|
|
999
|
-
const startRef = useRef3(0);
|
|
1000
|
-
const { start, end, hiddenAbove, hiddenBelow } = getVirtualizedListRange({
|
|
1001
|
-
itemCount: items.length,
|
|
1002
|
-
activeIndex,
|
|
1003
|
-
viewportSize,
|
|
1004
|
-
previousStart: startRef.current
|
|
1005
|
-
});
|
|
1006
|
-
startRef.current = start;
|
|
1007
|
-
const visibleItems = items.slice(start, end);
|
|
1008
|
-
return /* @__PURE__ */ jsxs5(Box6, { flexDirection: "column", children: [
|
|
1009
|
-
hiddenAbove > 0 && /* @__PURE__ */ jsx11(Text5, { dimColor: true, children: ` \u2191 ${hiddenAbove} more` }, "virtualized-list-hidden-above"),
|
|
1010
|
-
visibleItems.map((item, offset) => {
|
|
1011
|
-
const index = start + offset;
|
|
1012
|
-
return /* @__PURE__ */ jsx11(Box6, { children: renderItem(item, index, index === activeIndex) }, getKey(item, index));
|
|
1013
|
-
}),
|
|
1014
|
-
hiddenBelow > 0 && /* @__PURE__ */ jsx11(Text5, { dimColor: true, children: ` \u2193 ${hiddenBelow} more` }, "virtualized-list-hidden-below")
|
|
1015
|
-
] });
|
|
1016
|
-
};
|
|
1017
|
-
|
|
1018
|
-
// src/features/tui/components/MenuList/MenuListItem.tsx
|
|
1019
|
-
import { Box as Box7, Text as Text8 } from "ink";
|
|
1020
|
-
|
|
1021
|
-
// src/features/tui/components/SelectableOption/SelectableOption.tsx
|
|
1022
|
-
import { Text as Text7 } from "ink";
|
|
1023
|
-
|
|
1024
|
-
// src/features/tui/components/SelectableOption/SelectableOption.utils.ts
|
|
1025
|
-
var SELECTION_PREFIX = "\u25BA ";
|
|
1026
|
-
var SELECTION_PREFIX_EMPTY = " ";
|
|
1027
|
-
var getSelectableColors = (selected, theme2) => ({
|
|
1028
|
-
color: selected ? "white" : void 0,
|
|
1029
|
-
backgroundColor: selected ? theme2.colors.primary : void 0
|
|
1030
|
-
});
|
|
1031
|
-
|
|
1032
|
-
// src/features/tui/components/SelectableOption/SelectionPrefix.tsx
|
|
1033
|
-
import { Text as Text6 } from "ink";
|
|
1034
|
-
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1035
|
-
var SelectionPrefix = ({ selected }) => {
|
|
1036
|
-
const { theme: theme2 } = useTheme();
|
|
1037
|
-
const { color, backgroundColor } = getSelectableColors(selected, theme2);
|
|
1038
|
-
return /* @__PURE__ */ jsx12(Text6, { color, backgroundColor, children: selected ? SELECTION_PREFIX : SELECTION_PREFIX_EMPTY });
|
|
1039
|
-
};
|
|
1040
|
-
|
|
1041
|
-
// src/features/tui/components/SelectableOption/SelectableOption.tsx
|
|
1042
|
-
import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1043
|
-
var SelectableOption = ({ selected, children }) => {
|
|
1044
|
-
const { theme: theme2 } = useTheme();
|
|
1045
|
-
const { color, backgroundColor } = getSelectableColors(selected, theme2);
|
|
1046
|
-
if (typeof children === "function") {
|
|
1047
|
-
return /* @__PURE__ */ jsx13(Fragment2, { children: children({ selected, color, backgroundColor }) });
|
|
1048
|
-
}
|
|
1049
|
-
return /* @__PURE__ */ jsxs6(Text7, { color, backgroundColor, children: [
|
|
1050
|
-
/* @__PURE__ */ jsx13(SelectionPrefix, { selected }),
|
|
1051
|
-
children
|
|
1052
|
-
] });
|
|
1053
|
-
};
|
|
1054
|
-
|
|
1055
|
-
// src/features/tui/components/MenuList/MenuListItem.tsx
|
|
1056
|
-
import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1057
|
-
var MenuListItem = ({ item, selected }) => /* @__PURE__ */ jsxs7(Box7, { children: [
|
|
1058
|
-
SelectableOption({ selected, children: item.label }),
|
|
1059
|
-
item.description && selected && /* @__PURE__ */ jsx14(Text8, { dimColor: true, children: ` \u2014 ${item.description}` })
|
|
1060
|
-
] });
|
|
1061
|
-
|
|
1062
|
-
// src/features/tui/components/MenuList/MenuList.tsx
|
|
1063
|
-
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1064
|
-
var MenuList = ({ options, onSelect }) => {
|
|
1065
|
-
const navigate = useNavigate3();
|
|
1066
|
-
const handleSelectItem = (item) => {
|
|
1067
|
-
if (item.to) {
|
|
1068
|
-
navigate(item.to, { state: item.state });
|
|
1069
|
-
return;
|
|
1070
|
-
}
|
|
1071
|
-
onSelect?.(item);
|
|
1072
|
-
};
|
|
1073
|
-
useShortcutHandler(({ input }) => {
|
|
1074
|
-
const item = options.find((option) => option.shortcut === input);
|
|
1075
|
-
if (!item) return false;
|
|
1076
|
-
handleSelectItem(item);
|
|
1077
|
-
return true;
|
|
1078
|
-
});
|
|
1079
|
-
return /* @__PURE__ */ jsx15(
|
|
1080
|
-
VirtualizedList,
|
|
1081
|
-
{
|
|
1082
|
-
items: options,
|
|
1083
|
-
getKey: (item) => item.key ?? item.to ?? item.label,
|
|
1084
|
-
renderItem: (item, _index, selected) => /* @__PURE__ */ jsx15(MenuListItem, { item, selected }),
|
|
1085
|
-
onSelect: handleSelectItem
|
|
1086
|
-
}
|
|
1087
|
-
);
|
|
1088
|
-
};
|
|
1089
|
-
|
|
1090
|
-
// src/app/views/MainMenu.tsx
|
|
1091
|
-
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1092
|
-
var MainMenu = () => {
|
|
1093
|
-
const isUserToken = useIsUserToken();
|
|
1094
|
-
const canSwitchProject = !hasProjectConfigFile();
|
|
1095
|
-
const options = [
|
|
1096
|
-
{ label: "Tests", shortcut: "t", description: "Run, list, import tests", to: "/tests" },
|
|
1097
|
-
{
|
|
1098
|
-
label: "Test runs",
|
|
1099
|
-
shortcut: "r",
|
|
1100
|
-
description: "Browse recent test runs",
|
|
1101
|
-
to: ROUTES.testRuns.root()
|
|
1102
|
-
},
|
|
1103
|
-
{
|
|
1104
|
-
label: "Suites",
|
|
1105
|
-
shortcut: "s",
|
|
1106
|
-
description: "Run and list test suites",
|
|
1107
|
-
to: "/suites"
|
|
1108
|
-
},
|
|
1109
|
-
{
|
|
1110
|
-
label: "Suite runs",
|
|
1111
|
-
shortcut: "u",
|
|
1112
|
-
description: "Browse recent suite runs",
|
|
1113
|
-
to: ROUTES.suiteRuns.root()
|
|
1114
|
-
},
|
|
1115
|
-
{
|
|
1116
|
-
label: "Profiles",
|
|
1117
|
-
shortcut: "f",
|
|
1118
|
-
description: "Manage profiles",
|
|
1119
|
-
to: "/profiles"
|
|
1120
|
-
},
|
|
1121
|
-
{
|
|
1122
|
-
label: "Current project",
|
|
1123
|
-
shortcut: "p",
|
|
1124
|
-
description: "Import or export current project",
|
|
1125
|
-
to: "/project"
|
|
1126
|
-
},
|
|
1127
|
-
...canSwitchProject ? [
|
|
1128
|
-
{
|
|
1129
|
-
label: "Switch project",
|
|
1130
|
-
shortcut: "w",
|
|
1131
|
-
description: "Pick another project for this session",
|
|
1132
|
-
to: "/project/switch"
|
|
1133
|
-
}
|
|
1134
|
-
] : [],
|
|
1135
|
-
...isUserToken ? [
|
|
1136
|
-
{
|
|
1137
|
-
label: "Logout",
|
|
1138
|
-
shortcut: "l",
|
|
1139
|
-
description: "Clear the current CLI session",
|
|
1140
|
-
to: "/logout"
|
|
1141
|
-
}
|
|
1142
|
-
] : []
|
|
1143
|
-
];
|
|
1144
|
-
return /* @__PURE__ */ jsx16(ViewLayout, { children: /* @__PURE__ */ jsx16(MenuList, { options }) });
|
|
1145
|
-
};
|
|
1146
|
-
|
|
1147
|
-
// src/app/hooks/useProfiles.ts
|
|
1148
|
-
var useProfilesList = () => useFeatureQuery(() => listProfiles(), []);
|
|
1149
|
-
|
|
1150
|
-
// src/features/profiles/profiles.utils.ts
|
|
1151
|
-
var profileColumns = [
|
|
1152
|
-
{ key: "name", label: "Name", width: 36 },
|
|
1153
|
-
{ key: "default", label: "Default", width: 10 }
|
|
1154
|
-
];
|
|
1155
|
-
var getProfileRow = (profile) => ({
|
|
1156
|
-
key: profile.id,
|
|
1157
|
-
cells: {
|
|
1158
|
-
name: profile.name,
|
|
1159
|
-
default: profile.isDefault ? "yes" : "no"
|
|
1160
|
-
},
|
|
1161
|
-
value: profile
|
|
1162
|
-
});
|
|
1163
|
-
|
|
1164
|
-
// src/features/tui/components/BaseResourceListScreen/BaseResourceListScreen.tsx
|
|
1165
|
-
import { Spinner, StatusMessage as StatusMessage2 } from "@inkjs/ui";
|
|
1166
|
-
import { Box as Box10 } from "ink";
|
|
1167
|
-
import { useState as useState8 } from "react";
|
|
1168
|
-
|
|
1169
|
-
// src/features/tui/components/TableList/TableList.tsx
|
|
1170
|
-
import { Box as Box9, Text as Text10 } from "ink";
|
|
1171
|
-
|
|
1172
|
-
// src/features/tui/components/TableList/TableList.utils.ts
|
|
1173
|
-
var fitCell = (value, width) => {
|
|
1174
|
-
const text = value === null || value === void 0 || value === "" ? "-" : String(value);
|
|
1175
|
-
const visible = text.length > width ? `${text.slice(0, Math.max(0, width - 1))}\u2026` : text;
|
|
1176
|
-
return visible.padEnd(width, " ");
|
|
1177
|
-
};
|
|
1178
|
-
|
|
1179
|
-
// src/features/tui/components/TableList/TableListRow.tsx
|
|
1180
|
-
import { Box as Box8, Text as Text9 } from "ink";
|
|
1181
|
-
import { jsx as jsx17, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1182
|
-
var TableListRow = ({
|
|
1183
|
-
columns,
|
|
1184
|
-
row,
|
|
1185
|
-
selected
|
|
1186
|
-
}) => /* @__PURE__ */ jsx17(SelectableOption, { selected, children: ({ color, backgroundColor }) => /* @__PURE__ */ jsxs8(Box8, { children: [
|
|
1187
|
-
/* @__PURE__ */ jsx17(SelectionPrefix, { selected }),
|
|
1188
|
-
columns.map((column, i) => {
|
|
1189
|
-
const sep = i === 0 ? "" : " ";
|
|
1190
|
-
const cell = row.cells[column.key];
|
|
1191
|
-
if (column.render) {
|
|
1192
|
-
return /* @__PURE__ */ jsxs8(Box8, { children: [
|
|
1193
|
-
sep ? /* @__PURE__ */ jsx17(Text9, { backgroundColor, children: sep }) : null,
|
|
1194
|
-
/* @__PURE__ */ jsx17(Box8, { width: column.width, children: column.render(cell, row, {
|
|
1195
|
-
selected,
|
|
1196
|
-
width: column.width,
|
|
1197
|
-
color,
|
|
1198
|
-
backgroundColor
|
|
1199
|
-
}) })
|
|
1200
|
-
] }, column.key);
|
|
1201
|
-
}
|
|
1202
|
-
return /* @__PURE__ */ jsxs8(Text9, { color, backgroundColor, children: [
|
|
1203
|
-
sep,
|
|
1204
|
-
fitCell(cell, column.width)
|
|
1205
|
-
] }, column.key);
|
|
1206
|
-
})
|
|
1207
|
-
] }) });
|
|
1208
|
-
|
|
1209
|
-
// src/features/tui/components/TableList/TableList.tsx
|
|
1210
|
-
import { jsx as jsx18, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1211
|
-
var TableList = ({
|
|
1212
|
-
columns,
|
|
1213
|
-
rows,
|
|
1214
|
-
navigationDisabled = false,
|
|
1215
|
-
onSelect
|
|
1216
|
-
}) => /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", children: [
|
|
1217
|
-
/* @__PURE__ */ jsx18(Box9, { children: /* @__PURE__ */ jsxs9(Text10, { dimColor: true, children: [
|
|
1218
|
-
" ",
|
|
1219
|
-
columns.map((column) => fitCell(column.label, column.width)).join(" ")
|
|
1220
|
-
] }) }),
|
|
1221
|
-
/* @__PURE__ */ jsx18(
|
|
1222
|
-
VirtualizedList,
|
|
1223
|
-
{
|
|
1224
|
-
items: rows,
|
|
1225
|
-
reservedTerminalRows: DEFAULT_RESERVED_TERMINAL_ROWS + 1,
|
|
1226
|
-
navigationDisabled,
|
|
1227
|
-
getKey: (row) => row.key,
|
|
1228
|
-
renderItem: (row, _rowIndex, selected) => /* @__PURE__ */ jsx18(TableListRow, { columns, row, selected: !navigationDisabled && selected }),
|
|
1229
|
-
onSelect: (row) => onSelect?.(row)
|
|
1230
|
-
}
|
|
1231
|
-
)
|
|
1232
|
-
] });
|
|
1233
|
-
|
|
1234
|
-
// src/features/tui/components/BaseResourceListScreen/BaseResourceListScreen.tsx
|
|
1235
|
-
import { jsx as jsx19, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1236
|
-
var BaseResourceListScreen = ({
|
|
1237
|
-
title,
|
|
1238
|
-
loadingLabel,
|
|
1239
|
-
emptyMessage,
|
|
1240
|
-
resources,
|
|
1241
|
-
isLoading,
|
|
1242
|
-
isError,
|
|
1243
|
-
error,
|
|
1244
|
-
columns,
|
|
1245
|
-
getRow,
|
|
1246
|
-
searchable,
|
|
1247
|
-
query = "",
|
|
1248
|
-
onSearch,
|
|
1249
|
-
onSelectResource
|
|
1250
|
-
}) => {
|
|
1251
|
-
const rows = resources ?? [];
|
|
1252
|
-
const [searchMode, setSearchMode] = useState8(false);
|
|
1253
|
-
const handleSelect = (row) => {
|
|
1254
|
-
if (row.value !== void 0 && onSelectResource) onSelectResource(row.value);
|
|
1255
|
-
};
|
|
1256
|
-
return /* @__PURE__ */ jsxs10(
|
|
1257
|
-
ViewLayout,
|
|
1258
|
-
{
|
|
1259
|
-
title: query ? `Search: "${query}"` : title,
|
|
1260
|
-
searchable,
|
|
1261
|
-
onSearch,
|
|
1262
|
-
onSearchModeChange: setSearchMode,
|
|
1263
|
-
children: [
|
|
1264
|
-
isLoading && /* @__PURE__ */ jsx19(Box10, { children: /* @__PURE__ */ jsx19(Spinner, { label: loadingLabel }) }),
|
|
1265
|
-
isError && /* @__PURE__ */ jsx19(StatusMessage2, { variant: "error", children: error }),
|
|
1266
|
-
!isLoading && !isError && rows.length === 0 && !query && /* @__PURE__ */ jsx19(StatusMessage2, { variant: "warning", children: emptyMessage }),
|
|
1267
|
-
!isLoading && !isError && (rows.length > 0 || query) && /* @__PURE__ */ jsx19(
|
|
1268
|
-
TableList,
|
|
1269
|
-
{
|
|
1270
|
-
columns,
|
|
1271
|
-
rows: rows.map(getRow),
|
|
1272
|
-
navigationDisabled: searchMode,
|
|
1273
|
-
onSelect: handleSelect
|
|
1274
|
-
}
|
|
1275
|
-
)
|
|
1276
|
-
]
|
|
1277
|
-
}
|
|
1278
|
-
);
|
|
1279
|
-
};
|
|
1280
|
-
|
|
1281
|
-
// src/app/views/profiles/ProfilesList.tsx
|
|
1282
|
-
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1283
|
-
var ProfilesList = () => {
|
|
1284
|
-
const request = useProfilesList();
|
|
1285
|
-
return /* @__PURE__ */ jsx20(
|
|
1286
|
-
BaseResourceListScreen,
|
|
1287
|
-
{
|
|
1288
|
-
title: "Profiles",
|
|
1289
|
-
loadingLabel: "Loading profiles...",
|
|
1290
|
-
emptyMessage: "No profiles found",
|
|
1291
|
-
resources: request.data,
|
|
1292
|
-
isLoading: request.isLoading,
|
|
1293
|
-
isError: request.isError,
|
|
1294
|
-
error: request.error,
|
|
1295
|
-
columns: profileColumns,
|
|
1296
|
-
getRow: getProfileRow
|
|
1297
|
-
}
|
|
1298
|
-
);
|
|
1299
|
-
};
|
|
1300
|
-
|
|
1301
|
-
// src/app/views/profiles/ProfilesMenu.tsx
|
|
1302
|
-
import { Spinner as Spinner2 } from "@inkjs/ui";
|
|
1303
|
-
import { useEffect as useEffect8 } from "react";
|
|
1304
|
-
import { useNavigate as useNavigate4 } from "react-router";
|
|
1305
|
-
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
1306
|
-
var ProfilesMenu = () => {
|
|
1307
|
-
const navigate = useNavigate4();
|
|
1308
|
-
useEffect8(() => {
|
|
1309
|
-
navigate("/profiles/list", { replace: true });
|
|
1310
|
-
}, [navigate]);
|
|
1311
|
-
return /* @__PURE__ */ jsx21(Spinner2, { label: "Loading..." });
|
|
1312
|
-
};
|
|
1313
|
-
|
|
1314
|
-
// src/app/views/project/ProjectExport.tsx
|
|
1315
|
-
import { Spinner as Spinner3, StatusMessage as StatusMessage3 } from "@inkjs/ui";
|
|
1316
|
-
import { useEffect as useEffect9, useState as useState10 } from "react";
|
|
1317
|
-
|
|
1318
|
-
// src/app/hooks/useFeatureMutation.ts
|
|
1319
|
-
import { useCallback as useCallback3, useRef as useRef4, useState as useState9 } from "react";
|
|
1320
|
-
var useFeatureMutation = (fn) => {
|
|
1321
|
-
const fnRef = useRef4(fn);
|
|
1322
|
-
const activeMutationRef = useRef4(0);
|
|
1323
|
-
const [state, setState] = useState9({
|
|
1324
|
-
data: void 0,
|
|
1325
|
-
error: void 0,
|
|
1326
|
-
status: "idle"
|
|
1327
|
-
});
|
|
1328
|
-
fnRef.current = fn;
|
|
1329
|
-
const trigger = useCallback3(async (arg) => {
|
|
1330
|
-
const mutationId = activeMutationRef.current + 1;
|
|
1331
|
-
activeMutationRef.current = mutationId;
|
|
1332
|
-
setState({
|
|
1333
|
-
data: void 0,
|
|
1334
|
-
error: void 0,
|
|
1335
|
-
status: "pending"
|
|
1336
|
-
});
|
|
1337
|
-
try {
|
|
1338
|
-
const data = await fnRef.current(arg);
|
|
1339
|
-
if (activeMutationRef.current === mutationId) {
|
|
1340
|
-
setState({ data, error: void 0, status: "fulfilled" });
|
|
1341
|
-
}
|
|
1342
|
-
return { data };
|
|
1343
|
-
} catch (err) {
|
|
1344
|
-
const error = formatErrorMessage(err);
|
|
1345
|
-
if (activeMutationRef.current === mutationId) {
|
|
1346
|
-
setState({ data: void 0, error, status: "rejected" });
|
|
1347
|
-
}
|
|
1348
|
-
return { error };
|
|
1349
|
-
}
|
|
1350
|
-
}, []);
|
|
1351
|
-
return [
|
|
1352
|
-
trigger,
|
|
1353
|
-
{
|
|
1354
|
-
data: state.data,
|
|
1355
|
-
error: state.error,
|
|
1356
|
-
isLoading: state.status === "pending",
|
|
1357
|
-
isSuccess: state.status === "fulfilled",
|
|
1358
|
-
isError: state.status === "rejected"
|
|
1359
|
-
}
|
|
1360
|
-
];
|
|
1361
|
-
};
|
|
1362
|
-
|
|
1363
|
-
// src/features/tui/components/TextInput/TextInput.tsx
|
|
1364
|
-
import { Box as Box11, Text as Text11 } from "ink";
|
|
1365
|
-
import InkTextInput from "ink-text-input";
|
|
1366
|
-
import { jsx as jsx22, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1367
|
-
var TextInput = (props) => {
|
|
1368
|
-
useShortcutBlocker();
|
|
1369
|
-
return /* @__PURE__ */ jsxs11(Box11, { children: [
|
|
1370
|
-
/* @__PURE__ */ jsx22(Text11, { color: "cyan", children: "\u203A " }),
|
|
1371
|
-
/* @__PURE__ */ jsx22(InkTextInput, { ...props })
|
|
1372
|
-
] });
|
|
1373
|
-
};
|
|
1374
|
-
|
|
1375
|
-
// src/app/views/project/ProjectExport.tsx
|
|
1376
|
-
import { jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1377
|
-
var ProjectExport = () => {
|
|
1378
|
-
const [outputValue, setOutputValue] = useState10("");
|
|
1379
|
-
const [output, setOutput] = useState10(null);
|
|
1380
|
-
const [exportProjectMutation, exportProjectResult] = useFeatureMutation(
|
|
1381
|
-
(outputPath) => exportProject(outputPath || void 0)
|
|
1382
|
-
);
|
|
1383
|
-
useEffect9(() => {
|
|
1384
|
-
if (output !== null) void exportProjectMutation(output);
|
|
1385
|
-
}, [exportProjectMutation, output]);
|
|
1386
|
-
if (output === null) {
|
|
1387
|
-
return /* @__PURE__ */ jsx23(ViewLayout, { title: "Output file (blank = auto)", hints: "confirm", hintsPosition: "bottom", children: /* @__PURE__ */ jsx23(TextInput, { value: outputValue, onChange: setOutputValue, onSubmit: setOutput }) });
|
|
1388
|
-
}
|
|
1389
|
-
return /* @__PURE__ */ jsxs12(ViewLayout, { hintsHidden: true, children: [
|
|
1390
|
-
exportProjectResult.isLoading && /* @__PURE__ */ jsx23(Spinner3, { label: "Exporting project..." }),
|
|
1391
|
-
exportProjectResult.isError && /* @__PURE__ */ jsx23(StatusMessage3, { variant: "error", children: exportProjectResult.error }),
|
|
1392
|
-
exportProjectResult.data && /* @__PURE__ */ jsx23(StatusMessage3, { variant: "success", children: `Exported project to ${exportProjectResult.data.outPath} (${exportProjectResult.data.size} bytes)` })
|
|
1393
|
-
] });
|
|
1394
|
-
};
|
|
1395
|
-
|
|
1396
|
-
// src/app/views/project/ProjectImport.tsx
|
|
1397
|
-
import { Spinner as Spinner4, StatusMessage as StatusMessage4 } from "@inkjs/ui";
|
|
1398
|
-
import { useEffect as useEffect10, useState as useState12 } from "react";
|
|
1399
|
-
import { useNavigate as useNavigate5 } from "react-router";
|
|
1400
|
-
|
|
1401
|
-
// src/features/tui/components/FilePicker/FilePicker.tsx
|
|
1402
|
-
import { readdirSync } from "fs";
|
|
1403
|
-
import { dirname, join, resolve } from "path";
|
|
1404
|
-
import { Box as Box12, Text as Text12 } from "ink";
|
|
1405
|
-
import { useMemo, useState as useState11 } from "react";
|
|
1406
|
-
|
|
1407
|
-
// src/utils/filePicker.ts
|
|
1408
|
-
import { extname } from "path";
|
|
1409
|
-
var toFilePickerItems = (entries, allowedExtensions) => {
|
|
1410
|
-
const normalizedExtensions = new Set(
|
|
1411
|
-
allowedExtensions.map((extension) => extension.toLowerCase())
|
|
1412
|
-
);
|
|
1413
|
-
return entries.filter((entry) => {
|
|
1414
|
-
if (entry.isDirectory()) return true;
|
|
1415
|
-
return normalizedExtensions.has(extname(entry.name).toLowerCase());
|
|
1416
|
-
}).map((entry) => {
|
|
1417
|
-
const type = entry.isDirectory() ? "directory" : "file";
|
|
1418
|
-
return {
|
|
1419
|
-
key: `${type === "directory" ? "dir" : "file"}:${entry.name}`,
|
|
1420
|
-
label: type === "directory" ? `${entry.name}/` : entry.name,
|
|
1421
|
-
name: entry.name,
|
|
1422
|
-
type
|
|
1423
|
-
};
|
|
1424
|
-
}).sort((left, right) => {
|
|
1425
|
-
if (left.type !== right.type) return left.type === "directory" ? -1 : 1;
|
|
1426
|
-
return left.name.localeCompare(right.name);
|
|
1427
|
-
});
|
|
1428
|
-
};
|
|
1429
|
-
|
|
1430
|
-
// src/features/tui/components/FilePicker/FilePicker.tsx
|
|
1431
|
-
import { jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1432
|
-
var FilePicker = ({
|
|
1433
|
-
label,
|
|
1434
|
-
extensions,
|
|
1435
|
-
initialDir = userCwd(),
|
|
1436
|
-
onSubmit,
|
|
1437
|
-
onBack
|
|
1438
|
-
}) => {
|
|
1439
|
-
const [currentDir, setCurrentDir] = useState11(() => resolve(userCwd(), initialDir));
|
|
1440
|
-
useEscHandler(() => {
|
|
1441
|
-
onBack();
|
|
1442
|
-
return true;
|
|
1443
|
-
});
|
|
1444
|
-
const { items, error } = useMemo(() => {
|
|
1445
|
-
try {
|
|
1446
|
-
const entries = readdirSync(currentDir, { withFileTypes: true });
|
|
1447
|
-
const pickerItems = toFilePickerItems(entries, extensions);
|
|
1448
|
-
const parent = dirname(currentDir);
|
|
1449
|
-
const allItems = parent === currentDir ? pickerItems : [
|
|
1450
|
-
{
|
|
1451
|
-
key: "dir:..",
|
|
1452
|
-
label: "../",
|
|
1453
|
-
name: "..",
|
|
1454
|
-
type: "directory"
|
|
1455
|
-
},
|
|
1456
|
-
...pickerItems
|
|
1457
|
-
];
|
|
1458
|
-
return { items: allItems, error: null };
|
|
1459
|
-
} catch (err) {
|
|
1460
|
-
return {
|
|
1461
|
-
items: [],
|
|
1462
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1463
|
-
};
|
|
1464
|
-
}
|
|
1465
|
-
}, [currentDir, extensions]);
|
|
1466
|
-
const handleSelect = (item) => {
|
|
1467
|
-
const selected = item.value;
|
|
1468
|
-
if (!selected) return;
|
|
1469
|
-
if (selected.type === "directory") {
|
|
1470
|
-
setCurrentDir((dir) => resolve(dir, selected.name));
|
|
1471
|
-
return;
|
|
1472
|
-
}
|
|
1473
|
-
onSubmit(join(currentDir, selected.name));
|
|
1474
|
-
};
|
|
1475
|
-
return /* @__PURE__ */ jsx24(Box12, { flexDirection: "column", children: /* @__PURE__ */ jsxs13(ViewLayout, { title: `${label}: ${currentDir}`, hints: "navigationOpenSelect", children: [
|
|
1476
|
-
/* @__PURE__ */ jsx24(
|
|
1477
|
-
MenuList,
|
|
1478
|
-
{
|
|
1479
|
-
options: items.map((item) => ({ label: item.label, value: item })),
|
|
1480
|
-
onSelect: handleSelect
|
|
1481
|
-
},
|
|
1482
|
-
currentDir
|
|
1483
|
-
),
|
|
1484
|
-
items.length === 0 && /* @__PURE__ */ jsx24(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx24(Text12, { dimColor: true, children: "No matching files in this directory." }) }),
|
|
1485
|
-
error && /* @__PURE__ */ jsx24(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx24(Text12, { color: "red", children: error }) })
|
|
1486
|
-
] }) });
|
|
1487
|
-
};
|
|
1488
|
-
|
|
1489
|
-
// src/app/views/project/ProjectImport.tsx
|
|
1490
|
-
import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1491
|
-
var ProjectImport = () => {
|
|
1492
|
-
const navigate = useNavigate5();
|
|
1493
|
-
const [file, setFile] = useState12(null);
|
|
1494
|
-
const [importProjectMutation, importProjectResult] = useFeatureMutation(importProject);
|
|
1495
|
-
useEffect10(() => {
|
|
1496
|
-
if (file) importProjectMutation(file);
|
|
1497
|
-
}, [file, importProjectMutation]);
|
|
1498
|
-
if (!file) {
|
|
1499
|
-
return /* @__PURE__ */ jsx25(
|
|
1500
|
-
FilePicker,
|
|
1501
|
-
{
|
|
1502
|
-
label: "Select .zip file",
|
|
1503
|
-
extensions: [".zip"],
|
|
1504
|
-
onSubmit: setFile,
|
|
1505
|
-
onBack: () => navigate(-1)
|
|
1506
|
-
}
|
|
1507
|
-
);
|
|
1508
|
-
}
|
|
1509
|
-
return /* @__PURE__ */ jsxs14(ViewLayout, { hintsHidden: true, children: [
|
|
1510
|
-
importProjectResult.isLoading && /* @__PURE__ */ jsx25(Spinner4, { label: `Importing project from ${file}...` }),
|
|
1511
|
-
importProjectResult.isError && /* @__PURE__ */ jsx25(StatusMessage4, { variant: "error", children: importProjectResult.error }),
|
|
1512
|
-
importProjectResult.data && /* @__PURE__ */ jsx25(StatusMessage4, { variant: "success", children: `Project import started from ${importProjectResult.data.path} (${importProjectResult.data.size} bytes)` })
|
|
1513
|
-
] });
|
|
1514
|
-
};
|
|
1515
|
-
|
|
1516
|
-
// src/app/views/project/ProjectInit.tsx
|
|
1517
|
-
import { useApp as useApp3 } from "ink";
|
|
1518
|
-
import { useEffect as useEffect11, useState as useState14 } from "react";
|
|
1519
|
-
import { useLocation as useLocation4, useNavigate as useNavigate6 } from "react-router";
|
|
1520
|
-
|
|
1521
|
-
// src/app/components/ProjectPicker/ProjectPicker.tsx
|
|
1522
|
-
import { Spinner as Spinner5, StatusMessage as StatusMessage5 } from "@inkjs/ui";
|
|
1523
|
-
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1524
|
-
var ProjectPicker = ({ onSelect, currentProjectId }) => {
|
|
1525
|
-
const projectsQuery = useFeatureQuery(listProjects, []);
|
|
1526
|
-
const projects = projectsQuery.data ?? [];
|
|
1527
|
-
return /* @__PURE__ */ jsxs15(ViewLayout, { title: "Choose BugBug project", hints: "navigationSelect", children: [
|
|
1528
|
-
projectsQuery.isLoading && /* @__PURE__ */ jsx26(Spinner5, { label: "Loading projects..." }),
|
|
1529
|
-
projectsQuery.isError && /* @__PURE__ */ jsx26(StatusMessage5, { variant: "error", children: `Error: ${projectsQuery.error ?? "Unknown error"}` }),
|
|
1530
|
-
!projectsQuery.isLoading && !projectsQuery.isError && projects.length === 0 && /* @__PURE__ */ jsx26(StatusMessage5, { variant: "warning", children: "No projects found" }),
|
|
1531
|
-
!projectsQuery.isLoading && !projectsQuery.isError && projects.length > 0 && /* @__PURE__ */ jsx26(
|
|
1532
|
-
MenuList,
|
|
1533
|
-
{
|
|
1534
|
-
options: projects.map((project) => ({
|
|
1535
|
-
key: project.id,
|
|
1536
|
-
label: project.id === currentProjectId ? ` ${project.name} (current)` : ` ${project.name}`,
|
|
1537
|
-
value: project
|
|
1538
|
-
})),
|
|
1539
|
-
onSelect: (item) => {
|
|
1540
|
-
if (item.value) onSelect(item.value);
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
)
|
|
1544
|
-
] });
|
|
1545
|
-
};
|
|
1546
|
-
|
|
1547
|
-
// src/app/views/project/ProjectInitAuth.tsx
|
|
1548
|
-
import { StatusMessage as StatusMessage6 } from "@inkjs/ui";
|
|
1549
|
-
import { useState as useState13 } from "react";
|
|
1550
|
-
import { jsx as jsx27, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1551
|
-
var ProjectInitAuth = ({
|
|
1552
|
-
onTokenReceive,
|
|
1553
|
-
onTokenError,
|
|
1554
|
-
message
|
|
1555
|
-
}) => {
|
|
1556
|
-
const [method, setMethod] = useState13("choose");
|
|
1557
|
-
const [tokenInput, setTokenInput] = useState13("");
|
|
1558
|
-
const handleLogin = () => {
|
|
1559
|
-
void (async () => {
|
|
1560
|
-
try {
|
|
1561
|
-
const { token } = await login();
|
|
1562
|
-
updateSdkConfig({ apiToken: token });
|
|
1563
|
-
onTokenReceive(token, { isUserToken: true });
|
|
1564
|
-
} catch (err) {
|
|
1565
|
-
onTokenError(err instanceof Error ? err.message : String(err));
|
|
1566
|
-
}
|
|
1567
|
-
})();
|
|
1568
|
-
};
|
|
1569
|
-
const handleTokenSubmit = (value) => {
|
|
1570
|
-
const trimmed = value.trim();
|
|
1571
|
-
if (!trimmed) {
|
|
1572
|
-
onTokenError("Token must not be empty.");
|
|
1573
|
-
return;
|
|
1574
|
-
}
|
|
1575
|
-
try {
|
|
1576
|
-
updateSdkConfig({ apiToken: trimmed });
|
|
1577
|
-
onTokenReceive(trimmed, { isUserToken: false });
|
|
1578
|
-
} catch (err) {
|
|
1579
|
-
onTokenError(err instanceof Error ? err.message : String(err));
|
|
1580
|
-
}
|
|
1581
|
-
};
|
|
1582
|
-
if (method === "token") {
|
|
1583
|
-
return /* @__PURE__ */ jsx27(EscProvider, { onUnhandled: () => setMethod("choose"), children: /* @__PURE__ */ jsxs16(ViewLayout, { title: "BugBug project API token", hints: "confirm", hintsPosition: "bottom", children: [
|
|
1584
|
-
/* @__PURE__ */ jsx27(
|
|
1585
|
-
TextInput,
|
|
1586
|
-
{
|
|
1587
|
-
value: tokenInput,
|
|
1588
|
-
onChange: setTokenInput,
|
|
1589
|
-
onSubmit: handleTokenSubmit,
|
|
1590
|
-
mask: "*"
|
|
1591
|
-
}
|
|
1592
|
-
),
|
|
1593
|
-
message && /* @__PURE__ */ jsx27(StatusMessage6, { variant: "error", children: `Error: ${message}` })
|
|
1594
|
-
] }) });
|
|
1595
|
-
}
|
|
1596
|
-
return /* @__PURE__ */ jsxs16(ViewLayout, { title: "How do you want to authenticate?", hints: "navigationSelect", children: [
|
|
1597
|
-
/* @__PURE__ */ jsx27(
|
|
1598
|
-
MenuList,
|
|
1599
|
-
{
|
|
1600
|
-
options: [
|
|
1601
|
-
{
|
|
1602
|
-
label: "Login using BugBug",
|
|
1603
|
-
description: "Authenticate via BugBug and use your user token",
|
|
1604
|
-
value: "login"
|
|
1605
|
-
},
|
|
1606
|
-
{
|
|
1607
|
-
label: "Set API Token",
|
|
1608
|
-
description: "Paste a project or organization API token",
|
|
1609
|
-
value: "token"
|
|
1610
|
-
}
|
|
1611
|
-
],
|
|
1612
|
-
onSelect: (item) => {
|
|
1613
|
-
if (item.value === "login") handleLogin();
|
|
1614
|
-
else setMethod("token");
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
),
|
|
1618
|
-
message && /* @__PURE__ */ jsx27(StatusMessage6, { variant: "error", children: `Error: ${message}` })
|
|
1619
|
-
] });
|
|
1620
|
-
};
|
|
1621
|
-
|
|
1622
|
-
// src/app/views/project/ProjectInit.tsx
|
|
1623
|
-
import { jsx as jsx28, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1624
|
-
var ProjectInit = () => {
|
|
1625
|
-
const { exit } = useApp3();
|
|
1626
|
-
const navigate = useNavigate6();
|
|
1627
|
-
const location = useLocation4();
|
|
1628
|
-
const state = location.state;
|
|
1629
|
-
const redirectUrl = state?.redirectUrl ?? "/";
|
|
1630
|
-
const onlyThisSession = state?.onlyThisSession ?? false;
|
|
1631
|
-
const ignoreConfiguredAuth = state?.ignoreConfiguredAuth ?? false;
|
|
1632
|
-
const { auth, config, authError, completeSession } = useNavigatorSession();
|
|
1633
|
-
const [token, setToken] = useState14(
|
|
1634
|
-
ignoreConfiguredAuth ? null : auth.token ?? null
|
|
1635
|
-
);
|
|
1636
|
-
const [usingUserToken, setUsingUserToken] = useState14(false);
|
|
1637
|
-
const [error, setError] = useState14(null);
|
|
1638
|
-
useEffect11(() => {
|
|
1639
|
-
if (auth.kind !== "ready" || ignoreConfiguredAuth) return;
|
|
1640
|
-
if (onlyThisSession) {
|
|
1641
|
-
navigate(redirectUrl, { replace: true });
|
|
1642
|
-
}
|
|
1643
|
-
}, [auth.kind, ignoreConfiguredAuth, navigate, redirectUrl, onlyThisSession, exit]);
|
|
1644
|
-
const handleTokenReceive = (newToken, { isUserToken }) => {
|
|
1645
|
-
setError(null);
|
|
1646
|
-
setUsingUserToken(isUserToken);
|
|
1647
|
-
setToken(newToken);
|
|
1648
|
-
};
|
|
1649
|
-
const handleTokenError = (errorMessage) => {
|
|
1650
|
-
setError(errorMessage);
|
|
1651
|
-
};
|
|
1652
|
-
const handleProjectSelectAndFinish = (project) => {
|
|
1653
|
-
if (!token) return;
|
|
1654
|
-
if (usingUserToken) switchProject(project.id, { currentProjectId: config.projectId });
|
|
1655
|
-
const completeProjectSession = () => {
|
|
1656
|
-
if (usingUserToken) completeSession(token, project.id, { isUserToken: true });
|
|
1657
|
-
else completeSession(token, project.id);
|
|
1658
|
-
};
|
|
1659
|
-
if (onlyThisSession) {
|
|
1660
|
-
completeProjectSession();
|
|
1661
|
-
navigate(redirectUrl, { replace: true });
|
|
1662
|
-
return;
|
|
1663
|
-
}
|
|
1664
|
-
(async () => {
|
|
1665
|
-
try {
|
|
1666
|
-
await initProject(token, project.id);
|
|
1667
|
-
completeProjectSession();
|
|
1668
|
-
exit();
|
|
1669
|
-
} catch (err) {
|
|
1670
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
1671
|
-
}
|
|
1672
|
-
})();
|
|
1673
|
-
};
|
|
1674
|
-
const message = error ?? authError;
|
|
1675
|
-
return /* @__PURE__ */ jsxs17(EscProvider, { onUnhandled: exit, children: [
|
|
1676
|
-
!token && /* @__PURE__ */ jsx28(
|
|
1677
|
-
ProjectInitAuth,
|
|
1678
|
-
{
|
|
1679
|
-
onTokenReceive: handleTokenReceive,
|
|
1680
|
-
onTokenError: handleTokenError,
|
|
1681
|
-
message
|
|
1682
|
-
}
|
|
1683
|
-
),
|
|
1684
|
-
token && /* @__PURE__ */ jsx28(ProjectPicker, { onSelect: handleProjectSelectAndFinish, currentProjectId: auth.projectId })
|
|
1685
|
-
] });
|
|
1686
|
-
};
|
|
1687
|
-
|
|
1688
|
-
// src/app/views/project/ProjectMenu.tsx
|
|
1689
|
-
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
1690
|
-
var ProjectMenu = () => {
|
|
1691
|
-
const canSwitchProject = !hasProjectConfigFile();
|
|
1692
|
-
return /* @__PURE__ */ jsx29(ViewLayout, { children: /* @__PURE__ */ jsx29(
|
|
1693
|
-
MenuList,
|
|
1694
|
-
{
|
|
1695
|
-
options: [
|
|
1696
|
-
{ label: "Export project (ZIP)", shortcut: "e", to: "/project/export" },
|
|
1697
|
-
...canSwitchProject ? [{ label: "Import project (ZIP)", shortcut: "i", to: "/project/import" }] : []
|
|
1698
|
-
]
|
|
1699
|
-
}
|
|
1700
|
-
) });
|
|
1701
|
-
};
|
|
1702
|
-
|
|
1703
|
-
// src/app/views/project/ProjectSwitch.tsx
|
|
1704
|
-
import { useNavigate as useNavigate7 } from "react-router";
|
|
1705
|
-
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
1706
|
-
var ProjectSwitch = () => {
|
|
1707
|
-
const navigate = useNavigate7();
|
|
1708
|
-
const { config, setSessionProject } = useNavigatorSession();
|
|
1709
|
-
const handleSelect = (project) => {
|
|
1710
|
-
switchProject(project.id, { currentProjectId: config.projectId });
|
|
1711
|
-
setSessionProject(project.id);
|
|
1712
|
-
navigate("/", { replace: true });
|
|
1713
|
-
};
|
|
1714
|
-
return /* @__PURE__ */ jsx30(ProjectPicker, { onSelect: handleSelect, currentProjectId: config.projectId });
|
|
1715
|
-
};
|
|
1716
|
-
|
|
1717
|
-
// src/app/views/settings/SettingsMenu.tsx
|
|
1718
|
-
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
1719
|
-
var SettingsMenu = () => {
|
|
1720
|
-
const isUserToken = useIsUserToken();
|
|
1721
|
-
const options = [
|
|
1722
|
-
{
|
|
1723
|
-
label: `Set current session token`,
|
|
1724
|
-
shortcut: "t",
|
|
1725
|
-
to: "/settings/setSessionToken"
|
|
1726
|
-
},
|
|
1727
|
-
...isUserToken ? [
|
|
1728
|
-
{
|
|
1729
|
-
label: "Logout",
|
|
1730
|
-
to: "/logout"
|
|
1731
|
-
}
|
|
1732
|
-
] : []
|
|
1733
|
-
];
|
|
1734
|
-
return /* @__PURE__ */ jsx31(ViewLayout, { children: /* @__PURE__ */ jsx31(MenuList, { options }) });
|
|
1735
|
-
};
|
|
1736
|
-
|
|
1737
|
-
// src/app/views/settings/SettingsSetSessionToken.tsx
|
|
1738
|
-
import { StatusMessage as StatusMessage7 } from "@inkjs/ui";
|
|
1739
|
-
import { useState as useState15 } from "react";
|
|
1740
|
-
import { jsx as jsx32, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1741
|
-
var SettingsSetSessionToken = () => {
|
|
1742
|
-
const { auth, completeSession } = useNavigatorSession();
|
|
1743
|
-
const [tokenValue, setTokenValue] = useState15("");
|
|
1744
|
-
const [token, setToken] = useState15(null);
|
|
1745
|
-
const [error, setError] = useState15(null);
|
|
1746
|
-
const [saved, setSaved] = useState15(false);
|
|
1747
|
-
const handleTokenSubmit = (value) => {
|
|
1748
|
-
const trimmed = value.trim();
|
|
1749
|
-
if (!trimmed) {
|
|
1750
|
-
setError("Token must not be empty.");
|
|
1751
|
-
return;
|
|
1752
|
-
}
|
|
1753
|
-
try {
|
|
1754
|
-
updateSdkConfig({ apiToken: trimmed });
|
|
1755
|
-
setError(null);
|
|
1756
|
-
setSaved(false);
|
|
1757
|
-
setToken(trimmed);
|
|
1758
|
-
} catch (err) {
|
|
1759
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
1760
|
-
}
|
|
1761
|
-
};
|
|
1762
|
-
const handleProjectSelect = (project) => {
|
|
1763
|
-
if (!token) return;
|
|
1764
|
-
completeSession(token, project.id);
|
|
1765
|
-
setSaved(true);
|
|
1766
|
-
};
|
|
1767
|
-
if (token === null) {
|
|
1768
|
-
return /* @__PURE__ */ jsxs18(ViewLayout, { title: "Project API token", hints: "confirm", hintsPosition: "bottom", children: [
|
|
1769
|
-
/* @__PURE__ */ jsx32(
|
|
1770
|
-
TextInput,
|
|
1771
|
-
{
|
|
1772
|
-
value: tokenValue,
|
|
1773
|
-
onChange: setTokenValue,
|
|
1774
|
-
onSubmit: handleTokenSubmit,
|
|
1775
|
-
mask: "*"
|
|
1776
|
-
}
|
|
1777
|
-
),
|
|
1778
|
-
error && /* @__PURE__ */ jsx32(StatusMessage7, { variant: "error", children: `Error: ${error}` })
|
|
1779
|
-
] });
|
|
1780
|
-
}
|
|
1781
|
-
if (!saved) {
|
|
1782
|
-
return /* @__PURE__ */ jsx32(ProjectPicker, { onSelect: handleProjectSelect, currentProjectId: auth.projectId });
|
|
1783
|
-
}
|
|
1784
|
-
return /* @__PURE__ */ jsx32(ViewLayout, { hintsHidden: true, children: /* @__PURE__ */ jsx32(StatusMessage7, { variant: "success", children: "Token saved and valid only for this session" }) });
|
|
1785
|
-
};
|
|
1786
|
-
|
|
1787
|
-
// src/app/views/suiteRuns/SuiteRunDetails.tsx
|
|
1788
|
-
import { Spinner as Spinner8, StatusMessage as StatusMessage9 } from "@inkjs/ui";
|
|
1789
|
-
import { Text as Text17 } from "ink";
|
|
1790
|
-
import { useLocation as useLocation5, useParams } from "react-router";
|
|
1791
|
-
|
|
1792
|
-
// src/app/components/BaseSuiteRunDetails/BaseSuiteRunDetails.tsx
|
|
1793
|
-
import { Spinner as Spinner7, StatusMessage as StatusMessage8 } from "@inkjs/ui";
|
|
1794
|
-
import { Box as Box17, useApp as useApp4 } from "ink";
|
|
1795
|
-
import { useEffect as useEffect12, useState as useState16 } from "react";
|
|
1796
|
-
|
|
1797
|
-
// ../core/dist/utils/duration.js
|
|
1798
|
-
var formatDuration = (duration, fallback) => {
|
|
1799
|
-
let totalSeconds = null;
|
|
1800
|
-
if (duration != null && duration !== "") {
|
|
1801
|
-
totalSeconds = typeof duration === "number" ? duration : parseDurationString(duration);
|
|
1802
|
-
}
|
|
1803
|
-
if (totalSeconds == null && fallback?.started && fallback?.ended) {
|
|
1804
|
-
const start = Date.parse(fallback.started);
|
|
1805
|
-
const end = Date.parse(fallback.ended);
|
|
1806
|
-
if (Number.isFinite(start) && Number.isFinite(end) && end >= start) {
|
|
1807
|
-
totalSeconds = (end - start) / 1e3;
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
if (totalSeconds == null || !Number.isFinite(totalSeconds) || totalSeconds < 0) {
|
|
1811
|
-
return "-";
|
|
1812
|
-
}
|
|
1813
|
-
const hours = Math.floor(totalSeconds / 3600);
|
|
1814
|
-
const minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
1815
|
-
const seconds = totalSeconds - hours * 3600 - minutes * 60;
|
|
1816
|
-
const secondsStr = `${seconds.toFixed(2).padStart(5, "0")}s`;
|
|
1817
|
-
if (hours > 0) {
|
|
1818
|
-
return `${String(hours).padStart(2, "0")}h ${String(minutes).padStart(2, "0")}m ${secondsStr}`;
|
|
1819
|
-
}
|
|
1820
|
-
if (minutes > 0) {
|
|
1821
|
-
return `${String(minutes).padStart(2, "0")}m ${secondsStr}`;
|
|
1822
|
-
}
|
|
1823
|
-
return secondsStr;
|
|
1824
|
-
};
|
|
1825
|
-
var parseDurationString = (value) => {
|
|
1826
|
-
const trimmed = value.trim();
|
|
1827
|
-
if (trimmed === "") {
|
|
1828
|
-
return null;
|
|
1829
|
-
}
|
|
1830
|
-
const numeric = Number(trimmed);
|
|
1831
|
-
if (Number.isFinite(numeric)) {
|
|
1832
|
-
return numeric;
|
|
1833
|
-
}
|
|
1834
|
-
const iso = /^P(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/i.exec(trimmed);
|
|
1835
|
-
if (iso) {
|
|
1836
|
-
const days = Number(iso[1] ?? 0);
|
|
1837
|
-
const hours = Number(iso[2] ?? 0);
|
|
1838
|
-
const minutes = Number(iso[3] ?? 0);
|
|
1839
|
-
const seconds = Number(iso[4] ?? 0);
|
|
1840
|
-
return days * 86400 + hours * 3600 + minutes * 60 + seconds;
|
|
1841
|
-
}
|
|
1842
|
-
const hms = /^(?:(\d+):)?(\d{1,2}):(\d{1,2}(?:\.\d+)?)$/.exec(trimmed);
|
|
1843
|
-
if (hms) {
|
|
1844
|
-
const hours = Number(hms[1] ?? 0);
|
|
1845
|
-
const minutes = Number(hms[2]);
|
|
1846
|
-
const seconds = Number(hms[3]);
|
|
1847
|
-
return hours * 3600 + minutes * 60 + seconds;
|
|
1848
|
-
}
|
|
1849
|
-
return null;
|
|
1850
|
-
};
|
|
1851
|
-
|
|
1852
|
-
// src/app/components/RunBody/RunBody.tsx
|
|
1853
|
-
import { Box as Box16, Text as Text16 } from "ink";
|
|
1854
|
-
|
|
1855
|
-
// src/app/components/RunProgress/RunProgress.tsx
|
|
1856
|
-
import { Box as Box13, Text as Text13 } from "ink";
|
|
1857
|
-
|
|
1858
|
-
// src/app/components/RunProgress/RunProgress.constants.ts
|
|
1859
|
-
var BAR_WIDTH = 20;
|
|
1860
|
-
|
|
1861
|
-
// src/app/components/RunProgress/RunProgress.utils.ts
|
|
1862
|
-
var renderBar = (finished, total) => {
|
|
1863
|
-
if (!total) return "";
|
|
1864
|
-
const filled = Math.min(BAR_WIDTH, Math.round(finished / total * BAR_WIDTH));
|
|
1865
|
-
return `[${"\u2588".repeat(filled)}${"\u2591".repeat(BAR_WIDTH - filled)}]`;
|
|
1866
|
-
};
|
|
1867
|
-
|
|
1868
|
-
// src/app/components/RunProgress/RunProgress.tsx
|
|
1869
|
-
import { jsx as jsx33, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1870
|
-
var RunProgress = ({ runState, isRunning }) => {
|
|
1871
|
-
if (!isRunning) return null;
|
|
1872
|
-
const { progress, resultsSummary: summary } = runState;
|
|
1873
|
-
if (progress && progress.total > 0) {
|
|
1874
|
-
const pct = Math.round(progress.finished / progress.total * 100);
|
|
1875
|
-
return /* @__PURE__ */ jsx33(Box13, { marginTop: 1, flexDirection: "column", children: /* @__PURE__ */ jsxs19(Text13, { children: [
|
|
1876
|
-
progress.unit === "steps" ? "Steps" : "Tests",
|
|
1877
|
-
": ",
|
|
1878
|
-
progress.finished,
|
|
1879
|
-
"/",
|
|
1880
|
-
progress.total,
|
|
1881
|
-
" ",
|
|
1882
|
-
renderBar(progress.finished, progress.total),
|
|
1883
|
-
" ",
|
|
1884
|
-
pct,
|
|
1885
|
-
"%"
|
|
1886
|
-
] }) });
|
|
1887
|
-
}
|
|
1888
|
-
if (!summary) return null;
|
|
1889
|
-
const passed = summary.passedSteps ?? 0;
|
|
1890
|
-
const failed = summary.failedSteps ?? 0;
|
|
1891
|
-
const skipped = summary.skippedSteps ?? 0;
|
|
1892
|
-
const total = summary.totalSteps;
|
|
1893
|
-
return /* @__PURE__ */ jsxs19(Box13, { marginTop: 1, flexDirection: "column", children: [
|
|
1894
|
-
/* @__PURE__ */ jsxs19(Text13, { children: [
|
|
1895
|
-
"Progress: ",
|
|
1896
|
-
passed,
|
|
1897
|
-
" passed",
|
|
1898
|
-
failed ? `, ${failed} failed` : "",
|
|
1899
|
-
skipped ? `, ${skipped} skipped` : "",
|
|
1900
|
-
total ? ` / ${total} total` : ""
|
|
1901
|
-
] }),
|
|
1902
|
-
total ? /* @__PURE__ */ jsxs19(Text13, { dimColor: true, children: [
|
|
1903
|
-
"Completion: ",
|
|
1904
|
-
Math.round((passed + failed) / total * 100),
|
|
1905
|
-
"%"
|
|
1906
|
-
] }) : null
|
|
1907
|
-
] });
|
|
1908
|
-
};
|
|
1909
|
-
|
|
1910
|
-
// src/app/components/Status/Status.tsx
|
|
1911
|
-
import { Box as Box15, Text as Text15 } from "ink";
|
|
1912
|
-
|
|
1913
|
-
// src/app/components/StatusIndicator/StatusIndicator.tsx
|
|
1914
|
-
import { Spinner as Spinner6 } from "@inkjs/ui";
|
|
1915
|
-
import { Box as Box14, Text as Text14 } from "ink";
|
|
1916
|
-
|
|
1917
|
-
// src/app/components/StatusIndicator/StatusIndicator.constants.ts
|
|
1918
|
-
var DOT = "\u25CF";
|
|
1919
|
-
|
|
1920
|
-
// src/app/components/StatusIndicator/StatusIndicator.tsx
|
|
1921
|
-
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
1922
|
-
var StatusIndicator = ({ status, autoRetried = false }) => {
|
|
1923
|
-
const { theme: theme2 } = useTheme();
|
|
1924
|
-
if (autoRetried) {
|
|
1925
|
-
return /* @__PURE__ */ jsx34(Text14, { color: theme2.colors.status.failure, children: DOT });
|
|
1926
|
-
}
|
|
1927
|
-
switch (status) {
|
|
1928
|
-
case "running":
|
|
1929
|
-
case "queued":
|
|
1930
|
-
case "recording":
|
|
1931
|
-
case "auto_retrying":
|
|
1932
|
-
return /* @__PURE__ */ jsx34(Box14, { children: /* @__PURE__ */ jsx34(Spinner6, {}) });
|
|
1933
|
-
case "passed":
|
|
1934
|
-
return /* @__PURE__ */ jsx34(Text14, { color: theme2.colors.status.success, children: DOT });
|
|
1935
|
-
case "failed":
|
|
1936
|
-
case "error":
|
|
1937
|
-
return /* @__PURE__ */ jsx34(Text14, { color: theme2.colors.status.failure, children: DOT });
|
|
1938
|
-
case "skipped":
|
|
1939
|
-
case "stopped":
|
|
1940
|
-
return /* @__PURE__ */ jsx34(Text14, { color: theme2.colors.status.stopped, children: DOT });
|
|
1941
|
-
case "paused":
|
|
1942
|
-
return /* @__PURE__ */ jsx34(Text14, { color: theme2.colors.status.paused, children: DOT });
|
|
1943
|
-
default:
|
|
1944
|
-
return /* @__PURE__ */ jsx34(Text14, { color: theme2.colors.status.info, children: DOT });
|
|
1945
|
-
}
|
|
1946
|
-
};
|
|
1947
|
-
|
|
1948
|
-
// src/app/components/Status/Status.tsx
|
|
1949
|
-
import { Fragment as Fragment3, jsx as jsx35, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1950
|
-
var ERROR_CODE_STATUSES = /* @__PURE__ */ new Set([
|
|
1951
|
-
"failed",
|
|
1952
|
-
"error",
|
|
1953
|
-
"passed-with-issues",
|
|
1954
|
-
"passed_with_issues"
|
|
1955
|
-
]);
|
|
1956
|
-
var Status = ({
|
|
1957
|
-
status,
|
|
1958
|
-
color,
|
|
1959
|
-
backgroundColor,
|
|
1960
|
-
autoRetried = false,
|
|
1961
|
-
errorCode
|
|
1962
|
-
}) => {
|
|
1963
|
-
const label = status ? formatRunStatus(status, autoRetried) : "-";
|
|
1964
|
-
const shouldShowErrorCode = Boolean(errorCode) && status !== void 0 && (autoRetried || ERROR_CODE_STATUSES.has(status));
|
|
1965
|
-
return /* @__PURE__ */ jsxs20(Box15, { backgroundColor, width: "100%", children: [
|
|
1966
|
-
status && /* @__PURE__ */ jsxs20(Fragment3, { children: [
|
|
1967
|
-
/* @__PURE__ */ jsx35(StatusIndicator, { status, autoRetried }),
|
|
1968
|
-
/* @__PURE__ */ jsx35(Text15, { backgroundColor, children: " " })
|
|
1969
|
-
] }),
|
|
1970
|
-
/* @__PURE__ */ jsxs20(Text15, { color, backgroundColor, children: [
|
|
1971
|
-
label,
|
|
1972
|
-
shouldShowErrorCode ? ` (${errorCode})` : ""
|
|
1973
|
-
] })
|
|
1974
|
-
] });
|
|
1975
|
-
};
|
|
1976
|
-
|
|
1977
|
-
// src/app/components/RunBody/RunBody.tsx
|
|
1978
|
-
import { jsx as jsx36, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
1979
|
-
var RunBody = ({ runState, isRunning, isCompleted = !isRunning }) => {
|
|
1980
|
-
const duration = formatDuration(runState.duration, {
|
|
1981
|
-
started: runState.started,
|
|
1982
|
-
ended: runState.ended
|
|
1983
|
-
});
|
|
1984
|
-
const finalResults = isCompleted ? formatFinalResults(runState) : null;
|
|
1985
|
-
const errorMessage = isCompleted ? getRunErrorMessage(runState) : null;
|
|
1986
|
-
return /* @__PURE__ */ jsxs21(Box16, { flexDirection: "column", children: [
|
|
1987
|
-
/* @__PURE__ */ jsxs21(Box16, { flexDirection: "column", children: [
|
|
1988
|
-
/* @__PURE__ */ jsx36(Box16, { children: /* @__PURE__ */ jsxs21(Text16, { children: [
|
|
1989
|
-
"Run id: ",
|
|
1990
|
-
runState.id
|
|
1991
|
-
] }) }),
|
|
1992
|
-
/* @__PURE__ */ jsxs21(Box16, { flexDirection: "row", rowGap: 2, children: [
|
|
1993
|
-
/* @__PURE__ */ jsx36(Text16, { children: "Status: " }),
|
|
1994
|
-
/* @__PURE__ */ jsx36(
|
|
1995
|
-
Status,
|
|
1996
|
-
{
|
|
1997
|
-
status: runState.status,
|
|
1998
|
-
autoRetried: runState.isAutoRetried,
|
|
1999
|
-
errorCode: runState.errorCode
|
|
2000
|
-
}
|
|
2001
|
-
)
|
|
2002
|
-
] }),
|
|
2003
|
-
/* @__PURE__ */ jsx36(Box16, { children: /* @__PURE__ */ jsxs21(Text16, { dimColor: true, children: [
|
|
2004
|
-
"Duration: ",
|
|
2005
|
-
duration
|
|
2006
|
-
] }) }),
|
|
2007
|
-
finalResults ? /* @__PURE__ */ jsx36(Box16, { children: /* @__PURE__ */ jsx36(Text16, { children: finalResults }) }) : null,
|
|
2008
|
-
errorMessage ? /* @__PURE__ */ jsx36(Box16, { children: /* @__PURE__ */ jsxs21(Text16, { children: [
|
|
2009
|
-
"Error: ",
|
|
2010
|
-
errorMessage
|
|
2011
|
-
] }) }) : null
|
|
2012
|
-
] }),
|
|
2013
|
-
/* @__PURE__ */ jsx36(RunProgress, { runState, isRunning })
|
|
2014
|
-
] });
|
|
2015
|
-
};
|
|
2016
|
-
|
|
2017
|
-
// src/app/components/BaseSuiteRunDetails/BaseSuiteRunDetails.tsx
|
|
2018
|
-
import { jsx as jsx37, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2019
|
-
var menuOptions = (runId, state) => [
|
|
2020
|
-
{
|
|
2021
|
-
label: "Show test runs",
|
|
2022
|
-
shortcut: "t",
|
|
2023
|
-
description: "Drill into the test runs that belong to this suite run",
|
|
2024
|
-
to: ROUTES.suiteRuns.showTestRuns(runId),
|
|
2025
|
-
state
|
|
2026
|
-
},
|
|
2027
|
-
{
|
|
2028
|
-
label: "Open in BugBug",
|
|
2029
|
-
shortcut: "o",
|
|
2030
|
-
description: "Open the suite run page in your browser",
|
|
2031
|
-
to: ROUTES.suiteRuns.open(runId),
|
|
2032
|
-
state
|
|
2033
|
-
}
|
|
2034
|
-
];
|
|
2035
|
-
var BaseSuiteRunDetails = ({
|
|
2036
|
-
runId,
|
|
2037
|
-
title,
|
|
2038
|
-
menuState,
|
|
2039
|
-
headless = false,
|
|
2040
|
-
intervalMs = 4e3,
|
|
2041
|
-
timeoutMs,
|
|
2042
|
-
exitDelayMs = 300,
|
|
2043
|
-
onComplete,
|
|
2044
|
-
onError
|
|
2045
|
-
}) => {
|
|
2046
|
-
const { exit } = useApp4();
|
|
2047
|
-
const [runState, setRunState] = useState16(null);
|
|
2048
|
-
const [error, setError] = useState16(null);
|
|
2049
|
-
useEffect12(() => {
|
|
2050
|
-
let cancelled = false;
|
|
2051
|
-
void (async () => {
|
|
2052
|
-
try {
|
|
2053
|
-
const finalStatus = await waitForSuiteRun(
|
|
2054
|
-
runId,
|
|
2055
|
-
intervalMs,
|
|
2056
|
-
(status) => {
|
|
2057
|
-
if (!cancelled) setRunState(status);
|
|
2058
|
-
},
|
|
2059
|
-
timeoutMs
|
|
2060
|
-
);
|
|
2061
|
-
if (!cancelled) {
|
|
2062
|
-
setRunState(finalStatus);
|
|
2063
|
-
onComplete?.(finalStatus);
|
|
2064
|
-
if (headless) setTimeout(exit, exitDelayMs);
|
|
2065
|
-
}
|
|
2066
|
-
} catch (err) {
|
|
2067
|
-
if (!cancelled) {
|
|
2068
|
-
const nextError = err instanceof Error ? err : new Error("Unknown error occurred");
|
|
2069
|
-
setError(nextError.message);
|
|
2070
|
-
onError?.(nextError);
|
|
2071
|
-
if (headless) setTimeout(exit, exitDelayMs);
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
|
-
})();
|
|
2075
|
-
return () => {
|
|
2076
|
-
cancelled = true;
|
|
2077
|
-
};
|
|
2078
|
-
}, [runId, intervalMs, timeoutMs, headless, exitDelayMs, exit, onComplete, onError]);
|
|
2079
|
-
const isRunning = runState ? isRunningStatus(runState.status) : false;
|
|
2080
|
-
const isCompleted = runState ? isCompletedStatus(runState.status) : false;
|
|
2081
|
-
const body = /* @__PURE__ */ jsxs22(Box17, { flexDirection: "column", children: [
|
|
2082
|
-
error && /* @__PURE__ */ jsx37(StatusMessage8, { variant: "error", children: `Failed to complete suite run: ${error}` }),
|
|
2083
|
-
!error && !runState && /* @__PURE__ */ jsx37(Spinner7, { label: "Initializing..." }),
|
|
2084
|
-
!error && runState && /* @__PURE__ */ jsx37(RunBody, { runState, isRunning, isCompleted })
|
|
2085
|
-
] });
|
|
2086
|
-
if (headless) return body;
|
|
2087
|
-
return /* @__PURE__ */ jsxs22(
|
|
2088
|
-
ViewLayout,
|
|
2089
|
-
{
|
|
2090
|
-
title,
|
|
2091
|
-
hints: isCompleted ? "navigationSelect" : "none",
|
|
2092
|
-
hintsHidden: !isCompleted,
|
|
2093
|
-
hintsPosition: "bottom",
|
|
2094
|
-
children: [
|
|
2095
|
-
body,
|
|
2096
|
-
isCompleted && /* @__PURE__ */ jsx37(MenuList, { options: menuOptions(runId, menuState) })
|
|
2097
|
-
]
|
|
2098
|
-
}
|
|
2099
|
-
);
|
|
2100
|
-
};
|
|
2101
|
-
|
|
2102
|
-
// src/app/hooks/useSuiteRuns.ts
|
|
2103
|
-
var useSuiteRunsList = () => useFeatureQuery(() => listSuiteRuns(), []);
|
|
2104
|
-
var useSuiteRunDetails = (runId) => useFeatureQuery(async () => {
|
|
2105
|
-
if (!runId) return void 0;
|
|
2106
|
-
return getSuiteRunDetails(runId);
|
|
2107
|
-
}, [runId]);
|
|
2108
|
-
|
|
2109
|
-
// src/features/suiteRuns/suiteRuns.utils.ts
|
|
2110
|
-
var getSuiteRunName = (run) => run.name || run.id;
|
|
2111
|
-
|
|
2112
|
-
// src/app/views/suiteRuns/SuiteRunDetails.tsx
|
|
2113
|
-
import { jsx as jsx38, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2114
|
-
var SuiteRunDetails = () => {
|
|
2115
|
-
const { runId } = useParams();
|
|
2116
|
-
const location = useLocation5();
|
|
2117
|
-
const state = location.state;
|
|
2118
|
-
const request = useSuiteRunDetails(runId);
|
|
2119
|
-
const title = request.data ? getSuiteRunName(request.data) : state?.suiteRunName;
|
|
2120
|
-
const menuState = title ? { suiteRunName: title } : void 0;
|
|
2121
|
-
if (!request.data || !runId) {
|
|
2122
|
-
return /* @__PURE__ */ jsxs23(ViewLayout, { title, hintsHidden: true, hintsPosition: "bottom", children: [
|
|
2123
|
-
request.isLoading && /* @__PURE__ */ jsx38(Spinner8, { label: "Loading suite run..." }),
|
|
2124
|
-
request.isError && /* @__PURE__ */ jsx38(StatusMessage9, { variant: "error", children: request.error }),
|
|
2125
|
-
!request.isLoading && !request.isError && !request.data && /* @__PURE__ */ jsx38(Text17, { color: "yellow", children: "Suite run not found." })
|
|
2126
|
-
] });
|
|
2127
|
-
}
|
|
2128
|
-
return /* @__PURE__ */ jsx38(BaseSuiteRunDetails, { runId, title, menuState });
|
|
2129
|
-
};
|
|
2130
|
-
|
|
2131
|
-
// src/app/views/suiteRuns/SuiteRunOpen.tsx
|
|
2132
|
-
import { Spinner as Spinner9, StatusMessage as StatusMessage10 } from "@inkjs/ui";
|
|
2133
|
-
import { Box as Box18, Text as Text18 } from "ink";
|
|
2134
|
-
import { useEffect as useEffect13 } from "react";
|
|
2135
|
-
import { useLocation as useLocation6, useParams as useParams2 } from "react-router";
|
|
2136
|
-
import { Fragment as Fragment4, jsx as jsx39, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
2137
|
-
var WebUrlUnavailableMessage = () => /* @__PURE__ */ jsx39(StatusMessage10, { variant: "warning", children: "No web URL available for this run" });
|
|
2138
|
-
var OpenSuiteRun = ({ url }) => {
|
|
2139
|
-
const [openSuiteRun, openSuiteRunResult] = useFeatureMutation(async (url2) => {
|
|
2140
|
-
await openExternalUrl(url2);
|
|
2141
|
-
return url2;
|
|
2142
|
-
});
|
|
2143
|
-
useEffect13(() => {
|
|
2144
|
-
if (url) void openSuiteRun(url);
|
|
2145
|
-
}, [openSuiteRun, url]);
|
|
2146
|
-
if (!url) return /* @__PURE__ */ jsx39(WebUrlUnavailableMessage, {});
|
|
2147
|
-
return /* @__PURE__ */ jsxs24(Fragment4, { children: [
|
|
2148
|
-
openSuiteRunResult.isLoading && /* @__PURE__ */ jsx39(Spinner9, { label: "Opening BugBug..." }),
|
|
2149
|
-
openSuiteRunResult.isError && /* @__PURE__ */ jsx39(StatusMessage10, { variant: "error", children: openSuiteRunResult.error }),
|
|
2150
|
-
openSuiteRunResult.data && /* @__PURE__ */ jsxs24(Box18, { flexDirection: "column", children: [
|
|
2151
|
-
/* @__PURE__ */ jsx39(StatusMessage10, { variant: "success", children: "Opened in BugBug" }),
|
|
2152
|
-
/* @__PURE__ */ jsx39(Text18, { dimColor: true, children: openSuiteRunResult.data })
|
|
2153
|
-
] })
|
|
2154
|
-
] });
|
|
2155
|
-
};
|
|
2156
|
-
var SuiteRunOpen = () => {
|
|
2157
|
-
const { runId } = useParams2();
|
|
2158
|
-
const location = useLocation6();
|
|
2159
|
-
const state = location.state;
|
|
2160
|
-
const request = useSuiteRunDetails(runId);
|
|
2161
|
-
const title = request.data ? getSuiteRunName(request.data) : state?.suiteRunName ?? runId;
|
|
2162
|
-
return /* @__PURE__ */ jsxs24(ViewLayout, { title, hintsHidden: true, hintsPosition: "bottom", children: [
|
|
2163
|
-
request.isLoading && /* @__PURE__ */ jsx39(Spinner9, { label: "Loading..." }),
|
|
2164
|
-
request.isError && /* @__PURE__ */ jsx39(Text18, { color: "red", children: request.error }),
|
|
2165
|
-
!request.isLoading && !request.isError && /* @__PURE__ */ jsx39(OpenSuiteRun, { url: request.data?.webappUrl })
|
|
2166
|
-
] });
|
|
2167
|
-
};
|
|
2168
|
-
|
|
2169
|
-
// src/app/views/suiteRuns/SuiteRunShowTestRuns.tsx
|
|
2170
|
-
import { Spinner as Spinner10 } from "@inkjs/ui";
|
|
2171
|
-
import { StatusMessage as StatusMessage11 } from "@inkjs/ui";
|
|
2172
|
-
import { useLocation as useLocation7, useParams as useParams3 } from "react-router";
|
|
2173
|
-
|
|
2174
|
-
// src/features/testRuns/components/TestRunsList.tsx
|
|
2175
|
-
import { useNavigate as useNavigate8 } from "react-router";
|
|
2176
|
-
|
|
2177
|
-
// src/features/testRuns/testRuns.utils.ts
|
|
2178
|
-
var getTestRunName = (run) => run.name || run.id;
|
|
2179
|
-
var DEBUG_ARTIFACT_LABELS = {
|
|
2180
|
-
logs_partial: "Download partial test run logs",
|
|
2181
|
-
logs: "Download test run logs",
|
|
2182
|
-
cloud_logs: "Download cloud logs",
|
|
2183
|
-
container_stats: "Download container stats",
|
|
2184
|
-
chrome_debug_logs: "Download Chrome debug logs",
|
|
2185
|
-
network_logs: "Download network logs (HAR)",
|
|
2186
|
-
dom_snapshot: "Show DOM snapshot"
|
|
2187
|
-
};
|
|
2188
|
-
var getDebugArtifactLabel = (artifact) => DEBUG_ARTIFACT_LABELS[artifact.kind];
|
|
2189
|
-
|
|
2190
|
-
// src/features/testRuns/components/TestRunsList.constants.tsx
|
|
2191
|
-
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
2192
|
-
var TEST_RUN_LIST_COLUMNS = [
|
|
2193
|
-
{ key: "name", label: "Name", width: 30 },
|
|
2194
|
-
{ key: "duration", label: "Duration", width: 8 },
|
|
2195
|
-
{ key: "profileName", label: "Profile", width: 8 },
|
|
2196
|
-
{ key: "triggeredBy", label: "Run by", width: 8 },
|
|
2197
|
-
{ key: "errorCode", label: "Error", width: 20 },
|
|
2198
|
-
{
|
|
2199
|
-
key: "status",
|
|
2200
|
-
label: "Status",
|
|
2201
|
-
width: 15,
|
|
2202
|
-
render: (_cell, row, ctx) => /* @__PURE__ */ jsx40(
|
|
2203
|
-
Status,
|
|
2204
|
-
{
|
|
2205
|
-
status: row.value?.status,
|
|
2206
|
-
autoRetried: row.value?.isAutoRetried,
|
|
2207
|
-
color: ctx.color,
|
|
2208
|
-
backgroundColor: ctx.backgroundColor
|
|
2209
|
-
}
|
|
2210
|
-
)
|
|
2211
|
-
}
|
|
2212
|
-
];
|
|
2213
|
-
|
|
2214
|
-
// src/features/testRuns/components/TestRunsList.utils.tsx
|
|
2215
|
-
var getTestRunRow = (run) => {
|
|
2216
|
-
return {
|
|
2217
|
-
key: run.id,
|
|
2218
|
-
cells: {
|
|
2219
|
-
name: getTestRunName(run),
|
|
2220
|
-
status: run.status ?? "",
|
|
2221
|
-
errorCode: run.errorCode ?? "",
|
|
2222
|
-
profileName: run.profileName ?? "",
|
|
2223
|
-
screenSizeType: run.screenSizeType ?? "",
|
|
2224
|
-
triggeredBy: run.triggeredBy ?? "",
|
|
2225
|
-
duration: formatDuration(run.duration, { started: run.started, ended: run.ended })
|
|
2226
|
-
},
|
|
2227
|
-
value: run
|
|
2228
|
-
};
|
|
2229
|
-
};
|
|
2230
|
-
|
|
2231
|
-
// src/features/testRuns/components/TestRunsList.tsx
|
|
2232
|
-
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
2233
|
-
var TestRunsList = ({
|
|
2234
|
-
title,
|
|
2235
|
-
loadingLabel = "Loading test runs...",
|
|
2236
|
-
emptyMessage = "No test runs found",
|
|
2237
|
-
testRuns,
|
|
2238
|
-
isLoading,
|
|
2239
|
-
isError,
|
|
2240
|
-
error
|
|
2241
|
-
}) => {
|
|
2242
|
-
const navigate = useNavigate8();
|
|
2243
|
-
return /* @__PURE__ */ jsx41(
|
|
2244
|
-
BaseResourceListScreen,
|
|
2245
|
-
{
|
|
2246
|
-
title,
|
|
2247
|
-
loadingLabel,
|
|
2248
|
-
emptyMessage,
|
|
2249
|
-
resources: testRuns,
|
|
2250
|
-
isLoading,
|
|
2251
|
-
isError,
|
|
2252
|
-
error,
|
|
2253
|
-
columns: TEST_RUN_LIST_COLUMNS,
|
|
2254
|
-
getRow: getTestRunRow,
|
|
2255
|
-
onSelectResource: (run) => navigate(ROUTES.testRuns.details(run.id), { state: { testRunName: getTestRunName(run) } })
|
|
2256
|
-
}
|
|
2257
|
-
);
|
|
2258
|
-
};
|
|
2259
|
-
|
|
2260
|
-
// src/app/views/suiteRuns/SuiteRunShowTestRuns.tsx
|
|
2261
|
-
import { jsx as jsx42, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
2262
|
-
var SuiteRunTestRuns = ({ run, title }) => {
|
|
2263
|
-
const request = useFeatureQuery(() => getSuiteRunTestRuns(run.id), [run.id]);
|
|
2264
|
-
return /* @__PURE__ */ jsx42(
|
|
2265
|
-
TestRunsList,
|
|
2266
|
-
{
|
|
2267
|
-
title,
|
|
2268
|
-
loadingLabel: `Loading test runs for ${getSuiteRunName(run)}...`,
|
|
2269
|
-
emptyMessage: "No test runs available",
|
|
2270
|
-
testRuns: request.data,
|
|
2271
|
-
isLoading: request.isLoading,
|
|
2272
|
-
isError: request.isError,
|
|
2273
|
-
error: request.error
|
|
2274
|
-
}
|
|
2275
|
-
);
|
|
2276
|
-
};
|
|
2277
|
-
var SuiteRunShowTestRuns = () => {
|
|
2278
|
-
const { runId } = useParams3();
|
|
2279
|
-
const location = useLocation7();
|
|
2280
|
-
const state = location.state;
|
|
2281
|
-
const request = useSuiteRunDetails(runId);
|
|
2282
|
-
const title = request.data ? `Test runs in "${getSuiteRunName(request.data)}"` : state?.suiteRunName ? `Test runs in "${state.suiteRunName}"` : void 0;
|
|
2283
|
-
if (!request.data) {
|
|
2284
|
-
return /* @__PURE__ */ jsxs25(ViewLayout, { title, hintsHidden: true, hintsPosition: "bottom", children: [
|
|
2285
|
-
request.isLoading && /* @__PURE__ */ jsx42(Spinner10, { label: "Loading..." }),
|
|
2286
|
-
request.isError && /* @__PURE__ */ jsx42(StatusMessage11, { variant: "error", children: request.error }),
|
|
2287
|
-
!request.isLoading && !request.isError && /* @__PURE__ */ jsx42(StatusMessage11, { variant: "warning", children: "No test runs available" })
|
|
2288
|
-
] });
|
|
2289
|
-
}
|
|
2290
|
-
return /* @__PURE__ */ jsx42(SuiteRunTestRuns, { run: request.data, title: title ?? "" });
|
|
2291
|
-
};
|
|
2292
|
-
|
|
2293
|
-
// src/app/views/suiteRuns/SuiteRunsList.tsx
|
|
2294
|
-
import { useNavigate as useNavigate9 } from "react-router";
|
|
2295
|
-
|
|
2296
|
-
// src/app/views/suiteRuns/SuiteRunsList.constants.tsx
|
|
2297
|
-
import { jsx as jsx43 } from "react/jsx-runtime";
|
|
2298
|
-
var SUITE_RUN_LIST_COLUMNS = [
|
|
2299
|
-
{ key: "name", label: "Name", width: 30 },
|
|
2300
|
-
{ key: "duration", label: "Duration", width: 10 },
|
|
2301
|
-
{ key: "profileName", label: "Profile", width: 8 },
|
|
2302
|
-
{ key: "triggeredBy", label: "Run by", width: 10 },
|
|
2303
|
-
{ key: "result", label: "Result", width: 14 },
|
|
2304
|
-
{
|
|
2305
|
-
key: "status",
|
|
2306
|
-
label: "Status",
|
|
2307
|
-
width: 10,
|
|
2308
|
-
render: (_cell, row, ctx) => /* @__PURE__ */ jsx43(Status, { status: row.value?.status, color: ctx.color, backgroundColor: ctx.backgroundColor })
|
|
2309
|
-
}
|
|
2310
|
-
];
|
|
2311
|
-
|
|
2312
|
-
// src/app/views/suiteRuns/SuiteRunsList.utils.tsx
|
|
2313
|
-
var getSuiteRunResult = (run) => {
|
|
2314
|
-
const testRuns = run.testRuns ?? [];
|
|
2315
|
-
if (testRuns.length === 0) return "";
|
|
2316
|
-
const passed = testRuns.filter((testRun) => testRun.status === "passed").length;
|
|
2317
|
-
return `${passed}/${testRuns.length} passed`;
|
|
2318
|
-
};
|
|
2319
|
-
var getSuiteRunRow = (run) => {
|
|
2320
|
-
return {
|
|
2321
|
-
key: run.id,
|
|
2322
|
-
cells: {
|
|
2323
|
-
name: getSuiteRunName(run),
|
|
2324
|
-
status: run.status ?? "",
|
|
2325
|
-
result: getSuiteRunResult(run),
|
|
2326
|
-
profileName: run.profileName ?? "",
|
|
2327
|
-
runMode: run.runMode ?? "",
|
|
2328
|
-
triggeredBy: run.triggeredBy ?? "",
|
|
2329
|
-
duration: formatDuration(run.duration, { started: run.started, ended: run.ended })
|
|
2330
|
-
},
|
|
2331
|
-
value: run
|
|
2332
|
-
};
|
|
2333
|
-
};
|
|
2334
|
-
|
|
2335
|
-
// src/app/views/suiteRuns/SuiteRunsList.tsx
|
|
2336
|
-
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
2337
|
-
var SuiteRunsList = () => {
|
|
2338
|
-
const navigate = useNavigate9();
|
|
2339
|
-
const request = useSuiteRunsList();
|
|
2340
|
-
return /* @__PURE__ */ jsx44(
|
|
2341
|
-
BaseResourceListScreen,
|
|
2342
|
-
{
|
|
2343
|
-
loadingLabel: "Loading suite runs...",
|
|
2344
|
-
emptyMessage: "No suite runs found",
|
|
2345
|
-
resources: request.data,
|
|
2346
|
-
isLoading: request.isLoading,
|
|
2347
|
-
isError: request.isError,
|
|
2348
|
-
error: request.error,
|
|
2349
|
-
columns: SUITE_RUN_LIST_COLUMNS,
|
|
2350
|
-
getRow: getSuiteRunRow,
|
|
2351
|
-
onSelectResource: (run) => navigate(ROUTES.suiteRuns.details(run.id), {
|
|
2352
|
-
state: { suiteRunName: getSuiteRunName(run) }
|
|
2353
|
-
})
|
|
2354
|
-
}
|
|
2355
|
-
);
|
|
2356
|
-
};
|
|
2357
|
-
|
|
2358
|
-
// src/app/views/suiteRuns/SuiteRunsMenu.tsx
|
|
2359
|
-
import { useEffect as useEffect14 } from "react";
|
|
2360
|
-
import { useNavigate as useNavigate10 } from "react-router";
|
|
2361
|
-
var SuiteRunsMenu = () => {
|
|
2362
|
-
const navigate = useNavigate10();
|
|
2363
|
-
useEffect14(() => {
|
|
2364
|
-
navigate(ROUTES.suiteRuns.list(), { replace: true });
|
|
2365
|
-
}, [navigate]);
|
|
2366
|
-
return null;
|
|
2367
|
-
};
|
|
2368
|
-
|
|
2369
|
-
// src/app/views/suites/RunSuite.tsx
|
|
2370
|
-
import { useNavigate as useNavigate11 } from "react-router";
|
|
2371
|
-
|
|
2372
|
-
// src/app/views/suites/BaseSuitesList.tsx
|
|
2373
|
-
import { useState as useState17 } from "react";
|
|
2374
|
-
|
|
2375
|
-
// src/app/hooks/useSuites.ts
|
|
2376
|
-
var useSuitesList = (query) => useFeatureQuery(() => loadSuiteTableResources(query), [query]);
|
|
2377
|
-
var useSuiteDetails = (suiteId) => useFeatureQuery(async () => {
|
|
2378
|
-
if (!suiteId) return void 0;
|
|
2379
|
-
return getSuiteDetails(suiteId);
|
|
2380
|
-
}, [suiteId]);
|
|
2381
|
-
|
|
2382
|
-
// src/features/suites/suites.constants.tsx
|
|
2383
|
-
import { jsx as jsx45 } from "react/jsx-runtime";
|
|
2384
|
-
var SUITE_COLUMNS = [
|
|
2385
|
-
{ key: "name", label: "Name", width: 42 },
|
|
2386
|
-
{
|
|
2387
|
-
key: "status",
|
|
2388
|
-
label: "Status",
|
|
2389
|
-
width: 14,
|
|
2390
|
-
render: (_cell, row, ctx) => /* @__PURE__ */ jsx45(Status, { status: row.value?.status, color: ctx.color, backgroundColor: ctx.backgroundColor })
|
|
2391
|
-
}
|
|
2392
|
-
];
|
|
2393
|
-
|
|
2394
|
-
// src/features/suites/suites.utils.tsx
|
|
2395
|
-
var getSuiteRow = (suite) => ({
|
|
2396
|
-
key: suite.id,
|
|
2397
|
-
cells: {
|
|
2398
|
-
name: getSuiteName(suite),
|
|
2399
|
-
status: formatRunStatus(suite.status)
|
|
2400
|
-
},
|
|
2401
|
-
value: suite
|
|
2402
|
-
});
|
|
2403
|
-
var getSuiteName = (suite) => suite.name || suite.id || "Untitled";
|
|
2404
|
-
|
|
2405
|
-
// src/app/views/suites/BaseSuitesList.tsx
|
|
2406
|
-
import { jsx as jsx46 } from "react/jsx-runtime";
|
|
2407
|
-
var BaseSuitesList = ({
|
|
2408
|
-
title,
|
|
2409
|
-
emptyMessage = "No suites found",
|
|
2410
|
-
onSelectSuite
|
|
2411
|
-
}) => {
|
|
2412
|
-
const [query, setQuery] = useState17("");
|
|
2413
|
-
const request = useSuitesList(query);
|
|
2414
|
-
return /* @__PURE__ */ jsx46(
|
|
2415
|
-
BaseResourceListScreen,
|
|
2416
|
-
{
|
|
2417
|
-
title,
|
|
2418
|
-
loadingLabel: "Loading suites...",
|
|
2419
|
-
emptyMessage,
|
|
2420
|
-
resources: request.data,
|
|
2421
|
-
isLoading: request.isLoading,
|
|
2422
|
-
isError: request.isError,
|
|
2423
|
-
error: request.error,
|
|
2424
|
-
columns: SUITE_COLUMNS,
|
|
2425
|
-
getRow: getSuiteRow,
|
|
2426
|
-
searchable: true,
|
|
2427
|
-
query,
|
|
2428
|
-
onSearch: (next) => setQuery(next.trim()),
|
|
2429
|
-
onSelectResource: onSelectSuite
|
|
2430
|
-
}
|
|
2431
|
-
);
|
|
2432
|
-
};
|
|
2433
|
-
|
|
2434
|
-
// src/app/views/suites/RunSuite.tsx
|
|
2435
|
-
import { jsx as jsx47 } from "react/jsx-runtime";
|
|
2436
|
-
var RunSuite = () => {
|
|
2437
|
-
const navigate = useNavigate11();
|
|
2438
|
-
return /* @__PURE__ */ jsx47(
|
|
2439
|
-
BaseSuitesList,
|
|
2440
|
-
{
|
|
2441
|
-
title: "Select a suite to run:",
|
|
2442
|
-
emptyMessage: "No suites available",
|
|
2443
|
-
onSelectSuite: (suite) => navigate(ROUTES.suites.run(suite.id))
|
|
2444
|
-
}
|
|
2445
|
-
);
|
|
2446
|
-
};
|
|
2447
|
-
|
|
2448
|
-
// src/app/views/suites/SuiteDetails.tsx
|
|
2449
|
-
import { Spinner as Spinner11, StatusMessage as StatusMessage12 } from "@inkjs/ui";
|
|
2450
|
-
import { Box as Box19 } from "ink";
|
|
2451
|
-
import { useLocation as useLocation8, useParams as useParams4 } from "react-router";
|
|
2452
|
-
import { jsx as jsx48, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
2453
|
-
var SuiteDetails = () => {
|
|
2454
|
-
const { suiteId } = useParams4();
|
|
2455
|
-
const location = useLocation8();
|
|
2456
|
-
const state = location.state;
|
|
2457
|
-
const request = useSuiteDetails(suiteId);
|
|
2458
|
-
const title = request.data ? getSuiteName(request.data) : state?.suiteName;
|
|
2459
|
-
const detailsState = title ? { suiteName: title } : void 0;
|
|
2460
|
-
const data = request.data;
|
|
2461
|
-
const isNotFound = !request.isLoading && !request.isError && data === void 0;
|
|
2462
|
-
const isReady = !request.isLoading && !request.isError && data !== void 0;
|
|
2463
|
-
const hints = isReady ? void 0 : "none";
|
|
2464
|
-
const options = [
|
|
2465
|
-
{
|
|
2466
|
-
label: "Run",
|
|
2467
|
-
shortcut: "r",
|
|
2468
|
-
description: "Start a fresh run of this suite",
|
|
2469
|
-
to: ROUTES.suites.run(suiteId ?? ""),
|
|
2470
|
-
state: detailsState
|
|
2471
|
-
},
|
|
2472
|
-
{
|
|
2473
|
-
label: "Show last run",
|
|
2474
|
-
shortcut: "h",
|
|
2475
|
-
description: "View the most recent run for this suite",
|
|
2476
|
-
to: ROUTES.suites.lastRun(suiteId ?? ""),
|
|
2477
|
-
state: detailsState
|
|
2478
|
-
},
|
|
2479
|
-
{
|
|
2480
|
-
label: "Open in BugBug",
|
|
2481
|
-
shortcut: "o",
|
|
2482
|
-
description: "Open the suite page in your browser",
|
|
2483
|
-
to: ROUTES.suites.open(suiteId ?? "")
|
|
2484
|
-
}
|
|
2485
|
-
];
|
|
2486
|
-
return /* @__PURE__ */ jsxs26(ViewLayout, { title, hints, children: [
|
|
2487
|
-
request.isLoading && /* @__PURE__ */ jsx48(Box19, { children: /* @__PURE__ */ jsx48(Spinner11, { label: "Loading suite..." }) }),
|
|
2488
|
-
request.isError && /* @__PURE__ */ jsx48(StatusMessage12, { variant: "error", children: request.error }),
|
|
2489
|
-
isNotFound && /* @__PURE__ */ jsx48(StatusMessage12, { variant: "warning", children: "Suite not found" }),
|
|
2490
|
-
isReady && /* @__PURE__ */ jsx48(MenuList, { options })
|
|
2491
|
-
] });
|
|
2492
|
-
};
|
|
2493
|
-
|
|
2494
|
-
// src/app/views/suites/SuiteDetailsLastRun.tsx
|
|
2495
|
-
import { Spinner as Spinner12, StatusMessage as StatusMessage13 } from "@inkjs/ui";
|
|
2496
|
-
import { Text as Text19 } from "ink";
|
|
2497
|
-
import { useLocation as useLocation9, useParams as useParams5 } from "react-router";
|
|
2498
|
-
import { jsx as jsx49, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
2499
|
-
var SuiteDetailsLastRun = () => {
|
|
2500
|
-
const { suiteId } = useParams5();
|
|
2501
|
-
const location = useLocation9();
|
|
2502
|
-
const state = location.state;
|
|
2503
|
-
const request = useSuiteDetails(suiteId);
|
|
2504
|
-
const suite = request.data;
|
|
2505
|
-
const isReady = !request.isLoading && !request.isError;
|
|
2506
|
-
const title = suite ? getSuiteName(suite) : state?.suiteName ?? suiteId;
|
|
2507
|
-
if (!isReady || !suite?.lastRunId) {
|
|
2508
|
-
return /* @__PURE__ */ jsxs27(ViewLayout, { title, hintsHidden: true, hintsPosition: "bottom", children: [
|
|
2509
|
-
request.isLoading && /* @__PURE__ */ jsx49(Spinner12, { label: "Loading..." }),
|
|
2510
|
-
request.isError && /* @__PURE__ */ jsx49(Text19, { color: "red", children: request.error }),
|
|
2511
|
-
isReady && !suite?.lastRunId && /* @__PURE__ */ jsx49(StatusMessage13, { variant: "warning", children: `No previous run found for ${suite ? getSuiteName(suite) : suiteId ?? "suite"}` })
|
|
2512
|
-
] });
|
|
2513
|
-
}
|
|
2514
|
-
return /* @__PURE__ */ jsx49(
|
|
2515
|
-
BaseSuiteRunDetails,
|
|
2516
|
-
{
|
|
2517
|
-
runId: suite.lastRunId,
|
|
2518
|
-
title,
|
|
2519
|
-
menuState: { suiteRunName: title }
|
|
2520
|
-
}
|
|
2521
|
-
);
|
|
2522
|
-
};
|
|
2523
|
-
|
|
2524
|
-
// src/app/views/suites/SuiteDetailsOpen.tsx
|
|
2525
|
-
import { StatusMessage as StatusMessage14 } from "@inkjs/ui";
|
|
2526
|
-
import { Spinner as Spinner13 } from "@inkjs/ui";
|
|
2527
|
-
import { Box as Box20, Text as Text20 } from "ink";
|
|
2528
|
-
import { useEffect as useEffect15 } from "react";
|
|
2529
|
-
import { useParams as useParams6 } from "react-router";
|
|
2530
|
-
import { jsx as jsx50, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
2531
|
-
var WebUrlUnavailableMessage2 = () => /* @__PURE__ */ jsx50(StatusMessage14, { variant: "warning", children: "No web URL available for this suite" });
|
|
2532
|
-
var SuiteDetailsOpen = () => {
|
|
2533
|
-
const { suiteId } = useParams6();
|
|
2534
|
-
const request = useFeatureQuery(async () => {
|
|
2535
|
-
if (!suiteId) return void 0;
|
|
2536
|
-
return getSuite(suiteId);
|
|
2537
|
-
}, [suiteId]);
|
|
2538
|
-
const url = request.data?.webappUrl;
|
|
2539
|
-
const isReady = !request.isLoading && !request.isError;
|
|
2540
|
-
const [openSuite, openSuiteResult] = useFeatureMutation(async (url2) => {
|
|
2541
|
-
await openExternalUrl(url2);
|
|
2542
|
-
return url2;
|
|
2543
|
-
});
|
|
2544
|
-
useEffect15(() => {
|
|
2545
|
-
if (isReady && url) void openSuite(url);
|
|
2546
|
-
}, [isReady, openSuite, url]);
|
|
2547
|
-
return /* @__PURE__ */ jsxs28(ViewLayout, { hintsHidden: true, children: [
|
|
2548
|
-
request.isLoading && /* @__PURE__ */ jsx50(Spinner13, { label: "Loading..." }),
|
|
2549
|
-
request.isError && /* @__PURE__ */ jsx50(Text20, { color: "red", children: request.error }),
|
|
2550
|
-
isReady && !url && /* @__PURE__ */ jsx50(WebUrlUnavailableMessage2, {}),
|
|
2551
|
-
isReady && url && openSuiteResult.isLoading && /* @__PURE__ */ jsx50(Spinner13, { label: "Opening BugBug..." }),
|
|
2552
|
-
isReady && url && openSuiteResult.isError && /* @__PURE__ */ jsx50(StatusMessage14, { variant: "error", children: openSuiteResult.error }),
|
|
2553
|
-
isReady && url && openSuiteResult.data && /* @__PURE__ */ jsxs28(Box20, { flexDirection: "column", children: [
|
|
2554
|
-
/* @__PURE__ */ jsx50(StatusMessage14, { variant: "success", children: "Opened in BugBug" }),
|
|
2555
|
-
/* @__PURE__ */ jsx50(Text20, { dimColor: true, children: openSuiteResult.data })
|
|
2556
|
-
] })
|
|
2557
|
-
] });
|
|
2558
|
-
};
|
|
2559
|
-
|
|
2560
|
-
// src/app/views/suites/SuiteDetailsRun.tsx
|
|
2561
|
-
import { Spinner as Spinner14, StatusMessage as StatusMessage15 } from "@inkjs/ui";
|
|
2562
|
-
import { useEffect as useEffect16 } from "react";
|
|
2563
|
-
import { useLocation as useLocation10, useNavigate as useNavigate12, useParams as useParams7 } from "react-router";
|
|
2564
|
-
import { jsx as jsx51, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
2565
|
-
var SuiteDetailsRun = () => {
|
|
2566
|
-
const { suiteId } = useParams7();
|
|
2567
|
-
const location = useLocation10();
|
|
2568
|
-
const navigate = useNavigate12();
|
|
2569
|
-
const state = location.state;
|
|
2570
|
-
const title = state?.suiteName ?? suiteId;
|
|
2571
|
-
const [runSuiteMutation, runSuiteResult] = useFeatureMutation((id) => runSuite(id, {}));
|
|
2572
|
-
useEffect16(() => {
|
|
2573
|
-
if (!suiteId) return;
|
|
2574
|
-
const startRun = async () => {
|
|
2575
|
-
try {
|
|
2576
|
-
const result = await runSuiteMutation(suiteId);
|
|
2577
|
-
if ("data" in result) {
|
|
2578
|
-
navigate(ROUTES.suiteRuns.details(result.data.id), { replace: true, state });
|
|
2579
|
-
}
|
|
2580
|
-
} catch {
|
|
2581
|
-
}
|
|
2582
|
-
};
|
|
2583
|
-
startRun();
|
|
2584
|
-
}, [navigate, runSuiteMutation, state, suiteId]);
|
|
2585
|
-
if (!runSuiteResult.data) {
|
|
2586
|
-
return /* @__PURE__ */ jsxs29(ViewLayout, { title, hintsHidden: true, hintsPosition: "bottom", children: [
|
|
2587
|
-
runSuiteResult.isError && /* @__PURE__ */ jsx51(StatusMessage15, { variant: "error", children: runSuiteResult.error }),
|
|
2588
|
-
!runSuiteResult.isError && /* @__PURE__ */ jsx51(Spinner14, { label: "Initializing..." })
|
|
2589
|
-
] });
|
|
2590
|
-
}
|
|
2591
|
-
return /* @__PURE__ */ jsx51(BaseSuiteRunDetails, { runId: runSuiteResult.data.id, title, menuState: state });
|
|
2592
|
-
};
|
|
2593
|
-
|
|
2594
|
-
// src/app/views/suites/SuitesList.tsx
|
|
2595
|
-
import { useNavigate as useNavigate13 } from "react-router";
|
|
2596
|
-
import { jsx as jsx52 } from "react/jsx-runtime";
|
|
2597
|
-
var SuitesList = () => {
|
|
2598
|
-
const navigate = useNavigate13();
|
|
2599
|
-
return /* @__PURE__ */ jsx52(
|
|
2600
|
-
BaseSuitesList,
|
|
2601
|
-
{
|
|
2602
|
-
onSelectSuite: (suite) => navigate(ROUTES.suites.details(suite.id), { state: { suiteName: getSuiteName(suite) } })
|
|
2603
|
-
}
|
|
2604
|
-
);
|
|
2605
|
-
};
|
|
2606
|
-
|
|
2607
|
-
// src/app/views/suites/SuitesMenu.tsx
|
|
2608
|
-
import { jsx as jsx53 } from "react/jsx-runtime";
|
|
2609
|
-
var SuitesMenu = () => {
|
|
2610
|
-
return /* @__PURE__ */ jsx53(ViewLayout, { children: /* @__PURE__ */ jsx53(
|
|
2611
|
-
MenuList,
|
|
2612
|
-
{
|
|
2613
|
-
options: [
|
|
2614
|
-
{ label: "List suites", shortcut: "l", to: "/suites/list" },
|
|
2615
|
-
{ label: "Run a suite", shortcut: "r", to: "/suites/run" }
|
|
2616
|
-
]
|
|
2617
|
-
}
|
|
2618
|
-
) });
|
|
2619
|
-
};
|
|
2620
|
-
|
|
2621
|
-
// src/app/views/testRuns/TestRunDebugArtifacts.tsx
|
|
2622
|
-
import { Spinner as Spinner15, StatusMessage as StatusMessage16 } from "@inkjs/ui";
|
|
2623
|
-
import { useLocation as useLocation11, useParams as useParams8 } from "react-router";
|
|
2624
|
-
|
|
2625
|
-
// src/app/hooks/useTestRuns.ts
|
|
2626
|
-
var useTestRunsList = () => useFeatureQuery(() => listTestRuns(), []);
|
|
2627
|
-
var useTestRunDetails = (runId) => useFeatureQuery(async () => {
|
|
2628
|
-
if (!runId) return void 0;
|
|
2629
|
-
return getTestRunDetails(runId);
|
|
2630
|
-
}, [runId]);
|
|
2631
|
-
|
|
2632
|
-
// src/app/views/testRuns/TestRunDebugArtifacts.tsx
|
|
2633
|
-
import { jsx as jsx54 } from "react/jsx-runtime";
|
|
2634
|
-
var ArtifactsUnavailableMessage = () => /* @__PURE__ */ jsx54(StatusMessage16, { variant: "warning", children: "No debug artifacts available" });
|
|
2635
|
-
var DebugArtifacts = ({ runId }) => {
|
|
2636
|
-
const request = useFeatureQuery(() => listTestRunDebugArtifacts(runId), [runId]);
|
|
2637
|
-
if (request.isLoading) {
|
|
2638
|
-
return /* @__PURE__ */ jsx54(Spinner15, { label: `Loading debug artifacts for ${runId}...` });
|
|
2639
|
-
}
|
|
2640
|
-
if (request.isError) {
|
|
2641
|
-
return /* @__PURE__ */ jsx54(StatusMessage16, { variant: "error", children: request.error });
|
|
2642
|
-
}
|
|
2643
|
-
if (!request.data || request.data.length === 0) {
|
|
2644
|
-
return /* @__PURE__ */ jsx54(ArtifactsUnavailableMessage, {});
|
|
2645
|
-
}
|
|
2646
|
-
return /* @__PURE__ */ jsx54(
|
|
2647
|
-
MenuList,
|
|
2648
|
-
{
|
|
2649
|
-
options: request.data.map((artifact) => ({
|
|
2650
|
-
label: getDebugArtifactLabel(artifact),
|
|
2651
|
-
value: artifact
|
|
2652
|
-
})),
|
|
2653
|
-
onSelect: (item) => {
|
|
2654
|
-
const artifact = item.value;
|
|
2655
|
-
if (artifact?.file) {
|
|
2656
|
-
void openExternalUrl(artifact.file);
|
|
2657
|
-
}
|
|
2658
|
-
}
|
|
2659
|
-
}
|
|
2660
|
-
);
|
|
2661
|
-
};
|
|
2662
|
-
var TestRunDebugArtifacts = () => {
|
|
2663
|
-
const { runId } = useParams8();
|
|
2664
|
-
const location = useLocation11();
|
|
2665
|
-
const state = location.state;
|
|
2666
|
-
const detailsRequest = useTestRunDetails(runId);
|
|
2667
|
-
const title = detailsRequest.data ? getTestRunName(detailsRequest.data) : state?.testRunName ?? "Debug artifacts";
|
|
2668
|
-
return /* @__PURE__ */ jsx54(
|
|
2669
|
-
ViewLayout,
|
|
2670
|
-
{
|
|
2671
|
-
title,
|
|
2672
|
-
hints: runId ? "navigationOpenSelect" : "none",
|
|
2673
|
-
hintsPosition: "bottom",
|
|
2674
|
-
children: runId ? /* @__PURE__ */ jsx54(DebugArtifacts, { runId }) : /* @__PURE__ */ jsx54(ArtifactsUnavailableMessage, {})
|
|
2675
|
-
}
|
|
2676
|
-
);
|
|
2677
|
-
};
|
|
2678
|
-
|
|
2679
|
-
// src/app/views/testRuns/TestRunDetails.tsx
|
|
2680
|
-
import { Spinner as Spinner17, StatusMessage as StatusMessage18 } from "@inkjs/ui";
|
|
2681
|
-
import { Text as Text21 } from "ink";
|
|
2682
|
-
import { useLocation as useLocation12, useParams as useParams9 } from "react-router";
|
|
2683
|
-
|
|
2684
|
-
// src/app/components/BaseTestRunDetails/BaseTestRunDetails.tsx
|
|
2685
|
-
import { Spinner as Spinner16, StatusMessage as StatusMessage17 } from "@inkjs/ui";
|
|
2686
|
-
import { Box as Box21, useApp as useApp5 } from "ink";
|
|
2687
|
-
import { useEffect as useEffect17, useState as useState18 } from "react";
|
|
2688
|
-
import { jsx as jsx55, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
2689
|
-
var getMenuOptions = (runId, state) => [
|
|
2690
|
-
{
|
|
2691
|
-
label: "Show run artifacts",
|
|
2692
|
-
shortcut: "a",
|
|
2693
|
-
description: "Browse console logs and downloadable debug artifacts",
|
|
2694
|
-
to: ROUTES.testRuns.debugArtifacts(runId),
|
|
2695
|
-
state
|
|
2696
|
-
},
|
|
2697
|
-
{
|
|
2698
|
-
label: "Download JUnit report",
|
|
2699
|
-
shortcut: "j",
|
|
2700
|
-
description: "Save the JUnit XML report to the current directory",
|
|
2701
|
-
to: ROUTES.testRuns.junitReport(runId),
|
|
2702
|
-
state
|
|
2703
|
-
},
|
|
2704
|
-
{
|
|
2705
|
-
label: "Open in BugBug",
|
|
2706
|
-
shortcut: "o",
|
|
2707
|
-
description: "Open the run page in your browser",
|
|
2708
|
-
to: ROUTES.testRuns.open(runId),
|
|
2709
|
-
state
|
|
2710
|
-
}
|
|
2711
|
-
];
|
|
2712
|
-
var BaseTestRunDetails = ({
|
|
2713
|
-
runId,
|
|
2714
|
-
title,
|
|
2715
|
-
menuState,
|
|
2716
|
-
headless = false,
|
|
2717
|
-
intervalMs = 4e3,
|
|
2718
|
-
timeoutMs,
|
|
2719
|
-
exitDelayMs = 300,
|
|
2720
|
-
onComplete,
|
|
2721
|
-
onError
|
|
2722
|
-
}) => {
|
|
2723
|
-
const { exit } = useApp5();
|
|
2724
|
-
const [runState, setRunState] = useState18(null);
|
|
2725
|
-
const [error, setError] = useState18(null);
|
|
2726
|
-
useEffect17(() => {
|
|
2727
|
-
let cancelled = false;
|
|
2728
|
-
void (async () => {
|
|
2729
|
-
try {
|
|
2730
|
-
const finalStatus = await waitForTestRun(
|
|
2731
|
-
runId,
|
|
2732
|
-
intervalMs,
|
|
2733
|
-
(status) => {
|
|
2734
|
-
if (!cancelled) setRunState(status);
|
|
2735
|
-
},
|
|
2736
|
-
timeoutMs
|
|
2737
|
-
);
|
|
2738
|
-
if (!cancelled) {
|
|
2739
|
-
setRunState(finalStatus);
|
|
2740
|
-
onComplete?.(finalStatus);
|
|
2741
|
-
if (headless) setTimeout(exit, exitDelayMs);
|
|
2742
|
-
}
|
|
2743
|
-
} catch (err) {
|
|
2744
|
-
if (!cancelled) {
|
|
2745
|
-
const nextError = err instanceof Error ? err : new Error("Unknown error occurred");
|
|
2746
|
-
setError(nextError.message);
|
|
2747
|
-
onError?.(nextError);
|
|
2748
|
-
if (headless) setTimeout(exit, exitDelayMs);
|
|
2749
|
-
}
|
|
2750
|
-
}
|
|
2751
|
-
})();
|
|
2752
|
-
return () => {
|
|
2753
|
-
cancelled = true;
|
|
2754
|
-
};
|
|
2755
|
-
}, [runId, intervalMs, timeoutMs, headless, exitDelayMs, exit, onComplete, onError]);
|
|
2756
|
-
const isRunning = runState ? isRunningStatus(runState.status) : false;
|
|
2757
|
-
const isCompleted = runState ? isCompletedStatus(runState.status) : false;
|
|
2758
|
-
const body = /* @__PURE__ */ jsxs30(Box21, { flexDirection: "column", children: [
|
|
2759
|
-
error && /* @__PURE__ */ jsx55(StatusMessage17, { variant: "error", children: `Failed to complete test run: ${error}` }),
|
|
2760
|
-
!error && !runState && /* @__PURE__ */ jsx55(Spinner16, { label: "Initializing..." }),
|
|
2761
|
-
!error && runState && /* @__PURE__ */ jsx55(RunBody, { runState, isRunning })
|
|
2762
|
-
] });
|
|
2763
|
-
if (headless) return body;
|
|
2764
|
-
return /* @__PURE__ */ jsxs30(
|
|
2765
|
-
ViewLayout,
|
|
2766
|
-
{
|
|
2767
|
-
title,
|
|
2768
|
-
hints: isCompleted ? "navigationSelect" : "none",
|
|
2769
|
-
hintsHidden: !isCompleted,
|
|
2770
|
-
hintsPosition: "bottom",
|
|
2771
|
-
children: [
|
|
2772
|
-
body,
|
|
2773
|
-
isCompleted && /* @__PURE__ */ jsx55(Box21, { marginTop: 1, children: /* @__PURE__ */ jsx55(MenuList, { options: getMenuOptions(runId, menuState) }) })
|
|
2774
|
-
]
|
|
2775
|
-
}
|
|
2776
|
-
);
|
|
2777
|
-
};
|
|
2778
|
-
|
|
2779
|
-
// src/app/views/testRuns/TestRunDetails.tsx
|
|
2780
|
-
import { jsx as jsx56, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
2781
|
-
var TestRunDetails = () => {
|
|
2782
|
-
const { runId } = useParams9();
|
|
2783
|
-
const location = useLocation12();
|
|
2784
|
-
const state = location.state;
|
|
2785
|
-
const request = useTestRunDetails(runId);
|
|
2786
|
-
const title = request.data ? getTestRunName(request.data) : state?.testRunName;
|
|
2787
|
-
const menuState = title ? { testRunName: title } : void 0;
|
|
2788
|
-
if (!request.data || !runId) {
|
|
2789
|
-
return /* @__PURE__ */ jsxs31(ViewLayout, { title, hintsHidden: true, children: [
|
|
2790
|
-
request.isLoading && /* @__PURE__ */ jsx56(Spinner17, { label: "Loading test run..." }),
|
|
2791
|
-
request.isError && /* @__PURE__ */ jsx56(StatusMessage18, { variant: "error", children: request.error }),
|
|
2792
|
-
!request.isLoading && !request.isError && !request.data && /* @__PURE__ */ jsx56(Text21, { color: "yellow", children: "Test run not found." })
|
|
2793
|
-
] });
|
|
2794
|
-
}
|
|
2795
|
-
return /* @__PURE__ */ jsx56(BaseTestRunDetails, { runId, title, menuState });
|
|
2796
|
-
};
|
|
2797
|
-
|
|
2798
|
-
// src/app/views/testRuns/TestRunJunitReport.tsx
|
|
2799
|
-
import { Spinner as Spinner18, StatusMessage as StatusMessage19 } from "@inkjs/ui";
|
|
2800
|
-
import { Text as Text22 } from "ink";
|
|
2801
|
-
import { useEffect as useEffect18 } from "react";
|
|
2802
|
-
import { useLocation as useLocation13, useParams as useParams10 } from "react-router";
|
|
2803
|
-
import { Fragment as Fragment5, jsx as jsx57, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
2804
|
-
var DownloadReport = ({ runId }) => {
|
|
2805
|
-
const [downloadReport, downloadReportResult] = useFeatureMutation(async (runId2) => {
|
|
2806
|
-
const xml = await getTestRunJunitReport(runId2);
|
|
2807
|
-
return writeReportXml(xml, defaultJunitReportPath("test", runId2));
|
|
2808
|
-
});
|
|
2809
|
-
useEffect18(() => {
|
|
2810
|
-
void downloadReport(runId);
|
|
2811
|
-
}, [downloadReport, runId]);
|
|
2812
|
-
return /* @__PURE__ */ jsxs32(Fragment5, { children: [
|
|
2813
|
-
downloadReportResult.isLoading && /* @__PURE__ */ jsx57(Spinner18, { label: "Downloading JUnit report..." }),
|
|
2814
|
-
downloadReportResult.isError && /* @__PURE__ */ jsx57(StatusMessage19, { variant: "error", children: downloadReportResult.error }),
|
|
2815
|
-
downloadReportResult.data?.outPath && /* @__PURE__ */ jsx57(StatusMessage19, { variant: "success", children: `Saved JUnit report to ${downloadReportResult.data.outPath} (${downloadReportResult.data.size} chars)` })
|
|
2816
|
-
] });
|
|
2817
|
-
};
|
|
2818
|
-
var TestRunJunitReport = () => {
|
|
2819
|
-
const { runId } = useParams10();
|
|
2820
|
-
const location = useLocation13();
|
|
2821
|
-
const state = location.state;
|
|
2822
|
-
const request = useTestRunDetails(runId);
|
|
2823
|
-
const title = request.data ? getTestRunName(request.data) : state?.testRunName ?? runId;
|
|
2824
|
-
return /* @__PURE__ */ jsxs32(ViewLayout, { title, hintsHidden: true, hintsPosition: "bottom", children: [
|
|
2825
|
-
request.isLoading && /* @__PURE__ */ jsx57(Spinner18, { label: "Loading..." }),
|
|
2826
|
-
request.isError && /* @__PURE__ */ jsx57(Text22, { color: "red", children: request.error }),
|
|
2827
|
-
!request.isLoading && !request.isError && runId && /* @__PURE__ */ jsx57(DownloadReport, { runId }),
|
|
2828
|
-
!request.isLoading && !request.isError && !runId && /* @__PURE__ */ jsx57(StatusMessage19, { variant: "warning", children: "No test run selected" })
|
|
2829
|
-
] });
|
|
2830
|
-
};
|
|
2831
|
-
|
|
2832
|
-
// src/app/views/testRuns/TestRunOpen.tsx
|
|
2833
|
-
import { Spinner as Spinner19, StatusMessage as StatusMessage20 } from "@inkjs/ui";
|
|
2834
|
-
import { Box as Box22, Text as Text23 } from "ink";
|
|
2835
|
-
import { useEffect as useEffect19 } from "react";
|
|
2836
|
-
import { useLocation as useLocation14, useParams as useParams11 } from "react-router";
|
|
2837
|
-
import { Fragment as Fragment6, jsx as jsx58, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
2838
|
-
var WebUrlUnavailableMessage3 = () => /* @__PURE__ */ jsx58(StatusMessage20, { variant: "warning", children: "No web URL available for this run" });
|
|
2839
|
-
var OpenRun = ({ url }) => {
|
|
2840
|
-
const [openRun, openRunResult] = useFeatureMutation(async (url2) => {
|
|
2841
|
-
await openExternalUrl(url2);
|
|
2842
|
-
return url2;
|
|
2843
|
-
});
|
|
2844
|
-
useEffect19(() => {
|
|
2845
|
-
if (url) void openRun(url);
|
|
2846
|
-
}, [openRun, url]);
|
|
2847
|
-
if (!url) return /* @__PURE__ */ jsx58(WebUrlUnavailableMessage3, {});
|
|
2848
|
-
return /* @__PURE__ */ jsxs33(Fragment6, { children: [
|
|
2849
|
-
openRunResult.isLoading && /* @__PURE__ */ jsx58(Spinner19, { label: "Opening BugBug..." }),
|
|
2850
|
-
openRunResult.isError && /* @__PURE__ */ jsx58(StatusMessage20, { variant: "error", children: openRunResult.error }),
|
|
2851
|
-
openRunResult.data && /* @__PURE__ */ jsxs33(Box22, { flexDirection: "column", children: [
|
|
2852
|
-
/* @__PURE__ */ jsx58(StatusMessage20, { variant: "success", children: "Opened in BugBug" }),
|
|
2853
|
-
/* @__PURE__ */ jsx58(Text23, { dimColor: true, children: openRunResult.data })
|
|
2854
|
-
] })
|
|
2855
|
-
] });
|
|
2856
|
-
};
|
|
2857
|
-
var TestRunOpen = () => {
|
|
2858
|
-
const { runId } = useParams11();
|
|
2859
|
-
const location = useLocation14();
|
|
2860
|
-
const state = location.state;
|
|
2861
|
-
const request = useTestRunDetails(runId);
|
|
2862
|
-
const title = request.data ? getTestRunName(request.data) : state?.testRunName ?? runId;
|
|
2863
|
-
return /* @__PURE__ */ jsxs33(ViewLayout, { title, hintsHidden: true, hintsPosition: "bottom", children: [
|
|
2864
|
-
request.isLoading && /* @__PURE__ */ jsx58(Spinner19, { label: "Loading..." }),
|
|
2865
|
-
request.isError && /* @__PURE__ */ jsx58(Text23, { color: "red", children: request.error }),
|
|
2866
|
-
!request.isLoading && !request.isError && /* @__PURE__ */ jsx58(OpenRun, { url: request.data?.webappUrl })
|
|
2867
|
-
] });
|
|
2868
|
-
};
|
|
2869
|
-
|
|
2870
|
-
// src/app/views/testRuns/TestRunsList.tsx
|
|
2871
|
-
import { jsx as jsx59 } from "react/jsx-runtime";
|
|
2872
|
-
var TestRunsList2 = () => {
|
|
2873
|
-
const request = useTestRunsList();
|
|
2874
|
-
return /* @__PURE__ */ jsx59(
|
|
2875
|
-
TestRunsList,
|
|
2876
|
-
{
|
|
2877
|
-
testRuns: request.data,
|
|
2878
|
-
isLoading: request.isLoading,
|
|
2879
|
-
isError: request.isError,
|
|
2880
|
-
error: request.error
|
|
2881
|
-
}
|
|
2882
|
-
);
|
|
2883
|
-
};
|
|
2884
|
-
|
|
2885
|
-
// src/app/views/testRuns/TestRunsMenu.tsx
|
|
2886
|
-
import { useEffect as useEffect20 } from "react";
|
|
2887
|
-
import { useNavigate as useNavigate14 } from "react-router";
|
|
2888
|
-
var TestRunsMenu = () => {
|
|
2889
|
-
const navigate = useNavigate14();
|
|
2890
|
-
useEffect20(() => {
|
|
2891
|
-
navigate(ROUTES.testRuns.list(), { replace: true });
|
|
2892
|
-
}, [navigate]);
|
|
2893
|
-
return null;
|
|
2894
|
-
};
|
|
2895
|
-
|
|
2896
|
-
// src/app/views/tests/RunTest.tsx
|
|
2897
|
-
import { useNavigate as useNavigate15 } from "react-router";
|
|
2898
|
-
|
|
2899
|
-
// src/app/views/tests/BaseTestsList.tsx
|
|
2900
|
-
import { useState as useState19 } from "react";
|
|
2901
|
-
|
|
2902
|
-
// src/app/hooks/useTests.ts
|
|
2903
|
-
var useTestsList = (query) => useFeatureQuery(() => loadTestTableResources(query), [query]);
|
|
2904
|
-
var useTestDetails = (testId) => useFeatureQuery(async () => {
|
|
2905
|
-
if (!testId) return void 0;
|
|
2906
|
-
return getTestDetails(testId);
|
|
2907
|
-
}, [testId]);
|
|
2908
|
-
|
|
2909
|
-
// src/features/tests/tests.constants.tsx
|
|
2910
|
-
import { jsx as jsx60 } from "react/jsx-runtime";
|
|
2911
|
-
var TEST_COLUMNS = [
|
|
2912
|
-
{ key: "name", label: "Name", width: 42 },
|
|
2913
|
-
{
|
|
2914
|
-
key: "status",
|
|
2915
|
-
label: "Status",
|
|
2916
|
-
width: 14,
|
|
2917
|
-
render: (_cell, row, ctx) => /* @__PURE__ */ jsx60(Status, { status: row.value?.status, color: ctx.color, backgroundColor: ctx.backgroundColor })
|
|
2918
|
-
}
|
|
2919
|
-
];
|
|
2920
|
-
|
|
2921
|
-
// src/features/tests/tests.utils.tsx
|
|
2922
|
-
var getTestRow = (test) => ({
|
|
2923
|
-
key: test.id,
|
|
2924
|
-
cells: {
|
|
2925
|
-
name: getTestName(test),
|
|
2926
|
-
status: formatRunStatus(test.status)
|
|
2927
|
-
},
|
|
2928
|
-
value: test
|
|
2929
|
-
});
|
|
2930
|
-
var getTestName = (test) => test.name || test.id || "Untitled";
|
|
2931
|
-
|
|
2932
|
-
// src/app/views/tests/BaseTestsList.tsx
|
|
2933
|
-
import { jsx as jsx61 } from "react/jsx-runtime";
|
|
2934
|
-
var BaseTestsList = ({
|
|
2935
|
-
title,
|
|
2936
|
-
emptyMessage = "No tests found",
|
|
2937
|
-
onSelectTest
|
|
2938
|
-
}) => {
|
|
2939
|
-
const [query, setQuery] = useState19("");
|
|
2940
|
-
const request = useTestsList(query);
|
|
2941
|
-
return /* @__PURE__ */ jsx61(
|
|
2942
|
-
BaseResourceListScreen,
|
|
2943
|
-
{
|
|
2944
|
-
title,
|
|
2945
|
-
loadingLabel: "Loading tests...",
|
|
2946
|
-
emptyMessage,
|
|
2947
|
-
resources: request.data,
|
|
2948
|
-
isLoading: request.isLoading,
|
|
2949
|
-
isError: request.isError,
|
|
2950
|
-
error: request.error,
|
|
2951
|
-
columns: TEST_COLUMNS,
|
|
2952
|
-
getRow: getTestRow,
|
|
2953
|
-
searchable: true,
|
|
2954
|
-
query,
|
|
2955
|
-
onSearch: (next) => setQuery(next.trim()),
|
|
2956
|
-
onSelectResource: onSelectTest
|
|
2957
|
-
}
|
|
2958
|
-
);
|
|
2959
|
-
};
|
|
2960
|
-
|
|
2961
|
-
// src/app/views/tests/RunTest.tsx
|
|
2962
|
-
import { jsx as jsx62 } from "react/jsx-runtime";
|
|
2963
|
-
var RunTest = () => {
|
|
2964
|
-
const navigate = useNavigate15();
|
|
2965
|
-
return /* @__PURE__ */ jsx62(
|
|
2966
|
-
BaseTestsList,
|
|
2967
|
-
{
|
|
2968
|
-
title: "Select a test to run:",
|
|
2969
|
-
emptyMessage: "No tests available",
|
|
2970
|
-
onSelectTest: (test) => navigate(ROUTES.tests.run(test.id))
|
|
2971
|
-
}
|
|
2972
|
-
);
|
|
2973
|
-
};
|
|
2974
|
-
|
|
2975
|
-
// src/app/views/tests/TestDetails.tsx
|
|
2976
|
-
import { Spinner as Spinner20, StatusMessage as StatusMessage21 } from "@inkjs/ui";
|
|
2977
|
-
import { Box as Box23 } from "ink";
|
|
2978
|
-
import { useLocation as useLocation15, useParams as useParams12 } from "react-router";
|
|
2979
|
-
import { jsx as jsx63, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
2980
|
-
var TestDetails = () => {
|
|
2981
|
-
const { testId } = useParams12();
|
|
2982
|
-
const location = useLocation15();
|
|
2983
|
-
const state = location.state;
|
|
2984
|
-
const request = useTestDetails(testId);
|
|
2985
|
-
const title = request.data ? getTestName(request.data) : state?.testName;
|
|
2986
|
-
const detailsState = title ? { testName: title } : void 0;
|
|
2987
|
-
const data = request.data;
|
|
2988
|
-
const isNotFound = !request.isLoading && !request.isError && data === void 0;
|
|
2989
|
-
const isReady = !request.isLoading && !request.isError && data !== void 0;
|
|
2990
|
-
const hints = isReady ? void 0 : "none";
|
|
2991
|
-
const options = [
|
|
2992
|
-
{
|
|
2993
|
-
label: "Run",
|
|
2994
|
-
shortcut: "r",
|
|
2995
|
-
description: "Start a fresh run of this test",
|
|
2996
|
-
to: ROUTES.tests.run(testId ?? ""),
|
|
2997
|
-
state: detailsState
|
|
2998
|
-
},
|
|
2999
|
-
{
|
|
3000
|
-
label: "Show last run",
|
|
3001
|
-
shortcut: "h",
|
|
3002
|
-
description: "View the most recent run for this test",
|
|
3003
|
-
to: ROUTES.tests.lastRun(testId ?? ""),
|
|
3004
|
-
state: detailsState
|
|
3005
|
-
},
|
|
3006
|
-
{
|
|
3007
|
-
label: "Export (YAML)",
|
|
3008
|
-
shortcut: "e",
|
|
3009
|
-
description: "Save the test definition to a YAML file in the current directory",
|
|
3010
|
-
to: ROUTES.tests.export(testId ?? "")
|
|
3011
|
-
},
|
|
3012
|
-
{
|
|
3013
|
-
label: "Open in BugBug",
|
|
3014
|
-
shortcut: "o",
|
|
3015
|
-
description: "Open the test page in your browser",
|
|
3016
|
-
to: ROUTES.tests.open(testId ?? "")
|
|
3017
|
-
}
|
|
3018
|
-
];
|
|
3019
|
-
return /* @__PURE__ */ jsxs34(ViewLayout, { title, hints, children: [
|
|
3020
|
-
request.isLoading && /* @__PURE__ */ jsx63(Box23, { children: /* @__PURE__ */ jsx63(Spinner20, { label: "Loading test..." }) }),
|
|
3021
|
-
request.isError && /* @__PURE__ */ jsx63(StatusMessage21, { variant: "error", children: request.error }),
|
|
3022
|
-
isNotFound && /* @__PURE__ */ jsx63(StatusMessage21, { variant: "warning", children: "Test not found." }),
|
|
3023
|
-
isReady && /* @__PURE__ */ jsx63(MenuList, { options })
|
|
3024
|
-
] });
|
|
3025
|
-
};
|
|
3026
|
-
|
|
3027
|
-
// src/app/views/tests/TestDetailsExport.tsx
|
|
3028
|
-
import { StatusMessage as StatusMessage22 } from "@inkjs/ui";
|
|
3029
|
-
import { Spinner as Spinner21 } from "@inkjs/ui";
|
|
3030
|
-
import { useEffect as useEffect21 } from "react";
|
|
3031
|
-
import { useParams as useParams13 } from "react-router";
|
|
3032
|
-
import { jsx as jsx64, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
3033
|
-
var TestDetailsExport = () => {
|
|
3034
|
-
const { testId } = useParams13();
|
|
3035
|
-
const [exportTestMutation, exportTestResult] = useFeatureMutation(
|
|
3036
|
-
(id) => exportTest(id, "yaml")
|
|
3037
|
-
);
|
|
3038
|
-
useEffect21(() => {
|
|
3039
|
-
if (testId) void exportTestMutation(testId);
|
|
3040
|
-
}, [exportTestMutation, testId]);
|
|
3041
|
-
return /* @__PURE__ */ jsxs35(ViewLayout, { hintsHidden: true, children: [
|
|
3042
|
-
exportTestResult.isLoading && /* @__PURE__ */ jsx64(Spinner21, { label: `Exporting ${testId}...` }),
|
|
3043
|
-
exportTestResult.isError && /* @__PURE__ */ jsx64(StatusMessage22, { variant: "error", children: exportTestResult.error }),
|
|
3044
|
-
exportTestResult.data && /* @__PURE__ */ jsx64(StatusMessage22, { variant: "success", children: `Exported to ${exportTestResult.data.outPath} (${exportTestResult.data.size} chars)` })
|
|
3045
|
-
] });
|
|
3046
|
-
};
|
|
3047
|
-
|
|
3048
|
-
// src/app/views/tests/TestDetailsLastRun.tsx
|
|
3049
|
-
import { Spinner as Spinner22, StatusMessage as StatusMessage23 } from "@inkjs/ui";
|
|
3050
|
-
import { Text as Text24 } from "ink";
|
|
3051
|
-
import { useLocation as useLocation16, useParams as useParams14 } from "react-router";
|
|
3052
|
-
import { jsx as jsx65, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
3053
|
-
var TestDetailsLastRun = () => {
|
|
3054
|
-
const { testId } = useParams14();
|
|
3055
|
-
const location = useLocation16();
|
|
3056
|
-
const state = location.state;
|
|
3057
|
-
const request = useTestDetails(testId);
|
|
3058
|
-
const test = request.data;
|
|
3059
|
-
const isReady = !request.isLoading && !request.isError;
|
|
3060
|
-
const title = test ? getTestName(test) : state?.testName ?? testId;
|
|
3061
|
-
if (!isReady || !test?.lastRunId) {
|
|
3062
|
-
return /* @__PURE__ */ jsxs36(ViewLayout, { title, hintsHidden: true, hintsPosition: "bottom", children: [
|
|
3063
|
-
request.isLoading && /* @__PURE__ */ jsx65(Spinner22, { label: "Loading..." }),
|
|
3064
|
-
request.isError && /* @__PURE__ */ jsx65(Text24, { color: "red", children: request.error }),
|
|
3065
|
-
isReady && !test?.lastRunId && /* @__PURE__ */ jsx65(StatusMessage23, { variant: "warning", children: `No previous run found for ${test ? getTestName(test) : testId ?? "test"}` })
|
|
3066
|
-
] });
|
|
3067
|
-
}
|
|
3068
|
-
return /* @__PURE__ */ jsx65(BaseTestRunDetails, { runId: test.lastRunId, title, menuState: { testRunName: title } });
|
|
3069
|
-
};
|
|
3070
|
-
|
|
3071
|
-
// src/app/views/tests/TestDetailsOpen.tsx
|
|
3072
|
-
import { StatusMessage as StatusMessage24 } from "@inkjs/ui";
|
|
3073
|
-
import { Spinner as Spinner23 } from "@inkjs/ui";
|
|
3074
|
-
import { Box as Box24, Text as Text25 } from "ink";
|
|
3075
|
-
import { useEffect as useEffect22 } from "react";
|
|
3076
|
-
import { useParams as useParams15 } from "react-router";
|
|
3077
|
-
import { jsx as jsx66, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
3078
|
-
var WebUrlUnavailableMessage4 = () => /* @__PURE__ */ jsx66(StatusMessage24, { variant: "warning", children: "No web URL available for this test" });
|
|
3079
|
-
var TestDetailsOpen = () => {
|
|
3080
|
-
const { testId } = useParams15();
|
|
3081
|
-
const request = useFeatureQuery(async () => {
|
|
3082
|
-
if (!testId) return void 0;
|
|
3083
|
-
return getTest(testId);
|
|
3084
|
-
}, [testId]);
|
|
3085
|
-
const url = request.data?.webappUrl;
|
|
3086
|
-
const isReady = !request.isLoading && !request.isError;
|
|
3087
|
-
const [openTest, openTestResult] = useFeatureMutation(async (url2) => {
|
|
3088
|
-
await openExternalUrl(url2);
|
|
3089
|
-
return url2;
|
|
3090
|
-
});
|
|
3091
|
-
useEffect22(() => {
|
|
3092
|
-
if (isReady && url) void openTest(url);
|
|
3093
|
-
}, [isReady, openTest, url]);
|
|
3094
|
-
return /* @__PURE__ */ jsxs37(ViewLayout, { hintsHidden: true, children: [
|
|
3095
|
-
request.isLoading && /* @__PURE__ */ jsx66(Spinner23, { label: "Loading..." }),
|
|
3096
|
-
request.isError && /* @__PURE__ */ jsx66(Text25, { color: "red", children: request.error }),
|
|
3097
|
-
isReady && !url && /* @__PURE__ */ jsx66(WebUrlUnavailableMessage4, {}),
|
|
3098
|
-
isReady && url && openTestResult.isLoading && /* @__PURE__ */ jsx66(Spinner23, { label: "Opening BugBug..." }),
|
|
3099
|
-
isReady && url && openTestResult.isError && /* @__PURE__ */ jsx66(StatusMessage24, { variant: "error", children: openTestResult.error }),
|
|
3100
|
-
isReady && url && openTestResult.data && /* @__PURE__ */ jsxs37(Box24, { flexDirection: "column", children: [
|
|
3101
|
-
/* @__PURE__ */ jsx66(StatusMessage24, { variant: "success", children: "Opened in BugBug" }),
|
|
3102
|
-
/* @__PURE__ */ jsx66(Text25, { dimColor: true, children: openTestResult.data })
|
|
3103
|
-
] })
|
|
3104
|
-
] });
|
|
3105
|
-
};
|
|
3106
|
-
|
|
3107
|
-
// src/app/views/tests/TestDetailsRun.tsx
|
|
3108
|
-
import { Spinner as Spinner24, StatusMessage as StatusMessage25 } from "@inkjs/ui";
|
|
3109
|
-
import { useEffect as useEffect23 } from "react";
|
|
3110
|
-
import { useLocation as useLocation17, useNavigate as useNavigate16, useParams as useParams16 } from "react-router";
|
|
3111
|
-
import { jsx as jsx67, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
3112
|
-
var TestDetailsRun = () => {
|
|
3113
|
-
const { testId } = useParams16();
|
|
3114
|
-
const location = useLocation17();
|
|
3115
|
-
const navigate = useNavigate16();
|
|
3116
|
-
const state = location.state;
|
|
3117
|
-
const title = state?.testName ?? testId;
|
|
3118
|
-
const [runTestMutation, runTestResult] = useFeatureMutation((id) => runTest(id, {}));
|
|
3119
|
-
useEffect23(() => {
|
|
3120
|
-
if (!testId) return;
|
|
3121
|
-
const startRun = async () => {
|
|
3122
|
-
try {
|
|
3123
|
-
const result = await runTestMutation(testId);
|
|
3124
|
-
if ("data" in result) {
|
|
3125
|
-
navigate(ROUTES.testRuns.details(result.data.id), { replace: true, state });
|
|
3126
|
-
}
|
|
3127
|
-
} catch {
|
|
3128
|
-
}
|
|
3129
|
-
};
|
|
3130
|
-
startRun();
|
|
3131
|
-
}, [navigate, runTestMutation, state, testId]);
|
|
3132
|
-
if (!runTestResult.data) {
|
|
3133
|
-
return /* @__PURE__ */ jsxs38(ViewLayout, { title, hintsHidden: true, hintsPosition: "bottom", children: [
|
|
3134
|
-
runTestResult.isError && /* @__PURE__ */ jsx67(StatusMessage25, { variant: "error", children: runTestResult.error }),
|
|
3135
|
-
!runTestResult.isError && /* @__PURE__ */ jsx67(Spinner24, { label: "Initializing..." })
|
|
3136
|
-
] });
|
|
3137
|
-
}
|
|
3138
|
-
return /* @__PURE__ */ jsx67(BaseTestRunDetails, { runId: runTestResult.data.id, title, menuState: state });
|
|
3139
|
-
};
|
|
3140
|
-
|
|
3141
|
-
// src/app/views/tests/TestImport.tsx
|
|
3142
|
-
import { Spinner as Spinner25, StatusMessage as StatusMessage26 } from "@inkjs/ui";
|
|
3143
|
-
import { useEffect as useEffect24, useState as useState20 } from "react";
|
|
3144
|
-
import { useNavigate as useNavigate17 } from "react-router";
|
|
3145
|
-
import { jsx as jsx68, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
3146
|
-
var TestImport = ({ initialDirectory } = {}) => {
|
|
3147
|
-
const navigate = useNavigate17();
|
|
3148
|
-
const [file, setFile] = useState20(null);
|
|
3149
|
-
const [conflictMode, setConflictMode] = useState20(null);
|
|
3150
|
-
const [importTestMutation, importTestResult] = useFeatureMutation(
|
|
3151
|
-
async ({ file: file2, conflictMode: conflictMode2 }) => {
|
|
3152
|
-
detectFormat(file2);
|
|
3153
|
-
return importTest(file2, {
|
|
3154
|
-
conflictMode: conflictMode2 || void 0
|
|
3155
|
-
});
|
|
3156
|
-
}
|
|
3157
|
-
);
|
|
3158
|
-
useEffect24(() => {
|
|
3159
|
-
if (file && conflictMode !== null) {
|
|
3160
|
-
void importTestMutation({ file, conflictMode });
|
|
3161
|
-
}
|
|
3162
|
-
}, [conflictMode, file, importTestMutation]);
|
|
3163
|
-
useEscHandler(() => {
|
|
3164
|
-
if (!file || conflictMode !== null) return false;
|
|
3165
|
-
setFile(null);
|
|
3166
|
-
return true;
|
|
3167
|
-
});
|
|
3168
|
-
if (!file) {
|
|
3169
|
-
return /* @__PURE__ */ jsx68(
|
|
3170
|
-
FilePicker,
|
|
3171
|
-
{
|
|
3172
|
-
label: "Select .yaml/.yml/.zip file",
|
|
3173
|
-
initialDir: initialDirectory,
|
|
3174
|
-
extensions: [".yaml", ".yml", ".zip"],
|
|
3175
|
-
onSubmit: setFile,
|
|
3176
|
-
onBack: () => navigate(-1)
|
|
3177
|
-
}
|
|
3178
|
-
);
|
|
3179
|
-
}
|
|
3180
|
-
if (conflictMode === null) {
|
|
3181
|
-
return /* @__PURE__ */ jsx68(ViewLayout, { title: "Conflict mode (blank = API default)", children: /* @__PURE__ */ jsx68(
|
|
3182
|
-
MenuList,
|
|
3183
|
-
{
|
|
3184
|
-
options: [
|
|
3185
|
-
{ label: "Default", value: "" },
|
|
3186
|
-
{ label: "Overwrite", value: "overwrite" }
|
|
3187
|
-
],
|
|
3188
|
-
onSelect: (item) => setConflictMode(item.value ?? "")
|
|
3189
|
-
}
|
|
3190
|
-
) });
|
|
3191
|
-
}
|
|
3192
|
-
return /* @__PURE__ */ jsxs39(ViewLayout, { hintsHidden: true, hintsPosition: "bottom", children: [
|
|
3193
|
-
importTestResult.isLoading && /* @__PURE__ */ jsx68(Spinner25, { label: `Importing ${file}...` }),
|
|
3194
|
-
importTestResult.isError && /* @__PURE__ */ jsx68(StatusMessage26, { variant: "error", children: importTestResult.error }),
|
|
3195
|
-
importTestResult.data && /* @__PURE__ */ jsx68(StatusMessage26, { variant: "success", children: `Imported test: ${importTestResult.data.id ?? "(unknown)"}${importTestResult.data.name ? ` (${importTestResult.data.name})` : ""}` })
|
|
3196
|
-
] });
|
|
3197
|
-
};
|
|
3198
|
-
|
|
3199
|
-
// src/app/views/tests/TestsList.tsx
|
|
3200
|
-
import { useNavigate as useNavigate18 } from "react-router";
|
|
3201
|
-
import { jsx as jsx69 } from "react/jsx-runtime";
|
|
3202
|
-
var TestsList = () => {
|
|
3203
|
-
const navigate = useNavigate18();
|
|
3204
|
-
return /* @__PURE__ */ jsx69(
|
|
3205
|
-
BaseTestsList,
|
|
3206
|
-
{
|
|
3207
|
-
onSelectTest: (test) => navigate(ROUTES.tests.details(test.id), { state: { testName: getTestName(test) } })
|
|
3208
|
-
}
|
|
3209
|
-
);
|
|
3210
|
-
};
|
|
3211
|
-
|
|
3212
|
-
// src/app/views/tests/TestsMenu.tsx
|
|
3213
|
-
import { jsx as jsx70 } from "react/jsx-runtime";
|
|
3214
|
-
var TestsMenu = () => {
|
|
3215
|
-
return /* @__PURE__ */ jsx70(ViewLayout, { children: /* @__PURE__ */ jsx70(
|
|
3216
|
-
MenuList,
|
|
3217
|
-
{
|
|
3218
|
-
options: [
|
|
3219
|
-
{ label: "List tests", shortcut: "l", to: "/tests/list" },
|
|
3220
|
-
{
|
|
3221
|
-
label: "Import test",
|
|
3222
|
-
shortcut: "i",
|
|
3223
|
-
description: "YAML or ZIP",
|
|
3224
|
-
to: "/tests/import"
|
|
3225
|
-
},
|
|
3226
|
-
{ label: "Run a test", shortcut: "r", to: "/tests/run" }
|
|
3227
|
-
]
|
|
3228
|
-
}
|
|
3229
|
-
) });
|
|
3230
|
-
};
|
|
3231
|
-
|
|
3232
|
-
// src/app/router.tsx
|
|
3233
|
-
import { jsx as jsx71, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
3234
|
-
var createNavigatorRouter = ({
|
|
3235
|
-
initialRoute,
|
|
3236
|
-
initialRouteState
|
|
3237
|
-
} = {}) => {
|
|
3238
|
-
const getInitialEntries = () => {
|
|
3239
|
-
if (initialRoute) {
|
|
3240
|
-
const routeEntry = initialRouteState === void 0 ? initialRoute : { pathname: initialRoute, state: initialRouteState };
|
|
3241
|
-
return [ROUTES.root(), routeEntry];
|
|
3242
|
-
}
|
|
3243
|
-
return [ROUTES.root()];
|
|
3244
|
-
};
|
|
3245
|
-
const initialEntries = getInitialEntries();
|
|
3246
|
-
const router = createMemoryRouter(
|
|
3247
|
-
createRoutesFromElements(
|
|
3248
|
-
/* @__PURE__ */ jsxs40(Route, { element: /* @__PURE__ */ jsx71(Navigator, {}), children: [
|
|
3249
|
-
/* @__PURE__ */ jsx71(Route, { index: true, element: /* @__PURE__ */ jsx71(MainMenu, {}) }),
|
|
3250
|
-
/* @__PURE__ */ jsx71(Route, { path: "/init", element: /* @__PURE__ */ jsx71(ProjectInit, {}) }),
|
|
3251
|
-
/* @__PURE__ */ jsx71(Route, { path: "/tests", element: /* @__PURE__ */ jsx71(TestsMenu, {}) }),
|
|
3252
|
-
/* @__PURE__ */ jsx71(Route, { path: "/tests/list", element: /* @__PURE__ */ jsx71(TestsList, {}) }),
|
|
3253
|
-
/* @__PURE__ */ jsx71(Route, { path: "/tests/import", element: /* @__PURE__ */ jsx71(TestImport, {}) }),
|
|
3254
|
-
/* @__PURE__ */ jsx71(Route, { path: "/tests/run", element: /* @__PURE__ */ jsx71(RunTest, {}) }),
|
|
3255
|
-
/* @__PURE__ */ jsx71(Route, { path: "/tests/:testId", element: /* @__PURE__ */ jsx71(TestDetails, {}) }),
|
|
3256
|
-
/* @__PURE__ */ jsx71(Route, { path: "/tests/:testId/run", element: /* @__PURE__ */ jsx71(TestDetailsRun, {}) }),
|
|
3257
|
-
/* @__PURE__ */ jsx71(Route, { path: "/tests/:testId/lastRun", element: /* @__PURE__ */ jsx71(TestDetailsLastRun, {}) }),
|
|
3258
|
-
/* @__PURE__ */ jsx71(Route, { path: "/tests/:testId/export", element: /* @__PURE__ */ jsx71(TestDetailsExport, {}) }),
|
|
3259
|
-
/* @__PURE__ */ jsx71(Route, { path: "/tests/:testId/open", element: /* @__PURE__ */ jsx71(TestDetailsOpen, {}) }),
|
|
3260
|
-
/* @__PURE__ */ jsx71(Route, { path: "/testruns", element: /* @__PURE__ */ jsx71(TestRunsMenu, {}) }),
|
|
3261
|
-
/* @__PURE__ */ jsx71(Route, { path: "/testruns/list", element: /* @__PURE__ */ jsx71(TestRunsList2, {}) }),
|
|
3262
|
-
/* @__PURE__ */ jsx71(Route, { path: "/testruns/:runId", element: /* @__PURE__ */ jsx71(TestRunDetails, {}) }),
|
|
3263
|
-
/* @__PURE__ */ jsx71(Route, { path: "/testruns/:runId/debugArtifacts", element: /* @__PURE__ */ jsx71(TestRunDebugArtifacts, {}) }),
|
|
3264
|
-
/* @__PURE__ */ jsx71(Route, { path: "/testruns/:runId/junitReport", element: /* @__PURE__ */ jsx71(TestRunJunitReport, {}) }),
|
|
3265
|
-
/* @__PURE__ */ jsx71(Route, { path: "/testruns/:runId/open", element: /* @__PURE__ */ jsx71(TestRunOpen, {}) }),
|
|
3266
|
-
/* @__PURE__ */ jsx71(Route, { path: "/suites", element: /* @__PURE__ */ jsx71(SuitesMenu, {}) }),
|
|
3267
|
-
/* @__PURE__ */ jsx71(Route, { path: "/suites/list", element: /* @__PURE__ */ jsx71(SuitesList, {}) }),
|
|
3268
|
-
/* @__PURE__ */ jsx71(Route, { path: "/suites/run", element: /* @__PURE__ */ jsx71(RunSuite, {}) }),
|
|
3269
|
-
/* @__PURE__ */ jsx71(Route, { path: "/suites/:suiteId", element: /* @__PURE__ */ jsx71(SuiteDetails, {}) }),
|
|
3270
|
-
/* @__PURE__ */ jsx71(Route, { path: "/suites/:suiteId/run", element: /* @__PURE__ */ jsx71(SuiteDetailsRun, {}) }),
|
|
3271
|
-
/* @__PURE__ */ jsx71(Route, { path: "/suites/:suiteId/lastRun", element: /* @__PURE__ */ jsx71(SuiteDetailsLastRun, {}) }),
|
|
3272
|
-
/* @__PURE__ */ jsx71(Route, { path: "/suites/:suiteId/open", element: /* @__PURE__ */ jsx71(SuiteDetailsOpen, {}) }),
|
|
3273
|
-
/* @__PURE__ */ jsx71(Route, { path: "/suiteruns", element: /* @__PURE__ */ jsx71(SuiteRunsMenu, {}) }),
|
|
3274
|
-
/* @__PURE__ */ jsx71(Route, { path: "/suiteruns/list", element: /* @__PURE__ */ jsx71(SuiteRunsList, {}) }),
|
|
3275
|
-
/* @__PURE__ */ jsx71(Route, { path: "/suiteruns/:runId", element: /* @__PURE__ */ jsx71(SuiteRunDetails, {}) }),
|
|
3276
|
-
/* @__PURE__ */ jsx71(Route, { path: "/suiteruns/:runId/showTestRuns", element: /* @__PURE__ */ jsx71(SuiteRunShowTestRuns, {}) }),
|
|
3277
|
-
/* @__PURE__ */ jsx71(Route, { path: "/suiteruns/:runId/open", element: /* @__PURE__ */ jsx71(SuiteRunOpen, {}) }),
|
|
3278
|
-
/* @__PURE__ */ jsx71(Route, { path: "/profiles", element: /* @__PURE__ */ jsx71(ProfilesMenu, {}) }),
|
|
3279
|
-
/* @__PURE__ */ jsx71(Route, { path: "/profiles/list", element: /* @__PURE__ */ jsx71(ProfilesList, {}) }),
|
|
3280
|
-
/* @__PURE__ */ jsx71(Route, { path: "/project", element: /* @__PURE__ */ jsx71(ProjectMenu, {}) }),
|
|
3281
|
-
/* @__PURE__ */ jsx71(Route, { path: "/project/switch", element: /* @__PURE__ */ jsx71(ProjectSwitch, {}) }),
|
|
3282
|
-
/* @__PURE__ */ jsx71(Route, { path: "/project/export", element: /* @__PURE__ */ jsx71(ProjectExport, {}) }),
|
|
3283
|
-
/* @__PURE__ */ jsx71(Route, { path: "/project/import", element: /* @__PURE__ */ jsx71(ProjectImport, {}) }),
|
|
3284
|
-
/* @__PURE__ */ jsx71(Route, { path: "/settings", element: /* @__PURE__ */ jsx71(SettingsMenu, {}) }),
|
|
3285
|
-
/* @__PURE__ */ jsx71(Route, { path: "/settings/setSessionToken", element: /* @__PURE__ */ jsx71(SettingsSetSessionToken, {}) }),
|
|
3286
|
-
/* @__PURE__ */ jsx71(Route, { path: "/logout", element: /* @__PURE__ */ jsx71(Logout, {}) })
|
|
3287
|
-
] })
|
|
3288
|
-
),
|
|
3289
|
-
{ initialEntries, initialIndex: initialEntries.length - 1 }
|
|
3290
|
-
);
|
|
3291
|
-
return router;
|
|
3292
|
-
};
|
|
3293
|
-
|
|
3294
|
-
// src/app/NavigatorApp.tsx
|
|
3295
|
-
import { jsx as jsx72 } from "react/jsx-runtime";
|
|
3296
|
-
var NavigatorApp = ({ initialRoute, initialRouteState }) => {
|
|
3297
|
-
const [router] = useState21(() => createNavigatorRouter({ initialRoute, initialRouteState }));
|
|
3298
|
-
return /* @__PURE__ */ jsx72(NavigatorSessionProvider, { children: /* @__PURE__ */ jsx72(RouterProvider, { router }) });
|
|
3299
|
-
};
|
|
3300
|
-
export {
|
|
3301
|
-
NavigatorApp
|
|
3302
|
-
};
|
|
3303
|
-
//# sourceMappingURL=NavigatorApp-FHG7FP7M.js.map
|
|
3304
|
-
//# debugId=20137d86-cd7e-5ca0-8a8c-3b405154dfa8
|