intellitester 0.2.15 → 0.2.18

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.
@@ -41,6 +41,36 @@ var inputActionSchema = z.object({
41
41
  target: LocatorSchema,
42
42
  value: z.string().describe("Text to input (can reference variables with ${VAR_NAME})")
43
43
  }).describe("Input text into a field");
44
+ var clearActionSchema = z.object({
45
+ type: z.literal("clear"),
46
+ target: LocatorSchema
47
+ }).describe("Clear the contents of an input field");
48
+ var hoverActionSchema = z.object({
49
+ type: z.literal("hover"),
50
+ target: LocatorSchema
51
+ }).describe("Hover over an element");
52
+ var selectActionSchema = z.object({
53
+ type: z.literal("select"),
54
+ target: LocatorSchema,
55
+ value: z.string().describe("Option value, label, or index to select")
56
+ }).describe("Select an option from a dropdown");
57
+ var checkActionSchema = z.object({
58
+ type: z.literal("check"),
59
+ target: LocatorSchema
60
+ }).describe("Check a checkbox");
61
+ var uncheckActionSchema = z.object({
62
+ type: z.literal("uncheck"),
63
+ target: LocatorSchema
64
+ }).describe("Uncheck a checkbox");
65
+ var pressActionSchema = z.object({
66
+ type: z.literal("press"),
67
+ key: nonEmptyString.describe("Key to press (e.g., Enter, Tab, Escape, ArrowDown)"),
68
+ target: LocatorSchema.optional().describe("Element to focus before pressing key")
69
+ }).describe("Press a keyboard key");
70
+ var focusActionSchema = z.object({
71
+ type: z.literal("focus"),
72
+ target: LocatorSchema
73
+ }).describe("Focus an element");
44
74
  var assertActionSchema = z.object({
45
75
  type: z.literal("assert"),
46
76
  target: LocatorSchema,
@@ -101,6 +131,13 @@ var ActionSchema = z.discriminatedUnion("type", [
101
131
  navigateActionSchema,
102
132
  tapActionSchema,
103
133
  inputActionSchema,
134
+ clearActionSchema,
135
+ hoverActionSchema,
136
+ selectActionSchema,
137
+ checkActionSchema,
138
+ uncheckActionSchema,
139
+ pressActionSchema,
140
+ focusActionSchema,
104
141
  assertActionSchema,
105
142
  waitActionSchema,
106
143
  scrollActionSchema,
@@ -274,6 +311,7 @@ var workflowConfigSchema = z.object({
274
311
  var WorkflowDefinitionSchema = z.object({
275
312
  name: nonEmptyString2.describe("The name of the workflow"),
276
313
  platform: z.enum(["web", "android", "ios"]).default("web").describe("The platform to run the workflow on"),
314
+ variables: z.record(z.string(), z.string()).optional().describe("Workflow-level variables available to all tests"),
277
315
  config: workflowConfigSchema.optional(),
278
316
  continueOnFailure: z.boolean().default(false).describe("Continue running subsequent tests even if a test fails"),
279
317
  tests: z.array(testReferenceSchema).min(1, "Workflow must contain at least one test").describe("List of test files to execute in this workflow")
@@ -1322,6 +1360,53 @@ async function executeActionWithRetry(page, action, index, options) {
1322
1360
  await runInput(page, action.target, action.value, context);
1323
1361
  break;
1324
1362
  }
1363
+ case "clear": {
1364
+ if (debugMode) console.log(`[DEBUG] Clearing element:`, action.target);
1365
+ const handle = resolveLocator(page, action.target);
1366
+ await handle.clear();
1367
+ break;
1368
+ }
1369
+ case "hover": {
1370
+ if (debugMode) console.log(`[DEBUG] Hovering element:`, action.target);
1371
+ const handle = resolveLocator(page, action.target);
1372
+ await handle.hover();
1373
+ break;
1374
+ }
1375
+ case "select": {
1376
+ const interpolated = interpolateVariables(action.value, context.variables);
1377
+ if (debugMode) console.log(`[DEBUG] Selecting: ${interpolated}`);
1378
+ const handle = resolveLocator(page, action.target);
1379
+ await handle.selectOption(interpolated);
1380
+ break;
1381
+ }
1382
+ case "check": {
1383
+ if (debugMode) console.log(`[DEBUG] Checking:`, action.target);
1384
+ const handle = resolveLocator(page, action.target);
1385
+ await handle.check();
1386
+ break;
1387
+ }
1388
+ case "uncheck": {
1389
+ if (debugMode) console.log(`[DEBUG] Unchecking:`, action.target);
1390
+ const handle = resolveLocator(page, action.target);
1391
+ await handle.uncheck();
1392
+ break;
1393
+ }
1394
+ case "press": {
1395
+ if (debugMode) console.log(`[DEBUG] Pressing key: ${action.key}`);
1396
+ if (action.target) {
1397
+ const handle = resolveLocator(page, action.target);
1398
+ await handle.press(action.key);
1399
+ } else {
1400
+ await page.keyboard.press(action.key);
1401
+ }
1402
+ break;
1403
+ }
1404
+ case "focus": {
1405
+ if (debugMode) console.log(`[DEBUG] Focusing:`, action.target);
1406
+ const handle = resolveLocator(page, action.target);
1407
+ await handle.focus();
1408
+ break;
1409
+ }
1325
1410
  case "assert": {
1326
1411
  if (debugMode) {
1327
1412
  console.log(`[DEBUG] Asserting element:`, action.target);
@@ -1853,6 +1938,53 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
1853
1938
  await handle.fill(interpolated);
1854
1939
  break;
1855
1940
  }
1941
+ case "clear": {
1942
+ if (debugMode) console.log(` [DEBUG] Clearing element:`, action.target);
1943
+ const handle = resolveLocator2(action.target);
1944
+ await handle.clear();
1945
+ break;
1946
+ }
1947
+ case "hover": {
1948
+ if (debugMode) console.log(` [DEBUG] Hovering element:`, action.target);
1949
+ const handle = resolveLocator2(action.target);
1950
+ await handle.hover();
1951
+ break;
1952
+ }
1953
+ case "select": {
1954
+ const interpolated = interpolateVariables2(action.value);
1955
+ if (debugMode) console.log(` [DEBUG] Selecting: ${interpolated}`);
1956
+ const handle = resolveLocator2(action.target);
1957
+ await handle.selectOption(interpolated);
1958
+ break;
1959
+ }
1960
+ case "check": {
1961
+ if (debugMode) console.log(` [DEBUG] Checking:`, action.target);
1962
+ const handle = resolveLocator2(action.target);
1963
+ await handle.check();
1964
+ break;
1965
+ }
1966
+ case "uncheck": {
1967
+ if (debugMode) console.log(` [DEBUG] Unchecking:`, action.target);
1968
+ const handle = resolveLocator2(action.target);
1969
+ await handle.uncheck();
1970
+ break;
1971
+ }
1972
+ case "press": {
1973
+ if (debugMode) console.log(` [DEBUG] Pressing key: ${action.key}`);
1974
+ if (action.target) {
1975
+ const handle = resolveLocator2(action.target);
1976
+ await handle.press(action.key);
1977
+ } else {
1978
+ await page.keyboard.press(action.key);
1979
+ }
1980
+ break;
1981
+ }
1982
+ case "focus": {
1983
+ if (debugMode) console.log(` [DEBUG] Focusing:`, action.target);
1984
+ const handle = resolveLocator2(action.target);
1985
+ await handle.focus();
1986
+ break;
1987
+ }
1856
1988
  case "assert": {
1857
1989
  if (debugMode) console.log(` [DEBUG] Assert:`, action.target);
1858
1990
  const handle = resolveLocator2(action.target);
@@ -2198,6 +2330,17 @@ Starting workflow: ${workflow.name}`);
2198
2330
  }
2199
2331
  setupAppwriteTracking(page, executionContext);
2200
2332
  }
2333
+ if (workflow.variables) {
2334
+ for (const [key, value] of Object.entries(workflow.variables)) {
2335
+ if (!executionContext.variables.has(key)) {
2336
+ const interpolated = value.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
2337
+ if (varName === "uuid") return crypto2.randomUUID().split("-")[0];
2338
+ return executionContext.variables.get(varName) ?? match;
2339
+ });
2340
+ executionContext.variables.set(key, interpolated);
2341
+ }
2342
+ }
2343
+ }
2201
2344
  const testResults = [];
2202
2345
  let workflowFailed = false;
2203
2346
  for (const [index, testRef] of workflow.tests.entries()) {
@@ -2381,11 +2524,13 @@ async function runWorkflow(workflow, workflowFilePath, options = {}) {
2381
2524
  process.env.INTELLITESTER_TRACK_URL = `http://localhost:${trackingServer.port}`;
2382
2525
  }
2383
2526
  let serverProcess = null;
2384
- if (workflow.config?.webServer) {
2527
+ const webServerConfig = workflow.config?.webServer ?? options.webServer;
2528
+ if (webServerConfig) {
2385
2529
  try {
2530
+ const serverCwd = workflow.config?.webServer ? workflowDir : process.cwd();
2386
2531
  serverProcess = await startWebServer({
2387
- ...workflow.config.webServer,
2388
- cwd: workflowDir
2532
+ ...webServerConfig,
2533
+ cwd: serverCwd
2389
2534
  });
2390
2535
  } catch (error) {
2391
2536
  console.error("Failed to start web server:", error);
@@ -2420,6 +2565,15 @@ async function runWorkflow(workflow, workflowFilePath, options = {}) {
2420
2565
  apiKey: workflow.config.appwrite.apiKey
2421
2566
  } : void 0
2422
2567
  };
2568
+ if (workflow.variables) {
2569
+ for (const [key, value] of Object.entries(workflow.variables)) {
2570
+ const interpolated = value.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
2571
+ if (varName === "uuid") return crypto2.randomUUID().split("-")[0];
2572
+ return executionContext.variables.get(varName) ?? match;
2573
+ });
2574
+ executionContext.variables.set(key, interpolated);
2575
+ }
2576
+ }
2423
2577
  try {
2424
2578
  const result = await runWorkflowWithContext(workflow, workflowFilePath, {
2425
2579
  ...options,
@@ -2536,5 +2690,5 @@ Collected ${serverResources.length} server-tracked resources`);
2536
2690
  }
2537
2691
 
2538
2692
  export { ActionSchema, IntellitesterConfigSchema, LocatorSchema, TestConfigSchema, TestDefinitionSchema, cleanupConfigSchema, cleanupDiscoverSchema, collectMissingEnvVars, createAIProvider, createTestContext, isPipelineContent, isPipelineFile, isWorkflowContent, isWorkflowFile, killServer, loadIntellitesterConfig, loadPipelineDefinition, loadTestDefinition, loadWorkflowDefinition, parseIntellitesterConfig, parsePipelineDefinition, parseTestDefinition, parseWorkflowDefinition, previewConfigSchema, runWebTest, runWorkflow, runWorkflowWithContext, setupAppwriteTracking, startTrackingServer, startWebServer };
2539
- //# sourceMappingURL=chunk-MRTD4FLN.js.map
2540
- //# sourceMappingURL=chunk-MRTD4FLN.js.map
2693
+ //# sourceMappingURL=chunk-EQJQS4RD.js.map
2694
+ //# sourceMappingURL=chunk-EQJQS4RD.js.map