bdy 1.25.34-beta → 1.25.34-dev-pr
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/distTs/package.json +2 -1
- package/distTs/src/api/client.js +191 -1
- package/distTs/src/autocomplete.js +90 -0
- package/distTs/src/cliError.js +5 -0
- package/distTs/src/cliIndex.js +3 -0
- package/distTs/src/command/artifact/downloadDir.js +110 -0
- package/distTs/src/command/autocomplete/install.js +16 -0
- package/distTs/src/command/autocomplete/uninstall.js +16 -0
- package/distTs/src/command/autocomplete.js +14 -0
- package/distTs/src/command/environment/resolve.js +39 -0
- package/distTs/src/command/package/create.js +64 -0
- package/distTs/src/command/package/delete.js +38 -0
- package/distTs/src/command/package/docker/login.js +26 -0
- package/distTs/src/command/package/docker.js +11 -0
- package/distTs/src/command/package/download.js +138 -0
- package/distTs/src/command/package/get.js +36 -0
- package/distTs/src/command/package/list.js +31 -0
- package/distTs/src/command/package/publish.js +241 -0
- package/distTs/src/command/package/version/delete.js +39 -0
- package/distTs/src/command/package/version/get.js +45 -0
- package/distTs/src/command/package/version/list.js +47 -0
- package/distTs/src/command/package/version.js +16 -0
- package/distTs/src/command/package.js +26 -0
- package/distTs/src/command/pipeline/run/apply.js +62 -0
- package/distTs/src/command/pr/comment/add.js +66 -0
- package/distTs/src/command/pr/comment/list.js +169 -0
- package/distTs/src/command/pr/comment/status.js +48 -0
- package/distTs/src/command/pr/comment.js +19 -0
- package/distTs/src/command/pr/create.js +43 -0
- package/distTs/src/command/pr/diff.js +227 -0
- package/distTs/src/command/pr/file/list.js +124 -0
- package/distTs/src/command/pr/file/mark.js +45 -0
- package/distTs/src/command/pr/file.js +16 -0
- package/distTs/src/command/pr/get.js +29 -0
- package/distTs/src/command/pr/list.js +79 -0
- package/distTs/src/command/pr/merge.js +66 -0
- package/distTs/src/command/pr/review/request.js +29 -0
- package/distTs/src/command/pr/review/start.js +29 -0
- package/distTs/src/command/pr/review/verdict.js +81 -0
- package/distTs/src/command/pr/review.js +18 -0
- package/distTs/src/command/pr/shared.js +595 -0
- package/distTs/src/command/pr/state.js +38 -0
- package/distTs/src/command/pr/summary.js +316 -0
- package/distTs/src/command/pr/update.js +54 -0
- package/distTs/src/command/pr/updateBranch.js +22 -0
- package/distTs/src/command/pr/versions.js +42 -0
- package/distTs/src/command/pr.js +39 -0
- package/distTs/src/command/scrape/validation.js +154 -0
- package/distTs/src/command/scrape.js +144 -0
- package/distTs/src/command/suiteLink.js +14 -0
- package/distTs/src/command/tests/visual/result/download.js +31 -0
- package/distTs/src/command/tests/visual/result/get.js +68 -0
- package/distTs/src/command/tests/visual/result/list.js +49 -0
- package/distTs/src/command/tests/visual/result.js +23 -0
- package/distTs/src/command/tests/visual/session/get.js +70 -0
- package/distTs/src/command/tests/visual/session/list.js +69 -0
- package/distTs/src/command/tests/visual/session/open.js +22 -0
- package/distTs/src/command/tests/visual/session/reviewUrl.js +37 -0
- package/distTs/src/command/tests/visual/session/update.js +26 -0
- package/distTs/src/command/tests/visual/shared/context.js +144 -0
- package/distTs/src/command/tests/visual/shared/diffRegions.js +172 -0
- package/distTs/src/command/tests/visual/shared/format.js +21 -0
- package/distTs/src/command/tests/visual/shared/lookup.js +107 -0
- package/distTs/src/command/tests/visual/shared/options.js +90 -0
- package/distTs/src/command/tests/visual/shared/review.js +146 -0
- package/distTs/src/command/tests/visual/shared/reviewUrl.js +62 -0
- package/distTs/src/command/tests/visual/shared/session.js +217 -0
- package/distTs/src/command/tests/visual/snapshot/get.js +46 -0
- package/distTs/src/command/tests/visual/snapshot/list.js +68 -0
- package/distTs/src/command/tests/visual/snapshot/open.js +26 -0
- package/distTs/src/command/tests/visual/snapshot/reviewUrl.js +48 -0
- package/distTs/src/command/tests/visual/snapshot.js +28 -0
- package/distTs/src/command/tests/visual/suite/create.js +38 -0
- package/distTs/src/command/tests/visual/suite/delete.js +29 -0
- package/distTs/src/command/tests/visual/suite/get.js +43 -0
- package/distTs/src/command/tests/visual/suite/list.js +35 -0
- package/distTs/src/command/tests/visual/suite/open.js +20 -0
- package/distTs/src/command/tests/visual/suite/update.js +47 -0
- package/distTs/src/command/tests/visual/suite.js +30 -0
- package/distTs/src/command/ut/upload.js +86 -0
- package/distTs/src/command/ut.js +12 -0
- package/distTs/src/command/vt/close.js +27 -0
- package/distTs/src/command/vt/compare/validation.js +46 -0
- package/distTs/src/command/vt/compare.js +100 -0
- package/distTs/src/command/vt/exec.js +82 -0
- package/distTs/src/command/vt/installBrowser.js +20 -0
- package/distTs/src/command/vt/shared/validation.js +145 -0
- package/distTs/src/command/vt/storybook.js +138 -0
- package/distTs/src/command/vt.js +20 -0
- package/distTs/src/command/yaml/agents.js +88 -0
- package/distTs/src/command/yaml/init.js +110 -0
- package/distTs/src/main.js +190 -0
- package/distTs/src/output.js +41 -1
- package/distTs/src/texts.js +450 -1
- package/distTs/src/types/options.js +2 -0
- package/distTs/src/types/scrape.js +2 -0
- package/distTs/src/types/visualTests.js +2 -0
- package/distTs/src/utils.js +133 -3
- package/package.json +2 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNewOrChanged = isNewOrChanged;
|
|
4
|
+
exports.reviewFiltersFor = reviewFiltersFor;
|
|
5
|
+
exports.vtSessionReviewUrl = vtSessionReviewUrl;
|
|
6
|
+
exports.vtSnapshotReviewUrl = vtSnapshotReviewUrl;
|
|
7
|
+
const utils_1 = require("../../../../utils");
|
|
8
|
+
// A snapshot the review view counts as "new or changed": no baseline, or a
|
|
9
|
+
// baseline it differs from (frontend SNAPSHOTS_FILTER_TYPE_MAP).
|
|
10
|
+
function isNewOrChanged(snapshot) {
|
|
11
|
+
return Boolean(snapshot.is_new || !snapshot.is_unchanged);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Filters the review view opens with, mirroring the web app's own session
|
|
15
|
+
* links: UNREVIEWED while something waits for a decision (ALL otherwise), plus
|
|
16
|
+
* NEW_AND_CHANGED when any of the given snapshots is new or differs from its
|
|
17
|
+
* baseline. The view drops a filter that matches nothing, so this only ever
|
|
18
|
+
* narrows to snapshots that exist.
|
|
19
|
+
*/
|
|
20
|
+
function reviewFiltersFor(snapshots) {
|
|
21
|
+
const waiting = snapshots.some((s) => s.status === utils_1.VT_SNAPSHOT_STATUS.WAITING_FOR_APPROVE);
|
|
22
|
+
const filters = [waiting ? utils_1.VT_REVIEW_FILTER.UNREVIEWED : utils_1.VT_REVIEW_FILTER.ALL];
|
|
23
|
+
if (snapshots.some(isNewOrChanged)) {
|
|
24
|
+
filters.push(utils_1.VT_REVIEW_FILTER.NEW_AND_CHANGED);
|
|
25
|
+
}
|
|
26
|
+
return filters;
|
|
27
|
+
}
|
|
28
|
+
// The session page with the review flow open; the reviewer steps through
|
|
29
|
+
// every undecided snapshot from there.
|
|
30
|
+
function vtSessionReviewUrl(sessionHtmlUrl, filters) {
|
|
31
|
+
const url = new URL(sessionHtmlUrl);
|
|
32
|
+
url.searchParams.set('review', 'true');
|
|
33
|
+
url.searchParams.set('filterTypes', filters.join(','));
|
|
34
|
+
return withLiteralCommas(url);
|
|
35
|
+
}
|
|
36
|
+
// The web app writes filterTypes=A,B with a bare comma; URLSearchParams would
|
|
37
|
+
// escape it to %2C, which also trips the terminal writer's %-formatting.
|
|
38
|
+
function withLiteralCommas(url) {
|
|
39
|
+
return url.toString().replace(/%2C/g, ',');
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Link to the session's review view opened on one snapshot, e.g.
|
|
43
|
+
* https://app.buddy.works/ws/project/visual-tests/<suite>/<session>
|
|
44
|
+
* ?browser=CHROMIUM&colorScheme=LIGHT&review=true&scale=1&snapshotId=<id>&width=1920
|
|
45
|
+
* Screen parameters are sent only when given; the view picks an existing
|
|
46
|
+
* screen of the snapshot otherwise.
|
|
47
|
+
*/
|
|
48
|
+
function vtSnapshotReviewUrl(sessionHtmlUrl, snapshotId, screen, filters) {
|
|
49
|
+
const url = new URL(sessionHtmlUrl);
|
|
50
|
+
if (screen.browser)
|
|
51
|
+
url.searchParams.set('browser', screen.browser);
|
|
52
|
+
if (screen.colorScheme)
|
|
53
|
+
url.searchParams.set('colorScheme', screen.colorScheme);
|
|
54
|
+
url.searchParams.set('filterTypes', filters.join(','));
|
|
55
|
+
url.searchParams.set('review', 'true');
|
|
56
|
+
if (screen.scale)
|
|
57
|
+
url.searchParams.set('scale', String(screen.scale));
|
|
58
|
+
url.searchParams.set('snapshotId', snapshotId);
|
|
59
|
+
if (screen.width)
|
|
60
|
+
url.searchParams.set('width', String(screen.width));
|
|
61
|
+
return withLiteralCommas(url);
|
|
62
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.DEFAULT_VT_WAIT_TIMEOUT_SEC = void 0;
|
|
40
|
+
exports.vtWaitOptions = vtWaitOptions;
|
|
41
|
+
exports.vtSnapshotCounts = vtSnapshotCounts;
|
|
42
|
+
exports.printVtSessionCreated = printVtSessionCreated;
|
|
43
|
+
exports.printVtWaitTimedOut = printVtWaitTimedOut;
|
|
44
|
+
exports.vtSessionExitCode = vtSessionExitCode;
|
|
45
|
+
exports.waitForVtSession = waitForVtSession;
|
|
46
|
+
exports.finishVtSession = finishVtSession;
|
|
47
|
+
const commander_1 = require("commander");
|
|
48
|
+
const cliError_1 = __importStar(require("../../../../cliError"));
|
|
49
|
+
const output_1 = __importDefault(require("../../../../output"));
|
|
50
|
+
const texts_1 = require("../../../../texts");
|
|
51
|
+
const utils_1 = require("../../../../utils");
|
|
52
|
+
const context_1 = require("./context");
|
|
53
|
+
const lookup_1 = require("./lookup");
|
|
54
|
+
const POLL_INTERVAL_MS = 3000;
|
|
55
|
+
exports.DEFAULT_VT_WAIT_TIMEOUT_SEC = 1800;
|
|
56
|
+
function parseWaitTimeout(value) {
|
|
57
|
+
if (!/^[1-9]\d*$/.test(value))
|
|
58
|
+
throw new commander_1.InvalidArgumentError(texts_1.ERR_VT_WAIT_TIMEOUT);
|
|
59
|
+
return Number(value);
|
|
60
|
+
}
|
|
61
|
+
function vtWaitOptions(command, { waitByDefault = true } = {}) {
|
|
62
|
+
if (waitByDefault)
|
|
63
|
+
command.option('-n, --no-wait', texts_1.OPTION_VT_SESSION_NO_WAIT);
|
|
64
|
+
else
|
|
65
|
+
command.option('--wait', texts_1.OPTION_VT_SESSION_WAIT);
|
|
66
|
+
command.option('--wait-timeout <seconds>', texts_1.OPTION_VT_SESSION_WAIT_TIMEOUT, parseWaitTimeout, exports.DEFAULT_VT_WAIT_TIMEOUT_SEC);
|
|
67
|
+
command.option('--exit-code', texts_1.OPTION_VT_SESSION_EXIT_CODE);
|
|
68
|
+
return command;
|
|
69
|
+
}
|
|
70
|
+
function vtSnapshotCounts(snapshots) {
|
|
71
|
+
const count = (matches) => snapshots.filter(matches).length;
|
|
72
|
+
const compared = (snapshot) => snapshot.status !== utils_1.VT_SNAPSHOT_STATUS.IN_PROGRESS &&
|
|
73
|
+
snapshot.status !== utils_1.VT_SNAPSHOT_STATUS.ERROR;
|
|
74
|
+
return {
|
|
75
|
+
total: snapshots.length,
|
|
76
|
+
new: count((s) => compared(s) && !!s.is_new),
|
|
77
|
+
changed: count((s) => compared(s) && !s.is_new && !s.is_unchanged),
|
|
78
|
+
unchanged: count((s) => compared(s) && !!s.is_unchanged),
|
|
79
|
+
error: count((s) => s.status === utils_1.VT_SNAPSHOT_STATUS.ERROR),
|
|
80
|
+
waiting_for_review: count((s) => s.status === utils_1.VT_SNAPSHOT_STATUS.WAITING_FOR_APPROVE),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Prints the outcome shared by every command that creates a session (capture,
|
|
85
|
+
* upload, session create): the session URL, its id and the command that
|
|
86
|
+
* reports its status.
|
|
87
|
+
*/
|
|
88
|
+
function printVtSessionCreated(response, options, statusHint = true) {
|
|
89
|
+
const { sessionUrl, sessionId } = response;
|
|
90
|
+
if (response.status === utils_1.VT_SESSION_STATUS.SKIPPED) {
|
|
91
|
+
output_1.default.warning((0, texts_1.TXT_VT_SESSION_SKIPPED)(sessionUrl, sessionId));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const created = (0, texts_1.TXT_VT_SESSION_CREATED)(sessionUrl, sessionId);
|
|
95
|
+
output_1.default.green(statusHint
|
|
96
|
+
? `${created}\n${(0, texts_1.TXT_VT_SESSION_STATUS_HINT)(sessionId, (0, context_1.vtContextFlags)(options))}`
|
|
97
|
+
: created);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Warns that the session is still in progress once --wait-timeout runs out,
|
|
101
|
+
* with the command that waits again. In JSON mode the warning goes to stderr.
|
|
102
|
+
*/
|
|
103
|
+
function printVtWaitTimedOut(timeout, sessionId, options, json = false) {
|
|
104
|
+
const note = (0, texts_1.TXT_VT_SESSION_WAIT_TIMED_OUT)(timeout, sessionId, (0, context_1.vtContextFlags)(options));
|
|
105
|
+
if (json)
|
|
106
|
+
output_1.default.noteWarning(note);
|
|
107
|
+
else
|
|
108
|
+
output_1.default.warning(note);
|
|
109
|
+
}
|
|
110
|
+
function vtSessionExitCode(status, semantic) {
|
|
111
|
+
if (!semantic) {
|
|
112
|
+
return status === utils_1.VT_SESSION_STATUS.ERROR ||
|
|
113
|
+
status === utils_1.VT_SESSION_STATUS.TERMINATED
|
|
114
|
+
? 1
|
|
115
|
+
: 0;
|
|
116
|
+
}
|
|
117
|
+
switch (status) {
|
|
118
|
+
case utils_1.VT_SESSION_STATUS.APPROVED:
|
|
119
|
+
return cliError_1.SemanticExitCode.SUCCESS;
|
|
120
|
+
case utils_1.VT_SESSION_STATUS.WAITING_FOR_APPROVE:
|
|
121
|
+
case utils_1.VT_SESSION_STATUS.REJECTED:
|
|
122
|
+
case utils_1.VT_SESSION_STATUS.ERROR:
|
|
123
|
+
case utils_1.VT_SESSION_STATUS.TERMINATED:
|
|
124
|
+
case utils_1.VT_SESSION_STATUS.SKIPPED:
|
|
125
|
+
return cliError_1.SemanticExitCode.FAILURE;
|
|
126
|
+
case utils_1.VT_SESSION_STATUS.IN_PROGRESS:
|
|
127
|
+
return cliError_1.SemanticExitCode.PENDING;
|
|
128
|
+
default:
|
|
129
|
+
throw new cliError_1.default('command_failed', (0, texts_1.ERR_VT_SESSION_STATUS_UNKNOWN)(status));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function waitForVtSession(ctx, sessionId, timeoutSec, onCheck = () => { }) {
|
|
133
|
+
const deadline = Date.now() + timeoutSec * 1000;
|
|
134
|
+
for (;;) {
|
|
135
|
+
const session = await (0, lookup_1.getVtSessionOrExit)(ctx, sessionId);
|
|
136
|
+
onCheck(session);
|
|
137
|
+
if (session.status !== utils_1.VT_SESSION_STATUS.IN_PROGRESS) {
|
|
138
|
+
return { session, timedOut: false };
|
|
139
|
+
}
|
|
140
|
+
const remaining = deadline - Date.now();
|
|
141
|
+
if (remaining <= 0)
|
|
142
|
+
return { session, timedOut: true };
|
|
143
|
+
await (0, utils_1.sleep)(Math.min(POLL_INTERVAL_MS, remaining));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function exitVtSession(code, jsonl) {
|
|
147
|
+
if (jsonl)
|
|
148
|
+
output_1.default.json({ type: 'exit', code });
|
|
149
|
+
return output_1.default.exitCode(code);
|
|
150
|
+
}
|
|
151
|
+
function printVtSessionFinished(status, sessionId, counts, options) {
|
|
152
|
+
const finished = (0, texts_1.TXT_VT_SESSION_FINISHED)(status);
|
|
153
|
+
const flags = (0, context_1.vtContextFlags)(options);
|
|
154
|
+
let hint;
|
|
155
|
+
switch (status) {
|
|
156
|
+
case utils_1.VT_SESSION_STATUS.APPROVED:
|
|
157
|
+
output_1.default.green(finished);
|
|
158
|
+
break;
|
|
159
|
+
case utils_1.VT_SESSION_STATUS.WAITING_FOR_APPROVE:
|
|
160
|
+
output_1.default.warning(finished);
|
|
161
|
+
hint = (0, texts_1.TXT_VT_SESSION_REVIEW_HINT)(sessionId, flags);
|
|
162
|
+
break;
|
|
163
|
+
case utils_1.VT_SESSION_STATUS.SKIPPED:
|
|
164
|
+
output_1.default.warning(finished);
|
|
165
|
+
hint = texts_1.TXT_VT_SESSION_SKIPPED_REASON;
|
|
166
|
+
break;
|
|
167
|
+
case utils_1.VT_SESSION_STATUS.ERROR:
|
|
168
|
+
output_1.default.error(finished);
|
|
169
|
+
hint = (0, texts_1.TXT_VT_SESSION_ERROR_HINT)(sessionId, flags);
|
|
170
|
+
break;
|
|
171
|
+
case utils_1.VT_SESSION_STATUS.REJECTED:
|
|
172
|
+
case utils_1.VT_SESSION_STATUS.TERMINATED:
|
|
173
|
+
output_1.default.error(finished);
|
|
174
|
+
break;
|
|
175
|
+
default:
|
|
176
|
+
output_1.default.normal(finished);
|
|
177
|
+
}
|
|
178
|
+
output_1.default.normal((0, texts_1.TXT_VT_SESSION_SNAPSHOT_COUNTS)(counts));
|
|
179
|
+
if (hint)
|
|
180
|
+
output_1.default.normal(hint);
|
|
181
|
+
}
|
|
182
|
+
async function finishVtSession(response, options) {
|
|
183
|
+
const jsonl = options.format === 'jsonl';
|
|
184
|
+
const semantic = Boolean(options.exitCode);
|
|
185
|
+
const timeout = options.waitTimeout ?? exports.DEFAULT_VT_WAIT_TIMEOUT_SEC;
|
|
186
|
+
const { sessionId } = response;
|
|
187
|
+
const wait = options.wait !== false &&
|
|
188
|
+
response.status === utils_1.VT_SESSION_STATUS.IN_PROGRESS;
|
|
189
|
+
if (jsonl)
|
|
190
|
+
output_1.default.json({ type: 'created', session: response });
|
|
191
|
+
else
|
|
192
|
+
printVtSessionCreated(response, options, !wait);
|
|
193
|
+
if (!wait)
|
|
194
|
+
exitVtSession(vtSessionExitCode(response.status, semantic), jsonl);
|
|
195
|
+
if (!jsonl)
|
|
196
|
+
output_1.default.normal(texts_1.TXT_VT_SESSION_WAITING);
|
|
197
|
+
const ctx = await (0, context_1.resolveVtSessionContext)(options);
|
|
198
|
+
const { session, timedOut } = await waitForVtSession(ctx, sessionId, timeout, (checked) => {
|
|
199
|
+
if (jsonl && checked.status === utils_1.VT_SESSION_STATUS.IN_PROGRESS) {
|
|
200
|
+
output_1.default.json({ type: 'status', status: checked.status });
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
const code = vtSessionExitCode(session.status, semantic);
|
|
204
|
+
if (timedOut) {
|
|
205
|
+
if (jsonl)
|
|
206
|
+
output_1.default.json({ type: 'timeout', seconds: timeout });
|
|
207
|
+
else
|
|
208
|
+
printVtWaitTimedOut(timeout, sessionId, options);
|
|
209
|
+
exitVtSession(code, jsonl);
|
|
210
|
+
}
|
|
211
|
+
const snapshots = vtSnapshotCounts(await (0, lookup_1.fetchAllVtSnapshots)(ctx, sessionId));
|
|
212
|
+
if (jsonl)
|
|
213
|
+
output_1.default.json({ type: 'finished', session, snapshots });
|
|
214
|
+
else
|
|
215
|
+
printVtSessionFinished(session.status, sessionId, snapshots, options);
|
|
216
|
+
exitVtSession(code, jsonl);
|
|
217
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../../utils");
|
|
7
|
+
const texts_1 = require("../../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../../output"));
|
|
9
|
+
const context_1 = require("../shared/context");
|
|
10
|
+
const lookup_1 = require("../shared/lookup");
|
|
11
|
+
const format_1 = require("../shared/format");
|
|
12
|
+
const reviewUrl_1 = require("../shared/reviewUrl");
|
|
13
|
+
const commandSnapshotGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_VT_SNAPSHOT_GET, {
|
|
14
|
+
examples: texts_1.EXAMPLE_TESTS_VISUAL_SNAPSHOT_GET,
|
|
15
|
+
});
|
|
16
|
+
(0, context_1.vtCommandOptions)(commandSnapshotGet);
|
|
17
|
+
commandSnapshotGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
18
|
+
commandSnapshotGet.argument('<session-id>', texts_1.OPTION_VT_SESSION_ID);
|
|
19
|
+
commandSnapshotGet.argument('<snapshot-id>', texts_1.OPTION_VT_SNAPSHOT_ID);
|
|
20
|
+
commandSnapshotGet.action(async (sessionId, snapshotId, options) => {
|
|
21
|
+
const json = options.format === 'json';
|
|
22
|
+
const ctx = await (0, context_1.resolveVtApiContext)(options);
|
|
23
|
+
const snapshot = await (0, lookup_1.getVtSnapshotOrExit)(ctx, sessionId, snapshotId);
|
|
24
|
+
if (json) {
|
|
25
|
+
output_1.default.json(snapshot);
|
|
26
|
+
output_1.default.exitNormal();
|
|
27
|
+
}
|
|
28
|
+
output_1.default.object({
|
|
29
|
+
ID: (0, format_1.dash)(snapshot.id),
|
|
30
|
+
Name: (0, format_1.dash)(snapshot.name),
|
|
31
|
+
'Path group': (0, format_1.dash)(snapshot.path_group),
|
|
32
|
+
Status: (0, format_1.dash)(snapshot.status),
|
|
33
|
+
'New (no baseline)': (0, format_1.formatVtFlag)(snapshot.is_new),
|
|
34
|
+
Unchanged: (0, format_1.formatVtFlag)(snapshot.is_unchanged),
|
|
35
|
+
'Auto-approved': (0, format_1.formatVtFlag)(snapshot.auto_approved),
|
|
36
|
+
'Used as baseline': (0, format_1.formatVtFlag)(snapshot.used_as_baseline),
|
|
37
|
+
Created: (0, format_1.formatVtDate)(snapshot.create_date),
|
|
38
|
+
Finished: (0, format_1.formatVtDate)(snapshot.finish_date),
|
|
39
|
+
'Status changed': (0, format_1.formatVtDate)(snapshot.status_change_date),
|
|
40
|
+
'Results folder': `snapshots/${snapshot.id}`,
|
|
41
|
+
'Review URL': (0, reviewUrl_1.vtSnapshotReviewUrl)(snapshot.html_url, snapshot.id, {}, (0, reviewUrl_1.reviewFiltersFor)([snapshot])),
|
|
42
|
+
});
|
|
43
|
+
output_1.default.note((0, texts_1.TXT_VT_SNAPSHOT_DETAILS_HINT)(sessionId, ctx.flags));
|
|
44
|
+
output_1.default.exitNormal();
|
|
45
|
+
});
|
|
46
|
+
exports.default = commandSnapshotGet;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../../utils");
|
|
7
|
+
const texts_1 = require("../../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../../output"));
|
|
9
|
+
const options_1 = require("../shared/options");
|
|
10
|
+
const context_1 = require("../shared/context");
|
|
11
|
+
const lookup_1 = require("../shared/lookup");
|
|
12
|
+
function snapshotFlags(snapshot) {
|
|
13
|
+
const flags = [];
|
|
14
|
+
if (snapshot.is_new)
|
|
15
|
+
flags.push('new');
|
|
16
|
+
if (snapshot.is_unchanged)
|
|
17
|
+
flags.push('unchanged');
|
|
18
|
+
if (snapshot.auto_approved)
|
|
19
|
+
flags.push('auto-approved');
|
|
20
|
+
if (snapshot.used_as_baseline)
|
|
21
|
+
flags.push('baseline');
|
|
22
|
+
return flags.join(', ') || '-';
|
|
23
|
+
}
|
|
24
|
+
const commandSnapshotList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_VT_SNAPSHOT_LIST, {
|
|
25
|
+
examples: texts_1.EXAMPLE_TESTS_VISUAL_SNAPSHOT_LIST,
|
|
26
|
+
});
|
|
27
|
+
commandSnapshotList.alias('ls');
|
|
28
|
+
(0, context_1.vtCommandOptions)(commandSnapshotList);
|
|
29
|
+
commandSnapshotList.option('--status <status>', texts_1.OPTION_VT_SNAPSHOT_STATUS);
|
|
30
|
+
commandSnapshotList.option('--name <prefix>', texts_1.OPTION_VT_SNAPSHOT_NAME);
|
|
31
|
+
commandSnapshotList.option('--page <number>', texts_1.OPTION_REST_API_PAGE, '1');
|
|
32
|
+
commandSnapshotList.option('--per-page <number>', texts_1.OPTION_VT_PER_PAGE, '20');
|
|
33
|
+
commandSnapshotList.option('--all', texts_1.OPTION_VT_ALL_PAGES);
|
|
34
|
+
commandSnapshotList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
35
|
+
commandSnapshotList.argument('<session-id>', texts_1.OPTION_VT_SESSION_ID);
|
|
36
|
+
commandSnapshotList.action(async (sessionId, options) => {
|
|
37
|
+
const parsed = (0, options_1.parseVtOptions)(options_1.vtSnapshotListOptions, options);
|
|
38
|
+
const { page } = parsed;
|
|
39
|
+
const json = options.format === 'json';
|
|
40
|
+
const perPage = parsed.all ? 100 : parsed.perPage;
|
|
41
|
+
const filter = { status: parsed.status, name: parsed.name };
|
|
42
|
+
const ctx = await (0, context_1.resolveVtApiContext)(options);
|
|
43
|
+
// Resolves a wrong session id to a specific message before listing.
|
|
44
|
+
await (0, lookup_1.getVtSessionOrExit)(ctx, sessionId);
|
|
45
|
+
const result = await (0, lookup_1.fetchVtPages)('snapshots', page, perPage, Boolean(parsed.all), (p) => ctx.client.getVtSnapshots(ctx.workspace, ctx.project, ctx.suiteId, sessionId, { ...filter, page: p, per_page: perPage }));
|
|
46
|
+
const snapshots = result.snapshots || [];
|
|
47
|
+
if (json) {
|
|
48
|
+
output_1.default.json(result);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
if (!snapshots.length) {
|
|
52
|
+
output_1.default.exitNormal(texts_1.TXT_VT_SNAPSHOTS_NOT_FOUND);
|
|
53
|
+
}
|
|
54
|
+
const data = [['ID', 'NAME', 'STATUS', 'FLAGS']];
|
|
55
|
+
for (const snapshot of snapshots) {
|
|
56
|
+
data.push([
|
|
57
|
+
snapshot.id,
|
|
58
|
+
(0, utils_1.truncate)(snapshot.name || '-', 60),
|
|
59
|
+
snapshot.status || '-',
|
|
60
|
+
snapshotFlags(snapshot),
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
output_1.default.table(data);
|
|
64
|
+
(0, lookup_1.vtPagingNote)(result, snapshots.length);
|
|
65
|
+
}
|
|
66
|
+
output_1.default.exitNormal();
|
|
67
|
+
});
|
|
68
|
+
exports.default = commandSnapshotList;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../../utils");
|
|
7
|
+
const texts_1 = require("../../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../../output"));
|
|
9
|
+
const context_1 = require("../shared/context");
|
|
10
|
+
const lookup_1 = require("../shared/lookup");
|
|
11
|
+
const reviewUrl_1 = require("../shared/reviewUrl");
|
|
12
|
+
const commandSnapshotOpen = (0, utils_1.newCommand)('open', texts_1.DESC_COMMAND_RESOURCE_OPEN, {
|
|
13
|
+
examples: texts_1.EXAMPLE_TESTS_VISUAL_SNAPSHOT_OPEN,
|
|
14
|
+
});
|
|
15
|
+
(0, context_1.vtCommandOptions)(commandSnapshotOpen);
|
|
16
|
+
commandSnapshotOpen.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
17
|
+
commandSnapshotOpen.argument('<session-id>', texts_1.OPTION_VT_SESSION_ID);
|
|
18
|
+
commandSnapshotOpen.argument('<snapshot-id>', texts_1.OPTION_VT_SNAPSHOT_ID);
|
|
19
|
+
commandSnapshotOpen.action(async (sessionId, snapshotId, options) => {
|
|
20
|
+
const ctx = await (0, context_1.resolveVtApiContext)(options);
|
|
21
|
+
const snapshot = await (0, lookup_1.getVtSnapshotOrExit)(ctx, sessionId, snapshotId);
|
|
22
|
+
// A snapshot has no page of its own; it is shown in its session's review view.
|
|
23
|
+
const url = (0, reviewUrl_1.vtSnapshotReviewUrl)(snapshot.html_url, snapshot.id, {}, (0, reviewUrl_1.reviewFiltersFor)([snapshot]));
|
|
24
|
+
await output_1.default.openUrl(url, options.format === 'json');
|
|
25
|
+
});
|
|
26
|
+
exports.default = commandSnapshotOpen;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../../utils");
|
|
7
|
+
const texts_1 = require("../../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../../output"));
|
|
9
|
+
const options_1 = require("../shared/options");
|
|
10
|
+
const context_1 = require("../shared/context");
|
|
11
|
+
const lookup_1 = require("../shared/lookup");
|
|
12
|
+
const reviewUrl_1 = require("../shared/reviewUrl");
|
|
13
|
+
const commandSnapshotReviewUrl = (0, utils_1.newCommand)('review-url', texts_1.DESC_COMMAND_VT_SNAPSHOT_REVIEW_URL, {
|
|
14
|
+
examples: texts_1.EXAMPLE_TESTS_VISUAL_SNAPSHOT_REVIEW_URL,
|
|
15
|
+
});
|
|
16
|
+
(0, context_1.vtCommandOptions)(commandSnapshotReviewUrl);
|
|
17
|
+
commandSnapshotReviewUrl.option('--browser <name>', texts_1.OPTION_VT_REVIEW_BROWSER);
|
|
18
|
+
commandSnapshotReviewUrl.option('--width <px>', texts_1.OPTION_VT_REVIEW_WIDTH);
|
|
19
|
+
commandSnapshotReviewUrl.option('--scale <ratio>', texts_1.OPTION_VT_REVIEW_SCALE);
|
|
20
|
+
commandSnapshotReviewUrl.option('--color-scheme <LIGHT|DARK>', texts_1.OPTION_VT_REVIEW_COLOR_SCHEME);
|
|
21
|
+
commandSnapshotReviewUrl.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
22
|
+
commandSnapshotReviewUrl.argument('<session-id>', texts_1.OPTION_VT_SESSION_ID);
|
|
23
|
+
commandSnapshotReviewUrl.argument('<snapshot-id>', texts_1.OPTION_VT_SNAPSHOT_ID);
|
|
24
|
+
commandSnapshotReviewUrl.action(async (sessionId, snapshotId, options) => {
|
|
25
|
+
const json = options.format === 'json';
|
|
26
|
+
const screen = (0, options_1.parseVtOptions)(options_1.vtSnapshotReviewUrlOptions, options);
|
|
27
|
+
const ctx = await (0, context_1.resolveVtApiContext)(options);
|
|
28
|
+
const snapshot = await (0, lookup_1.getVtSnapshotOrExit)(ctx, sessionId, snapshotId);
|
|
29
|
+
const filters = (0, reviewUrl_1.reviewFiltersFor)([snapshot]);
|
|
30
|
+
const url = (0, reviewUrl_1.vtSnapshotReviewUrl)(snapshot.html_url, snapshot.id, screen, filters);
|
|
31
|
+
if (json) {
|
|
32
|
+
output_1.default.json({
|
|
33
|
+
url,
|
|
34
|
+
session_id: sessionId,
|
|
35
|
+
snapshot_id: snapshot.id,
|
|
36
|
+
filter_types: filters,
|
|
37
|
+
browser: screen.browser ?? null,
|
|
38
|
+
width: screen.width ?? null,
|
|
39
|
+
scale: screen.scale ?? null,
|
|
40
|
+
color_scheme: screen.colorScheme ?? null,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
output_1.default.normal(url);
|
|
45
|
+
}
|
|
46
|
+
output_1.default.exitNormal();
|
|
47
|
+
});
|
|
48
|
+
exports.default = commandSnapshotReviewUrl;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const list_1 = __importDefault(require("./snapshot/list"));
|
|
9
|
+
const get_1 = __importDefault(require("./snapshot/get"));
|
|
10
|
+
const open_1 = __importDefault(require("./snapshot/open"));
|
|
11
|
+
const reviewUrl_1 = __importDefault(require("./snapshot/reviewUrl"));
|
|
12
|
+
const review_1 = require("./shared/review");
|
|
13
|
+
const commandSnapshot = (0, utils_1.newCommand)('snapshot', texts_1.DESC_COMMAND_VT_SNAPSHOT, {
|
|
14
|
+
examples: [
|
|
15
|
+
...texts_1.EXAMPLE_TESTS_VISUAL_SNAPSHOT_LIST,
|
|
16
|
+
...texts_1.EXAMPLE_TESTS_VISUAL_SNAPSHOT_GET,
|
|
17
|
+
...texts_1.EXAMPLE_TESTS_VISUAL_SNAPSHOT_OPEN,
|
|
18
|
+
...texts_1.EXAMPLE_TESTS_VISUAL_SNAPSHOT_REVIEW_URL,
|
|
19
|
+
...texts_1.EXAMPLE_TESTS_VISUAL_SNAPSHOT_APPROVE,
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
commandSnapshot.alias('snap');
|
|
23
|
+
commandSnapshot.addCommand(list_1.default);
|
|
24
|
+
commandSnapshot.addCommand(get_1.default);
|
|
25
|
+
commandSnapshot.addCommand(open_1.default);
|
|
26
|
+
commandSnapshot.addCommand(reviewUrl_1.default);
|
|
27
|
+
(0, review_1.vtReviewCommands)('snapshot').forEach((c) => commandSnapshot.addCommand(c));
|
|
28
|
+
exports.default = commandSnapshot;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const cliError_1 = __importDefault(require("../../../../cliError"));
|
|
7
|
+
const utils_1 = require("../../../../utils");
|
|
8
|
+
const texts_1 = require("../../../../texts");
|
|
9
|
+
const output_1 = __importDefault(require("../../../../output"));
|
|
10
|
+
const context_1 = require("../shared/context");
|
|
11
|
+
const commandSuiteCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_VT_SUITE_CREATE, {
|
|
12
|
+
examples: texts_1.EXAMPLE_TESTS_VISUAL_SUITE_CREATE,
|
|
13
|
+
});
|
|
14
|
+
commandSuiteCreate.alias('add');
|
|
15
|
+
(0, context_1.vtCommandOptions)(commandSuiteCreate, { suite: false });
|
|
16
|
+
commandSuiteCreate.option('--identifier <identifier>', texts_1.OPTION_VT_SUITE_CREATE_IDENTIFIER);
|
|
17
|
+
commandSuiteCreate.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
18
|
+
commandSuiteCreate.argument('<name>', texts_1.OPTION_VT_SUITE_CREATE_NAME);
|
|
19
|
+
commandSuiteCreate.action(async (name, options) => {
|
|
20
|
+
const json = options.format === 'json';
|
|
21
|
+
const { client, workspace, project } = await (0, context_1.resolveVtProjectContext)(options);
|
|
22
|
+
const existing = (await client.getVtSuites(workspace, project)).suites || [];
|
|
23
|
+
const flags = (0, context_1.vtContextFlags)(options);
|
|
24
|
+
const sameName = existing.find((s) => s.name === name);
|
|
25
|
+
if (sameName) {
|
|
26
|
+
output_1.default.exitError(new cliError_1.default('usage_error', (0, texts_1.ERR_VT_SUITE_NAME_TAKEN)(name, sameName.identifier), (0, texts_1.HINT_VT_SUITE_NAME_TAKEN)(sameName.identifier)));
|
|
27
|
+
}
|
|
28
|
+
if (options.identifier &&
|
|
29
|
+
existing.some((s) => s.identifier === options.identifier)) {
|
|
30
|
+
output_1.default.exitError(new cliError_1.default('usage_error', (0, texts_1.ERR_VT_SUITE_IDENTIFIER_TAKEN)(options.identifier), (0, texts_1.HINT_VT_SUITE_IDENTIFIER_TAKEN)(flags)));
|
|
31
|
+
}
|
|
32
|
+
const suite = await client.createVtSuite(workspace, project, {
|
|
33
|
+
name,
|
|
34
|
+
identifier: options.identifier,
|
|
35
|
+
});
|
|
36
|
+
output_1.default.exitResult(json, { ...suite, token: undefined }, (0, texts_1.TXT_VT_SUITE_CREATED)(suite.identifier, suite.html_url, flags));
|
|
37
|
+
});
|
|
38
|
+
exports.default = commandSuiteCreate;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../../utils");
|
|
7
|
+
const texts_1 = require("../../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../../output"));
|
|
9
|
+
const context_1 = require("../shared/context");
|
|
10
|
+
const commandSuiteDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_VT_SUITE_DELETE, {
|
|
11
|
+
examples: texts_1.EXAMPLE_TESTS_VISUAL_SUITE_DELETE,
|
|
12
|
+
});
|
|
13
|
+
commandSuiteDelete.alias('rm');
|
|
14
|
+
(0, context_1.vtCommandOptions)(commandSuiteDelete);
|
|
15
|
+
commandSuiteDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
16
|
+
commandSuiteDelete.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
17
|
+
commandSuiteDelete.action(async (options) => {
|
|
18
|
+
const json = options.format === 'json';
|
|
19
|
+
const { client, workspace, project, suiteId } = await (0, context_1.resolveVtApiContext)(options);
|
|
20
|
+
// Fetched first so the prompt and the summary can name the suite by its
|
|
21
|
+
// identifier rather than by the hash id.
|
|
22
|
+
const suite = await client.getVtSuite(workspace, project, suiteId);
|
|
23
|
+
const confirmed = await output_1.default.confirmDestructive(options.force, (0, texts_1.TXT_VT_SUITE_DELETE_CONFIRM)(suite.identifier), json);
|
|
24
|
+
if (!confirmed)
|
|
25
|
+
output_1.default.exitResult(json, { deleted: null });
|
|
26
|
+
await client.deleteVtSuite(workspace, project, suiteId);
|
|
27
|
+
output_1.default.exitResult(json, { deleted: suite.identifier }, (0, texts_1.TXT_VT_SUITE_DELETED)(suite.identifier));
|
|
28
|
+
});
|
|
29
|
+
exports.default = commandSuiteDelete;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../../utils");
|
|
7
|
+
const texts_1 = require("../../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../../output"));
|
|
9
|
+
const context_1 = require("../shared/context");
|
|
10
|
+
const format_1 = require("../shared/format");
|
|
11
|
+
const commandSuiteGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_VT_SUITE_GET, {
|
|
12
|
+
examples: texts_1.EXAMPLE_TESTS_VISUAL_SUITE_GET,
|
|
13
|
+
});
|
|
14
|
+
(0, context_1.vtCommandOptions)(commandSuiteGet);
|
|
15
|
+
commandSuiteGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
16
|
+
commandSuiteGet.action(async (options) => {
|
|
17
|
+
const json = options.format === 'json';
|
|
18
|
+
const { client, workspace, project, suiteId } = await (0, context_1.resolveVtApiContext)(options);
|
|
19
|
+
const suite = await client.getVtSuite(workspace, project, suiteId);
|
|
20
|
+
if (json) {
|
|
21
|
+
output_1.default.json(suite);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
output_1.default.object({
|
|
25
|
+
ID: (0, format_1.dash)(suite.id),
|
|
26
|
+
Identifier: (0, format_1.dash)(suite.identifier),
|
|
27
|
+
Name: (0, format_1.dash)(suite.name),
|
|
28
|
+
Workspace: workspace,
|
|
29
|
+
Project: project,
|
|
30
|
+
'Base branch': (0, format_1.dash)(suite.base_branch),
|
|
31
|
+
Threshold: (0, format_1.dash)(suite.threshold),
|
|
32
|
+
Timeout: suite.timeout === undefined ? '-' : `${suite.timeout} ms`,
|
|
33
|
+
'JavaScript enabled': (0, format_1.formatVtFlag)(suite.enable_javascript),
|
|
34
|
+
'Full page': (0, format_1.formatVtFlag)(suite.full_page),
|
|
35
|
+
'Auto-approved wildcard': (0, format_1.dash)(suite.auto_approved_wildcard),
|
|
36
|
+
'Ignored snapshots': (0, format_1.dash)((suite.ignored_snapshots || []).join(', ')),
|
|
37
|
+
'Results artifact ID': (0, format_1.dash)(suite.artifact_id),
|
|
38
|
+
URL: (0, format_1.dash)(suite.html_url),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
output_1.default.exitNormal();
|
|
42
|
+
});
|
|
43
|
+
exports.default = commandSuiteGet;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../../utils");
|
|
7
|
+
const texts_1 = require("../../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../../output"));
|
|
9
|
+
const context_1 = require("../shared/context");
|
|
10
|
+
const commandSuiteList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_VT_SUITE_LIST, {
|
|
11
|
+
examples: texts_1.EXAMPLE_TESTS_VISUAL_SUITE_LIST,
|
|
12
|
+
});
|
|
13
|
+
commandSuiteList.alias('ls');
|
|
14
|
+
(0, context_1.vtCommandOptions)(commandSuiteList, { suite: false });
|
|
15
|
+
commandSuiteList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
16
|
+
commandSuiteList.action(async (options) => {
|
|
17
|
+
const json = options.format === 'json';
|
|
18
|
+
const { client, workspace, project } = await (0, context_1.resolveVtProjectContext)(options);
|
|
19
|
+
const result = await client.getVtSuites(workspace, project);
|
|
20
|
+
const suites = result?.suites || [];
|
|
21
|
+
if (json) {
|
|
22
|
+
output_1.default.json(result);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if (!suites.length)
|
|
26
|
+
output_1.default.exitNormal(texts_1.TXT_VT_SUITES_NOT_FOUND);
|
|
27
|
+
const data = [['IDENTIFIER', 'NAME', 'ID']];
|
|
28
|
+
for (const suite of suites) {
|
|
29
|
+
data.push([suite.identifier || '-', suite.name || '-', suite.id || '-']);
|
|
30
|
+
}
|
|
31
|
+
output_1.default.table(data);
|
|
32
|
+
}
|
|
33
|
+
output_1.default.exitNormal();
|
|
34
|
+
});
|
|
35
|
+
exports.default = commandSuiteList;
|