@intuned/runtime-dev 1.2.8-dev-peer-script → 1.3.0-responseLimits.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +2 -2
- package/CHANGELOG.md +5 -1
- package/bin/intuned +2 -0
- package/dist/commands/api/run.js +10 -3
- package/dist/commands/auth-sessions/run-check.js +18 -4
- package/dist/commands/auth-sessions/run-create.js +2 -1
- package/dist/commands/common/browserUtils.d.ts +1 -1
- package/dist/commands/common/browserUtils.js +1 -1
- package/dist/commands/common/getFirstLineNumber.js +2 -4
- package/dist/commands/interface/run.js +7 -6
- package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +40 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +24 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +36 -0
- package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/build.command.js +12 -0
- package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
- package/dist/commands/intuned-cli/commands/command.js +9 -0
- package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/deploy.command.js +46 -0
- package/dist/commands/intuned-cli/commands/index.d.ts +15 -0
- package/dist/commands/intuned-cli/commands/index.js +170 -0
- package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/init.command.js +13 -0
- package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run.command.js +8 -0
- package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_api.command.js +54 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +20 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +13 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +39 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +39 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +37 -0
- package/dist/commands/intuned-cli/commands/types.d.ts +21 -0
- package/dist/commands/intuned-cli/commands/types.js +21 -0
- package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
- package/dist/commands/intuned-cli/constants/index.js +25 -0
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +280 -0
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +676 -0
- package/dist/commands/intuned-cli/controller/api.d.ts +44 -0
- package/dist/commands/intuned-cli/controller/api.js +181 -0
- package/dist/commands/intuned-cli/controller/authSession.d.ts +198 -0
- package/dist/commands/intuned-cli/controller/authSession.js +292 -0
- package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/build.js +36 -0
- package/dist/commands/intuned-cli/controller/deploy.d.ts +15 -0
- package/dist/commands/{deploy/utils.js → intuned-cli/controller/deploy.js} +115 -109
- package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/index.js +46 -0
- package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/api.js +19 -0
- package/dist/commands/intuned-cli/helpers/auth.d.ts +41 -0
- package/dist/commands/intuned-cli/helpers/auth.js +129 -0
- package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
- package/dist/commands/intuned-cli/helpers/backend.js +26 -0
- package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/context.js +33 -0
- package/dist/commands/intuned-cli/helpers/errors.d.ts +14 -0
- package/dist/commands/intuned-cli/helpers/errors.js +55 -0
- package/dist/commands/intuned-cli/helpers/index.d.ts +10 -0
- package/dist/commands/intuned-cli/helpers/index.js +115 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +1 -0
- package/dist/{common/cli/utils.js → commands/intuned-cli/helpers/intunedJson.js} +0 -16
- package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
- package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
- package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
- package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
- package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/validation.js +12 -0
- package/dist/commands/intuned-cli/index.d.ts +1 -0
- package/dist/commands/intuned-cli/index.js +16 -0
- package/dist/commands/intuned-cli/main.d.ts +1 -0
- package/dist/commands/intuned-cli/main.js +15 -0
- package/dist/{common/cli → commands/intuned-cli}/types.d.ts +1 -34
- package/dist/{common/cli → commands/intuned-cli}/types.js +1 -2
- package/dist/common/assets/browser_scripts.js +2509 -2143
- package/dist/common/asyncLocalStorage/index.d.ts +1 -2
- package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
- package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +2 -1
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +4 -12
- package/dist/common/jwtTokenManager.js +3 -5
- package/dist/common/runApi/errors.d.ts +10 -3
- package/dist/common/runApi/errors.js +21 -8
- package/dist/common/runApi/index.d.ts +4 -1
- package/dist/common/runApi/index.js +33 -21
- package/dist/common/runApi/types.d.ts +140 -9
- package/dist/common/runApi/types.js +28 -27
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -0
- package/dist/runtime/executionHelpers.test.js +3 -4
- package/dist/runtime/export.d.ts +16 -0
- package/dist/runtime/extendPayload.js +1 -1
- package/dist/runtime/extendTimeout.js +0 -7
- package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
- package/dist/runtime/getAuthSessionParameters.js +20 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +7 -0
- package/package.json +12 -11
- package/template.tsconfig.json +4 -7
- package/tsconfig.json +2 -1
- package/bin/check-auth-session +0 -3
- package/bin/cli-build +0 -3
- package/bin/create-auth-session +0 -3
- package/bin/deploy +0 -3
- package/bin/init +0 -3
- package/bin/run-api +0 -3
- package/dist/commands/cli-auth-sessions/check.d.ts +0 -2
- package/dist/commands/cli-auth-sessions/check.js +0 -40
- package/dist/commands/cli-auth-sessions/create.d.ts +0 -2
- package/dist/commands/cli-auth-sessions/create.js +0 -53
- package/dist/commands/cli-auth-sessions/utils.d.ts +0 -28
- package/dist/commands/cli-auth-sessions/utils.js +0 -285
- package/dist/commands/cli-build/cli-build.d.ts +0 -2
- package/dist/commands/cli-build/cli-build.js +0 -20
- package/dist/commands/deploy/deploy.d.ts +0 -2
- package/dist/commands/deploy/deploy.js +0 -47
- package/dist/commands/deploy/utils.d.ts +0 -16
- package/dist/commands/init/init.d.ts +0 -2
- package/dist/commands/init/init.js +0 -22
- package/dist/commands/init/utils.d.ts +0 -11
- package/dist/commands/init/utils.js +0 -181
- package/dist/commands/run-api-cli/run-api.d.ts +0 -2
- package/dist/commands/run-api-cli/run-api.js +0 -57
- package/dist/commands/run-api-cli/utils.d.ts +0 -9
- package/dist/commands/run-api-cli/utils.js +0 -144
- package/dist/common/cli/cliReadme.d.ts +0 -1
- package/dist/common/cli/cliReadme.js +0 -92
- package/dist/common/cli/constants.d.ts +0 -33
- package/dist/common/cli/constants.js +0 -39
- package/dist/common/cli/utils.d.ts +0 -6
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vitest = require("vitest");
|
|
4
|
+
var _authSession = require("../authSession");
|
|
5
|
+
var _helpers = require("../../helpers");
|
|
6
|
+
var _neverthrow = require("neverthrow");
|
|
7
|
+
var _runApi = require("../../../../common/runApi");
|
|
8
|
+
const _checkPassedResult = (0, _neverthrow.ok)({
|
|
9
|
+
result: true
|
|
10
|
+
});
|
|
11
|
+
const _checkFailedResult = (0, _neverthrow.ok)({
|
|
12
|
+
result: false
|
|
13
|
+
});
|
|
14
|
+
const _errorResult = (0, _neverthrow.err)(new _runApi.AutomationError("failed"));
|
|
15
|
+
function _createSuccessResult(session) {
|
|
16
|
+
return (0, _neverthrow.ok)({
|
|
17
|
+
session
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function getTerminal() {
|
|
21
|
+
return new Proxy(() => ({}), {
|
|
22
|
+
get: () => getTerminal(),
|
|
23
|
+
apply: () => ({})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
_vitest.vi.mock("fs-extra", () => ({
|
|
27
|
+
writeJSON: _vitest.vi.fn()
|
|
28
|
+
}));
|
|
29
|
+
_vitest.vi.mock("../../../../common/runApi", async importOriginal => {
|
|
30
|
+
const original = await importOriginal();
|
|
31
|
+
return {
|
|
32
|
+
...original,
|
|
33
|
+
runApi: _vitest.vi.fn().mockImplementation(() => (0, _neverthrow.ok)({}))
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
_vitest.vi.mock("../../helpers/terminal", () => ({
|
|
37
|
+
terminal: getTerminal()
|
|
38
|
+
}));
|
|
39
|
+
_vitest.vi.mock("../../helpers", async importOriginal => {
|
|
40
|
+
const original = await importOriginal();
|
|
41
|
+
return {
|
|
42
|
+
...original,
|
|
43
|
+
terminal: getTerminal(),
|
|
44
|
+
assertApiFileExists: _vitest.vi.fn(),
|
|
45
|
+
withCLIContext: _vitest.vi.fn(fn => fn()),
|
|
46
|
+
withTimeout: _vitest.vi.fn(fn => fn()),
|
|
47
|
+
parseUrlProxy: _vitest.vi.fn(),
|
|
48
|
+
loadAuthSessionInstance: _vitest.vi.fn(),
|
|
49
|
+
storeAuthSessionInstance: _vitest.vi.fn().mockResolvedValue("authSessionInstancePath"),
|
|
50
|
+
registerGetAuthSessionParameters: _vitest.vi.fn()
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
(0, _vitest.describe)("Auth session controller", () => {
|
|
54
|
+
(0, _vitest.beforeEach)(() => {
|
|
55
|
+
_vitest.vi.clearAllMocks();
|
|
56
|
+
});
|
|
57
|
+
(0, _vitest.describe)("runCheck", () => {
|
|
58
|
+
(0, _vitest.it)("calls timeout middleware with timeout", async () => {
|
|
59
|
+
await (0, _authSession._runCheck)({
|
|
60
|
+
auth: "session",
|
|
61
|
+
headless: false,
|
|
62
|
+
timeout: 6000
|
|
63
|
+
});
|
|
64
|
+
(0, _vitest.expect)(_helpers.withTimeout).toHaveBeenCalledWith(_vitest.expect.any(Function), 6000);
|
|
65
|
+
});
|
|
66
|
+
(0, _vitest.it)("calls runApi with correct parameters and parses proxy", async () => {
|
|
67
|
+
_vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
|
|
68
|
+
await (0, _authSession._runCheck)({
|
|
69
|
+
auth: "session",
|
|
70
|
+
headless: "headless",
|
|
71
|
+
timeout: 999999999,
|
|
72
|
+
proxy: "proxy"
|
|
73
|
+
});
|
|
74
|
+
(0, _vitest.expect)(_helpers.parseUrlProxy).toHaveBeenCalledWith("proxy");
|
|
75
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
76
|
+
automationFunction: {
|
|
77
|
+
name: "auth-sessions/check"
|
|
78
|
+
},
|
|
79
|
+
runOptions: {
|
|
80
|
+
headless: "headless",
|
|
81
|
+
environment: "standalone",
|
|
82
|
+
proxy: "parsed-proxy"
|
|
83
|
+
},
|
|
84
|
+
auth: _vitest.expect.objectContaining({
|
|
85
|
+
session: {
|
|
86
|
+
type: "state",
|
|
87
|
+
state: "session"
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
}));
|
|
91
|
+
});
|
|
92
|
+
(0, _vitest.it)("returns if check returns", async () => {
|
|
93
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
|
|
94
|
+
const resultTrue = await (0, _authSession._runCheck)({
|
|
95
|
+
auth: "session",
|
|
96
|
+
headless: "headless",
|
|
97
|
+
timeout: 999999999
|
|
98
|
+
});
|
|
99
|
+
(0, _vitest.expect)(resultTrue).toEqual(true);
|
|
100
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkFailedResult);
|
|
101
|
+
const resultFalse = await (0, _authSession._runCheck)({
|
|
102
|
+
auth: "session",
|
|
103
|
+
headless: "headless",
|
|
104
|
+
timeout: 999999999
|
|
105
|
+
});
|
|
106
|
+
(0, _vitest.expect)(resultFalse).toEqual(false);
|
|
107
|
+
});
|
|
108
|
+
(0, _vitest.it)("throws the error check fails with an error", async () => {
|
|
109
|
+
const error = new Error("runApi failed");
|
|
110
|
+
_vitest.vi.mocked(_runApi.runApi).mockRejectedValueOnce(error);
|
|
111
|
+
await (0, _vitest.expect)((0, _authSession._runCheck)({
|
|
112
|
+
auth: "session",
|
|
113
|
+
headless: "headless",
|
|
114
|
+
timeout: 999999999
|
|
115
|
+
})).rejects.toThrow(error);
|
|
116
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_errorResult);
|
|
117
|
+
await (0, _vitest.expect)((0, _authSession._runCheck)({
|
|
118
|
+
auth: "session",
|
|
119
|
+
headless: "headless",
|
|
120
|
+
timeout: 999999999
|
|
121
|
+
})).rejects.toThrow("failed");
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
(0, _vitest.describe)("runCheckWithRetries", () => {
|
|
125
|
+
(0, _vitest.it)("retries the check if it fails", async () => {
|
|
126
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkFailedResult).mockResolvedValueOnce(_checkPassedResult);
|
|
127
|
+
const result = await (0, _authSession._runCheckWithRetries)({
|
|
128
|
+
auth: "session",
|
|
129
|
+
retries: 10,
|
|
130
|
+
headless: "headless",
|
|
131
|
+
timeout: 999999999
|
|
132
|
+
});
|
|
133
|
+
(0, _vitest.expect)(result).toEqual(true);
|
|
134
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
|
|
135
|
+
});
|
|
136
|
+
(0, _vitest.it)("returns false if all retries fail", async () => {
|
|
137
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
|
|
138
|
+
result: false
|
|
139
|
+
}));
|
|
140
|
+
const result = await (0, _authSession._runCheckWithRetries)({
|
|
141
|
+
auth: "session",
|
|
142
|
+
retries: 10,
|
|
143
|
+
headless: "headless",
|
|
144
|
+
timeout: 999999999
|
|
145
|
+
});
|
|
146
|
+
(0, _vitest.expect)(result).toEqual(false);
|
|
147
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(10);
|
|
148
|
+
});
|
|
149
|
+
(0, _vitest.it)("continues retrying if check fails due to an automation error", async () => {
|
|
150
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_errorResult).mockResolvedValueOnce(_checkPassedResult);
|
|
151
|
+
const result = await (0, _authSession._runCheckWithRetries)({
|
|
152
|
+
auth: "session",
|
|
153
|
+
retries: 10,
|
|
154
|
+
headless: "headless",
|
|
155
|
+
timeout: 999999999
|
|
156
|
+
});
|
|
157
|
+
(0, _vitest.expect)(result).toEqual(true);
|
|
158
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
|
|
159
|
+
});
|
|
160
|
+
(0, _vitest.it)("throws the error if check fails with a non-automation error", async () => {
|
|
161
|
+
const error = new Error("runCheck failed");
|
|
162
|
+
_vitest.vi.mocked(_runApi.runApi).mockRejectedValueOnce(error);
|
|
163
|
+
await (0, _vitest.expect)((0, _authSession._runCheckWithRetries)({
|
|
164
|
+
auth: "session",
|
|
165
|
+
retries: 10,
|
|
166
|
+
headless: "headless",
|
|
167
|
+
timeout: 999999999
|
|
168
|
+
})).rejects.toThrow(error);
|
|
169
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
(0, _vitest.describe)("runCreate", () => {
|
|
173
|
+
(0, _vitest.it)("calls timeout middleware with timeout", async () => {
|
|
174
|
+
await (0, _authSession._runCreate)({
|
|
175
|
+
authSessionInput: {},
|
|
176
|
+
headless: false,
|
|
177
|
+
timeout: 6000
|
|
178
|
+
});
|
|
179
|
+
(0, _vitest.expect)(_helpers.withTimeout).toHaveBeenCalledWith(_vitest.expect.any(Function), 6000);
|
|
180
|
+
});
|
|
181
|
+
(0, _vitest.it)("calls runApi with correct parameters and parses proxy", async () => {
|
|
182
|
+
_vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
|
|
183
|
+
await (0, _authSession._runCreate)({
|
|
184
|
+
authSessionInput: "authSessionInput",
|
|
185
|
+
headless: "headless",
|
|
186
|
+
timeout: 999999999,
|
|
187
|
+
proxy: "proxy"
|
|
188
|
+
});
|
|
189
|
+
(0, _vitest.expect)(_helpers.parseUrlProxy).toHaveBeenCalledWith("proxy");
|
|
190
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
191
|
+
automationFunction: {
|
|
192
|
+
name: "auth-sessions/create",
|
|
193
|
+
params: "authSessionInput"
|
|
194
|
+
},
|
|
195
|
+
runOptions: {
|
|
196
|
+
headless: "headless",
|
|
197
|
+
environment: "standalone",
|
|
198
|
+
proxy: "parsed-proxy"
|
|
199
|
+
},
|
|
200
|
+
retrieveSession: true
|
|
201
|
+
}));
|
|
202
|
+
});
|
|
203
|
+
(0, _vitest.it)("returns if create returns", async () => {
|
|
204
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session"));
|
|
205
|
+
const storageState = await (0, _authSession._runCreate)({
|
|
206
|
+
authSessionInput: {},
|
|
207
|
+
headless: "headless",
|
|
208
|
+
timeout: 999999999
|
|
209
|
+
});
|
|
210
|
+
(0, _vitest.expect)(storageState).toEqual("session");
|
|
211
|
+
});
|
|
212
|
+
(0, _vitest.it)("throws the error create fails with an error", async () => {
|
|
213
|
+
const error = new Error("runApi failed");
|
|
214
|
+
_vitest.vi.mocked(_runApi.runApi).mockRejectedValueOnce(error);
|
|
215
|
+
await (0, _vitest.expect)((0, _authSession._runCreate)({
|
|
216
|
+
authSessionInput: {},
|
|
217
|
+
headless: "headless",
|
|
218
|
+
timeout: 999999999
|
|
219
|
+
})).rejects.toThrow(error);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
(0, _vitest.describe)("runCreateWithRetries", () => {
|
|
223
|
+
(0, _vitest.it)("saves the auth session instance", async () => {
|
|
224
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session"));
|
|
225
|
+
_vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
|
|
226
|
+
await (0, _authSession._runCreateWithRetries)({
|
|
227
|
+
authSessionId: "authSessionId",
|
|
228
|
+
authSessionInput: "authSessionInput",
|
|
229
|
+
retries: 10,
|
|
230
|
+
headless: "headless",
|
|
231
|
+
proxy: "proxy",
|
|
232
|
+
timeout: 999999999
|
|
233
|
+
});
|
|
234
|
+
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith({
|
|
235
|
+
state: "session",
|
|
236
|
+
id: "authSessionId",
|
|
237
|
+
input: "authSessionInput",
|
|
238
|
+
proxy: "proxy"
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
(0, _vitest.it)("retries the create if it fails with automation error", async () => {
|
|
242
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_errorResult).mockResolvedValueOnce(_createSuccessResult("session"));
|
|
243
|
+
await (0, _authSession._runCreateWithRetries)({
|
|
244
|
+
authSessionId: "authSessionId",
|
|
245
|
+
authSessionInput: "authSessionInput",
|
|
246
|
+
retries: 10,
|
|
247
|
+
headless: "headless",
|
|
248
|
+
timeout: 999999999
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
(0, _vitest.it)("throws if all retries fail", async () => {
|
|
252
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValue(_errorResult);
|
|
253
|
+
await (0, _vitest.expect)((0, _authSession._runCreateWithRetries)({
|
|
254
|
+
authSessionId: "authSessionId",
|
|
255
|
+
authSessionInput: {},
|
|
256
|
+
retries: 10,
|
|
257
|
+
headless: "headless",
|
|
258
|
+
timeout: 999999999
|
|
259
|
+
})).rejects.toThrow(_helpers.CLIError);
|
|
260
|
+
});
|
|
261
|
+
(0, _vitest.it)("continues retrying if create fails due to an automation error", async () => {
|
|
262
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_errorResult).mockResolvedValueOnce(_createSuccessResult("session"));
|
|
263
|
+
const result = await (0, _authSession._runCreateWithRetries)({
|
|
264
|
+
authSessionId: "authSessionId",
|
|
265
|
+
authSessionInput: {},
|
|
266
|
+
retries: 10,
|
|
267
|
+
headless: "headless",
|
|
268
|
+
timeout: 999999999
|
|
269
|
+
});
|
|
270
|
+
(0, _vitest.expect)(result).toEqual("session");
|
|
271
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
|
|
272
|
+
});
|
|
273
|
+
(0, _vitest.it)("throws the error if create fails with a non-automation error", async () => {
|
|
274
|
+
const error = new Error("runCheck failed");
|
|
275
|
+
_vitest.vi.mocked(_runApi.runApi).mockRejectedValueOnce(error);
|
|
276
|
+
await (0, _vitest.expect)((0, _authSession._runCreateWithRetries)({
|
|
277
|
+
authSessionId: "authSessionId",
|
|
278
|
+
authSessionInput: {},
|
|
279
|
+
retries: 10,
|
|
280
|
+
headless: "headless",
|
|
281
|
+
timeout: 999999999
|
|
282
|
+
})).rejects.toThrow(error);
|
|
283
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
(0, _vitest.describe)("executeRunValidateAuthSessionCLI", () => {
|
|
287
|
+
(0, _vitest.beforeEach)(() => {
|
|
288
|
+
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
|
|
289
|
+
storageState: {},
|
|
290
|
+
metadata: {
|
|
291
|
+
authSessionId: "authSessionId",
|
|
292
|
+
authSessionType: "API",
|
|
293
|
+
authSessionInput: {},
|
|
294
|
+
createdAt: "",
|
|
295
|
+
updatedAt: ""
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
(0, _vitest.it)("asserts check API file exists", async () => {
|
|
300
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
|
|
301
|
+
await (0, _authSession.executeRunValidateAuthSessionCLI)({
|
|
302
|
+
id: "authSessionId",
|
|
303
|
+
checkRetries: 1,
|
|
304
|
+
createRetries: 1,
|
|
305
|
+
autoRecreate: false,
|
|
306
|
+
headless: false,
|
|
307
|
+
timeout: 999999999
|
|
308
|
+
});
|
|
309
|
+
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "check");
|
|
310
|
+
});
|
|
311
|
+
(0, _vitest.it)("succeeds if check succeeds", async () => {
|
|
312
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
|
|
313
|
+
await (0, _authSession.executeRunValidateAuthSessionCLI)({
|
|
314
|
+
id: "authSessionId",
|
|
315
|
+
checkRetries: 1,
|
|
316
|
+
createRetries: 1,
|
|
317
|
+
autoRecreate: false,
|
|
318
|
+
headless: false,
|
|
319
|
+
timeout: 999999999
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
(0, _vitest.it)("throws if check fails with auto recreate disabled", async () => {
|
|
323
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkFailedResult);
|
|
324
|
+
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
|
|
325
|
+
storageState: {},
|
|
326
|
+
metadata: {
|
|
327
|
+
authSessionId: "authSessionId",
|
|
328
|
+
authSessionType: "API",
|
|
329
|
+
authSessionInput: {},
|
|
330
|
+
createdAt: "1970-01-01T00:00:00Z",
|
|
331
|
+
updatedAt: "1970-01-01T00:00:00Z"
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
await (0, _vitest.expect)((0, _authSession.executeRunValidateAuthSessionCLI)({
|
|
335
|
+
id: "authSessionId",
|
|
336
|
+
checkRetries: 1,
|
|
337
|
+
createRetries: 1,
|
|
338
|
+
autoRecreate: false,
|
|
339
|
+
headless: false,
|
|
340
|
+
timeout: 999999999
|
|
341
|
+
})).rejects.toThrow(_helpers.CLIError);
|
|
342
|
+
});
|
|
343
|
+
(0, _vitest.describe)("check failed with auto recreate enabled", () => {
|
|
344
|
+
(0, _vitest.beforeEach)(() => {
|
|
345
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkFailedResult);
|
|
346
|
+
});
|
|
347
|
+
afterEach(() => {
|
|
348
|
+
_vitest.vi.mocked(_runApi.runApi).mockReset();
|
|
349
|
+
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockReset();
|
|
350
|
+
});
|
|
351
|
+
(0, _vitest.it)("asserts create API file exists", async () => {
|
|
352
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session")).mockResolvedValueOnce(_checkPassedResult);
|
|
353
|
+
await (0, _authSession.executeRunValidateAuthSessionCLI)({
|
|
354
|
+
id: "authSessionId",
|
|
355
|
+
checkRetries: 1,
|
|
356
|
+
createRetries: 1,
|
|
357
|
+
autoRecreate: true,
|
|
358
|
+
headless: false,
|
|
359
|
+
timeout: 999999999
|
|
360
|
+
});
|
|
361
|
+
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "create");
|
|
362
|
+
});
|
|
363
|
+
(0, _vitest.it)("throws if auth session is manual", async () => {
|
|
364
|
+
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
|
|
365
|
+
storageState: {},
|
|
366
|
+
metadata: {
|
|
367
|
+
authSessionId: "authSessionId",
|
|
368
|
+
authSessionType: "MANUAL",
|
|
369
|
+
authSessionInput: {},
|
|
370
|
+
createdAt: "",
|
|
371
|
+
updatedAt: ""
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
await (0, _vitest.expect)((0, _authSession.executeRunValidateAuthSessionCLI)({
|
|
375
|
+
id: "authSessionId",
|
|
376
|
+
checkRetries: 1,
|
|
377
|
+
createRetries: 1,
|
|
378
|
+
autoRecreate: true,
|
|
379
|
+
headless: false,
|
|
380
|
+
timeout: 999999999
|
|
381
|
+
})).rejects.toThrow(_helpers.CLIError);
|
|
382
|
+
});
|
|
383
|
+
(0, _vitest.it)("throws if create fails", async () => {
|
|
384
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_errorResult);
|
|
385
|
+
await (0, _vitest.expect)((0, _authSession.executeRunValidateAuthSessionCLI)({
|
|
386
|
+
id: "authSessionId",
|
|
387
|
+
checkRetries: 1,
|
|
388
|
+
createRetries: 1,
|
|
389
|
+
autoRecreate: true,
|
|
390
|
+
headless: false,
|
|
391
|
+
timeout: 999999999
|
|
392
|
+
})).rejects.toThrow(_helpers.CLIError);
|
|
393
|
+
});
|
|
394
|
+
(0, _vitest.it)("throws if create succeeds then check fails", async () => {
|
|
395
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session")).mockResolvedValueOnce(_checkFailedResult);
|
|
396
|
+
await (0, _vitest.expect)((0, _authSession.executeRunValidateAuthSessionCLI)({
|
|
397
|
+
id: "authSessionId",
|
|
398
|
+
checkRetries: 1,
|
|
399
|
+
createRetries: 1,
|
|
400
|
+
autoRecreate: true,
|
|
401
|
+
headless: false,
|
|
402
|
+
timeout: 999999999
|
|
403
|
+
})).rejects.toThrow(_helpers.CLIError);
|
|
404
|
+
});
|
|
405
|
+
(0, _vitest.it)("succeeds if create succeeds then check succeeds", async () => {
|
|
406
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session")).mockResolvedValueOnce(_checkPassedResult);
|
|
407
|
+
await (0, _authSession.executeRunValidateAuthSessionCLI)({
|
|
408
|
+
id: "authSessionId",
|
|
409
|
+
checkRetries: 1,
|
|
410
|
+
createRetries: 1,
|
|
411
|
+
autoRecreate: true,
|
|
412
|
+
headless: false,
|
|
413
|
+
timeout: 999999999
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
(0, _vitest.describe)("executeRunCreateAuthSessionCLI", () => {
|
|
419
|
+
(0, _vitest.beforeEach)(() => {
|
|
420
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session")).mockResolvedValueOnce(_checkPassedResult);
|
|
421
|
+
});
|
|
422
|
+
(0, _vitest.it)("asserts create check API file exists", async () => {
|
|
423
|
+
await (0, _authSession.executeRunCreateAuthSessionCLI)({
|
|
424
|
+
input: {},
|
|
425
|
+
checkRetries: 1,
|
|
426
|
+
createRetries: 1,
|
|
427
|
+
headless: false,
|
|
428
|
+
timeout: 999999999
|
|
429
|
+
});
|
|
430
|
+
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "check");
|
|
431
|
+
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "create");
|
|
432
|
+
});
|
|
433
|
+
(0, _vitest.it)("throws if create fails", async () => {
|
|
434
|
+
_vitest.vi.mocked(_runApi.runApi).mockReset().mockResolvedValueOnce(_errorResult);
|
|
435
|
+
await (0, _vitest.expect)((0, _authSession.executeRunCreateAuthSessionCLI)({
|
|
436
|
+
input: {},
|
|
437
|
+
checkRetries: 1,
|
|
438
|
+
createRetries: 1,
|
|
439
|
+
headless: false,
|
|
440
|
+
timeout: 999999999
|
|
441
|
+
})).rejects.toThrow(_helpers.CLIError);
|
|
442
|
+
});
|
|
443
|
+
(0, _vitest.it)("throws if check fails after create succeeds", async () => {
|
|
444
|
+
_vitest.vi.mocked(_runApi.runApi).mockReset().mockResolvedValueOnce(_createSuccessResult("session")).mockResolvedValueOnce(_checkFailedResult);
|
|
445
|
+
await (0, _vitest.expect)((0, _authSession.executeRunCreateAuthSessionCLI)({
|
|
446
|
+
input: {},
|
|
447
|
+
checkRetries: 1,
|
|
448
|
+
createRetries: 1,
|
|
449
|
+
headless: false,
|
|
450
|
+
timeout: 999999999
|
|
451
|
+
})).rejects.toThrow(_helpers.CLIError);
|
|
452
|
+
});
|
|
453
|
+
(0, _vitest.it)("saves to auth session instance path if create and check succeed", async () => {
|
|
454
|
+
await (0, _authSession.executeRunCreateAuthSessionCLI)({
|
|
455
|
+
input: "authSessionInput",
|
|
456
|
+
checkRetries: 1,
|
|
457
|
+
createRetries: 1,
|
|
458
|
+
headless: false,
|
|
459
|
+
timeout: 999999999
|
|
460
|
+
});
|
|
461
|
+
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
462
|
+
id: _vitest.expect.any(String)
|
|
463
|
+
}));
|
|
464
|
+
});
|
|
465
|
+
(0, _vitest.it)("uses auth session id to save if provided", async () => {
|
|
466
|
+
const result = await (0, _authSession.executeRunCreateAuthSessionCLI)({
|
|
467
|
+
id: "authSessionId",
|
|
468
|
+
input: "authSessionInput",
|
|
469
|
+
checkRetries: 1,
|
|
470
|
+
createRetries: 1,
|
|
471
|
+
headless: false,
|
|
472
|
+
timeout: 999999999
|
|
473
|
+
});
|
|
474
|
+
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
475
|
+
id: "authSessionId"
|
|
476
|
+
}));
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
(0, _vitest.describe)("executeRunUpdateAuthSessionCLI", () => {
|
|
480
|
+
(0, _vitest.beforeEach)(() => {
|
|
481
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session")).mockResolvedValueOnce(_checkPassedResult);
|
|
482
|
+
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
|
|
483
|
+
storageState: {},
|
|
484
|
+
metadata: {
|
|
485
|
+
authSessionId: "authSessionId",
|
|
486
|
+
authSessionType: "API",
|
|
487
|
+
authSessionInput: {},
|
|
488
|
+
createdAt: "",
|
|
489
|
+
updatedAt: ""
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
afterEach(() => {
|
|
494
|
+
_vitest.vi.mocked(_runApi.runApi).mockReset();
|
|
495
|
+
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockReset();
|
|
496
|
+
});
|
|
497
|
+
(0, _vitest.it)("throws if auth session is manual", async () => {
|
|
498
|
+
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
|
|
499
|
+
storageState: {},
|
|
500
|
+
metadata: {
|
|
501
|
+
authSessionId: "authSessionId",
|
|
502
|
+
authSessionType: "MANUAL",
|
|
503
|
+
authSessionInput: {},
|
|
504
|
+
createdAt: "",
|
|
505
|
+
updatedAt: ""
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
await (0, _vitest.expect)((0, _authSession.executeRunUpdateAuthSessionCLI)({
|
|
509
|
+
id: "authSessionId",
|
|
510
|
+
checkRetries: 1,
|
|
511
|
+
createRetries: 1,
|
|
512
|
+
headless: false,
|
|
513
|
+
timeout: 999999999
|
|
514
|
+
})).rejects.toThrow(_helpers.CLIError);
|
|
515
|
+
});
|
|
516
|
+
(0, _vitest.it)("calls create with existing input if no input provided", async () => {
|
|
517
|
+
await (0, _authSession.executeRunUpdateAuthSessionCLI)({
|
|
518
|
+
id: "authSessionId",
|
|
519
|
+
checkRetries: 1,
|
|
520
|
+
createRetries: 1,
|
|
521
|
+
headless: false,
|
|
522
|
+
timeout: 999999999
|
|
523
|
+
});
|
|
524
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
525
|
+
automationFunction: {
|
|
526
|
+
name: "auth-sessions/create",
|
|
527
|
+
params: {}
|
|
528
|
+
},
|
|
529
|
+
runOptions: {
|
|
530
|
+
headless: false,
|
|
531
|
+
environment: "standalone",
|
|
532
|
+
proxy: undefined
|
|
533
|
+
},
|
|
534
|
+
retrieveSession: true
|
|
535
|
+
}));
|
|
536
|
+
});
|
|
537
|
+
(0, _vitest.it)("calls create with new input if provided", async () => {
|
|
538
|
+
_vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("newProxy");
|
|
539
|
+
await (0, _authSession.executeRunUpdateAuthSessionCLI)({
|
|
540
|
+
id: "authSessionId",
|
|
541
|
+
input: "newAuthSessionInput",
|
|
542
|
+
proxy: "newProxyUrl",
|
|
543
|
+
checkRetries: 1,
|
|
544
|
+
createRetries: 1,
|
|
545
|
+
headless: false,
|
|
546
|
+
timeout: 999999999
|
|
547
|
+
});
|
|
548
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
549
|
+
automationFunction: {
|
|
550
|
+
name: "auth-sessions/create",
|
|
551
|
+
params: "newAuthSessionInput"
|
|
552
|
+
},
|
|
553
|
+
runOptions: {
|
|
554
|
+
headless: false,
|
|
555
|
+
environment: "standalone",
|
|
556
|
+
proxy: "newProxy"
|
|
557
|
+
},
|
|
558
|
+
retrieveSession: true
|
|
559
|
+
}));
|
|
560
|
+
});
|
|
561
|
+
(0, _vitest.it)("saves the auth session with existing input if create and check succeed without providing input", async () => {
|
|
562
|
+
const result = await (0, _authSession.executeRunUpdateAuthSessionCLI)({
|
|
563
|
+
id: "authSessionId",
|
|
564
|
+
checkRetries: 1,
|
|
565
|
+
createRetries: 1,
|
|
566
|
+
headless: false,
|
|
567
|
+
timeout: 999999999
|
|
568
|
+
});
|
|
569
|
+
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
570
|
+
id: "authSessionId",
|
|
571
|
+
input: {},
|
|
572
|
+
proxy: undefined
|
|
573
|
+
}));
|
|
574
|
+
});
|
|
575
|
+
(0, _vitest.it)("saves the auth session with new input if create and check succeed with new input", async () => {
|
|
576
|
+
const result = await (0, _authSession.executeRunUpdateAuthSessionCLI)({
|
|
577
|
+
id: "authSessionId",
|
|
578
|
+
input: "newAuthSessionInput",
|
|
579
|
+
proxy: "newProxyUrl",
|
|
580
|
+
checkRetries: 1,
|
|
581
|
+
createRetries: 1,
|
|
582
|
+
headless: false,
|
|
583
|
+
timeout: 999999999
|
|
584
|
+
});
|
|
585
|
+
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
586
|
+
id: "authSessionId",
|
|
587
|
+
input: "newAuthSessionInput",
|
|
588
|
+
proxy: "newProxyUrl"
|
|
589
|
+
}));
|
|
590
|
+
});
|
|
591
|
+
});
|
|
592
|
+
(0, _vitest.describe)("executeAttemptCheckAuthSessionCLI", () => {
|
|
593
|
+
(0, _vitest.beforeEach)(() => {
|
|
594
|
+
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
|
|
595
|
+
storageState: {},
|
|
596
|
+
metadata: {
|
|
597
|
+
authSessionId: "authSessionId",
|
|
598
|
+
authSessionType: "API",
|
|
599
|
+
authSessionInput: {},
|
|
600
|
+
createdAt: "",
|
|
601
|
+
updatedAt: ""
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
|
|
605
|
+
});
|
|
606
|
+
afterEach(() => {
|
|
607
|
+
_vitest.vi.mocked(_runApi.runApi).mockReset();
|
|
608
|
+
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockReset();
|
|
609
|
+
});
|
|
610
|
+
(0, _vitest.it)("asserts check API file exists", async () => {
|
|
611
|
+
await (0, _authSession.executeAttemptCheckAuthSessionCLI)({
|
|
612
|
+
id: "authSessionId",
|
|
613
|
+
headless: false,
|
|
614
|
+
timeout: 999999999
|
|
615
|
+
});
|
|
616
|
+
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "check");
|
|
617
|
+
});
|
|
618
|
+
(0, _vitest.it)("succeeds if check succeeds", async () => {
|
|
619
|
+
await (0, _authSession.executeAttemptCheckAuthSessionCLI)({
|
|
620
|
+
id: "authSessionId",
|
|
621
|
+
headless: false,
|
|
622
|
+
timeout: 999999999
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
(0, _vitest.it)("throws if check fails", async () => {
|
|
626
|
+
_vitest.vi.mocked(_runApi.runApi).mockReset().mockResolvedValueOnce(_checkFailedResult);
|
|
627
|
+
await (0, _vitest.expect)((0, _authSession.executeAttemptCheckAuthSessionCLI)({
|
|
628
|
+
id: "authSessionId",
|
|
629
|
+
headless: false,
|
|
630
|
+
timeout: 999999999
|
|
631
|
+
})).rejects.toThrow(_helpers.CLIError);
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
(0, _vitest.describe)("executeAttemptCreateAuthSessionCLI", () => {
|
|
635
|
+
(0, _vitest.beforeEach)(() => {
|
|
636
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session"));
|
|
637
|
+
});
|
|
638
|
+
(0, _vitest.it)("asserts create API file exists", async () => {
|
|
639
|
+
await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
|
|
640
|
+
input: {},
|
|
641
|
+
headless: false,
|
|
642
|
+
timeout: 999999999
|
|
643
|
+
});
|
|
644
|
+
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "create");
|
|
645
|
+
});
|
|
646
|
+
(0, _vitest.it)("throws if create fails", async () => {
|
|
647
|
+
_vitest.vi.mocked(_runApi.runApi).mockReset().mockResolvedValueOnce(_errorResult);
|
|
648
|
+
await (0, _vitest.expect)((0, _authSession.executeAttemptCreateAuthSessionCLI)({
|
|
649
|
+
input: {},
|
|
650
|
+
headless: false,
|
|
651
|
+
timeout: 999999999
|
|
652
|
+
})).rejects.toThrow(_helpers.CLIError);
|
|
653
|
+
});
|
|
654
|
+
(0, _vitest.it)("saves to auth session instance path if create and check succeed", async () => {
|
|
655
|
+
await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
|
|
656
|
+
input: "authSessionInput",
|
|
657
|
+
headless: false,
|
|
658
|
+
timeout: 999999999
|
|
659
|
+
});
|
|
660
|
+
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
661
|
+
id: _vitest.expect.any(String)
|
|
662
|
+
}));
|
|
663
|
+
});
|
|
664
|
+
(0, _vitest.it)("uses auth session id to save if provided", async () => {
|
|
665
|
+
await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
|
|
666
|
+
id: "authSessionId",
|
|
667
|
+
input: "authSessionInput",
|
|
668
|
+
headless: false,
|
|
669
|
+
timeout: 999999999
|
|
670
|
+
});
|
|
671
|
+
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
672
|
+
id: "authSessionId"
|
|
673
|
+
}));
|
|
674
|
+
});
|
|
675
|
+
});
|
|
676
|
+
});
|