@intuned/runtime-dev 1.3.4-dev.4 → 1.3.4-enhancements.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/WebTemplate.zip +0 -0
- package/bin/intuned +0 -0
- package/dist/commands/api/run.js +1 -2
- package/dist/commands/auth-sessions/run-check.js +0 -1
- package/dist/commands/auth-sessions/run-create.js +0 -1
- package/dist/commands/common/projectExclusions.js +1 -1
- package/dist/commands/common/tsNodeImport.js +1 -1
- package/dist/commands/common/utils/settings.js +5 -7
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +10 -20
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +2 -7
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +5 -17
- package/dist/commands/intuned-cli/commands/authsession.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/authsession.command.js +8 -0
- package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/authsession_record.command.js +31 -0
- package/dist/commands/intuned-cli/commands/build.command.js +1 -1
- package/dist/commands/intuned-cli/commands/deploy.command.js +2 -7
- package/dist/commands/intuned-cli/commands/index.d.ts +2 -0
- package/dist/commands/intuned-cli/commands/index.js +22 -0
- package/dist/commands/intuned-cli/commands/init.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_api.command.js +13 -21
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +9 -1
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +5 -1
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +16 -20
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +16 -20
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +16 -20
- package/dist/commands/intuned-cli/commands/save.command.d.ts +3 -2
- package/dist/commands/intuned-cli/commands/save.command.js +6 -10
- package/dist/commands/intuned-cli/commands/types.d.ts +10 -0
- package/dist/commands/intuned-cli/commands/types.js +11 -3
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +128 -10
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +428 -45
- package/dist/commands/intuned-cli/controller/api.d.ts +5 -7
- package/dist/commands/intuned-cli/controller/api.js +16 -7
- package/dist/commands/intuned-cli/controller/authSession.d.ts +18 -7
- package/dist/commands/intuned-cli/controller/authSession.js +153 -24
- package/dist/commands/intuned-cli/controller/save.js +10 -3
- package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +103 -0
- package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +40 -0
- package/dist/commands/intuned-cli/helpers/auth.d.ts +7 -2
- package/dist/commands/intuned-cli/helpers/auth.js +38 -23
- package/dist/commands/intuned-cli/helpers/backend.d.ts +1 -1
- package/dist/commands/intuned-cli/helpers/backend.js +2 -2
- package/dist/commands/intuned-cli/helpers/browser.d.ts +14 -0
- package/dist/commands/intuned-cli/helpers/browser.js +57 -0
- package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -1
- package/dist/commands/intuned-cli/helpers/errors.js +0 -22
- package/dist/commands/intuned-cli/helpers/index.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/index.js +22 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +69 -1
- package/dist/commands/intuned-cli/helpers/intunedJson.js +59 -7
- package/dist/commands/intuned-cli/helpers/traces.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/traces.js +32 -0
- package/dist/commands/intuned-cli/helpers/validation.js +5 -3
- package/dist/commands/intuned-cli/helpers/wrapper.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/wrapper.js +60 -0
- package/dist/common/constants.d.ts +0 -1
- package/dist/common/constants.js +1 -2
- package/dist/common/playwrightContext.d.ts +1 -0
- package/dist/common/playwrightContext.js +5 -18
- package/dist/common/runApi/types.d.ts +0 -5
- package/dist/common/runApi/types.js +1 -2
- package/dist/common/settingsSchema.d.ts +0 -513
- package/dist/common/settingsSchema.js +2 -40
- package/package.json +4 -1
- package/dist/common/extensionsHelpers.d.ts +0 -15
- package/dist/common/extensionsHelpers.js +0 -84
|
@@ -5,6 +5,9 @@ var _authSession = require("../authSession");
|
|
|
5
5
|
var _helpers = require("../../helpers");
|
|
6
6
|
var _neverthrow = require("neverthrow");
|
|
7
7
|
var _runApi = require("../../../../common/runApi");
|
|
8
|
+
var _browser = require("../../helpers/browser");
|
|
9
|
+
var _playwrightContext = require("../../../../common/playwrightContext");
|
|
10
|
+
var _promises = require("timers/promises");
|
|
8
11
|
const _checkPassedResult = (0, _neverthrow.ok)({
|
|
9
12
|
result: true
|
|
10
13
|
});
|
|
@@ -23,8 +26,30 @@ function getTerminal() {
|
|
|
23
26
|
apply: () => ({})
|
|
24
27
|
});
|
|
25
28
|
}
|
|
29
|
+
function getMockTimeout() {
|
|
30
|
+
let resolveTimeout = () => undefined;
|
|
31
|
+
_vitest.vi.mocked(_promises.setTimeout).mockImplementation(() => new Promise(r => {
|
|
32
|
+
resolveTimeout = r;
|
|
33
|
+
}));
|
|
34
|
+
return {
|
|
35
|
+
async resolve() {
|
|
36
|
+
await Promise.resolve();
|
|
37
|
+
resolveTimeout();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
26
41
|
_vitest.vi.mock("fs-extra", () => ({
|
|
27
|
-
writeJSON: _vitest.vi.fn()
|
|
42
|
+
writeJSON: _vitest.vi.fn(),
|
|
43
|
+
exists: _vitest.vi.fn().mockResolvedValue(true)
|
|
44
|
+
}));
|
|
45
|
+
_vitest.vi.mock("timers/promises", () => ({
|
|
46
|
+
setTimeout: _vitest.vi.fn().mockResolvedValue(undefined)
|
|
47
|
+
}));
|
|
48
|
+
_vitest.vi.mock("../../../../common/contextStorageStateHelpers", () => ({
|
|
49
|
+
getStorageState: _vitest.vi.fn()
|
|
50
|
+
}));
|
|
51
|
+
_vitest.vi.mock("../../../../common/playwrightContext", () => ({
|
|
52
|
+
launchChromium: _vitest.vi.fn()
|
|
28
53
|
}));
|
|
29
54
|
_vitest.vi.mock("../../../../common/runApi", async importOriginal => {
|
|
30
55
|
const original = await importOriginal();
|
|
@@ -36,15 +61,32 @@ _vitest.vi.mock("../../../../common/runApi", async importOriginal => {
|
|
|
36
61
|
_vitest.vi.mock("../../helpers/terminal", () => ({
|
|
37
62
|
terminal: getTerminal()
|
|
38
63
|
}));
|
|
64
|
+
_vitest.vi.mock("../../helpers/proxy", () => {
|
|
65
|
+
return {
|
|
66
|
+
parseUrlProxy: _vitest.vi.fn(v => v)
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
_vitest.vi.mock("../../helpers/browser", async importOriginal => {
|
|
70
|
+
const original = await importOriginal();
|
|
71
|
+
return {
|
|
72
|
+
getCLIRunOptions: _vitest.vi.fn(({
|
|
73
|
+
keepBrowserOpen: _,
|
|
74
|
+
...rest
|
|
75
|
+
}) => original.getCLIRunOptions({
|
|
76
|
+
keepBrowserOpen: false,
|
|
77
|
+
...rest
|
|
78
|
+
}))
|
|
79
|
+
};
|
|
80
|
+
});
|
|
39
81
|
_vitest.vi.mock("../../helpers", async importOriginal => {
|
|
40
82
|
const original = await importOriginal();
|
|
41
83
|
return {
|
|
42
84
|
...original,
|
|
43
85
|
terminal: getTerminal(),
|
|
44
86
|
assertApiFileExists: _vitest.vi.fn(),
|
|
45
|
-
withCLIContext: _vitest.vi.fn(fn => fn()),
|
|
46
87
|
withTimeout: _vitest.vi.fn(fn => fn()),
|
|
47
|
-
|
|
88
|
+
keepBrowserOpen: false,
|
|
89
|
+
withCLITrace: _vitest.vi.fn(original.withCLITrace),
|
|
48
90
|
loadAuthSessionInstance: _vitest.vi.fn(),
|
|
49
91
|
storeAuthSessionInstance: _vitest.vi.fn().mockResolvedValue("authSessionInstancePath"),
|
|
50
92
|
registerGetAuthSessionParameters: _vitest.vi.fn()
|
|
@@ -59,16 +101,61 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
59
101
|
await (0, _authSession._runCheck)({
|
|
60
102
|
auth: "session",
|
|
61
103
|
headless: false,
|
|
62
|
-
timeout: 6000
|
|
104
|
+
timeout: 6000,
|
|
105
|
+
keepBrowserOpen: false
|
|
63
106
|
});
|
|
64
107
|
(0, _vitest.expect)(_helpers.withTimeout).toHaveBeenCalledWith(_vitest.expect.any(Function), 6000);
|
|
65
108
|
});
|
|
109
|
+
(0, _vitest.it)("uses tracing wrapper and calls with correct parameters", async () => {
|
|
110
|
+
await (0, _authSession._runCheck)({
|
|
111
|
+
auth: "session",
|
|
112
|
+
headless: false,
|
|
113
|
+
timeout: 6000,
|
|
114
|
+
keepBrowserOpen: false
|
|
115
|
+
});
|
|
116
|
+
(0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), undefined);
|
|
117
|
+
_vitest.vi.mocked(_helpers.withCLITrace).mockClear();
|
|
118
|
+
_vitest.vi.mocked(_runApi.runApi).mockClear();
|
|
119
|
+
await (0, _authSession._runCheck)({
|
|
120
|
+
auth: "session",
|
|
121
|
+
headless: false,
|
|
122
|
+
timeout: 6000,
|
|
123
|
+
keepBrowserOpen: false,
|
|
124
|
+
traceId: "trace-id"
|
|
125
|
+
});
|
|
126
|
+
(0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), "trace-id");
|
|
127
|
+
});
|
|
128
|
+
(0, _vitest.it)("uses cli browser helper", async () => {
|
|
129
|
+
await (0, _authSession._runCheck)({
|
|
130
|
+
auth: "session",
|
|
131
|
+
headless: false,
|
|
132
|
+
timeout: 6000,
|
|
133
|
+
keepBrowserOpen: false
|
|
134
|
+
});
|
|
135
|
+
(0, _vitest.expect)(_browser.getCLIRunOptions).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
136
|
+
headless: false,
|
|
137
|
+
keepBrowserOpen: false
|
|
138
|
+
}));
|
|
139
|
+
_vitest.vi.mocked(_helpers.withCLITrace).mockClear();
|
|
140
|
+
_vitest.vi.mocked(_runApi.runApi).mockClear();
|
|
141
|
+
await (0, _authSession._runCheck)({
|
|
142
|
+
auth: "session",
|
|
143
|
+
headless: true,
|
|
144
|
+
timeout: 6000,
|
|
145
|
+
keepBrowserOpen: true
|
|
146
|
+
});
|
|
147
|
+
(0, _vitest.expect)(_browser.getCLIRunOptions).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
148
|
+
headless: true,
|
|
149
|
+
keepBrowserOpen: true
|
|
150
|
+
}));
|
|
151
|
+
});
|
|
66
152
|
(0, _vitest.it)("calls runApi with correct parameters and parses proxy", async () => {
|
|
67
153
|
_vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
|
|
68
154
|
await (0, _authSession._runCheck)({
|
|
69
155
|
auth: "session",
|
|
70
156
|
headless: "headless",
|
|
71
157
|
timeout: 999999999,
|
|
158
|
+
keepBrowserOpen: false,
|
|
72
159
|
proxy: "proxy"
|
|
73
160
|
});
|
|
74
161
|
(0, _vitest.expect)(_helpers.parseUrlProxy).toHaveBeenCalledWith("proxy");
|
|
@@ -94,14 +181,16 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
94
181
|
const resultTrue = await (0, _authSession._runCheck)({
|
|
95
182
|
auth: "session",
|
|
96
183
|
headless: "headless",
|
|
97
|
-
timeout: 999999999
|
|
184
|
+
timeout: 999999999,
|
|
185
|
+
keepBrowserOpen: false
|
|
98
186
|
});
|
|
99
187
|
(0, _vitest.expect)(resultTrue).toEqual(true);
|
|
100
188
|
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkFailedResult);
|
|
101
189
|
const resultFalse = await (0, _authSession._runCheck)({
|
|
102
190
|
auth: "session",
|
|
103
191
|
headless: "headless",
|
|
104
|
-
timeout: 999999999
|
|
192
|
+
timeout: 999999999,
|
|
193
|
+
keepBrowserOpen: false
|
|
105
194
|
});
|
|
106
195
|
(0, _vitest.expect)(resultFalse).toEqual(false);
|
|
107
196
|
});
|
|
@@ -111,24 +200,51 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
111
200
|
await (0, _vitest.expect)((0, _authSession._runCheck)({
|
|
112
201
|
auth: "session",
|
|
113
202
|
headless: "headless",
|
|
114
|
-
timeout: 999999999
|
|
203
|
+
timeout: 999999999,
|
|
204
|
+
keepBrowserOpen: false
|
|
115
205
|
})).rejects.toThrow(error);
|
|
116
206
|
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_errorResult);
|
|
117
207
|
await (0, _vitest.expect)((0, _authSession._runCheck)({
|
|
118
208
|
auth: "session",
|
|
119
209
|
headless: "headless",
|
|
120
|
-
timeout: 999999999
|
|
210
|
+
timeout: 999999999,
|
|
211
|
+
keepBrowserOpen: false
|
|
121
212
|
})).rejects.toThrow("failed");
|
|
122
213
|
});
|
|
123
214
|
});
|
|
124
215
|
(0, _vitest.describe)("runCheckWithRetries", () => {
|
|
216
|
+
(0, _vitest.it)("enables tracing on runCheck if trace is true", async () => {
|
|
217
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
|
|
218
|
+
await (0, _authSession._runCheckWithRetries)({
|
|
219
|
+
auth: "session",
|
|
220
|
+
retries: 1,
|
|
221
|
+
headless: "headless",
|
|
222
|
+
timeout: 999999999,
|
|
223
|
+
keepBrowserOpen: false,
|
|
224
|
+
trace: false
|
|
225
|
+
});
|
|
226
|
+
(0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), undefined);
|
|
227
|
+
_vitest.vi.mocked(_helpers.withCLITrace).mockClear();
|
|
228
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
|
|
229
|
+
await (0, _authSession._runCheckWithRetries)({
|
|
230
|
+
auth: "session",
|
|
231
|
+
retries: 1,
|
|
232
|
+
headless: "headless",
|
|
233
|
+
timeout: 999999999,
|
|
234
|
+
keepBrowserOpen: false,
|
|
235
|
+
trace: true
|
|
236
|
+
});
|
|
237
|
+
(0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), _vitest.expect.any(String));
|
|
238
|
+
});
|
|
125
239
|
(0, _vitest.it)("retries the check if it fails", async () => {
|
|
126
240
|
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkFailedResult).mockResolvedValueOnce(_checkPassedResult);
|
|
127
241
|
const result = await (0, _authSession._runCheckWithRetries)({
|
|
128
242
|
auth: "session",
|
|
129
243
|
retries: 10,
|
|
130
244
|
headless: "headless",
|
|
131
|
-
timeout: 999999999
|
|
245
|
+
timeout: 999999999,
|
|
246
|
+
keepBrowserOpen: false,
|
|
247
|
+
trace: false
|
|
132
248
|
});
|
|
133
249
|
(0, _vitest.expect)(result).toEqual(true);
|
|
134
250
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
|
|
@@ -141,7 +257,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
141
257
|
auth: "session",
|
|
142
258
|
retries: 10,
|
|
143
259
|
headless: "headless",
|
|
144
|
-
timeout: 999999999
|
|
260
|
+
timeout: 999999999,
|
|
261
|
+
keepBrowserOpen: false,
|
|
262
|
+
trace: false
|
|
145
263
|
});
|
|
146
264
|
(0, _vitest.expect)(result).toEqual(false);
|
|
147
265
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(10);
|
|
@@ -152,7 +270,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
152
270
|
auth: "session",
|
|
153
271
|
retries: 10,
|
|
154
272
|
headless: "headless",
|
|
155
|
-
timeout: 999999999
|
|
273
|
+
timeout: 999999999,
|
|
274
|
+
keepBrowserOpen: false,
|
|
275
|
+
trace: false
|
|
156
276
|
});
|
|
157
277
|
(0, _vitest.expect)(result).toEqual(true);
|
|
158
278
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
|
|
@@ -164,7 +284,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
164
284
|
auth: "session",
|
|
165
285
|
retries: 10,
|
|
166
286
|
headless: "headless",
|
|
167
|
-
timeout: 999999999
|
|
287
|
+
timeout: 999999999,
|
|
288
|
+
keepBrowserOpen: false,
|
|
289
|
+
trace: false
|
|
168
290
|
})).rejects.toThrow(error);
|
|
169
291
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
|
|
170
292
|
});
|
|
@@ -174,16 +296,61 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
174
296
|
await (0, _authSession._runCreate)({
|
|
175
297
|
authSessionInput: {},
|
|
176
298
|
headless: false,
|
|
177
|
-
timeout: 6000
|
|
299
|
+
timeout: 6000,
|
|
300
|
+
keepBrowserOpen: false
|
|
178
301
|
});
|
|
179
302
|
(0, _vitest.expect)(_helpers.withTimeout).toHaveBeenCalledWith(_vitest.expect.any(Function), 6000);
|
|
180
303
|
});
|
|
304
|
+
(0, _vitest.it)("uses tracing wrapper and calls with correct parameters", async () => {
|
|
305
|
+
await (0, _authSession._runCreate)({
|
|
306
|
+
authSessionInput: {},
|
|
307
|
+
headless: false,
|
|
308
|
+
timeout: 6000,
|
|
309
|
+
keepBrowserOpen: false
|
|
310
|
+
});
|
|
311
|
+
(0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), undefined);
|
|
312
|
+
_vitest.vi.mocked(_helpers.withCLITrace).mockClear();
|
|
313
|
+
_vitest.vi.mocked(_runApi.runApi).mockClear();
|
|
314
|
+
await (0, _authSession._runCreate)({
|
|
315
|
+
authSessionInput: {},
|
|
316
|
+
headless: false,
|
|
317
|
+
timeout: 6000,
|
|
318
|
+
keepBrowserOpen: false,
|
|
319
|
+
traceId: "trace-id"
|
|
320
|
+
});
|
|
321
|
+
(0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), "trace-id");
|
|
322
|
+
});
|
|
323
|
+
(0, _vitest.it)("uses cli browser helper", async () => {
|
|
324
|
+
await (0, _authSession._runCreate)({
|
|
325
|
+
authSessionInput: {},
|
|
326
|
+
headless: false,
|
|
327
|
+
timeout: 6000,
|
|
328
|
+
keepBrowserOpen: false
|
|
329
|
+
});
|
|
330
|
+
(0, _vitest.expect)(_browser.getCLIRunOptions).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
331
|
+
headless: false,
|
|
332
|
+
keepBrowserOpen: false
|
|
333
|
+
}));
|
|
334
|
+
_vitest.vi.mocked(_helpers.withCLITrace).mockClear();
|
|
335
|
+
_vitest.vi.mocked(_runApi.runApi).mockClear();
|
|
336
|
+
await (0, _authSession._runCreate)({
|
|
337
|
+
authSessionInput: {},
|
|
338
|
+
headless: true,
|
|
339
|
+
timeout: 6000,
|
|
340
|
+
keepBrowserOpen: true
|
|
341
|
+
});
|
|
342
|
+
(0, _vitest.expect)(_browser.getCLIRunOptions).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
343
|
+
headless: true,
|
|
344
|
+
keepBrowserOpen: true
|
|
345
|
+
}));
|
|
346
|
+
});
|
|
181
347
|
(0, _vitest.it)("calls runApi with correct parameters and parses proxy", async () => {
|
|
182
348
|
_vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
|
|
183
349
|
await (0, _authSession._runCreate)({
|
|
184
350
|
authSessionInput: "authSessionInput",
|
|
185
351
|
headless: "headless",
|
|
186
352
|
timeout: 999999999,
|
|
353
|
+
keepBrowserOpen: false,
|
|
187
354
|
proxy: "proxy"
|
|
188
355
|
});
|
|
189
356
|
(0, _vitest.expect)(_helpers.parseUrlProxy).toHaveBeenCalledWith("proxy");
|
|
@@ -205,7 +372,8 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
205
372
|
const storageState = await (0, _authSession._runCreate)({
|
|
206
373
|
authSessionInput: {},
|
|
207
374
|
headless: "headless",
|
|
208
|
-
timeout: 999999999
|
|
375
|
+
timeout: 999999999,
|
|
376
|
+
keepBrowserOpen: false
|
|
209
377
|
});
|
|
210
378
|
(0, _vitest.expect)(storageState).toEqual("session");
|
|
211
379
|
});
|
|
@@ -215,11 +383,41 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
215
383
|
await (0, _vitest.expect)((0, _authSession._runCreate)({
|
|
216
384
|
authSessionInput: {},
|
|
217
385
|
headless: "headless",
|
|
218
|
-
timeout: 999999999
|
|
386
|
+
timeout: 999999999,
|
|
387
|
+
keepBrowserOpen: false
|
|
219
388
|
})).rejects.toThrow(error);
|
|
220
389
|
});
|
|
221
390
|
});
|
|
222
391
|
(0, _vitest.describe)("runCreateWithRetries", () => {
|
|
392
|
+
(0, _vitest.it)("enables tracing on runCreate if trace is true", async () => {
|
|
393
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session"));
|
|
394
|
+
_vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
|
|
395
|
+
await (0, _authSession._runCreateWithRetries)({
|
|
396
|
+
authSessionId: "authSessionId",
|
|
397
|
+
authSessionInput: "authSessionInput",
|
|
398
|
+
retries: 10,
|
|
399
|
+
headless: "headless",
|
|
400
|
+
proxy: "proxy",
|
|
401
|
+
timeout: 999999999,
|
|
402
|
+
keepBrowserOpen: false,
|
|
403
|
+
trace: false
|
|
404
|
+
});
|
|
405
|
+
(0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), undefined);
|
|
406
|
+
_vitest.vi.mocked(_helpers.withCLITrace).mockClear();
|
|
407
|
+
_vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
|
|
408
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session"));
|
|
409
|
+
await (0, _authSession._runCreateWithRetries)({
|
|
410
|
+
authSessionId: "authSessionId",
|
|
411
|
+
authSessionInput: "authSessionInput",
|
|
412
|
+
retries: 10,
|
|
413
|
+
headless: "headless",
|
|
414
|
+
proxy: "proxy",
|
|
415
|
+
timeout: 999999999,
|
|
416
|
+
keepBrowserOpen: false,
|
|
417
|
+
trace: true
|
|
418
|
+
});
|
|
419
|
+
(0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), _vitest.expect.any(String));
|
|
420
|
+
});
|
|
223
421
|
(0, _vitest.it)("saves the auth session instance", async () => {
|
|
224
422
|
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session"));
|
|
225
423
|
_vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
|
|
@@ -229,7 +427,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
229
427
|
retries: 10,
|
|
230
428
|
headless: "headless",
|
|
231
429
|
proxy: "proxy",
|
|
232
|
-
timeout: 999999999
|
|
430
|
+
timeout: 999999999,
|
|
431
|
+
keepBrowserOpen: false,
|
|
432
|
+
trace: false
|
|
233
433
|
});
|
|
234
434
|
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith({
|
|
235
435
|
state: "session",
|
|
@@ -245,7 +445,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
245
445
|
authSessionInput: "authSessionInput",
|
|
246
446
|
retries: 10,
|
|
247
447
|
headless: "headless",
|
|
248
|
-
timeout: 999999999
|
|
448
|
+
timeout: 999999999,
|
|
449
|
+
keepBrowserOpen: false,
|
|
450
|
+
trace: false
|
|
249
451
|
});
|
|
250
452
|
});
|
|
251
453
|
(0, _vitest.it)("throws if all retries fail", async () => {
|
|
@@ -255,7 +457,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
255
457
|
authSessionInput: {},
|
|
256
458
|
retries: 10,
|
|
257
459
|
headless: "headless",
|
|
258
|
-
timeout: 999999999
|
|
460
|
+
timeout: 999999999,
|
|
461
|
+
keepBrowserOpen: false,
|
|
462
|
+
trace: false
|
|
259
463
|
})).rejects.toThrow(_helpers.CLIError);
|
|
260
464
|
});
|
|
261
465
|
(0, _vitest.it)("continues retrying if create fails due to an automation error", async () => {
|
|
@@ -265,7 +469,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
265
469
|
authSessionInput: {},
|
|
266
470
|
retries: 10,
|
|
267
471
|
headless: "headless",
|
|
268
|
-
timeout: 999999999
|
|
472
|
+
timeout: 999999999,
|
|
473
|
+
keepBrowserOpen: false,
|
|
474
|
+
trace: false
|
|
269
475
|
});
|
|
270
476
|
(0, _vitest.expect)(result).toEqual("session");
|
|
271
477
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
|
|
@@ -278,7 +484,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
278
484
|
authSessionInput: {},
|
|
279
485
|
retries: 10,
|
|
280
486
|
headless: "headless",
|
|
281
|
-
timeout: 999999999
|
|
487
|
+
timeout: 999999999,
|
|
488
|
+
keepBrowserOpen: false,
|
|
489
|
+
trace: false
|
|
282
490
|
})).rejects.toThrow(error);
|
|
283
491
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
|
|
284
492
|
});
|
|
@@ -304,7 +512,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
304
512
|
createRetries: 1,
|
|
305
513
|
autoRecreate: false,
|
|
306
514
|
headless: false,
|
|
307
|
-
timeout: 999999999
|
|
515
|
+
timeout: 999999999,
|
|
516
|
+
keepBrowserOpen: false,
|
|
517
|
+
trace: false
|
|
308
518
|
});
|
|
309
519
|
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "check");
|
|
310
520
|
});
|
|
@@ -316,7 +526,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
316
526
|
createRetries: 1,
|
|
317
527
|
autoRecreate: false,
|
|
318
528
|
headless: false,
|
|
319
|
-
timeout: 999999999
|
|
529
|
+
timeout: 999999999,
|
|
530
|
+
keepBrowserOpen: false,
|
|
531
|
+
trace: false
|
|
320
532
|
});
|
|
321
533
|
});
|
|
322
534
|
(0, _vitest.it)("throws if check fails with auto recreate disabled", async () => {
|
|
@@ -337,7 +549,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
337
549
|
createRetries: 1,
|
|
338
550
|
autoRecreate: false,
|
|
339
551
|
headless: false,
|
|
340
|
-
timeout: 999999999
|
|
552
|
+
timeout: 999999999,
|
|
553
|
+
keepBrowserOpen: false,
|
|
554
|
+
trace: false
|
|
341
555
|
})).rejects.toThrow(_helpers.CLIError);
|
|
342
556
|
});
|
|
343
557
|
(0, _vitest.describe)("check failed with auto recreate enabled", () => {
|
|
@@ -356,7 +570,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
356
570
|
createRetries: 1,
|
|
357
571
|
autoRecreate: true,
|
|
358
572
|
headless: false,
|
|
359
|
-
timeout: 999999999
|
|
573
|
+
timeout: 999999999,
|
|
574
|
+
keepBrowserOpen: false,
|
|
575
|
+
trace: false
|
|
360
576
|
});
|
|
361
577
|
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "create");
|
|
362
578
|
});
|
|
@@ -377,7 +593,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
377
593
|
createRetries: 1,
|
|
378
594
|
autoRecreate: true,
|
|
379
595
|
headless: false,
|
|
380
|
-
timeout: 999999999
|
|
596
|
+
timeout: 999999999,
|
|
597
|
+
keepBrowserOpen: false,
|
|
598
|
+
trace: false
|
|
381
599
|
})).rejects.toThrow(_helpers.CLIError);
|
|
382
600
|
});
|
|
383
601
|
(0, _vitest.it)("throws if create fails", async () => {
|
|
@@ -388,7 +606,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
388
606
|
createRetries: 1,
|
|
389
607
|
autoRecreate: true,
|
|
390
608
|
headless: false,
|
|
391
|
-
timeout: 999999999
|
|
609
|
+
timeout: 999999999,
|
|
610
|
+
keepBrowserOpen: false,
|
|
611
|
+
trace: false
|
|
392
612
|
})).rejects.toThrow(_helpers.CLIError);
|
|
393
613
|
});
|
|
394
614
|
(0, _vitest.it)("throws if create succeeds then check fails", async () => {
|
|
@@ -399,7 +619,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
399
619
|
createRetries: 1,
|
|
400
620
|
autoRecreate: true,
|
|
401
621
|
headless: false,
|
|
402
|
-
timeout: 999999999
|
|
622
|
+
timeout: 999999999,
|
|
623
|
+
keepBrowserOpen: false,
|
|
624
|
+
trace: false
|
|
403
625
|
})).rejects.toThrow(_helpers.CLIError);
|
|
404
626
|
});
|
|
405
627
|
(0, _vitest.it)("succeeds if create succeeds then check succeeds", async () => {
|
|
@@ -410,7 +632,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
410
632
|
createRetries: 1,
|
|
411
633
|
autoRecreate: true,
|
|
412
634
|
headless: false,
|
|
413
|
-
timeout: 999999999
|
|
635
|
+
timeout: 999999999,
|
|
636
|
+
keepBrowserOpen: false,
|
|
637
|
+
trace: false
|
|
414
638
|
});
|
|
415
639
|
});
|
|
416
640
|
});
|
|
@@ -425,7 +649,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
425
649
|
checkRetries: 1,
|
|
426
650
|
createRetries: 1,
|
|
427
651
|
headless: false,
|
|
428
|
-
timeout: 999999999
|
|
652
|
+
timeout: 999999999,
|
|
653
|
+
keepBrowserOpen: false,
|
|
654
|
+
trace: false
|
|
429
655
|
});
|
|
430
656
|
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "check");
|
|
431
657
|
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "create");
|
|
@@ -437,7 +663,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
437
663
|
checkRetries: 1,
|
|
438
664
|
createRetries: 1,
|
|
439
665
|
headless: false,
|
|
440
|
-
timeout: 999999999
|
|
666
|
+
timeout: 999999999,
|
|
667
|
+
keepBrowserOpen: false,
|
|
668
|
+
trace: false
|
|
441
669
|
})).rejects.toThrow(_helpers.CLIError);
|
|
442
670
|
});
|
|
443
671
|
(0, _vitest.it)("throws if check fails after create succeeds", async () => {
|
|
@@ -447,7 +675,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
447
675
|
checkRetries: 1,
|
|
448
676
|
createRetries: 1,
|
|
449
677
|
headless: false,
|
|
450
|
-
timeout: 999999999
|
|
678
|
+
timeout: 999999999,
|
|
679
|
+
keepBrowserOpen: false,
|
|
680
|
+
trace: false
|
|
451
681
|
})).rejects.toThrow(_helpers.CLIError);
|
|
452
682
|
});
|
|
453
683
|
(0, _vitest.it)("saves to auth session instance path if create and check succeed", async () => {
|
|
@@ -456,7 +686,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
456
686
|
checkRetries: 1,
|
|
457
687
|
createRetries: 1,
|
|
458
688
|
headless: false,
|
|
459
|
-
timeout: 999999999
|
|
689
|
+
timeout: 999999999,
|
|
690
|
+
keepBrowserOpen: false,
|
|
691
|
+
trace: false
|
|
460
692
|
});
|
|
461
693
|
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
462
694
|
id: _vitest.expect.any(String)
|
|
@@ -469,7 +701,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
469
701
|
checkRetries: 1,
|
|
470
702
|
createRetries: 1,
|
|
471
703
|
headless: false,
|
|
472
|
-
timeout: 999999999
|
|
704
|
+
timeout: 999999999,
|
|
705
|
+
keepBrowserOpen: false,
|
|
706
|
+
trace: false
|
|
473
707
|
});
|
|
474
708
|
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
475
709
|
id: "authSessionId"
|
|
@@ -510,7 +744,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
510
744
|
checkRetries: 1,
|
|
511
745
|
createRetries: 1,
|
|
512
746
|
headless: false,
|
|
513
|
-
timeout: 999999999
|
|
747
|
+
timeout: 999999999,
|
|
748
|
+
keepBrowserOpen: false,
|
|
749
|
+
trace: false
|
|
514
750
|
})).rejects.toThrow(_helpers.CLIError);
|
|
515
751
|
});
|
|
516
752
|
(0, _vitest.it)("calls create with existing input if no input provided", async () => {
|
|
@@ -519,7 +755,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
519
755
|
checkRetries: 1,
|
|
520
756
|
createRetries: 1,
|
|
521
757
|
headless: false,
|
|
522
|
-
timeout: 999999999
|
|
758
|
+
timeout: 999999999,
|
|
759
|
+
keepBrowserOpen: false,
|
|
760
|
+
trace: false
|
|
523
761
|
});
|
|
524
762
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
525
763
|
automationFunction: {
|
|
@@ -543,7 +781,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
543
781
|
checkRetries: 1,
|
|
544
782
|
createRetries: 1,
|
|
545
783
|
headless: false,
|
|
546
|
-
timeout: 999999999
|
|
784
|
+
timeout: 999999999,
|
|
785
|
+
keepBrowserOpen: false,
|
|
786
|
+
trace: false
|
|
547
787
|
});
|
|
548
788
|
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
549
789
|
automationFunction: {
|
|
@@ -564,7 +804,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
564
804
|
checkRetries: 1,
|
|
565
805
|
createRetries: 1,
|
|
566
806
|
headless: false,
|
|
567
|
-
timeout: 999999999
|
|
807
|
+
timeout: 999999999,
|
|
808
|
+
keepBrowserOpen: false,
|
|
809
|
+
trace: false
|
|
568
810
|
});
|
|
569
811
|
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
570
812
|
id: "authSessionId",
|
|
@@ -580,7 +822,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
580
822
|
checkRetries: 1,
|
|
581
823
|
createRetries: 1,
|
|
582
824
|
headless: false,
|
|
583
|
-
timeout: 999999999
|
|
825
|
+
timeout: 999999999,
|
|
826
|
+
keepBrowserOpen: false,
|
|
827
|
+
trace: false
|
|
584
828
|
});
|
|
585
829
|
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
586
830
|
id: "authSessionId",
|
|
@@ -611,7 +855,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
611
855
|
await (0, _authSession.executeAttemptCheckAuthSessionCLI)({
|
|
612
856
|
id: "authSessionId",
|
|
613
857
|
headless: false,
|
|
614
|
-
timeout: 999999999
|
|
858
|
+
timeout: 999999999,
|
|
859
|
+
keepBrowserOpen: false,
|
|
860
|
+
trace: false
|
|
615
861
|
});
|
|
616
862
|
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "check");
|
|
617
863
|
});
|
|
@@ -619,7 +865,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
619
865
|
await (0, _authSession.executeAttemptCheckAuthSessionCLI)({
|
|
620
866
|
id: "authSessionId",
|
|
621
867
|
headless: false,
|
|
622
|
-
timeout: 999999999
|
|
868
|
+
timeout: 999999999,
|
|
869
|
+
keepBrowserOpen: false,
|
|
870
|
+
trace: false
|
|
623
871
|
});
|
|
624
872
|
});
|
|
625
873
|
(0, _vitest.it)("throws if check fails", async () => {
|
|
@@ -627,7 +875,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
627
875
|
await (0, _vitest.expect)((0, _authSession.executeAttemptCheckAuthSessionCLI)({
|
|
628
876
|
id: "authSessionId",
|
|
629
877
|
headless: false,
|
|
630
|
-
timeout: 999999999
|
|
878
|
+
timeout: 999999999,
|
|
879
|
+
keepBrowserOpen: false,
|
|
880
|
+
trace: false
|
|
631
881
|
})).rejects.toThrow(_helpers.CLIError);
|
|
632
882
|
});
|
|
633
883
|
});
|
|
@@ -639,7 +889,9 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
639
889
|
await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
|
|
640
890
|
input: {},
|
|
641
891
|
headless: false,
|
|
642
|
-
timeout: 999999999
|
|
892
|
+
timeout: 999999999,
|
|
893
|
+
keepBrowserOpen: false,
|
|
894
|
+
trace: false
|
|
643
895
|
});
|
|
644
896
|
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "create");
|
|
645
897
|
});
|
|
@@ -648,14 +900,18 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
648
900
|
await (0, _vitest.expect)((0, _authSession.executeAttemptCreateAuthSessionCLI)({
|
|
649
901
|
input: {},
|
|
650
902
|
headless: false,
|
|
651
|
-
timeout: 999999999
|
|
903
|
+
timeout: 999999999,
|
|
904
|
+
keepBrowserOpen: false,
|
|
905
|
+
trace: false
|
|
652
906
|
})).rejects.toThrow(_helpers.CLIError);
|
|
653
907
|
});
|
|
654
908
|
(0, _vitest.it)("saves to auth session instance path if create and check succeed", async () => {
|
|
655
909
|
await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
|
|
656
910
|
input: "authSessionInput",
|
|
657
911
|
headless: false,
|
|
658
|
-
timeout: 999999999
|
|
912
|
+
timeout: 999999999,
|
|
913
|
+
keepBrowserOpen: false,
|
|
914
|
+
trace: false
|
|
659
915
|
});
|
|
660
916
|
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
661
917
|
id: _vitest.expect.any(String)
|
|
@@ -666,11 +922,138 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
666
922
|
id: "authSessionId",
|
|
667
923
|
input: "authSessionInput",
|
|
668
924
|
headless: false,
|
|
669
|
-
timeout: 999999999
|
|
925
|
+
timeout: 999999999,
|
|
926
|
+
keepBrowserOpen: false,
|
|
927
|
+
trace: false
|
|
670
928
|
});
|
|
671
929
|
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
672
930
|
id: "authSessionId"
|
|
673
931
|
}));
|
|
674
932
|
});
|
|
675
933
|
});
|
|
934
|
+
(0, _vitest.describe)("executeRecordAuthSessionCLI", () => {
|
|
935
|
+
let mockPage;
|
|
936
|
+
let mockContext;
|
|
937
|
+
(0, _vitest.beforeEach)(() => {
|
|
938
|
+
_vitest.vi.useFakeTimers();
|
|
939
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
|
|
940
|
+
mockPage = {
|
|
941
|
+
url: _vitest.vi.fn().mockReturnValue(""),
|
|
942
|
+
close: _vitest.vi.fn(),
|
|
943
|
+
goto: _vitest.vi.fn(),
|
|
944
|
+
waitForLoadState: _vitest.vi.fn()
|
|
945
|
+
};
|
|
946
|
+
mockContext = {
|
|
947
|
+
pages: _vitest.vi.fn().mockReturnValue([mockPage]),
|
|
948
|
+
close: _vitest.vi.fn()
|
|
949
|
+
};
|
|
950
|
+
_vitest.vi.mocked(_playwrightContext.launchChromium).mockResolvedValue({
|
|
951
|
+
context: mockContext,
|
|
952
|
+
page: mockPage
|
|
953
|
+
});
|
|
954
|
+
_vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
|
|
955
|
+
storageState: {},
|
|
956
|
+
metadata: {
|
|
957
|
+
authSessionId: "authSessionId",
|
|
958
|
+
authSessionType: "MANUAL",
|
|
959
|
+
authSessionInput: {},
|
|
960
|
+
createdAt: "",
|
|
961
|
+
updatedAt: ""
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
});
|
|
965
|
+
afterEach(() => {
|
|
966
|
+
_vitest.vi.mocked(_runApi.runApi).mockReset();
|
|
967
|
+
_vitest.vi.mocked(_playwrightContext.launchChromium).mockReset();
|
|
968
|
+
_vitest.vi.useRealTimers();
|
|
969
|
+
});
|
|
970
|
+
(0, _vitest.it)("launches browser with app mode", async () => {
|
|
971
|
+
mockPage.url.mockReturnValue("finishUrl");
|
|
972
|
+
await (0, _authSession.executeRecordAuthSessionCLI)({
|
|
973
|
+
checkRetries: 1,
|
|
974
|
+
startUrl: "startUrl",
|
|
975
|
+
finishUrl: "finishUrl",
|
|
976
|
+
headless: false,
|
|
977
|
+
keepBrowserOpen: false
|
|
978
|
+
});
|
|
979
|
+
(0, _vitest.expect)(_playwrightContext.launchChromium).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
980
|
+
appModeInitialUrl: "startUrl"
|
|
981
|
+
}));
|
|
982
|
+
});
|
|
983
|
+
(0, _vitest.it)("navigates to the start url if the page doesn't load with it", async () => {
|
|
984
|
+
mockPage.url.mockReturnValue("finishUrl");
|
|
985
|
+
await (0, _authSession.executeRecordAuthSessionCLI)({
|
|
986
|
+
checkRetries: 1,
|
|
987
|
+
startUrl: "startUrl",
|
|
988
|
+
finishUrl: "finishUrl",
|
|
989
|
+
headless: false,
|
|
990
|
+
keepBrowserOpen: false
|
|
991
|
+
});
|
|
992
|
+
(0, _vitest.expect)(mockPage.goto).toHaveBeenCalledWith("startUrl");
|
|
993
|
+
});
|
|
994
|
+
(0, _vitest.it)("waits for the finish url", async () => {
|
|
995
|
+
mockPage.url.mockReturnValueOnce("startUrl");
|
|
996
|
+
const mockTimeout = getMockTimeout();
|
|
997
|
+
let pending = true;
|
|
998
|
+
const p = (0, _authSession.executeRecordAuthSessionCLI)({
|
|
999
|
+
checkRetries: 1,
|
|
1000
|
+
startUrl: "startUrl",
|
|
1001
|
+
finishUrl: "finishUrl",
|
|
1002
|
+
headless: false,
|
|
1003
|
+
keepBrowserOpen: false
|
|
1004
|
+
}).finally(() => pending = false);
|
|
1005
|
+
await mockTimeout.resolve();
|
|
1006
|
+
await mockTimeout.resolve();
|
|
1007
|
+
await mockTimeout.resolve();
|
|
1008
|
+
(0, _vitest.expect)(pending).toEqual(true);
|
|
1009
|
+
mockPage.url.mockClear();
|
|
1010
|
+
mockPage.url.mockReturnValueOnce("finishUrl");
|
|
1011
|
+
await mockTimeout.resolve();
|
|
1012
|
+
await p;
|
|
1013
|
+
});
|
|
1014
|
+
(0, _vitest.it)("throws if timeout is reached", async () => {
|
|
1015
|
+
mockPage.url.mockReturnValueOnce("startUrl");
|
|
1016
|
+
const mockTimeout = getMockTimeout();
|
|
1017
|
+
_vitest.vi.setSystemTime(new Date(0));
|
|
1018
|
+
let pending = true;
|
|
1019
|
+
const p = (0, _authSession.executeRecordAuthSessionCLI)({
|
|
1020
|
+
checkRetries: 1,
|
|
1021
|
+
startUrl: "startUrl",
|
|
1022
|
+
finishUrl: "finishUrl",
|
|
1023
|
+
headless: false,
|
|
1024
|
+
keepBrowserOpen: false,
|
|
1025
|
+
timeout: 1000
|
|
1026
|
+
}).finally(() => pending = false);
|
|
1027
|
+
await mockTimeout.resolve();
|
|
1028
|
+
await mockTimeout.resolve();
|
|
1029
|
+
await mockTimeout.resolve();
|
|
1030
|
+
(0, _vitest.expect)(pending).toEqual(true);
|
|
1031
|
+
_vitest.vi.setSystemTime(new Date(2000));
|
|
1032
|
+
await mockTimeout.resolve();
|
|
1033
|
+
await (0, _vitest.expect)(p).rejects.toThrow(_helpers.CLIError);
|
|
1034
|
+
});
|
|
1035
|
+
(0, _vitest.it)("stores auth session and validates it if successful", async () => {
|
|
1036
|
+
mockPage.url.mockReturnValue("finishUrl");
|
|
1037
|
+
await (0, _authSession.executeRecordAuthSessionCLI)({
|
|
1038
|
+
checkRetries: 1,
|
|
1039
|
+
startUrl: "startUrl",
|
|
1040
|
+
finishUrl: "finishUrl",
|
|
1041
|
+
headless: false,
|
|
1042
|
+
keepBrowserOpen: false
|
|
1043
|
+
});
|
|
1044
|
+
(0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
1045
|
+
id: _vitest.expect.any(String),
|
|
1046
|
+
metadata: _vitest.expect.objectContaining({
|
|
1047
|
+
authSessionType: "MANUAL",
|
|
1048
|
+
recorderStartUrl: "startUrl",
|
|
1049
|
+
recorderEndUrl: "finishUrl"
|
|
1050
|
+
})
|
|
1051
|
+
}));
|
|
1052
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
1053
|
+
automationFunction: _vitest.expect.objectContaining({
|
|
1054
|
+
name: "auth-sessions/check"
|
|
1055
|
+
})
|
|
1056
|
+
}));
|
|
1057
|
+
});
|
|
1058
|
+
});
|
|
676
1059
|
});
|