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.
@@ -1020,6 +1020,30 @@ var APPWRITE_DELETE_PATTERNS = {
1020
1020
  teamDelete: /\/v1\/teams\/([\w-]+)$/,
1021
1021
  membershipDelete: /\/v1\/teams\/([\w-]+)\/memberships\/([\w-]+)$/
1022
1022
  };
1023
+
1024
+ // src/executors/web/browserOptions.ts
1025
+ function getBrowserLaunchOptions(options) {
1026
+ return {
1027
+ headless: options.headless,
1028
+ args: [
1029
+ // Shared memory - critical for Docker/CI, harmless locally
1030
+ "--disable-dev-shm-usage",
1031
+ // GPU acceleration - not needed in headless mode
1032
+ "--disable-gpu",
1033
+ // Reduce overhead
1034
+ "--disable-extensions",
1035
+ // Prevent JavaScript throttling (helps with slow page loads)
1036
+ "--disable-background-timer-throttling",
1037
+ "--disable-backgrounding-occluded-windows",
1038
+ "--disable-renderer-backgrounding",
1039
+ // Process isolation - reduces overhead for testing
1040
+ "--disable-features=IsolateOrigins,site-per-process",
1041
+ // Networking tweaks
1042
+ "--disable-features=VizDisplayCompositor",
1043
+ "--disable-blink-features=AutomationControlled"
1044
+ ]
1045
+ };
1046
+ }
1023
1047
  function resolveEnvVars(value) {
1024
1048
  return value.replace(/\$\{(\w+)\}/g, (_, name) => process.env[name] || "");
1025
1049
  }
@@ -1972,7 +1996,7 @@ var runWebTest = async (test, options = {}) => {
1972
1996
  process.on("SIGINT", cleanup);
1973
1997
  process.on("SIGTERM", cleanup);
1974
1998
  console.log(`Launching ${browserName}${headless ? " (headless)" : " (visible)"}...`);
1975
- const browser = await getBrowser(browserName).launch({ headless });
1999
+ const browser = await getBrowser(browserName).launch(getBrowserLaunchOptions({ headless }));
1976
2000
  console.log(`Browser launched successfully`);
1977
2001
  const browserContext = await browser.newContext();
1978
2002
  const page = await browserContext.newPage();
@@ -2507,6 +2531,99 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
2507
2531
  await page.pause();
2508
2532
  break;
2509
2533
  }
2534
+ case "waitForSelector": {
2535
+ const handle = resolveLocator2(action.target);
2536
+ const timeout = action.timeout ?? 3e4;
2537
+ if (debugMode) {
2538
+ console.log(` [DEBUG] Waiting for element to be ${action.state}:`, action.target);
2539
+ }
2540
+ const waitForCondition2 = async (checkFn, timeoutMs, errorMessage) => {
2541
+ const start = Date.now();
2542
+ while (Date.now() - start < timeoutMs) {
2543
+ if (await checkFn()) return;
2544
+ await new Promise((r) => setTimeout(r, 100));
2545
+ }
2546
+ throw new Error(errorMessage);
2547
+ };
2548
+ switch (action.state) {
2549
+ case "visible":
2550
+ case "hidden":
2551
+ case "attached":
2552
+ case "detached":
2553
+ await handle.waitFor({ state: action.state, timeout });
2554
+ break;
2555
+ case "enabled":
2556
+ await waitForCondition2(
2557
+ () => handle.isEnabled(),
2558
+ timeout,
2559
+ `Element did not become enabled within ${timeout}ms`
2560
+ );
2561
+ break;
2562
+ case "disabled":
2563
+ await waitForCondition2(
2564
+ () => handle.isDisabled(),
2565
+ timeout,
2566
+ `Element did not become disabled within ${timeout}ms`
2567
+ );
2568
+ break;
2569
+ }
2570
+ break;
2571
+ }
2572
+ case "conditional": {
2573
+ const handle = resolveLocator2(action.condition.target);
2574
+ let conditionMet = false;
2575
+ if (debugMode) {
2576
+ console.log(` [DEBUG] Checking condition ${action.condition.type}:`, action.condition.target);
2577
+ }
2578
+ try {
2579
+ switch (action.condition.type) {
2580
+ case "exists":
2581
+ await handle.waitFor({ state: "attached", timeout: 500 });
2582
+ conditionMet = true;
2583
+ break;
2584
+ case "notExists":
2585
+ try {
2586
+ await handle.waitFor({ state: "detached", timeout: 500 });
2587
+ conditionMet = true;
2588
+ } catch {
2589
+ conditionMet = false;
2590
+ }
2591
+ break;
2592
+ case "visible":
2593
+ conditionMet = await handle.isVisible();
2594
+ break;
2595
+ case "hidden":
2596
+ conditionMet = !await handle.isVisible();
2597
+ break;
2598
+ }
2599
+ } catch {
2600
+ conditionMet = action.condition.type === "notExists";
2601
+ }
2602
+ if (debugMode) {
2603
+ console.log(` [DEBUG] Condition result: ${conditionMet}`);
2604
+ }
2605
+ const stepsToRun = conditionMet ? action.then : action.else ?? [];
2606
+ for (const nestedAction of stepsToRun) {
2607
+ switch (nestedAction.type) {
2608
+ case "screenshot": {
2609
+ const filename = nestedAction.name ?? `conditional-step.png`;
2610
+ const filePath = path__default.default.join(screenshotDir, filename);
2611
+ await page.screenshot({ path: filePath, fullPage: true });
2612
+ results.push({ action: nestedAction, status: "passed", screenshotPath: filePath });
2613
+ break;
2614
+ }
2615
+ case "fail": {
2616
+ throw new Error(nestedAction.message);
2617
+ }
2618
+ default:
2619
+ throw new Error(`Nested action type ${nestedAction.type} in conditional not yet supported`);
2620
+ }
2621
+ }
2622
+ break;
2623
+ }
2624
+ case "fail": {
2625
+ throw new Error(action.message);
2626
+ }
2510
2627
  default:
2511
2628
  throw new Error(`Unsupported action type: ${action.type}`);
2512
2629
  }
@@ -2931,7 +3048,7 @@ async function runWorkflow(workflow, workflowFilePath, options = {}) {
2931
3048
  const browserName = options.browser ?? workflow.config?.web?.browser ?? "chromium";
2932
3049
  const headless = options.headed === true ? false : workflow.config?.web?.headless ?? true;
2933
3050
  console.log(`Launching ${browserName}${headless ? " (headless)" : " (visible)"}...`);
2934
- const browser = await getBrowser2(browserName).launch({ headless });
3051
+ const browser = await getBrowser2(browserName).launch(getBrowserLaunchOptions({ headless }));
2935
3052
  console.log(`Browser launched successfully`);
2936
3053
  const browserContext = await browser.newContext();
2937
3054
  const page = await browserContext.newPage();
@@ -3083,6 +3200,7 @@ exports.generateRandomEmail = generateRandomEmail;
3083
3200
  exports.generateRandomPhone = generateRandomPhone;
3084
3201
  exports.generateRandomPhoto = generateRandomPhoto;
3085
3202
  exports.generateRandomUsername = generateRandomUsername;
3203
+ exports.getBrowserLaunchOptions = getBrowserLaunchOptions;
3086
3204
  exports.interpolateVariables = interpolateVariables;
3087
3205
  exports.isPipelineContent = isPipelineContent;
3088
3206
  exports.isPipelineFile = isPipelineFile;
@@ -3104,5 +3222,5 @@ exports.runWorkflowWithContext = runWorkflowWithContext;
3104
3222
  exports.setupAppwriteTracking = setupAppwriteTracking;
3105
3223
  exports.startTrackingServer = startTrackingServer;
3106
3224
  exports.startWebServer = startWebServer;
3107
- //# sourceMappingURL=chunk-PP666GZQ.cjs.map
3108
- //# sourceMappingURL=chunk-PP666GZQ.cjs.map
3225
+ //# sourceMappingURL=chunk-GCF2Q77Q.cjs.map
3226
+ //# sourceMappingURL=chunk-GCF2Q77Q.cjs.map