intellitester 0.2.21 → 0.2.22

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.
@@ -1011,6 +1011,30 @@ var APPWRITE_DELETE_PATTERNS = {
1011
1011
  teamDelete: /\/v1\/teams\/([\w-]+)$/,
1012
1012
  membershipDelete: /\/v1\/teams\/([\w-]+)\/memberships\/([\w-]+)$/
1013
1013
  };
1014
+
1015
+ // src/executors/web/browserOptions.ts
1016
+ function getBrowserLaunchOptions(options) {
1017
+ return {
1018
+ headless: options.headless,
1019
+ args: [
1020
+ // Shared memory - critical for Docker/CI, harmless locally
1021
+ "--disable-dev-shm-usage",
1022
+ // GPU acceleration - not needed in headless mode
1023
+ "--disable-gpu",
1024
+ // Reduce overhead
1025
+ "--disable-extensions",
1026
+ // Prevent JavaScript throttling (helps with slow page loads)
1027
+ "--disable-background-timer-throttling",
1028
+ "--disable-backgrounding-occluded-windows",
1029
+ "--disable-renderer-backgrounding",
1030
+ // Process isolation - reduces overhead for testing
1031
+ "--disable-features=IsolateOrigins,site-per-process",
1032
+ // Networking tweaks
1033
+ "--disable-features=VizDisplayCompositor",
1034
+ "--disable-blink-features=AutomationControlled"
1035
+ ]
1036
+ };
1037
+ }
1014
1038
  function resolveEnvVars(value) {
1015
1039
  return value.replace(/\$\{(\w+)\}/g, (_, name) => process.env[name] || "");
1016
1040
  }
@@ -1963,7 +1987,7 @@ var runWebTest = async (test, options = {}) => {
1963
1987
  process.on("SIGINT", cleanup);
1964
1988
  process.on("SIGTERM", cleanup);
1965
1989
  console.log(`Launching ${browserName}${headless ? " (headless)" : " (visible)"}...`);
1966
- const browser = await getBrowser(browserName).launch({ headless });
1990
+ const browser = await getBrowser(browserName).launch(getBrowserLaunchOptions({ headless }));
1967
1991
  console.log(`Browser launched successfully`);
1968
1992
  const browserContext = await browser.newContext();
1969
1993
  const page = await browserContext.newPage();
@@ -2498,6 +2522,99 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
2498
2522
  await page.pause();
2499
2523
  break;
2500
2524
  }
2525
+ case "waitForSelector": {
2526
+ const handle = resolveLocator2(action.target);
2527
+ const timeout = action.timeout ?? 3e4;
2528
+ if (debugMode) {
2529
+ console.log(` [DEBUG] Waiting for element to be ${action.state}:`, action.target);
2530
+ }
2531
+ const waitForCondition2 = async (checkFn, timeoutMs, errorMessage) => {
2532
+ const start = Date.now();
2533
+ while (Date.now() - start < timeoutMs) {
2534
+ if (await checkFn()) return;
2535
+ await new Promise((r) => setTimeout(r, 100));
2536
+ }
2537
+ throw new Error(errorMessage);
2538
+ };
2539
+ switch (action.state) {
2540
+ case "visible":
2541
+ case "hidden":
2542
+ case "attached":
2543
+ case "detached":
2544
+ await handle.waitFor({ state: action.state, timeout });
2545
+ break;
2546
+ case "enabled":
2547
+ await waitForCondition2(
2548
+ () => handle.isEnabled(),
2549
+ timeout,
2550
+ `Element did not become enabled within ${timeout}ms`
2551
+ );
2552
+ break;
2553
+ case "disabled":
2554
+ await waitForCondition2(
2555
+ () => handle.isDisabled(),
2556
+ timeout,
2557
+ `Element did not become disabled within ${timeout}ms`
2558
+ );
2559
+ break;
2560
+ }
2561
+ break;
2562
+ }
2563
+ case "conditional": {
2564
+ const handle = resolveLocator2(action.condition.target);
2565
+ let conditionMet = false;
2566
+ if (debugMode) {
2567
+ console.log(` [DEBUG] Checking condition ${action.condition.type}:`, action.condition.target);
2568
+ }
2569
+ try {
2570
+ switch (action.condition.type) {
2571
+ case "exists":
2572
+ await handle.waitFor({ state: "attached", timeout: 500 });
2573
+ conditionMet = true;
2574
+ break;
2575
+ case "notExists":
2576
+ try {
2577
+ await handle.waitFor({ state: "detached", timeout: 500 });
2578
+ conditionMet = true;
2579
+ } catch {
2580
+ conditionMet = false;
2581
+ }
2582
+ break;
2583
+ case "visible":
2584
+ conditionMet = await handle.isVisible();
2585
+ break;
2586
+ case "hidden":
2587
+ conditionMet = !await handle.isVisible();
2588
+ break;
2589
+ }
2590
+ } catch {
2591
+ conditionMet = action.condition.type === "notExists";
2592
+ }
2593
+ if (debugMode) {
2594
+ console.log(` [DEBUG] Condition result: ${conditionMet}`);
2595
+ }
2596
+ const stepsToRun = conditionMet ? action.then : action.else ?? [];
2597
+ for (const nestedAction of stepsToRun) {
2598
+ switch (nestedAction.type) {
2599
+ case "screenshot": {
2600
+ const filename = nestedAction.name ?? `conditional-step.png`;
2601
+ const filePath = path.join(screenshotDir, filename);
2602
+ await page.screenshot({ path: filePath, fullPage: true });
2603
+ results.push({ action: nestedAction, status: "passed", screenshotPath: filePath });
2604
+ break;
2605
+ }
2606
+ case "fail": {
2607
+ throw new Error(nestedAction.message);
2608
+ }
2609
+ default:
2610
+ throw new Error(`Nested action type ${nestedAction.type} in conditional not yet supported`);
2611
+ }
2612
+ }
2613
+ break;
2614
+ }
2615
+ case "fail": {
2616
+ throw new Error(action.message);
2617
+ }
2501
2618
  default:
2502
2619
  throw new Error(`Unsupported action type: ${action.type}`);
2503
2620
  }
@@ -2922,7 +3039,7 @@ async function runWorkflow(workflow, workflowFilePath, options = {}) {
2922
3039
  const browserName = options.browser ?? workflow.config?.web?.browser ?? "chromium";
2923
3040
  const headless = options.headed === true ? false : workflow.config?.web?.headless ?? true;
2924
3041
  console.log(`Launching ${browserName}${headless ? " (headless)" : " (visible)"}...`);
2925
- const browser = await getBrowser2(browserName).launch({ headless });
3042
+ const browser = await getBrowser2(browserName).launch(getBrowserLaunchOptions({ headless }));
2926
3043
  console.log(`Browser launched successfully`);
2927
3044
  const browserContext = await browser.newContext();
2928
3045
  const page = await browserContext.newPage();
@@ -3059,6 +3176,6 @@ Collected ${serverResources.length} server-tracked resources`);
3059
3176
  }
3060
3177
  }
3061
3178
 
3062
- export { ActionSchema, IntellitesterConfigSchema, LocatorSchema, TestConfigSchema, TestDefinitionSchema, cleanupConfigSchema, cleanupDiscoverSchema, collectMissingEnvVars, createAIProvider, createTestContext, generateFillerText, generateRandomEmail, generateRandomPhone, generateRandomPhoto, generateRandomUsername, interpolateVariables, isPipelineContent, isPipelineFile, isWorkflowContent, isWorkflowFile, killServer, loadIntellitesterConfig, loadPipelineDefinition, loadTestDefinition, loadWorkflowDefinition, parseIntellitesterConfig, parsePipelineDefinition, parseTestDefinition, parseWorkflowDefinition, previewConfigSchema, runWebTest, runWorkflow, runWorkflowWithContext, setupAppwriteTracking, startTrackingServer, startWebServer };
3063
- //# sourceMappingURL=chunk-CKUSY4ZM.js.map
3064
- //# sourceMappingURL=chunk-CKUSY4ZM.js.map
3179
+ export { ActionSchema, IntellitesterConfigSchema, LocatorSchema, TestConfigSchema, TestDefinitionSchema, cleanupConfigSchema, cleanupDiscoverSchema, collectMissingEnvVars, createAIProvider, createTestContext, generateFillerText, generateRandomEmail, generateRandomPhone, generateRandomPhoto, generateRandomUsername, getBrowserLaunchOptions, interpolateVariables, isPipelineContent, isPipelineFile, isWorkflowContent, isWorkflowFile, killServer, loadIntellitesterConfig, loadPipelineDefinition, loadTestDefinition, loadWorkflowDefinition, parseIntellitesterConfig, parsePipelineDefinition, parseTestDefinition, parseWorkflowDefinition, previewConfigSchema, runWebTest, runWorkflow, runWorkflowWithContext, setupAppwriteTracking, startTrackingServer, startWebServer };
3180
+ //# sourceMappingURL=chunk-EQJZ2E5H.js.map
3181
+ //# sourceMappingURL=chunk-EQJZ2E5H.js.map