@lambdatest/smartui-cli 4.1.50 → 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 +122 -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"
@@ -1337,6 +1370,18 @@ var FigmaWebConfigSchema = {
1337
1370
  "type": "string"
1338
1371
  },
1339
1372
  uniqueItems: false
1373
+ },
1374
+ "screenshot_viewports": {
1375
+ "type": "array",
1376
+ "items": {
1377
+ "type": "array",
1378
+ "items": {
1379
+ "type": "integer",
1380
+ "minimum": 1
1381
+ },
1382
+ "minItems": 1,
1383
+ "maxItems": 2
1384
+ }
1340
1385
  }
1341
1386
  },
1342
1387
  "required": ["figma_file_token", "figma_ids"]
@@ -1538,6 +1583,35 @@ function scrollToBottomAndBackToTop({
1538
1583
  })();
1539
1584
  });
1540
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
+ }
1541
1615
  function launchBrowsers(ctx) {
1542
1616
  return __async(this, null, function* () {
1543
1617
  var _a;
@@ -2821,7 +2895,7 @@ var authExec_default = (ctx) => {
2821
2895
  };
2822
2896
 
2823
2897
  // package.json
2824
- var version = "4.1.50";
2898
+ var version = "4.1.52";
2825
2899
  var package_default = {
2826
2900
  name: "@lambdatest/smartui-cli",
2827
2901
  version,
@@ -3653,6 +3727,7 @@ var ctx_default = (options) => {
3653
3727
  let webConfig;
3654
3728
  let mobileConfig;
3655
3729
  let basicAuthObj;
3730
+ let lazyLoadConfigObj;
3656
3731
  let tunnelObj;
3657
3732
  let config = constants_default.DEFAULT_CONFIG;
3658
3733
  let port;
@@ -3749,6 +3824,9 @@ var ctx_default = (options) => {
3749
3824
  if (config.basicAuthorization) {
3750
3825
  basicAuthObj = config.basicAuthorization;
3751
3826
  }
3827
+ if (config.lazyLoadConfiguration) {
3828
+ lazyLoadConfigObj = config.lazyLoadConfiguration;
3829
+ }
3752
3830
  if (config.tunnel) {
3753
3831
  tunnelObj = config.tunnel;
3754
3832
  }
@@ -3786,6 +3864,7 @@ var ctx_default = (options) => {
3786
3864
  allowedHostnames: config.allowedHostnames || [],
3787
3865
  allowedAssets: config.allowedAssets || [],
3788
3866
  basicAuthorization: basicAuthObj,
3867
+ lazyLoadConfiguration: lazyLoadConfigObj,
3789
3868
  smartIgnore: (_f = config.smartIgnore) != null ? _f : false,
3790
3869
  delayedUpload: (_g = config.delayedUpload) != null ? _g : false,
3791
3870
  useGlobalCache: (_h = config.useGlobalCache) != null ? _h : false,
@@ -4447,6 +4526,19 @@ function prepareSnapshot(snapshot, ctx) {
4447
4526
  if (ctx.config.useExtendedViewport) {
4448
4527
  processedOptions.useExtendedViewport = true;
4449
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
+ }
4450
4542
  try {
4451
4543
  if (options == null ? void 0 : options.customCSS) {
4452
4544
  const resolvedCSS = resolveCustomCSS(options.customCSS, "", ctx.log);
@@ -4873,6 +4965,19 @@ function processSnapshot(snapshot, ctx) {
4873
4965
  } else {
4874
4966
  renderViewports = getRenderViewports(ctx);
4875
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
+ }
4876
4981
  for (const { viewport, viewportString, fullPage, device } of renderViewports) {
4877
4982
  if (previousDeviceType !== null && previousDeviceType !== device) {
4878
4983
  navigated = false;
@@ -4916,7 +5021,19 @@ function processSnapshot(snapshot, ctx) {
4916
5021
  }
4917
5022
  }
4918
5023
  }
4919
- 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
+ }
4920
5037
  try {
4921
5038
  yield page.waitForLoadState("networkidle", { timeout: 15e3 });
4922
5039
  ctx.log.debug("Network idle 500ms");
@@ -5770,6 +5887,9 @@ function verifyFigmaWebConfig(ctx) {
5770
5887
  if (c.screenshot_names && c.screenshot_names.length > 0 && c.figma_ids && c.figma_ids.length != c.screenshot_names.length) {
5771
5888
  throw new Error("Mismatch in Figma Ids and Screenshot Names in figma config");
5772
5889
  }
5890
+ if (c.screenshot_viewports && c.screenshot_viewports.length > 0 && c.figma_ids && c.figma_ids.length != c.screenshot_viewports.length) {
5891
+ throw new Error("Mismatch in Figma Ids and Screenshot Viewports in figma config");
5892
+ }
5773
5893
  if (isValidArray(c.screenshot_names)) {
5774
5894
  for (const name of c.screenshot_names) {
5775
5895
  screenshots.push(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.1.50",
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/**/*"