@lambdatest/smartui-cli 4.1.51 → 4.1.53

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.
Files changed (2) hide show
  1. package/dist/index.cjs +117 -7
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -778,6 +778,39 @@ var ConfigSchema = {
778
778
  }
779
779
  }
780
780
  },
781
+ lazyLoadConfiguration: {
782
+ type: "object",
783
+ properties: {
784
+ enabled: {
785
+ type: "boolean",
786
+ errorMessage: "Invalid config; lazyLoad enabled must be true/false"
787
+ },
788
+ scrollStep: {
789
+ type: "number",
790
+ minimum: 50,
791
+ maximum: 2e3,
792
+ errorMessage: "Invalid config; lazyLoad scrollStep must be > 50 and <= 2000"
793
+ },
794
+ scrollDelay: {
795
+ type: "number",
796
+ minimum: 100,
797
+ maximum: 5e3,
798
+ errorMessage: "Invalid config; lazyLoad scrollDelay must be > 100 and <= 5000"
799
+ },
800
+ maxScrolls: {
801
+ type: "number",
802
+ minimum: 1,
803
+ maximum: 100,
804
+ errorMessage: "Invalid config; lazyLoad maxScrolls must be > 1 and <= 100"
805
+ },
806
+ jumpBackToTop: {
807
+ type: "boolean",
808
+ errorMessage: "Invalid config; lazyLoad jumpBackToTop must be true/false"
809
+ }
810
+ },
811
+ required: ["enabled"],
812
+ additionalProperties: false
813
+ },
781
814
  delayedUpload: {
782
815
  type: "boolean",
783
816
  errorMessage: "Invalid config; delayedUpload must be true/false"
@@ -1550,6 +1583,35 @@ function scrollToBottomAndBackToTop({
1550
1583
  })();
1551
1584
  });
1552
1585
  }
1586
+ function smoothScrollToBottom({
1587
+ step = 250,
1588
+ delay = 300,
1589
+ maxScrolls = 50,
1590
+ jumpBackToTop = true
1591
+ } = {}) {
1592
+ return new Promise((resolve) => {
1593
+ let totalHeight = document.body.scrollHeight;
1594
+ let currentScroll = window.scrollY;
1595
+ let scrollCount = 0;
1596
+ function scroll() {
1597
+ if (currentScroll + window.innerHeight >= totalHeight || scrollCount >= maxScrolls) {
1598
+ if (jumpBackToTop) {
1599
+ window.scrollTo(0, 0);
1600
+ }
1601
+ resolve();
1602
+ return;
1603
+ }
1604
+ window.scrollBy(0, step);
1605
+ scrollCount++;
1606
+ setTimeout(() => {
1607
+ currentScroll = window.scrollY;
1608
+ totalHeight = document.body.scrollHeight;
1609
+ scroll();
1610
+ }, delay);
1611
+ }
1612
+ scroll();
1613
+ });
1614
+ }
1553
1615
  function launchBrowsers(ctx) {
1554
1616
  return __async(this, null, function* () {
1555
1617
  var _a;
@@ -2833,7 +2895,7 @@ var authExec_default = (ctx) => {
2833
2895
  };
2834
2896
 
2835
2897
  // package.json
2836
- var version = "4.1.51";
2898
+ var version = "4.1.53";
2837
2899
  var package_default = {
2838
2900
  name: "@lambdatest/smartui-cli",
2839
2901
  version,
@@ -3600,7 +3662,7 @@ var httpClient = class {
3600
3662
  }
3601
3663
  });
3602
3664
  }
3603
- uploadPdf(ctx, form, buildName) {
3665
+ uploadPdf(ctx, form, buildName, pdfNames) {
3604
3666
  return __async(this, null, function* () {
3605
3667
  form.append("projectToken", this.projectToken);
3606
3668
  if (ctx.build.name !== void 0 && ctx.build.name !== "") {
@@ -3609,6 +3671,9 @@ var httpClient = class {
3609
3671
  if (ctx.options.markBaseline) {
3610
3672
  form.append("markBaseline", ctx.options.markBaseline.toString());
3611
3673
  }
3674
+ if (pdfNames && pdfNames !== "") {
3675
+ form.append("pdfNames", pdfNames);
3676
+ }
3612
3677
  try {
3613
3678
  const response = yield this.axiosInstance.request({
3614
3679
  url: ctx.env.SMARTUI_UPLOAD_URL + "/pdf/upload",
@@ -3665,6 +3730,7 @@ var ctx_default = (options) => {
3665
3730
  let webConfig;
3666
3731
  let mobileConfig;
3667
3732
  let basicAuthObj;
3733
+ let lazyLoadConfigObj;
3668
3734
  let tunnelObj;
3669
3735
  let config = constants_default.DEFAULT_CONFIG;
3670
3736
  let port;
@@ -3761,6 +3827,9 @@ var ctx_default = (options) => {
3761
3827
  if (config.basicAuthorization) {
3762
3828
  basicAuthObj = config.basicAuthorization;
3763
3829
  }
3830
+ if (config.lazyLoadConfiguration) {
3831
+ lazyLoadConfigObj = config.lazyLoadConfiguration;
3832
+ }
3764
3833
  if (config.tunnel) {
3765
3834
  tunnelObj = config.tunnel;
3766
3835
  }
@@ -3798,6 +3867,7 @@ var ctx_default = (options) => {
3798
3867
  allowedHostnames: config.allowedHostnames || [],
3799
3868
  allowedAssets: config.allowedAssets || [],
3800
3869
  basicAuthorization: basicAuthObj,
3870
+ lazyLoadConfiguration: lazyLoadConfigObj,
3801
3871
  smartIgnore: (_f = config.smartIgnore) != null ? _f : false,
3802
3872
  delayedUpload: (_g = config.delayedUpload) != null ? _g : false,
3803
3873
  useGlobalCache: (_h = config.useGlobalCache) != null ? _h : false,
@@ -3857,7 +3927,8 @@ var ctx_default = (options) => {
3857
3927
  githubURL: options.gitURL || options.githubURL || "",
3858
3928
  showRenderErrors: options.showRenderErrors ? true : false,
3859
3929
  userName: options.userName || "",
3860
- accessKey: options.accessKey || ""
3930
+ accessKey: options.accessKey || "",
3931
+ pdfNames: options.pdfNames || ""
3861
3932
  },
3862
3933
  cliVersion: version,
3863
3934
  totalSnapshots: -1,
@@ -4459,6 +4530,19 @@ function prepareSnapshot(snapshot, ctx) {
4459
4530
  if (ctx.config.useExtendedViewport) {
4460
4531
  processedOptions.useExtendedViewport = true;
4461
4532
  }
4533
+ if (ctx.config.lazyLoadConfiguration && ctx.config.lazyLoadConfiguration.enabled) {
4534
+ let stepValue = ctx.config.lazyLoadConfiguration.scrollStep || 250;
4535
+ let delayValue = ctx.config.lazyLoadConfiguration.scrollDelay || 100;
4536
+ let maxScrollsValue = ctx.config.lazyLoadConfiguration.maxScrolls || 50;
4537
+ let jumpBackToTopValue = ctx.config.lazyLoadConfiguration.jumpBackToTop !== false;
4538
+ processedOptions.lazyLoadConfiguration = {
4539
+ enabled: true,
4540
+ scrollStep: stepValue,
4541
+ scrollDelay: delayValue,
4542
+ maxScrolls: maxScrollsValue,
4543
+ jumpBackToTop: jumpBackToTopValue
4544
+ };
4545
+ }
4462
4546
  try {
4463
4547
  if (options == null ? void 0 : options.customCSS) {
4464
4548
  const resolvedCSS = resolveCustomCSS(options.customCSS, "", ctx.log);
@@ -4885,6 +4969,19 @@ function processSnapshot(snapshot, ctx) {
4885
4969
  } else {
4886
4970
  renderViewports = getRenderViewports(ctx);
4887
4971
  }
4972
+ if (ctx.config.lazyLoadConfiguration && ctx.config.lazyLoadConfiguration.enabled) {
4973
+ let stepValue = ctx.config.lazyLoadConfiguration.scrollStep || 250;
4974
+ let delayValue = ctx.config.lazyLoadConfiguration.scrollDelay || 100;
4975
+ let maxScrollsValue = ctx.config.lazyLoadConfiguration.maxScrolls || 50;
4976
+ let jumpBackToTopValue = ctx.config.lazyLoadConfiguration.jumpBackToTop || false;
4977
+ processedOptions.lazyLoadConfiguration = {
4978
+ enabled: true,
4979
+ scrollStep: stepValue,
4980
+ scrollDelay: delayValue,
4981
+ maxScrolls: maxScrollsValue,
4982
+ jumpBackToTop: jumpBackToTopValue
4983
+ };
4984
+ }
4888
4985
  for (const { viewport, viewportString, fullPage, device } of renderViewports) {
4889
4986
  if (previousDeviceType !== null && previousDeviceType !== device) {
4890
4987
  navigated = false;
@@ -4928,7 +5025,19 @@ function processSnapshot(snapshot, ctx) {
4928
5025
  }
4929
5026
  }
4930
5027
  }
4931
- if (ctx.config.cliEnableJavaScript && fullPage) yield page.evaluate(scrollToBottomAndBackToTop, { frequency: 100, timing: ctx.config.scrollTime });
5028
+ if (ctx.config.cliEnableJavaScript && fullPage) {
5029
+ if (ctx.config.lazyLoadConfiguration && ctx.config.lazyLoadConfiguration.enabled) {
5030
+ let stepValue = ctx.config.lazyLoadConfiguration.scrollStep || 250;
5031
+ let delayValue = ctx.config.lazyLoadConfiguration.scrollDelay || 300;
5032
+ let maxScrollsValue = ctx.config.lazyLoadConfiguration.maxScrolls || 50;
5033
+ let jumpBackToTopValue = ctx.config.lazyLoadConfiguration.jumpBackToTop !== false;
5034
+ ctx.log.debug("Starting lazy load scrolling with configuration: " + JSON.stringify({ step: stepValue, delay: delayValue, maxScrolls: maxScrollsValue, jumpBackToTop: jumpBackToTopValue }));
5035
+ yield page.evaluate(smoothScrollToBottom, { step: stepValue, delay: delayValue, maxScrolls: maxScrollsValue, jumpBackToTop: jumpBackToTopValue });
5036
+ ctx.log.debug("Completed lazy load scrolling");
5037
+ } else {
5038
+ yield page.evaluate(scrollToBottomAndBackToTop, { frequency: 100, timing: ctx.config.scrollTime });
5039
+ }
5040
+ }
4932
5041
  try {
4933
5042
  yield page.waitForLoadState("networkidle", { timeout: 15e3 });
4934
5043
  ctx.log.debug("Network idle 500ms");
@@ -7424,18 +7533,19 @@ function uploadPdfs(ctx, pdfPath) {
7424
7533
  formData.append("pathToFiles", fs6__default.default.createReadStream(pdfPath));
7425
7534
  } else {
7426
7535
  const files = fs6__default.default.readdirSync(pdfPath);
7427
- const pdfFiles = files.filter((file) => file.endsWith(".pdf"));
7536
+ const pdfFiles = files.filter((file) => file.endsWith(".pdf")).sort();
7428
7537
  pdfFiles.forEach((pdf) => {
7429
7538
  const filePath = path3__default.default.join(pdfPath, pdf);
7430
7539
  formData.append("pathToFiles", fs6__default.default.createReadStream(filePath));
7431
7540
  });
7432
7541
  }
7433
7542
  const buildName = ctx.options.buildName;
7543
+ const pdfNames = ctx.options.pdfNames;
7434
7544
  if (buildName) {
7435
7545
  ctx.build.name = buildName;
7436
7546
  }
7437
7547
  try {
7438
- const response = yield ctx.client.uploadPdf(ctx, formData, buildName);
7548
+ const response = yield ctx.client.uploadPdf(ctx, formData, buildName, pdfNames);
7439
7549
  if (response && response.buildId) {
7440
7550
  ctx.build.id = response.buildId;
7441
7551
  ctx.log.debug(`PDF upload successful. Build ID: ${ctx.build.id}`);
@@ -7451,7 +7561,7 @@ function uploadPdfs(ctx, pdfPath) {
7451
7561
 
7452
7562
  // src/commander/uploadPdf.ts
7453
7563
  var command10 = new commander.Command();
7454
- command10.name("upload-pdf").description("Upload PDFs for visual comparison").argument("<directory>", "Path of the directory containing PDFs").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--markBaseline", "Mark this build baseline").action(function(directory, _, command11) {
7564
+ command10.name("upload-pdf").description("Upload PDFs for visual comparison").argument("<directory>", "Path of the directory containing PDFs").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--markBaseline", "Mark this build baseline").option("--pdfNames <string>", "Specify PDF names for the upload").action(function(directory, _, command11) {
7455
7565
  return __async(this, null, function* () {
7456
7566
  const options = command11.optsWithGlobals();
7457
7567
  if (options.buildName === "") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.1.51",
3
+ "version": "4.1.53",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"