intellitester 0.2.18 → 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,7 +4,9 @@ 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');
@@ -18,7 +20,7 @@ var http = require('http');
18
20
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
19
21
 
20
22
  var fs2__default = /*#__PURE__*/_interopDefault(fs2);
21
- var crypto2__default = /*#__PURE__*/_interopDefault(crypto2);
23
+ var crypto4__default = /*#__PURE__*/_interopDefault(crypto4);
22
24
  var path__default = /*#__PURE__*/_interopDefault(path);
23
25
  var prompts__default = /*#__PURE__*/_interopDefault(prompts);
24
26
 
@@ -485,6 +487,285 @@ var isPipelineContent = (content) => {
485
487
  return false;
486
488
  }
487
489
  };
490
+ function generateRandomUsername() {
491
+ const numberDictionary = uniqueNamesGenerator.NumberDictionary.generate({ min: 0, max: 99 });
492
+ const username = uniqueNamesGenerator.uniqueNamesGenerator({
493
+ dictionaries: [uniqueNamesGenerator.adjectives, uniqueNamesGenerator.animals, numberDictionary],
494
+ separator: "",
495
+ style: "capital",
496
+ length: 3
497
+ });
498
+ if (username.length > 30) {
499
+ return username.slice(0, 30);
500
+ }
501
+ return username;
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
+ }
488
769
 
489
770
  // src/integrations/email/inbucketClient.ts
490
771
  var InbucketClient = class {
@@ -1020,14 +1301,6 @@ async function startTrackingServer(options) {
1020
1301
 
1021
1302
  // src/executors/web/playwrightExecutor.ts
1022
1303
  var defaultScreenshotDir = path__default.default.join(process.cwd(), "artifacts", "screenshots");
1023
- function interpolateVariables(value, variables) {
1024
- return value.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
1025
- if (varName === "uuid") {
1026
- return crypto2__default.default.randomUUID().split("-")[0];
1027
- }
1028
- return variables.get(varName) ?? match;
1029
- });
1030
- }
1031
1304
  var resolveUrl = (value, baseUrl) => {
1032
1305
  if (!baseUrl) return value;
1033
1306
  try {
@@ -1567,7 +1840,7 @@ var runWebTest = async (test, options = {}) => {
1567
1840
  const headless = !(options.headed ?? false);
1568
1841
  const screenshotDir = options.screenshotDir ?? defaultScreenshotDir;
1569
1842
  const defaultTimeout = options.defaultTimeoutMs ?? 3e4;
1570
- const sessionId = crypto2__default.default.randomUUID();
1843
+ const sessionId = crypto4__default.default.randomUUID();
1571
1844
  const trackingServer = new TrackingServer();
1572
1845
  await trackingServer.start();
1573
1846
  process.env.INTELLITESTER_SESSION_ID = sessionId;
@@ -1873,16 +2146,14 @@ var getBrowser2 = (browser) => {
1873
2146
  };
1874
2147
  function interpolateWorkflowVariables(value, currentVariables, testResults) {
1875
2148
  return value.replace(/\{\{([^}]+)\}\}/g, (match, path3) => {
1876
- if (path3.includes(".")) {
2149
+ if (path3.includes(".") && !path3.includes(":")) {
1877
2150
  const [testId, _varName] = path3.split(".", 2);
1878
2151
  testResults.find((t) => t.id === testId);
1879
2152
  console.warn(`Cross-test variable interpolation {{${path3}}} not yet fully implemented`);
1880
2153
  return match;
1881
2154
  }
1882
- if (path3 === "uuid") {
1883
- return crypto2__default.default.randomUUID().split("-")[0];
1884
- }
1885
- return currentVariables.get(path3) ?? match;
2155
+ const result = interpolateVariables(`{{${path3}}}`, currentVariables);
2156
+ return result;
1886
2157
  });
1887
2158
  }
1888
2159
  async function runTestInWorkflow(test, page, context, options, _workflowDir, workflowBaseUrl) {
@@ -1898,13 +2169,8 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
1898
2169
  return value;
1899
2170
  }
1900
2171
  };
1901
- const interpolateVariables2 = (value) => {
1902
- return value.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
1903
- if (varName === "uuid") {
1904
- return crypto2__default.default.randomUUID().split("-")[0];
1905
- }
1906
- return context.variables.get(varName) ?? match;
1907
- });
2172
+ const interpolate = (value) => {
2173
+ return interpolateVariables(value, context.variables);
1908
2174
  };
1909
2175
  const resolveLocator2 = (locator) => {
1910
2176
  if (locator.testId) return page.getByTestId(locator.testId);
@@ -1927,7 +2193,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
1927
2193
  try {
1928
2194
  switch (action.type) {
1929
2195
  case "navigate": {
1930
- const interpolated = interpolateVariables2(action.value);
2196
+ const interpolated = interpolate(action.value);
1931
2197
  const baseUrl = test.config?.web?.baseUrl ?? workflowBaseUrl;
1932
2198
  const target = resolveUrl2(interpolated, baseUrl);
1933
2199
  if (debugMode) console.log(` [DEBUG] Navigating to: ${target}`);
@@ -1941,7 +2207,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
1941
2207
  break;
1942
2208
  }
1943
2209
  case "input": {
1944
- const interpolated = interpolateVariables2(action.value);
2210
+ const interpolated = interpolate(action.value);
1945
2211
  if (debugMode) console.log(` [DEBUG] Input: ${interpolated}`);
1946
2212
  const handle = resolveLocator2(action.target);
1947
2213
  await handle.fill(interpolated);
@@ -1960,7 +2226,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
1960
2226
  break;
1961
2227
  }
1962
2228
  case "select": {
1963
- const interpolated = interpolateVariables2(action.value);
2229
+ const interpolated = interpolate(action.value);
1964
2230
  if (debugMode) console.log(` [DEBUG] Selecting: ${interpolated}`);
1965
2231
  const handle = resolveLocator2(action.target);
1966
2232
  await handle.selectOption(interpolated);
@@ -1999,7 +2265,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
1999
2265
  const handle = resolveLocator2(action.target);
2000
2266
  await handle.waitFor({ state: "visible" });
2001
2267
  if (action.value) {
2002
- const interpolated = interpolateVariables2(action.value);
2268
+ const interpolated = interpolate(action.value);
2003
2269
  const text = (await handle.textContent())?.trim() ?? "";
2004
2270
  if (!text.includes(interpolated)) {
2005
2271
  throw new Error(
@@ -2040,7 +2306,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
2040
2306
  case "setVar": {
2041
2307
  let value;
2042
2308
  if (action.value) {
2043
- value = interpolateVariables2(action.value);
2309
+ value = interpolate(action.value);
2044
2310
  } else if (action.from === "response") {
2045
2311
  throw new Error("setVar from response not yet implemented");
2046
2312
  } else if (action.from === "element") {
@@ -2058,7 +2324,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
2058
2324
  if (!context.emailClient) {
2059
2325
  throw new Error("Email client not configured");
2060
2326
  }
2061
- const mailbox = interpolateVariables2(action.mailbox);
2327
+ const mailbox = interpolate(action.mailbox);
2062
2328
  context.lastEmail = await context.emailClient.waitForEmail(mailbox, {
2063
2329
  timeout: action.timeout,
2064
2330
  subjectContains: action.subjectContains
@@ -2103,7 +2369,7 @@ async function runTestInWorkflow(test, page, context, options, _workflowDir, wor
2103
2369
  if (!context.emailClient) {
2104
2370
  throw new Error("Email client not configured");
2105
2371
  }
2106
- const mailbox = interpolateVariables2(action.mailbox);
2372
+ const mailbox = interpolate(action.mailbox);
2107
2373
  await context.emailClient.clearMailbox(mailbox);
2108
2374
  break;
2109
2375
  }
@@ -2323,7 +2589,7 @@ function inferCleanupConfig(config) {
2323
2589
  async function runWorkflowWithContext(workflow, workflowFilePath, options) {
2324
2590
  const { page, executionContext, skipCleanup = false, sessionId: providedSessionId, testStartTime: providedTestStartTime } = options;
2325
2591
  const workflowDir = path__default.default.dirname(workflowFilePath);
2326
- const sessionId = providedSessionId ?? crypto2__default.default.randomUUID();
2592
+ const sessionId = providedSessionId ?? crypto4__default.default.randomUUID();
2327
2593
  const testStartTime = providedTestStartTime ?? (/* @__PURE__ */ new Date()).toISOString();
2328
2594
  console.log(`
2329
2595
  Starting workflow: ${workflow.name}`);
@@ -2342,10 +2608,7 @@ Starting workflow: ${workflow.name}`);
2342
2608
  if (workflow.variables) {
2343
2609
  for (const [key, value] of Object.entries(workflow.variables)) {
2344
2610
  if (!executionContext.variables.has(key)) {
2345
- const interpolated = value.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
2346
- if (varName === "uuid") return crypto2__default.default.randomUUID().split("-")[0];
2347
- return executionContext.variables.get(varName) ?? match;
2348
- });
2611
+ const interpolated = interpolateVariables(value, executionContext.variables);
2349
2612
  executionContext.variables.set(key, interpolated);
2350
2613
  }
2351
2614
  }
@@ -2375,12 +2638,7 @@ Starting workflow: ${workflow.name}`);
2375
2638
  }
2376
2639
  if (test.variables) {
2377
2640
  for (const [key, value] of Object.entries(test.variables)) {
2378
- const interpolated = value.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
2379
- if (varName === "uuid") {
2380
- return crypto2__default.default.randomUUID().split("-")[0];
2381
- }
2382
- return executionContext.variables.get(varName) ?? match;
2383
- });
2641
+ const interpolated = interpolateVariables(value, executionContext.variables);
2384
2642
  executionContext.variables.set(key, interpolated);
2385
2643
  }
2386
2644
  }
@@ -2519,7 +2777,7 @@ ${"=".repeat(60)}`);
2519
2777
  }
2520
2778
  async function runWorkflow(workflow, workflowFilePath, options = {}) {
2521
2779
  const workflowDir = path__default.default.dirname(workflowFilePath);
2522
- const sessionId = crypto2__default.default.randomUUID();
2780
+ const sessionId = crypto4__default.default.randomUUID();
2523
2781
  const testStartTime = (/* @__PURE__ */ new Date()).toISOString();
2524
2782
  let trackingServer = null;
2525
2783
  try {
@@ -2576,10 +2834,7 @@ async function runWorkflow(workflow, workflowFilePath, options = {}) {
2576
2834
  };
2577
2835
  if (workflow.variables) {
2578
2836
  for (const [key, value] of Object.entries(workflow.variables)) {
2579
- const interpolated = value.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
2580
- if (varName === "uuid") return crypto2__default.default.randomUUID().split("-")[0];
2581
- return executionContext.variables.get(varName) ?? match;
2582
- });
2837
+ const interpolated = interpolateVariables(value, executionContext.variables);
2583
2838
  executionContext.variables.set(key, interpolated);
2584
2839
  }
2585
2840
  }
@@ -2708,6 +2963,12 @@ exports.cleanupDiscoverSchema = cleanupDiscoverSchema;
2708
2963
  exports.collectMissingEnvVars = collectMissingEnvVars;
2709
2964
  exports.createAIProvider = createAIProvider;
2710
2965
  exports.createTestContext = createTestContext;
2966
+ exports.generateFillerText = generateFillerText;
2967
+ exports.generateRandomEmail = generateRandomEmail;
2968
+ exports.generateRandomPhone = generateRandomPhone;
2969
+ exports.generateRandomPhoto = generateRandomPhoto;
2970
+ exports.generateRandomUsername = generateRandomUsername;
2971
+ exports.interpolateVariables = interpolateVariables;
2711
2972
  exports.isPipelineContent = isPipelineContent;
2712
2973
  exports.isPipelineFile = isPipelineFile;
2713
2974
  exports.isWorkflowContent = isWorkflowContent;
@@ -2728,5 +2989,5 @@ exports.runWorkflowWithContext = runWorkflowWithContext;
2728
2989
  exports.setupAppwriteTracking = setupAppwriteTracking;
2729
2990
  exports.startTrackingServer = startTrackingServer;
2730
2991
  exports.startWebServer = startWebServer;
2731
- //# sourceMappingURL=chunk-PL3IQXLK.cjs.map
2732
- //# sourceMappingURL=chunk-PL3IQXLK.cjs.map
2992
+ //# sourceMappingURL=chunk-JIVORCLQ.cjs.map
2993
+ //# sourceMappingURL=chunk-JIVORCLQ.cjs.map