@lambdatest/smartui-cli 4.1.51 → 4.1.52

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 +107 -2
  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.52";
2837
2899
  var package_default = {
2838
2900
  name: "@lambdatest/smartui-cli",
2839
2901
  version,
@@ -3665,6 +3727,7 @@ var ctx_default = (options) => {
3665
3727
  let webConfig;
3666
3728
  let mobileConfig;
3667
3729
  let basicAuthObj;
3730
+ let lazyLoadConfigObj;
3668
3731
  let tunnelObj;
3669
3732
  let config = constants_default.DEFAULT_CONFIG;
3670
3733
  let port;
@@ -3761,6 +3824,9 @@ var ctx_default = (options) => {
3761
3824
  if (config.basicAuthorization) {
3762
3825
  basicAuthObj = config.basicAuthorization;
3763
3826
  }
3827
+ if (config.lazyLoadConfiguration) {
3828
+ lazyLoadConfigObj = config.lazyLoadConfiguration;
3829
+ }
3764
3830
  if (config.tunnel) {
3765
3831
  tunnelObj = config.tunnel;
3766
3832
  }
@@ -3798,6 +3864,7 @@ var ctx_default = (options) => {
3798
3864
  allowedHostnames: config.allowedHostnames || [],
3799
3865
  allowedAssets: config.allowedAssets || [],
3800
3866
  basicAuthorization: basicAuthObj,
3867
+ lazyLoadConfiguration: lazyLoadConfigObj,
3801
3868
  smartIgnore: (_f = config.smartIgnore) != null ? _f : false,
3802
3869
  delayedUpload: (_g = config.delayedUpload) != null ? _g : false,
3803
3870
  useGlobalCache: (_h = config.useGlobalCache) != null ? _h : false,
@@ -4459,6 +4526,19 @@ function prepareSnapshot(snapshot, ctx) {
4459
4526
  if (ctx.config.useExtendedViewport) {
4460
4527
  processedOptions.useExtendedViewport = true;
4461
4528
  }
4529
+ if (ctx.config.lazyLoadConfiguration && ctx.config.lazyLoadConfiguration.enabled) {
4530
+ let stepValue = ctx.config.lazyLoadConfiguration.scrollStep || 250;
4531
+ let delayValue = ctx.config.lazyLoadConfiguration.scrollDelay || 100;
4532
+ let maxScrollsValue = ctx.config.lazyLoadConfiguration.maxScrolls || 50;
4533
+ let jumpBackToTopValue = ctx.config.lazyLoadConfiguration.jumpBackToTop !== false;
4534
+ processedOptions.lazyLoadConfiguration = {
4535
+ enabled: true,
4536
+ scrollStep: stepValue,
4537
+ scrollDelay: delayValue,
4538
+ maxScrolls: maxScrollsValue,
4539
+ jumpBackToTop: jumpBackToTopValue
4540
+ };
4541
+ }
4462
4542
  try {
4463
4543
  if (options == null ? void 0 : options.customCSS) {
4464
4544
  const resolvedCSS = resolveCustomCSS(options.customCSS, "", ctx.log);
@@ -4885,6 +4965,19 @@ function processSnapshot(snapshot, ctx) {
4885
4965
  } else {
4886
4966
  renderViewports = getRenderViewports(ctx);
4887
4967
  }
4968
+ if (ctx.config.lazyLoadConfiguration && ctx.config.lazyLoadConfiguration.enabled) {
4969
+ let stepValue = ctx.config.lazyLoadConfiguration.scrollStep || 250;
4970
+ let delayValue = ctx.config.lazyLoadConfiguration.scrollDelay || 100;
4971
+ let maxScrollsValue = ctx.config.lazyLoadConfiguration.maxScrolls || 50;
4972
+ let jumpBackToTopValue = ctx.config.lazyLoadConfiguration.jumpBackToTop || false;
4973
+ processedOptions.lazyLoadConfiguration = {
4974
+ enabled: true,
4975
+ scrollStep: stepValue,
4976
+ scrollDelay: delayValue,
4977
+ maxScrolls: maxScrollsValue,
4978
+ jumpBackToTop: jumpBackToTopValue
4979
+ };
4980
+ }
4888
4981
  for (const { viewport, viewportString, fullPage, device } of renderViewports) {
4889
4982
  if (previousDeviceType !== null && previousDeviceType !== device) {
4890
4983
  navigated = false;
@@ -4928,7 +5021,19 @@ function processSnapshot(snapshot, ctx) {
4928
5021
  }
4929
5022
  }
4930
5023
  }
4931
- if (ctx.config.cliEnableJavaScript && fullPage) yield page.evaluate(scrollToBottomAndBackToTop, { frequency: 100, timing: ctx.config.scrollTime });
5024
+ if (ctx.config.cliEnableJavaScript && fullPage) {
5025
+ if (ctx.config.lazyLoadConfiguration && ctx.config.lazyLoadConfiguration.enabled) {
5026
+ let stepValue = ctx.config.lazyLoadConfiguration.scrollStep || 250;
5027
+ let delayValue = ctx.config.lazyLoadConfiguration.scrollDelay || 300;
5028
+ let maxScrollsValue = ctx.config.lazyLoadConfiguration.maxScrolls || 50;
5029
+ let jumpBackToTopValue = ctx.config.lazyLoadConfiguration.jumpBackToTop !== false;
5030
+ ctx.log.debug("Starting lazy load scrolling with configuration: " + JSON.stringify({ step: stepValue, delay: delayValue, maxScrolls: maxScrollsValue, jumpBackToTop: jumpBackToTopValue }));
5031
+ yield page.evaluate(smoothScrollToBottom, { step: stepValue, delay: delayValue, maxScrolls: maxScrollsValue, jumpBackToTop: jumpBackToTopValue });
5032
+ ctx.log.debug("Completed lazy load scrolling");
5033
+ } else {
5034
+ yield page.evaluate(scrollToBottomAndBackToTop, { frequency: 100, timing: ctx.config.scrollTime });
5035
+ }
5036
+ }
4932
5037
  try {
4933
5038
  yield page.waitForLoadState("networkidle", { timeout: 15e3 });
4934
5039
  ctx.log.debug("Network idle 500ms");
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.52",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"