@intuned/runtime-dev 0.1.0-test.28 → 0.1.0-test.3

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.
Files changed (86) hide show
  1. package/Intuned.json +1 -1
  2. package/WebTemplate/api.ts +92 -90
  3. package/WebTemplate/controllers/authSessions/check.ts +4 -3
  4. package/WebTemplate/controllers/authSessions/create.ts +8 -10
  5. package/WebTemplate/controllers/authSessions/resumeOperation.ts +1 -1
  6. package/WebTemplate/controllers/runApi/helpers.ts +6 -11
  7. package/WebTemplate/index.playwright.ts +42 -32
  8. package/WebTemplate/jobs.ts +2 -13
  9. package/WebTemplate/utils.ts +1 -51
  10. package/api/test2.ts +5 -7
  11. package/auth-sessions/check.ts +1 -3
  12. package/auth-sessions/create.ts +10 -10
  13. package/bin/intuned-api-run +1 -1
  14. package/bin/intuned-auth-session-check +1 -1
  15. package/bin/intuned-auth-session-create +1 -1
  16. package/bin/intuned-auth-session-load +1 -1
  17. package/bin/intuned-auth-session-refresh +1 -1
  18. package/bin/intuned-browser-save-state +1 -1
  19. package/bin/intuned-browser-start +1 -1
  20. package/bin/intuned-build +1 -1
  21. package/bin/intuned-ts-check +1 -1
  22. package/dist/commands/api/run.js +2 -4
  23. package/dist/commands/auth-sessions/run-check.js +1 -3
  24. package/dist/commands/auth-sessions/run-create.js +3 -5
  25. package/dist/commands/build.js +4 -6
  26. package/dist/commands/common/browserUtils.js +1 -1
  27. package/dist/commands/common/getDefaultExportFromFile.d.ts +1 -0
  28. package/dist/commands/common/{tsNodeImport.js → getDefaultExportFromFile.js} +5 -6
  29. package/dist/commands/common/getFirstLineNumber.test.js +2 -2
  30. package/dist/commands/common/utils/settings.js +2 -1
  31. package/dist/commands/common/utils/webTemplate.js +2 -2
  32. package/dist/commands/interface/run.js +106 -122
  33. package/dist/commands/ts-check.js +2 -2
  34. package/dist/common/Logger/Logger/index.d.ts +1 -1
  35. package/dist/common/Logger/index.d.ts +1 -1
  36. package/dist/common/getPlaywrightConstructs.d.ts +1 -1
  37. package/dist/common/getPlaywrightConstructs.js +3 -3
  38. package/dist/common/runApi/errors.d.ts +1 -1
  39. package/dist/common/runApi/index.d.ts +5 -5
  40. package/dist/common/runApi/index.js +50 -21
  41. package/dist/common/runApi/types.d.ts +1 -2
  42. package/dist/index.d.ts +4 -4
  43. package/dist/index.js +12 -12
  44. package/dist/runtime/RunError.d.ts +1 -1
  45. package/dist/runtime/executionHelpers.test.js +2 -2
  46. package/dist/runtime/export.d.ts +1 -1
  47. package/dist/runtime/extendPayload.d.ts +1 -1
  48. package/dist/runtime/extendPayload.js +1 -1
  49. package/dist/runtime/index.d.ts +7 -7
  50. package/dist/runtime/index.js +6 -6
  51. package/dist/runtime/runInfo.d.ts +1 -1
  52. package/dist/runtime/runInfo.js +1 -1
  53. package/package.json +5 -6
  54. package/tsconfig.json +1 -1
  55. package/InterfaceTemplate/index.js +0 -1
  56. package/WebTemplate/accessKeyHelpers.js +0 -20
  57. package/WebTemplate/api.js +0 -48
  58. package/WebTemplate/app.js +0 -13
  59. package/WebTemplate/controllers/async.js +0 -78
  60. package/WebTemplate/controllers/authSessions/check.js +0 -44
  61. package/WebTemplate/controllers/authSessions/create.js +0 -69
  62. package/WebTemplate/controllers/authSessions/index.js +0 -25
  63. package/WebTemplate/controllers/authSessions/killOperation.js +0 -26
  64. package/WebTemplate/controllers/authSessions/resumeOperation.js +0 -42
  65. package/WebTemplate/controllers/authSessions/store.js +0 -1
  66. package/WebTemplate/controllers/controllers.js +0 -30
  67. package/WebTemplate/controllers/runApi/helpers.js +0 -90
  68. package/WebTemplate/controllers/runApi/index.js +0 -45
  69. package/WebTemplate/controllers/runApi/types.js +0 -1
  70. package/WebTemplate/controllers/traces.js +0 -108
  71. package/WebTemplate/features.js +0 -6
  72. package/WebTemplate/headers.js +0 -6
  73. package/WebTemplate/index.playwright.js +0 -37
  74. package/WebTemplate/index.vanilla.js +0 -19
  75. package/WebTemplate/jobs.js +0 -259
  76. package/WebTemplate/shutdown.js +0 -51
  77. package/WebTemplate/utils.js +0 -189
  78. package/api/authed.js +0 -6
  79. package/api/test.js +0 -3
  80. package/api/test2.js +0 -17
  81. package/auth-sessions/check.js +0 -6
  82. package/auth-sessions/create.js +0 -20
  83. package/dist/commands/common/tsNodeImport.d.ts +0 -1
  84. package/playwright.config.js +0 -43
  85. package/preserve-dynamic-imports.js +0 -16
  86. package/vite.config.js +0 -16
@@ -1,259 +0,0 @@
1
- import { runApi } from "./controllers/runApi";
2
- import { ATTEMPT_NUMBER_HEADER, JOB_ID_HEADER, JOB_RUN_ID_HEADER, RUN_ID_HEADER, SHOULD_SHUTDOWN_HEADER, } from "./headers";
3
- import { getErrorResponse, isHeadless, isJobRunMachine, proxyToUrl, } from "./utils";
4
- import { callBackendFunctionWithToken, backendFunctionsTokenManager, } from "@intuned/runtime/dist/common/jwtTokenManager";
5
- import retry from "async-retry";
6
- import { runWithContext } from "@intuned/runtime";
7
- import { setTimeout } from "timers/promises";
8
- import { deleteTrace, uploadTrace } from "./controllers/traces";
9
- if (isJobRunMachine()) {
10
- console.log("Running in job v3 mode");
11
- void jobsV3();
12
- }
13
- async function runApiInContext(jobPayload) {
14
- const runId = jobPayload.headers[RUN_ID_HEADER];
15
- const jobId = process.env.JOB_ID;
16
- const jobRunId = process.env.JOB_RUN_ID;
17
- const proxy = jobPayload.payload.proxy
18
- ? proxyToUrl(jobPayload.payload.proxy)
19
- : undefined;
20
- const contextData = {
21
- runId: runId ?? "",
22
- jobId,
23
- jobRunId,
24
- queueId: undefined,
25
- proxy,
26
- timeoutInfo: {
27
- extendTimeoutCallback: async () => {
28
- try {
29
- await extendTimeout(jobPayload);
30
- }
31
- catch (error) {
32
- console.error("Error extending timeout", error);
33
- }
34
- },
35
- },
36
- ...(jobPayload.payload.executionContext ?? {}),
37
- };
38
- const backendFunctionsToken = jobPayload.payload.functionsToken;
39
- if (backendFunctionsToken) {
40
- backendFunctionsTokenManager.token = backendFunctionsToken;
41
- }
42
- try {
43
- return await runWithContext(contextData, runApi, {
44
- functionName: jobPayload.functionName,
45
- ...jobPayload.payload,
46
- runId: jobPayload.headers[RUN_ID_HEADER],
47
- attemptNumber: jobPayload.headers[ATTEMPT_NUMBER_HEADER],
48
- shouldSaveTrace: true,
49
- headless: isHeadless(),
50
- });
51
- }
52
- catch (error) {
53
- return getErrorResponse(error);
54
- }
55
- }
56
- async function jobsV3() {
57
- await reportReady();
58
- const initialDelay = 1000;
59
- let delay = initialDelay;
60
- while (true) {
61
- await setTimeout(delay);
62
- try {
63
- const { payload, shouldShutdown } = await requestPayload();
64
- if (!payload) {
65
- if (shouldShutdown) {
66
- console.log("Received shutdown signal from job");
67
- process.exit(0);
68
- }
69
- delay = Math.min(delay * 2, 60000);
70
- continue;
71
- }
72
- delay = initialDelay;
73
- console.log("Running payload", payload.functionName);
74
- const { body, status } = await runApiInContext(payload);
75
- await reportResultsAndUploadTraces(payload, status, body);
76
- if (shouldShutdown) {
77
- process.exit(0);
78
- }
79
- }
80
- catch (error) {
81
- console.error("Error in payload", error);
82
- }
83
- }
84
- }
85
- async function reportReady() {
86
- console.log("Ready");
87
- }
88
- async function requestPayload() {
89
- console.log("Requesting payload");
90
- const result = await callBackendFunctionWithToken("jobs/requestPayload", {
91
- headers: {
92
- "fly-instance-id": process.env.FLY_ALLOC_ID ?? "",
93
- [JOB_ID_HEADER]: process.env.JOB_ID ?? "",
94
- [JOB_RUN_ID_HEADER]: process.env.JOB_RUN_ID ?? "",
95
- },
96
- });
97
- const shouldShutdown = result.headers.get(SHOULD_SHUTDOWN_HEADER) === "true";
98
- if (result.status === 200) {
99
- const payload = (await result.json());
100
- console.log("Received payload", payload);
101
- return {
102
- payload: {
103
- ...payload,
104
- headers: {
105
- ...payload.headers,
106
- [JOB_ID_HEADER]: process.env.JOB_ID ?? "",
107
- [JOB_RUN_ID_HEADER]: process.env.JOB_RUN_ID ?? "",
108
- },
109
- },
110
- shouldShutdown,
111
- };
112
- }
113
- if (result.status === 204) {
114
- console.log("No payload available");
115
- return {
116
- payload: null,
117
- shouldShutdown,
118
- };
119
- }
120
- console.log("Failed to obtain payload", result.status, await result.text());
121
- return {
122
- payload: null,
123
- shouldShutdown,
124
- };
125
- }
126
- async function reportResultsAndUploadTraces(payload, statusCode, body) {
127
- await reportJobRunResult({
128
- runId: payload.headers[RUN_ID_HEADER],
129
- result: {
130
- statusCode,
131
- body,
132
- receiptHandle: payload.receiptHandle,
133
- },
134
- originalPayload: payload.originalPayload,
135
- startTime: payload.startTime,
136
- functionsToken: backendFunctionsTokenManager.token,
137
- });
138
- await uploadJobRunTrace(payload);
139
- }
140
- async function reportJobRunResult({ runId, result, originalPayload, startTime, functionsToken, }) {
141
- console.log("Reporting payload result");
142
- const reqResult = await retry(async (bail) => {
143
- const response = await callBackendFunctionWithToken("jobs/reportResult", {
144
- method: "POST",
145
- headers: {
146
- "Content-Type": "application/json",
147
- "fly-instance-id": process.env.FLY_ALLOC_ID ?? "",
148
- [JOB_ID_HEADER]: process.env.JOB_ID ?? "",
149
- [JOB_RUN_ID_HEADER]: process.env.JOB_RUN_ID ?? "",
150
- },
151
- body: JSON.stringify({
152
- runId,
153
- result,
154
- originalPayload,
155
- startTime,
156
- }),
157
- });
158
- if (!response.ok) {
159
- if ([401, 403, 404, 413].includes(response.status)) {
160
- bail(new Error(`Reporting result failed (non-retryable), status ${response.status}`));
161
- }
162
- throw new Error(`Reporting result failed, status ${response.status}`);
163
- }
164
- return response;
165
- }, {
166
- retries: 5,
167
- factor: 2,
168
- maxTimeout: 1000 * 60, // 1 minute
169
- minTimeout: 1000 * 5, // 5 seconds
170
- });
171
- console.log("Reported payload result", reqResult.ok, await reqResult.text());
172
- }
173
- async function uploadJobRunTrace(payload) {
174
- if (!payload.traceSignedUrl) {
175
- return;
176
- }
177
- const runId = payload.headers[RUN_ID_HEADER];
178
- const attemptNumber = payload.headers[ATTEMPT_NUMBER_HEADER];
179
- console.log("Uploading trace", runId, attemptNumber);
180
- const uploadTraceResult = await uploadTrace({
181
- runId,
182
- attemptNumber,
183
- signedUrl: payload.traceSignedUrl,
184
- });
185
- if (uploadTraceResult.isErr()) {
186
- console.error("Error uploading trace", uploadTraceResult.error, {
187
- runId,
188
- attemptNumber,
189
- });
190
- }
191
- else {
192
- console.log("Trace uploaded successfully, reporting trace", runId, attemptNumber);
193
- await retry(async (bail) => {
194
- const response = await callBackendFunctionWithToken("jobs/reportTrace", {
195
- method: "POST",
196
- headers: {
197
- "Content-Type": "application/json",
198
- "fly-instance-id": process.env.FLY_ALLOC_ID ?? "",
199
- [JOB_ID_HEADER]: process.env.JOB_ID ?? "",
200
- [JOB_RUN_ID_HEADER]: process.env.JOB_RUN_ID ?? "",
201
- },
202
- body: JSON.stringify({
203
- runId,
204
- attemptNumber,
205
- traceSignedUrl: payload.traceSignedUrl,
206
- }),
207
- });
208
- if (!response.ok) {
209
- if ([401, 403, 404].includes(response.status)) {
210
- bail(new Error(`Reporting trace failed (non-retryable), status ${response.status}`));
211
- }
212
- throw new Error(`Reporting trace failed, status ${response.status}`);
213
- }
214
- console.log("Trace reported successfully", runId, attemptNumber);
215
- return response;
216
- }, {
217
- retries: 2,
218
- minTimeout: 1000 * 5,
219
- }).catch(() => undefined);
220
- }
221
- console.log("Deleting trace", runId, attemptNumber);
222
- const deleteTraceResult = await deleteTrace({
223
- runId,
224
- attemptNumber,
225
- });
226
- if (deleteTraceResult.isErr()) {
227
- console.error("Error deleting trace", deleteTraceResult.error, {
228
- runId,
229
- attemptNumber,
230
- });
231
- }
232
- }
233
- async function extendTimeout(payload) {
234
- console.log("Requesting timeout extension for", payload.functionName);
235
- const extendTimeoutRes = await callBackendFunctionWithToken("jobs/extendTimeout", {
236
- method: "POST",
237
- headers: {
238
- "Content-Type": "application/json",
239
- "fly-instance-id": process.env.FLY_ALLOC_ID ?? "",
240
- [JOB_ID_HEADER]: process.env.JOB_ID ?? "",
241
- [JOB_RUN_ID_HEADER]: process.env.JOB_RUN_ID ?? "",
242
- },
243
- body: JSON.stringify({
244
- receiptHandle: payload.receiptHandle,
245
- }),
246
- });
247
- if (!extendTimeoutRes.ok) {
248
- console.error("Requesting timeout extension failed", extendTimeoutRes.status, await extendTimeoutRes.text());
249
- return false;
250
- }
251
- console.log("Request timeout extension success", extendTimeoutRes.ok);
252
- const response = await extendTimeoutRes.json();
253
- const newFunctionsToken = response.functionsToken;
254
- if (newFunctionsToken) {
255
- backendFunctionsTokenManager.token = newFunctionsToken;
256
- console.log("Backend functions token renewed");
257
- }
258
- return true;
259
- }
@@ -1,51 +0,0 @@
1
- import { isJobRunMachine } from "./utils";
2
- import { promisify } from "util";
3
- import { AsyncRunEndpointController } from "./utils";
4
- export class ShutdownController {
5
- static initialize(server) {
6
- if (this._instance) {
7
- throw new Error("ShutdownController is already initialized");
8
- }
9
- this._instance = new ShutdownController(server);
10
- }
11
- static get instance() {
12
- if (!this._instance) {
13
- throw new Error("ShutdownController is not initialized");
14
- }
15
- return this._instance;
16
- }
17
- constructor(server) {
18
- this.timer = null;
19
- this.server = server;
20
- }
21
- async checkForShutdown() {
22
- if (await this.serverShouldShutdown()) {
23
- if (this.timer)
24
- clearTimeout(this.timer);
25
- this.timer = setTimeout(async () => {
26
- if (await this.serverShouldShutdown()) {
27
- console.log("No active requests, shutting down the server.");
28
- process.exit(0);
29
- }
30
- // TIME_TO_SHUTDOWN in seconds to match tired-proxy
31
- }, this.calculateShutdownDelay());
32
- }
33
- }
34
- async getActiveRequests() {
35
- const activeConnections = await promisify((...params) => this.server.getConnections(...params))();
36
- return activeConnections + AsyncRunEndpointController.activeRequestsCount;
37
- }
38
- async serverShouldShutdown() {
39
- if (isJobRunMachine()) {
40
- return false;
41
- }
42
- return (await this.getActiveRequests()) === 0;
43
- }
44
- calculateShutdownDelay() {
45
- const shutdownTime = +process.env.TIME_TO_SHUTDOWN;
46
- if (isNaN(shutdownTime) || shutdownTime <= 0) {
47
- return 60 * 1000;
48
- }
49
- return shutdownTime * 1000;
50
- }
51
- }
@@ -1,189 +0,0 @@
1
- import * as playwright from "@intuned/playwright-core";
2
- import * as path from "path";
3
- import { getExecutionContext } from "@intuned/runtime";
4
- import { setTimeout } from "timers/promises";
5
- export class FunctionNotFoundError extends Error {
6
- constructor(functionName, path) {
7
- const message = `function ${functionName} not found in ${path}`;
8
- super(message);
9
- this.functionName = functionName;
10
- this.path = path;
11
- this.name = "FunctionNotFound";
12
- Object.setPrototypeOf(this, FunctionNotFoundError.prototype);
13
- }
14
- }
15
- export function getIsRetryableError(error) {
16
- if (error?.message) {
17
- return error.message.includes("ERR_NETWORK_CHANGED");
18
- }
19
- return false;
20
- }
21
- export function getErrorResponse(error) {
22
- if (error instanceof FunctionNotFoundError) {
23
- return {
24
- status: 404,
25
- body: {
26
- message: error.message,
27
- error: error.name,
28
- },
29
- };
30
- }
31
- if (error instanceof playwright.errors.TimeoutError) {
32
- return {
33
- status: 500,
34
- body: { message: error.message, error: error.name },
35
- };
36
- }
37
- /**
38
- * here we use error.constructor.name instead of error instanceof RunError
39
- * this is because the error is thrown by importing the runner from the api code on intuned app
40
- * the definition of class RunError which is imported from here is different than the class RunError
41
- * imported from the user.
42
- */
43
- if (error.constructor.name === "RunError") {
44
- return {
45
- status: 200,
46
- body: {
47
- status: error.options.status_code ?? 500,
48
- message: error.message,
49
- error: error.options.error_code ?? error.name,
50
- intunedOptions: error.options,
51
- },
52
- };
53
- }
54
- return {
55
- status: 500,
56
- body: { error: error?.name ?? error, message: error?.message },
57
- };
58
- }
59
- export function handlePlaywrightExecutionError(error, res) {
60
- const { status, body } = getErrorResponse(error);
61
- return res.status(status).json(body);
62
- }
63
- export function errorRetryMiddleware(handler) {
64
- return async (...args) => {
65
- let attempts = 1;
66
- const [req, res, next] = args;
67
- // eslint-disable-next-line no-constant-condition
68
- while (true) {
69
- try {
70
- await handler(req, res, next);
71
- break;
72
- }
73
- catch (error) {
74
- console.log(error?.name, error?.message);
75
- if (!getIsRetryableError(error) || attempts >= 3) {
76
- return handlePlaywrightExecutionError(error, res);
77
- }
78
- attempts++;
79
- }
80
- }
81
- };
82
- }
83
- export function getTraceFilePath(runId, attemptNumber) {
84
- const fileName = `${runId}${attemptNumber ? `_${attemptNumber}` : ""}`;
85
- return path.join(process.env.TRACES_DIRECTORY ?? "", `${fileName}.zip`);
86
- }
87
- export function proxyToUrl(proxy) {
88
- const url = new URL(proxy.server);
89
- url.username = proxy.username;
90
- url.password = proxy.password;
91
- return url.toString();
92
- }
93
- export function isJobRunMachine() {
94
- return process.env.JOB_ID && process.env.JOB_RUN_ID;
95
- }
96
- export function isHeadless() {
97
- return process.env.INTUNED_PLAYWRIGHT_HEADLESS !== "0";
98
- }
99
- export class AsyncRunEndpointController {
100
- static isRunning(taskToken) {
101
- return this.activeRequests.has(taskToken);
102
- }
103
- static addRequest(taskToken) {
104
- this.activeRequests.add(taskToken);
105
- }
106
- static removeRequest(taskToken) {
107
- this.activeRequests.delete(taskToken);
108
- }
109
- static get activeRequestsCount() {
110
- return this.activeRequests.size;
111
- }
112
- }
113
- AsyncRunEndpointController.activeRequests = new Set();
114
- export async function waitWithExtendableTimeout({ initialTimeout, promise, abortController, }) {
115
- const context = getExecutionContext();
116
- if (context.timeoutInfo) {
117
- context.timeoutInfo.timeoutTimestamp = Date.now() + initialTimeout;
118
- }
119
- const timerSymbol = Symbol("timer");
120
- if (!context) {
121
- const result = await Promise.race([
122
- promise,
123
- setTimeout(initialTimeout, timerSymbol),
124
- ]);
125
- if (result === timerSymbol) {
126
- abortController?.abort("Timed out");
127
- return { timedOut: true };
128
- }
129
- return { timedOut: false, result };
130
- }
131
- let taskTimeout = initialTimeout;
132
- while (true) {
133
- const result = await Promise.race([
134
- promise,
135
- setTimeout(taskTimeout, timerSymbol),
136
- ]);
137
- if (result !== timerSymbol) {
138
- break;
139
- }
140
- const remainingTime = (context.timeoutInfo?.timeoutTimestamp ?? 0) - Date.now();
141
- if (remainingTime < 0) {
142
- abortController?.abort("Timed out");
143
- return { timedOut: true };
144
- }
145
- taskTimeout = remainingTime;
146
- }
147
- return {
148
- timedOut: false,
149
- result: await promise,
150
- };
151
- }
152
- export async function importModule(path) {
153
- // cleanup environment variables before running the user code
154
- // cleanEnvironmentVariables();
155
- const [folderName, ...functionNameParts] = path.split("/");
156
- const functionNameDepth = functionNameParts.length;
157
- // string literals should be inline
158
- // currently we support only 5 levels of depth
159
- // rollup dynamic import does not support multiple levels of dynamic imports so we need to specify the possible paths explicitly
160
- try {
161
- let imported = undefined;
162
- switch (functionNameDepth) {
163
- case 1:
164
- imported = await import(`./${folderName}/${functionNameParts[0]}.ts`);
165
- break;
166
- case 2:
167
- imported = await import(`./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}.ts`);
168
- break;
169
- case 3:
170
- imported = await import(`./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}.ts`);
171
- break;
172
- case 4:
173
- imported = await import(`./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}.ts`);
174
- break;
175
- case 5:
176
- imported = await import(`./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}/${functionNameParts[4]}.ts`);
177
- break;
178
- default:
179
- throw new Error("intuned supports maximum 5 levels of depth in the api folder");
180
- }
181
- return imported;
182
- }
183
- catch (error) {
184
- if (error.message.includes("Unknown variable dynamic import")) {
185
- throw new FunctionNotFoundError("", path);
186
- }
187
- throw error;
188
- }
189
- }
package/api/authed.js DELETED
@@ -1,6 +0,0 @@
1
- export default async function authed(params, page, context) {
2
- await page.goto("https://setcookie.net");
3
- return {
4
- cookies: await page.locator("ul li code").allInnerTexts(),
5
- };
6
- }
package/api/test.js DELETED
@@ -1,3 +0,0 @@
1
- export default async function whatever() {
2
- console.log("whatever");
3
- }
package/api/test2.js DELETED
@@ -1,17 +0,0 @@
1
- import { extendTimeout, extendPayload } from "../src/runtime";
2
- export default async function test2({ n }, page, context) {
3
- await page.goto("https://wikipedia.org/");
4
- await page.waitForTimeout(1000);
5
- const titles = [];
6
- for (let i = 0; i < (n ?? 2); i++) {
7
- await page.goto(`https://wikipedia.org/wiki/Special:Random`);
8
- await page.waitForTimeout(1000);
9
- titles.push(await page.locator("h1").innerText());
10
- extendTimeout();
11
- }
12
- extendPayload({
13
- api: "test",
14
- parameters: {},
15
- });
16
- return { titles };
17
- }
@@ -1,6 +0,0 @@
1
- export default async function check(page, _context) {
2
- await page.goto("https://setcookie.net");
3
- const result = (await page.locator("ul li code").all()).length > 0;
4
- console.log("Check result", result);
5
- return result;
6
- }
@@ -1,20 +0,0 @@
1
- // eslint-disable-next-line require-yield
2
- export default async function* create(params, page, context) {
3
- await page.goto("https://setcookie.net/");
4
- await page.locator("#name").fill("intuned");
5
- await page.locator("#value").fill("password");
6
- await page.locator("input[type=submit]").click();
7
- // console.log("Received", yield requestOTP("Enter useless otp"));
8
- // console.log(
9
- // "Received",
10
- // yield requestMultipleChoice("Choose the correct answer", [
11
- // "A",
12
- // "B",
13
- // "C",
14
- // "D",
15
- // ])
16
- // );
17
- await page.goto("http://www.sharonminsuk.com/code/storage-test.html");
18
- await page.locator("#local").fill("intuned");
19
- await page.locator("#local + input[type=button]").click();
20
- }
@@ -1 +0,0 @@
1
- export declare function tsNodeImport(apiName: string): Promise<any>;
@@ -1,43 +0,0 @@
1
- import { defineConfig, devices } from "@intuned/playwright-test";
2
- /**
3
- * Read environment variables from file.
4
- * https://github.com/motdotla/dotenv
5
- */
6
- // require('dotenv').config();
7
- /**
8
- * See https://playwright.dev/docs/test-configuration.
9
- */
10
- export default defineConfig({
11
- testDir: "./e2e-tests",
12
- /* Run tests in files in parallel */
13
- fullyParallel: true,
14
- /* Fail the build on CI if you accidentally left test.only in the source code. */
15
- forbidOnly: !!process.env.CI,
16
- /* Retry on CI only */
17
- retries: process.env.CI ? 2 : 0,
18
- /* Opt out of parallel tests on CI. */
19
- workers: process.env.CI ? 1 : undefined,
20
- /* Reporter to use. See https://playwright.dev/docs/test-reporters */
21
- reporter: "html",
22
- /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
23
- use: {
24
- /* Base URL to use in actions like `await page.goto('/')`. */
25
- // baseURL: 'http://127.0.0.1:3000',
26
- /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
27
- trace: "on-first-retry",
28
- // headless: false,
29
- },
30
- /* Configure projects for major browsers */
31
- projects: [
32
- {
33
- name: "chromium",
34
- use: { ...devices["Desktop Chrome"] },
35
- },
36
- ],
37
- /* Run your local dev server before starting the tests */
38
- // webServer: {
39
- // command: 'npm run start',
40
- // url: 'http://127.0.0.1:3000',
41
- // reuseExistingServer: !process.env.CI,
42
- // },
43
- });
@@ -1,16 +0,0 @@
1
- module.exports = function ({ template }) {
2
- return {
3
- visitor: {
4
- CallExpression(path) {
5
- if (path.node.callee.type === "Import") {
6
- const buildRequire = template(`Promise.resolve(require(ARGUMENT))`);
7
- path.replaceWith(
8
- buildRequire({
9
- ARGUMENT: path.node.arguments[0],
10
- })
11
- );
12
- }
13
- },
14
- },
15
- };
16
- };
package/vite.config.js DELETED
@@ -1,16 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import macros from "vite-plugin-babel-macros";
3
- require('dotenv').config();
4
- export default defineConfig({
5
- test: {
6
- reporters: ['verbose', "html"],
7
- outputFile: { html: './reports/html/index.html' },
8
- testTimeout: 30000,
9
- env: {
10
- RUN_ENVIRONMENT: "AUTHORING",
11
- }
12
- },
13
- plugins: [
14
- macros(),
15
- ],
16
- });