bdy 1.25.43-dev-pr → 1.25.44-dev
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 +6 -5
- package/distTs/src/api/client.js +1 -191
- package/distTs/src/cliError.js +0 -5
- package/distTs/src/cliIndex.js +0 -3
- package/distTs/src/command/login.js +1 -1
- package/distTs/src/output/pipeline.js +56 -54
- package/distTs/src/output.js +22 -85
- package/distTs/src/texts.js +1 -510
- package/distTs/src/tunnel/output/interactive/tunnel.js +10 -14
- package/distTs/src/tunnel/output/noninteractive/tunnel.js +1 -3
- package/distTs/src/utils.js +6 -142
- package/package.json +6 -5
- package/distTs/src/autocomplete.js +0 -90
- package/distTs/src/command/artifact/downloadDir.js +0 -110
- package/distTs/src/command/autocomplete/install.js +0 -16
- package/distTs/src/command/autocomplete/uninstall.js +0 -16
- package/distTs/src/command/autocomplete.js +0 -14
- package/distTs/src/command/environment/resolve.js +0 -39
- package/distTs/src/command/package/create.js +0 -64
- package/distTs/src/command/package/delete.js +0 -38
- package/distTs/src/command/package/docker/login.js +0 -26
- package/distTs/src/command/package/docker.js +0 -11
- package/distTs/src/command/package/download.js +0 -138
- package/distTs/src/command/package/get.js +0 -36
- package/distTs/src/command/package/list.js +0 -31
- package/distTs/src/command/package/publish.js +0 -241
- package/distTs/src/command/package/version/delete.js +0 -39
- package/distTs/src/command/package/version/get.js +0 -45
- package/distTs/src/command/package/version/list.js +0 -47
- package/distTs/src/command/package/version.js +0 -16
- package/distTs/src/command/package.js +0 -26
- package/distTs/src/command/pipeline/run/apply.js +0 -62
- package/distTs/src/command/pr/comment/add.js +0 -66
- package/distTs/src/command/pr/comment/list.js +0 -167
- package/distTs/src/command/pr/comment/status.js +0 -50
- package/distTs/src/command/pr/comment.js +0 -19
- package/distTs/src/command/pr/create.js +0 -44
- package/distTs/src/command/pr/diff.js +0 -337
- package/distTs/src/command/pr/file/list.js +0 -139
- package/distTs/src/command/pr/file/mark.js +0 -45
- package/distTs/src/command/pr/file.js +0 -16
- package/distTs/src/command/pr/get.js +0 -29
- package/distTs/src/command/pr/list.js +0 -79
- package/distTs/src/command/pr/merge.js +0 -67
- package/distTs/src/command/pr/review/request.js +0 -30
- package/distTs/src/command/pr/review/start.js +0 -29
- package/distTs/src/command/pr/review/verdict.js +0 -81
- package/distTs/src/command/pr/review.js +0 -18
- package/distTs/src/command/pr/shared.js +0 -704
- package/distTs/src/command/pr/state.js +0 -38
- package/distTs/src/command/pr/summary.js +0 -341
- package/distTs/src/command/pr/update.js +0 -56
- package/distTs/src/command/pr/updateBranch.js +0 -22
- package/distTs/src/command/pr/versions.js +0 -42
- package/distTs/src/command/pr.js +0 -39
- package/distTs/src/command/scrape/validation.js +0 -154
- package/distTs/src/command/scrape.js +0 -144
- package/distTs/src/command/suiteLink.js +0 -14
- package/distTs/src/command/tests/visual/result/download.js +0 -31
- package/distTs/src/command/tests/visual/result/get.js +0 -68
- package/distTs/src/command/tests/visual/result/list.js +0 -49
- package/distTs/src/command/tests/visual/result.js +0 -23
- package/distTs/src/command/tests/visual/session/get.js +0 -70
- package/distTs/src/command/tests/visual/session/list.js +0 -69
- package/distTs/src/command/tests/visual/session/open.js +0 -22
- package/distTs/src/command/tests/visual/session/reviewUrl.js +0 -37
- package/distTs/src/command/tests/visual/session/update.js +0 -26
- package/distTs/src/command/tests/visual/shared/context.js +0 -144
- package/distTs/src/command/tests/visual/shared/diffRegions.js +0 -172
- package/distTs/src/command/tests/visual/shared/format.js +0 -21
- package/distTs/src/command/tests/visual/shared/lookup.js +0 -107
- package/distTs/src/command/tests/visual/shared/options.js +0 -90
- package/distTs/src/command/tests/visual/shared/review.js +0 -146
- package/distTs/src/command/tests/visual/shared/reviewUrl.js +0 -62
- package/distTs/src/command/tests/visual/shared/session.js +0 -217
- package/distTs/src/command/tests/visual/snapshot/get.js +0 -46
- package/distTs/src/command/tests/visual/snapshot/list.js +0 -68
- package/distTs/src/command/tests/visual/snapshot/open.js +0 -26
- package/distTs/src/command/tests/visual/snapshot/reviewUrl.js +0 -48
- package/distTs/src/command/tests/visual/snapshot.js +0 -28
- package/distTs/src/command/tests/visual/suite/create.js +0 -38
- package/distTs/src/command/tests/visual/suite/delete.js +0 -29
- package/distTs/src/command/tests/visual/suite/get.js +0 -43
- package/distTs/src/command/tests/visual/suite/list.js +0 -35
- package/distTs/src/command/tests/visual/suite/open.js +0 -20
- package/distTs/src/command/tests/visual/suite/update.js +0 -47
- package/distTs/src/command/tests/visual/suite.js +0 -30
- package/distTs/src/command/ut/upload.js +0 -86
- package/distTs/src/command/ut.js +0 -12
- package/distTs/src/command/vt/close.js +0 -27
- package/distTs/src/command/vt/compare/validation.js +0 -46
- package/distTs/src/command/vt/compare.js +0 -100
- package/distTs/src/command/vt/exec.js +0 -82
- package/distTs/src/command/vt/installBrowser.js +0 -20
- package/distTs/src/command/vt/shared/validation.js +0 -145
- package/distTs/src/command/vt/storybook.js +0 -138
- package/distTs/src/command/vt.js +0 -20
- package/distTs/src/command/yaml/agents.js +0 -88
- package/distTs/src/command/yaml/init.js +0 -110
- package/distTs/src/main.js +0 -190
- package/distTs/src/types/options.js +0 -2
- package/distTs/src/types/scrape.js +0 -2
- package/distTs/src/types/visualTests.js +0 -2
|
@@ -1,146 +0,0 @@
|
|
|
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
|
-
exports.vtReviewCommands = vtReviewCommands;
|
|
7
|
-
const cliError_1 = __importDefault(require("../../../../cliError"));
|
|
8
|
-
const output_1 = __importDefault(require("../../../../output"));
|
|
9
|
-
const utils_1 = require("../../../../utils");
|
|
10
|
-
const texts_1 = require("../../../../texts");
|
|
11
|
-
const context_1 = require("./context");
|
|
12
|
-
const lookup_1 = require("./lookup");
|
|
13
|
-
// Mirrors the backend's per-snapshot validation (UpdateSnapshotStatusCommand):
|
|
14
|
-
// the API rejects the whole batch if any member cannot legally change, so the
|
|
15
|
-
// CLI only ever sends snapshots that will pass.
|
|
16
|
-
function skipReason(snapshot, target) {
|
|
17
|
-
if (snapshot.status === target)
|
|
18
|
-
return 'already';
|
|
19
|
-
if (target === utils_1.VT_SNAPSHOT_STATUS.WAITING_FOR_APPROVE &&
|
|
20
|
-
snapshot.auto_approved) {
|
|
21
|
-
return 'auto-approved';
|
|
22
|
-
}
|
|
23
|
-
if (snapshot.status === utils_1.VT_SNAPSHOT_STATUS.IN_PROGRESS ||
|
|
24
|
-
snapshot.status === utils_1.VT_SNAPSHOT_STATUS.ERROR) {
|
|
25
|
-
return 'in-progress-or-error';
|
|
26
|
-
}
|
|
27
|
-
if (snapshot.used_as_baseline)
|
|
28
|
-
return 'baseline';
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
const ACTIONS = {
|
|
32
|
-
[utils_1.VT_SNAPSHOT_STATUS.APPROVED]: { verb: 'approve', done: 'Approved' },
|
|
33
|
-
[utils_1.VT_SNAPSHOT_STATUS.REJECTED]: { verb: 'reject', done: 'Rejected' },
|
|
34
|
-
[utils_1.VT_SNAPSHOT_STATUS.WAITING_FOR_APPROVE]: {
|
|
35
|
-
verb: 'unreview',
|
|
36
|
-
done: 'Unreviewed',
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
function pickSnapshots(all, ids, sessionId, flags) {
|
|
40
|
-
const byId = new Map(all.map((s) => [s.id, s]));
|
|
41
|
-
const missing = ids.filter((id) => !byId.has(id));
|
|
42
|
-
if (missing.length) {
|
|
43
|
-
output_1.default.exitError(new cliError_1.default('not_found', (0, texts_1.ERR_VT_REVIEW_NOT_FOUND)(missing), (0, texts_1.HINT_VT_SNAPSHOT_LIST)(sessionId, flags)));
|
|
44
|
-
}
|
|
45
|
-
return ids.map((id) => byId.get(id));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Splits the candidate snapshots into ones that can move to `target` and ones
|
|
49
|
-
* to skip (with the reason), sends the bulk update and reports the resulting
|
|
50
|
-
* session status. `snapshotIds` limits the candidates to the named snapshots;
|
|
51
|
-
* without it every snapshot of the session is a candidate. The JSON result is
|
|
52
|
-
* assembled by the CLI: the bulk endpoint returns only the changed snapshots
|
|
53
|
-
* and says nothing about the skipped ones or the session.
|
|
54
|
-
*/
|
|
55
|
-
async function review(sessionId, snapshotIds, target, options) {
|
|
56
|
-
const json = options.format === 'json';
|
|
57
|
-
const ctx = await (0, context_1.resolveVtApiContext)(options);
|
|
58
|
-
const before = await (0, lookup_1.getVtSessionOrExit)(ctx, sessionId);
|
|
59
|
-
const all = await (0, lookup_1.fetchAllVtSnapshots)(ctx, sessionId);
|
|
60
|
-
const candidates = snapshotIds
|
|
61
|
-
? pickSnapshots(all, snapshotIds, sessionId, ctx.flags)
|
|
62
|
-
: all;
|
|
63
|
-
const eligible = [];
|
|
64
|
-
const skipped = new Map();
|
|
65
|
-
for (const snapshot of candidates) {
|
|
66
|
-
const reason = skipReason(snapshot, target);
|
|
67
|
-
if (reason) {
|
|
68
|
-
const ids = skipped.get(reason) || [];
|
|
69
|
-
ids.push(snapshot.id);
|
|
70
|
-
skipped.set(reason, ids);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
eligible.push(snapshot);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
const summary = (updated, sessionStatus) => ({
|
|
77
|
-
session_id: sessionId,
|
|
78
|
-
status: target,
|
|
79
|
-
updated: updated.map((s) => s.id),
|
|
80
|
-
skipped: [...skipped].flatMap(([reason, ids]) => ids.map((id) => ({ id, reason }))),
|
|
81
|
-
session_status: sessionStatus,
|
|
82
|
-
});
|
|
83
|
-
// Named snapshots are echoed back; a whole session would be dozens of ids.
|
|
84
|
-
if (!json) {
|
|
85
|
-
for (const [reason, ids] of skipped) {
|
|
86
|
-
output_1.default.note((0, texts_1.TXT_VT_REVIEW_SKIPPED)(texts_1.VT_REVIEW_SKIP_REASON[reason], ids, snapshotIds !== null));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const action = ACTIONS[target];
|
|
90
|
-
if (!eligible.length) {
|
|
91
|
-
if (json)
|
|
92
|
-
output_1.default.exitResult(json, summary([], before.status));
|
|
93
|
-
output_1.default.exitNormal((0, texts_1.ERR_VT_REVIEW_NOTHING_ELIGIBLE)(action.verb));
|
|
94
|
-
}
|
|
95
|
-
await ctx.client.updateVtSnapshotsStatuses(ctx.workspace, ctx.project, ctx.suiteId, sessionId, { snapshot_ids: eligible.map((s) => s.id), status: target });
|
|
96
|
-
// The bulk response only carries the changed snapshots; refetch the session
|
|
97
|
-
// to report its recomputed status.
|
|
98
|
-
const session = await (0, lookup_1.getVtSessionOrExit)(ctx, sessionId);
|
|
99
|
-
output_1.default.exitResult(json, summary(eligible, session.status), (0, texts_1.TXT_VT_REVIEW_DONE)(action.done, eligible.length, session.status));
|
|
100
|
-
}
|
|
101
|
-
const TARGETS = {
|
|
102
|
-
approve: utils_1.VT_SNAPSHOT_STATUS.APPROVED,
|
|
103
|
-
reject: utils_1.VT_SNAPSHOT_STATUS.REJECTED,
|
|
104
|
-
unreview: utils_1.VT_SNAPSHOT_STATUS.WAITING_FOR_APPROVE,
|
|
105
|
-
};
|
|
106
|
-
const DESCRIPTIONS = {
|
|
107
|
-
session: {
|
|
108
|
-
approve: texts_1.DESC_COMMAND_SESSION_APPROVE,
|
|
109
|
-
reject: texts_1.DESC_COMMAND_SESSION_REJECT,
|
|
110
|
-
unreview: texts_1.DESC_COMMAND_SESSION_UNREVIEW,
|
|
111
|
-
},
|
|
112
|
-
snapshot: {
|
|
113
|
-
approve: texts_1.DESC_COMMAND_VT_SNAPSHOT_APPROVE,
|
|
114
|
-
reject: texts_1.DESC_COMMAND_VT_SNAPSHOT_REJECT,
|
|
115
|
-
unreview: texts_1.DESC_COMMAND_VT_SNAPSHOT_UNREVIEW,
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
const EXAMPLES = {
|
|
119
|
-
session: texts_1.EXAMPLE_TESTS_VISUAL_SESSION_APPROVE,
|
|
120
|
-
snapshot: texts_1.EXAMPLE_TESTS_VISUAL_SNAPSHOT_APPROVE,
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* The approve, reject and unreview commands of one group (unreview puts
|
|
124
|
-
* snapshots back to WAITING_FOR_APPROVE). The snapshot group takes the
|
|
125
|
-
* snapshot ids to act on; the session group acts on every snapshot of the
|
|
126
|
-
* session, since a session has no status endpoint of its own and the API
|
|
127
|
-
* recomputes its status from the snapshots.
|
|
128
|
-
*/
|
|
129
|
-
function vtReviewCommands(scope) {
|
|
130
|
-
const names = ['approve', 'reject', 'unreview'];
|
|
131
|
-
return names.map((name) => reviewCommand(name, DESCRIPTIONS[scope][name], EXAMPLES[scope], TARGETS[name], scope === 'snapshot'));
|
|
132
|
-
}
|
|
133
|
-
function reviewCommand(name, description, examples, target, withSnapshotIds) {
|
|
134
|
-
const command = (0, utils_1.newCommand)(name, description, { examples });
|
|
135
|
-
(0, context_1.vtCommandOptions)(command);
|
|
136
|
-
command.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
137
|
-
command.argument('<session-id>', texts_1.OPTION_VT_SESSION_ID);
|
|
138
|
-
if (withSnapshotIds) {
|
|
139
|
-
command.argument('<snapshot-ids...>', texts_1.OPTION_VT_SNAPSHOT_IDS);
|
|
140
|
-
command.action((sessionId, snapshotIds, options) => review(sessionId, snapshotIds, target, options));
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
command.action((sessionId, options) => review(sessionId, null, target, options));
|
|
144
|
-
}
|
|
145
|
-
return command;
|
|
146
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,217 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
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;
|
|
@@ -1,68 +0,0 @@
|
|
|
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;
|
|
@@ -1,26 +0,0 @@
|
|
|
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;
|
|
@@ -1,48 +0,0 @@
|
|
|
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;
|
|
@@ -1,28 +0,0 @@
|
|
|
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;
|