intellitester 0.2.19 → 0.2.20

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.
@@ -4,12 +4,13 @@ var chunkARJYJVRM_cjs = require('./chunk-ARJYJVRM.cjs');
4
4
  var zod = require('zod');
5
5
  var fs2 = require('fs/promises');
6
6
  var yaml = require('yaml');
7
- var crypto2 = require('crypto');
7
+ var uniqueNamesGenerator = require('unique-names-generator');
8
+ var crypto4 = require('crypto');
9
+ var libphonenumberJs = require('libphonenumber-js');
8
10
  var path = require('path');
9
11
  var child_process = require('child_process');
10
12
  var playwright = require('playwright');
11
13
  var prompts = require('prompts');
12
- var uniqueNamesGenerator = require('unique-names-generator');
13
14
  var nodeAppwrite = require('node-appwrite');
14
15
  var anthropic = require('@llamaindex/anthropic');
15
16
  var openai = require('@llamaindex/openai');
@@ -19,7 +20,7 @@ var http = require('http');
19
20
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
20
21
 
21
22
  var fs2__default = /*#__PURE__*/_interopDefault(fs2);
22
- var crypto2__default = /*#__PURE__*/_interopDefault(crypto2);
23
+ var crypto4__default = /*#__PURE__*/_interopDefault(crypto4);
23
24
  var path__default = /*#__PURE__*/_interopDefault(path);
24
25
  var prompts__default = /*#__PURE__*/_interopDefault(prompts);
25
26
 
@@ -500,6 +501,272 @@ function generateRandomUsername() {
500
501
  return username;
501
502
  }
502
503
 
504
+ // src/core/randomPhoto.ts
505
+ function generateRandomPhoto(dimensions) {
506
+ let width = 500;
507
+ let height = 500;
508
+ if (dimensions) {
509
+ if (dimensions.includes("x")) {
510
+ const [w, h] = dimensions.split("x").map((d) => parseInt(d.trim(), 10));
511
+ if (!isNaN(w) && w > 0) width = w;
512
+ if (!isNaN(h) && h > 0) height = h;
513
+ } else {
514
+ const size = parseInt(dimensions.trim(), 10);
515
+ if (!isNaN(size) && size > 0) {
516
+ width = size;
517
+ height = size;
518
+ }
519
+ }
520
+ }
521
+ return `https://picsum.photos/${width}/${height}`;
522
+ }
523
+
524
+ // src/core/fillerText.ts
525
+ var LOREM_WORDS = [
526
+ "lorem",
527
+ "ipsum",
528
+ "dolor",
529
+ "sit",
530
+ "amet",
531
+ "consectetur",
532
+ "adipiscing",
533
+ "elit",
534
+ "sed",
535
+ "do",
536
+ "eiusmod",
537
+ "tempor",
538
+ "incididunt",
539
+ "ut",
540
+ "labore",
541
+ "et",
542
+ "dolore",
543
+ "magna",
544
+ "aliqua",
545
+ "enim",
546
+ "ad",
547
+ "minim",
548
+ "veniam",
549
+ "quis",
550
+ "nostrud",
551
+ "exercitation",
552
+ "ullamco",
553
+ "laboris",
554
+ "nisi",
555
+ "aliquip",
556
+ "ex",
557
+ "ea",
558
+ "commodo",
559
+ "consequat",
560
+ "duis",
561
+ "aute",
562
+ "irure",
563
+ "in",
564
+ "reprehenderit",
565
+ "voluptate",
566
+ "velit",
567
+ "esse",
568
+ "cillum",
569
+ "fugiat",
570
+ "nulla",
571
+ "pariatur",
572
+ "excepteur",
573
+ "sint",
574
+ "occaecat",
575
+ "cupidatat",
576
+ "non",
577
+ "proident",
578
+ "sunt",
579
+ "culpa",
580
+ "qui",
581
+ "officia",
582
+ "deserunt",
583
+ "mollit",
584
+ "anim",
585
+ "id",
586
+ "est",
587
+ "laborum",
588
+ "perspiciatis",
589
+ "unde",
590
+ "omnis",
591
+ "iste",
592
+ "natus",
593
+ "error",
594
+ "voluptatem",
595
+ "accusantium",
596
+ "doloremque",
597
+ "laudantium",
598
+ "totam",
599
+ "rem",
600
+ "aperiam",
601
+ "eaque",
602
+ "ipsa",
603
+ "quae",
604
+ "ab",
605
+ "illo",
606
+ "inventore",
607
+ "veritatis",
608
+ "quasi",
609
+ "architecto",
610
+ "beatae",
611
+ "vitae",
612
+ "dicta",
613
+ "explicabo",
614
+ "nemo",
615
+ "ipsam",
616
+ "quia",
617
+ "voluptas",
618
+ "aspernatur",
619
+ "aut",
620
+ "odit",
621
+ "fugit",
622
+ "consequuntur",
623
+ "magni",
624
+ "dolores",
625
+ "eos",
626
+ "ratione",
627
+ "sequi",
628
+ "nesciunt",
629
+ "neque",
630
+ "porro",
631
+ "quisquam",
632
+ "nihil",
633
+ "impedit",
634
+ "quo",
635
+ "minus"
636
+ ];
637
+ function generateFillerText(wordCount) {
638
+ let count = 50;
639
+ if (wordCount !== void 0) {
640
+ const parsed = typeof wordCount === "string" ? parseInt(wordCount.trim(), 10) : wordCount;
641
+ if (!isNaN(parsed) && parsed > 0) {
642
+ count = parsed;
643
+ }
644
+ }
645
+ const words = [];
646
+ if (count >= 2) {
647
+ words.push("Lorem", "ipsum");
648
+ count -= 2;
649
+ }
650
+ for (let i = 0; i < count; i++) {
651
+ const randomIndex = Math.floor(Math.random() * LOREM_WORDS.length);
652
+ words.push(LOREM_WORDS[randomIndex]);
653
+ }
654
+ let result = words.join(" ");
655
+ const resultWords = result.split(" ");
656
+ const sentenceWords = [];
657
+ let sentenceLength = 0;
658
+ const nextSentenceLength = () => 8 + Math.floor(Math.random() * 5);
659
+ let targetLength = nextSentenceLength();
660
+ for (let i = 0; i < resultWords.length; i++) {
661
+ let word = resultWords[i];
662
+ if (sentenceLength === 0) {
663
+ word = word.charAt(0).toUpperCase() + word.slice(1);
664
+ }
665
+ sentenceWords.push(word);
666
+ sentenceLength++;
667
+ if (sentenceLength >= targetLength && i < resultWords.length - 1) {
668
+ sentenceWords[sentenceWords.length - 1] += ".";
669
+ sentenceLength = 0;
670
+ targetLength = nextSentenceLength();
671
+ }
672
+ }
673
+ result = sentenceWords.join(" ");
674
+ if (!result.endsWith(".")) {
675
+ result += ".";
676
+ }
677
+ return result;
678
+ }
679
+ function generateRandomEmail(domain) {
680
+ const randomPart = crypto4__default.default.randomBytes(3).toString("hex");
681
+ const emailDomain = domain?.trim() || "test.local";
682
+ return `test-${randomPart}@${emailDomain}`;
683
+ }
684
+ var COUNTRY_FORMATS = {
685
+ US: {
686
+ areaCode: () => {
687
+ const areaCodes = ["201", "212", "213", "310", "312", "404", "415", "512", "617", "702", "713", "718", "805", "818", "917"];
688
+ return areaCodes[Math.floor(Math.random() * areaCodes.length)];
689
+ },
690
+ subscriber: () => String(Math.floor(Math.random() * 9e6) + 1e6).slice(0, 7)
691
+ },
692
+ GB: {
693
+ areaCode: () => {
694
+ const areaCodes = ["20", "121", "131", "141", "151", "161", "171", "181"];
695
+ return areaCodes[Math.floor(Math.random() * areaCodes.length)];
696
+ },
697
+ subscriber: () => String(Math.floor(Math.random() * 9e7) + 1e7).slice(0, 8)
698
+ },
699
+ DE: {
700
+ areaCode: () => {
701
+ const areaCodes = ["30", "40", "69", "89", "211", "221", "341", "351"];
702
+ return areaCodes[Math.floor(Math.random() * areaCodes.length)];
703
+ },
704
+ subscriber: () => String(Math.floor(Math.random() * 9e6) + 1e6).slice(0, 7)
705
+ },
706
+ FR: {
707
+ areaCode: () => {
708
+ const areaCodes = ["1", "2", "3", "4", "5"];
709
+ return areaCodes[Math.floor(Math.random() * areaCodes.length)];
710
+ },
711
+ subscriber: () => String(Math.floor(Math.random() * 9e7) + 1e7).slice(0, 8)
712
+ },
713
+ AU: {
714
+ areaCode: () => {
715
+ const areaCodes = ["2", "3", "7", "8"];
716
+ return areaCodes[Math.floor(Math.random() * areaCodes.length)];
717
+ },
718
+ subscriber: () => String(Math.floor(Math.random() * 9e7) + 1e7).slice(0, 8)
719
+ }
720
+ };
721
+ function generateRandomPhone(country = "US") {
722
+ const countryCode = country.toUpperCase();
723
+ const format = COUNTRY_FORMATS[countryCode] || COUNTRY_FORMATS["US"];
724
+ for (let i = 0; i < 10; i++) {
725
+ const areaCode2 = format.areaCode();
726
+ const subscriber2 = format.subscriber();
727
+ const nationalNumber = areaCode2 + subscriber2;
728
+ try {
729
+ const phoneNumber = libphonenumberJs.parsePhoneNumber(nationalNumber, countryCode);
730
+ if (phoneNumber && libphonenumberJs.isValidPhoneNumber(phoneNumber.number)) {
731
+ return phoneNumber.format("E.164");
732
+ }
733
+ } catch {
734
+ }
735
+ }
736
+ const fallbackFormat = COUNTRY_FORMATS[countryCode] || COUNTRY_FORMATS["US"];
737
+ const areaCode = fallbackFormat.areaCode();
738
+ const subscriber = fallbackFormat.subscriber();
739
+ const callingCodes = {
740
+ US: "1",
741
+ GB: "44",
742
+ DE: "49",
743
+ FR: "33",
744
+ AU: "61"
745
+ };
746
+ const callingCode = callingCodes[countryCode] || "1";
747
+ return `+${callingCode}${areaCode}${subscriber}`;
748
+ }
749
+ function interpolateVariables(value, variables) {
750
+ return value.replace(/\{\{(\w+)(?::([^}]+))?\}\}/g, (match, name, param) => {
751
+ switch (name) {
752
+ case "uuid":
753
+ return crypto4__default.default.randomUUID().split("-")[0];
754
+ case "randomUsername":
755
+ return generateRandomUsername();
756
+ case "randomPhoto":
757
+ return generateRandomPhoto(param);
758
+ case "fillerText":
759
+ return generateFillerText(param);
760
+ case "randomEmail":
761
+ return generateRandomEmail(param);
762
+ case "randomPhone":
763
+ return generateRandomPhone(param);
764
+ default:
765
+ return variables.get(name) ?? match;
766
+ }
767
+ });
768
+ }
769
+
503
770
  // src/integrations/email/inbucketClient.ts
504
771
  var InbucketClient = class {
505
772
  constructor(config) {
@@ -1034,17 +1301,6 @@ async function startTrackingServer(options) {
1034
1301
 
1035
1302
  // src/executors/web/playwrightExecutor.ts
1036
1303
  var defaultScreenshotDir = path__default.default.join(process.cwd(), "artifacts", "screenshots");
1037
- function interpolateVariables(value, variables) {
1038
- return value.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
1039
- if (varName === "uuid") {
1040
- return crypto2__default.default.randomUUID().split("-")[0];
1041
- }
1042
- if (varName === "randomUsername") {
1043
- return generateRandomUsername();
1044
- }
1045
- return variables.get(varName) ?? match;
1046
- });
1047
- }
1048
1304
  var resolveUrl = (value, baseUrl) => {
1049
1305
  if (!baseUrl) return value;
1050
1306
  try {
@@ -1584,7 +1840,7 @@ var runWebTest = async (test, options = {}) => {
1584
1840
  const headless = !(options.headed ?? false);
1585
1841
  const screenshotDir = options.screenshotDir ?? defaultScreenshotDir;
1586
1842
  const defaultTimeout = options.defaultTimeoutMs ?? 3e4;
1587
- const sessionId = crypto2__default.default.randomUUID();
1843
+ const sessionId = crypto4__default.default.randomUUID();
1588
1844
  const trackingServer = new TrackingServer();
1589
1845
  await trackingServer.start();
1590
1846
  process.env.INTELLITESTER_SESSION_ID = sessionId;
@@ -1890,19 +2146,14 @@ var getBrowser2 = (browser) => {
1890
2146
  };
1891
2147
  function interpolateWorkflowVariables(value, currentVariables, testResults) {
1892
2148
  return value.replace(/\{\{([^}]+)\}\}/g, (match, path3) => {
1893
- if (path3.includes(".")) {
2149
+ if (path3.includes(".") && !path3.includes(":")) {
1894
2150
  const [testId, _varName] = path3.split(".", 2);
1895
2151
  testResults.find((t) => t.id === testId);
1896
2152
  console.warn(`Cross-test variable interpolation {{${path3}}} not yet fully implemented`);
1897
2153
  return match;
1898
2154
  }
1899
- if (path3 === "uuid") {
1900
- return crypto2__default.default.randomUUID().split("-")[0];
1901
- }
1902
- if (path3 === "randomUsername") {
1903
- return generateRandomUsername();
1904
- }
1905
- return currentVariables.get(path3) ?? match;
2155
+ const result = interpolateVariables(`{{${path3}}}`, currentVariables);
2156
+ return result;
1906
2157
  });
1907
2158
  }
1908
2159
  async function runTestInWorkflow(test, page, context, options, _workflowDir, workflowBaseUrl) {
@@ -1918,16 +2169,8 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
1918
2169
  return value;
1919
2170
  }
1920
2171
  };
1921
- const interpolateVariables2 = (value) => {
1922
- return value.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
1923
- if (varName === "uuid") {
1924
- return crypto2__default.default.randomUUID().split("-")[0];
1925
- }
1926
- if (varName === "randomUsername") {
1927
- return generateRandomUsername();
1928
- }
1929
- return context.variables.get(varName) ?? match;
1930
- });
2172
+ const interpolate = (value) => {
2173
+ return interpolateVariables(value, context.variables);
1931
2174
  };
1932
2175
  const resolveLocator2 = (locator) => {
1933
2176
  if (locator.testId) return page.getByTestId(locator.testId);
@@ -1950,7 +2193,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
1950
2193
  try {
1951
2194
  switch (action.type) {
1952
2195
  case "navigate": {
1953
- const interpolated = interpolateVariables2(action.value);
2196
+ const interpolated = interpolate(action.value);
1954
2197
  const baseUrl = test.config?.web?.baseUrl ?? workflowBaseUrl;
1955
2198
  const target = resolveUrl2(interpolated, baseUrl);
1956
2199
  if (debugMode) console.log(` [DEBUG] Navigating to: ${target}`);
@@ -1964,7 +2207,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
1964
2207
  break;
1965
2208
  }
1966
2209
  case "input": {
1967
- const interpolated = interpolateVariables2(action.value);
2210
+ const interpolated = interpolate(action.value);
1968
2211
  if (debugMode) console.log(` [DEBUG] Input: ${interpolated}`);
1969
2212
  const handle = resolveLocator2(action.target);
1970
2213
  await handle.fill(interpolated);
@@ -1983,7 +2226,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
1983
2226
  break;
1984
2227
  }
1985
2228
  case "select": {
1986
- const interpolated = interpolateVariables2(action.value);
2229
+ const interpolated = interpolate(action.value);
1987
2230
  if (debugMode) console.log(` [DEBUG] Selecting: ${interpolated}`);
1988
2231
  const handle = resolveLocator2(action.target);
1989
2232
  await handle.selectOption(interpolated);
@@ -2022,7 +2265,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
2022
2265
  const handle = resolveLocator2(action.target);
2023
2266
  await handle.waitFor({ state: "visible" });
2024
2267
  if (action.value) {
2025
- const interpolated = interpolateVariables2(action.value);
2268
+ const interpolated = interpolate(action.value);
2026
2269
  const text = (await handle.textContent())?.trim() ?? "";
2027
2270
  if (!text.includes(interpolated)) {
2028
2271
  throw new Error(
@@ -2063,7 +2306,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
2063
2306
  case "setVar": {
2064
2307
  let value;
2065
2308
  if (action.value) {
2066
- value = interpolateVariables2(action.value);
2309
+ value = interpolate(action.value);
2067
2310
  } else if (action.from === "response") {
2068
2311
  throw new Error("setVar from response not yet implemented");
2069
2312
  } else if (action.from === "element") {
@@ -2081,7 +2324,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
2081
2324
  if (!context.emailClient) {
2082
2325
  throw new Error("Email client not configured");
2083
2326
  }
2084
- const mailbox = interpolateVariables2(action.mailbox);
2327
+ const mailbox = interpolate(action.mailbox);
2085
2328
  context.lastEmail = await context.emailClient.waitForEmail(mailbox, {
2086
2329
  timeout: action.timeout,
2087
2330
  subjectContains: action.subjectContains
@@ -2126,7 +2369,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
2126
2369
  if (!context.emailClient) {
2127
2370
  throw new Error("Email client not configured");
2128
2371
  }
2129
- const mailbox = interpolateVariables2(action.mailbox);
2372
+ const mailbox = interpolate(action.mailbox);
2130
2373
  await context.emailClient.clearMailbox(mailbox);
2131
2374
  break;
2132
2375
  }
@@ -2346,7 +2589,7 @@ function inferCleanupConfig(config) {
2346
2589
  async function runWorkflowWithContext(workflow, workflowFilePath, options) {
2347
2590
  const { page, executionContext, skipCleanup = false, sessionId: providedSessionId, testStartTime: providedTestStartTime } = options;
2348
2591
  const workflowDir = path__default.default.dirname(workflowFilePath);
2349
- const sessionId = providedSessionId ?? crypto2__default.default.randomUUID();
2592
+ const sessionId = providedSessionId ?? crypto4__default.default.randomUUID();
2350
2593
  const testStartTime = providedTestStartTime ?? (/* @__PURE__ */ new Date()).toISOString();
2351
2594
  console.log(`
2352
2595
  Starting workflow: ${workflow.name}`);
@@ -2365,11 +2608,7 @@ Starting workflow: ${workflow.name}`);
2365
2608
  if (workflow.variables) {
2366
2609
  for (const [key, value] of Object.entries(workflow.variables)) {
2367
2610
  if (!executionContext.variables.has(key)) {
2368
- const interpolated = value.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
2369
- if (varName === "uuid") return crypto2__default.default.randomUUID().split("-")[0];
2370
- if (varName === "randomUsername") return generateRandomUsername();
2371
- return executionContext.variables.get(varName) ?? match;
2372
- });
2611
+ const interpolated = interpolateVariables(value, executionContext.variables);
2373
2612
  executionContext.variables.set(key, interpolated);
2374
2613
  }
2375
2614
  }
@@ -2399,15 +2638,7 @@ Starting workflow: ${workflow.name}`);
2399
2638
  }
2400
2639
  if (test.variables) {
2401
2640
  for (const [key, value] of Object.entries(test.variables)) {
2402
- const interpolated = value.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
2403
- if (varName === "uuid") {
2404
- return crypto2__default.default.randomUUID().split("-")[0];
2405
- }
2406
- if (varName === "randomUsername") {
2407
- return generateRandomUsername();
2408
- }
2409
- return executionContext.variables.get(varName) ?? match;
2410
- });
2641
+ const interpolated = interpolateVariables(value, executionContext.variables);
2411
2642
  executionContext.variables.set(key, interpolated);
2412
2643
  }
2413
2644
  }
@@ -2546,7 +2777,7 @@ ${"=".repeat(60)}`);
2546
2777
  }
2547
2778
  async function runWorkflow(workflow, workflowFilePath, options = {}) {
2548
2779
  const workflowDir = path__default.default.dirname(workflowFilePath);
2549
- const sessionId = crypto2__default.default.randomUUID();
2780
+ const sessionId = crypto4__default.default.randomUUID();
2550
2781
  const testStartTime = (/* @__PURE__ */ new Date()).toISOString();
2551
2782
  let trackingServer = null;
2552
2783
  try {
@@ -2603,11 +2834,7 @@ async function runWorkflow(workflow, workflowFilePath, options = {}) {
2603
2834
  };
2604
2835
  if (workflow.variables) {
2605
2836
  for (const [key, value] of Object.entries(workflow.variables)) {
2606
- const interpolated = value.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
2607
- if (varName === "uuid") return crypto2__default.default.randomUUID().split("-")[0];
2608
- if (varName === "randomUsername") return generateRandomUsername();
2609
- return executionContext.variables.get(varName) ?? match;
2610
- });
2837
+ const interpolated = interpolateVariables(value, executionContext.variables);
2611
2838
  executionContext.variables.set(key, interpolated);
2612
2839
  }
2613
2840
  }
@@ -2736,7 +2963,12 @@ exports.cleanupDiscoverSchema = cleanupDiscoverSchema;
2736
2963
  exports.collectMissingEnvVars = collectMissingEnvVars;
2737
2964
  exports.createAIProvider = createAIProvider;
2738
2965
  exports.createTestContext = createTestContext;
2966
+ exports.generateFillerText = generateFillerText;
2967
+ exports.generateRandomEmail = generateRandomEmail;
2968
+ exports.generateRandomPhone = generateRandomPhone;
2969
+ exports.generateRandomPhoto = generateRandomPhoto;
2739
2970
  exports.generateRandomUsername = generateRandomUsername;
2971
+ exports.interpolateVariables = interpolateVariables;
2740
2972
  exports.isPipelineContent = isPipelineContent;
2741
2973
  exports.isPipelineFile = isPipelineFile;
2742
2974
  exports.isWorkflowContent = isWorkflowContent;
@@ -2757,5 +2989,5 @@ exports.runWorkflowWithContext = runWorkflowWithContext;
2757
2989
  exports.setupAppwriteTracking = setupAppwriteTracking;
2758
2990
  exports.startTrackingServer = startTrackingServer;
2759
2991
  exports.startWebServer = startWebServer;
2760
- //# sourceMappingURL=chunk-LFCMPHWU.cjs.map
2761
- //# sourceMappingURL=chunk-LFCMPHWU.cjs.map
2992
+ //# sourceMappingURL=chunk-JIVORCLQ.cjs.map
2993
+ //# sourceMappingURL=chunk-JIVORCLQ.cjs.map