@vizzly-testing/cli 0.21.1 → 0.21.2

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.
@@ -20,7 +20,8 @@ import * as output from '../utils/output.js';
20
20
  */
21
21
  let DEFAULT_CONFIG = {
22
22
  comparison: {
23
- threshold: 2.0
23
+ threshold: 2.0,
24
+ minClusterSize: 2
24
25
  },
25
26
  server: {
26
27
  port: 47392,
@@ -102,6 +103,10 @@ export function createConfigService({
102
103
  config.comparison.threshold = parseFloat(process.env.VIZZLY_THRESHOLD);
103
104
  sources.comparison = 'env';
104
105
  }
106
+ if (process.env.VIZZLY_MIN_CLUSTER_SIZE) {
107
+ config.comparison.minClusterSize = parseInt(process.env.VIZZLY_MIN_CLUSTER_SIZE, 10);
108
+ sources.comparison = 'env';
109
+ }
105
110
  if (process.env.VIZZLY_PORT) {
106
111
  config.server.port = parseInt(process.env.VIZZLY_PORT, 10);
107
112
  sources.server = 'env';
@@ -243,6 +248,16 @@ export default defineConfig(${JSON.stringify(newConfig, null, 2)});
243
248
  }
244
249
  }
245
250
 
251
+ // Validate minClusterSize
252
+ if (config.comparison?.minClusterSize !== undefined) {
253
+ let minClusterSize = config.comparison.minClusterSize;
254
+ if (!Number.isInteger(minClusterSize) || minClusterSize < 1) {
255
+ errors.push('comparison.minClusterSize must be a positive integer (1 or greater)');
256
+ } else if (minClusterSize > 100) {
257
+ warnings.push('comparison.minClusterSize above 100 may filter out most differences');
258
+ }
259
+ }
260
+
246
261
  // Validate port
247
262
  if (config.server?.port !== undefined) {
248
263
  let port = config.server.port;
@@ -863,6 +863,20 @@ export class TddService {
863
863
  return metadata;
864
864
  }
865
865
 
866
+ /**
867
+ * Upsert a comparison result - replaces existing if same ID, otherwise appends.
868
+ * This prevents stale results from accumulating in daemon mode.
869
+ * @private
870
+ */
871
+ _upsertComparison(result) {
872
+ let existingIndex = this.comparisons.findIndex(c => c.id === result.id);
873
+ if (existingIndex >= 0) {
874
+ this.comparisons[existingIndex] = result;
875
+ } else {
876
+ this.comparisons.push(result);
877
+ }
878
+ }
879
+
866
880
  /**
867
881
  * Compare a screenshot against baseline
868
882
  */
@@ -959,7 +973,7 @@ export class TddService {
959
973
  currentPath: currentImagePath,
960
974
  properties: validatedProperties
961
975
  });
962
- this.comparisons.push(result);
976
+ this._upsertComparison(result);
963
977
  return result;
964
978
  }
965
979
 
@@ -982,7 +996,7 @@ export class TddService {
982
996
  minClusterSize: effectiveMinClusterSize,
983
997
  honeydiffResult
984
998
  });
985
- this.comparisons.push(result);
999
+ this._upsertComparison(result);
986
1000
  return result;
987
1001
  } else {
988
1002
  let hotspotAnalysis = this.getHotspotForScreenshot(name);
@@ -1007,7 +1021,7 @@ export class TddService {
1007
1021
  output.debug('comparison', `${sanitizedName}: ${result.status}`, {
1008
1022
  diff: diffInfo
1009
1023
  });
1010
- this.comparisons.push(result);
1024
+ this._upsertComparison(result);
1011
1025
  return result;
1012
1026
  }
1013
1027
  } catch (error) {
@@ -1035,7 +1049,7 @@ export class TddService {
1035
1049
  currentPath: currentImagePath,
1036
1050
  properties: validatedProperties
1037
1051
  });
1038
- this.comparisons.push(result);
1052
+ this._upsertComparison(result);
1039
1053
  return result;
1040
1054
  }
1041
1055
  output.debug('comparison', `${sanitizedName}: error - ${error.message}`);
@@ -1047,7 +1061,7 @@ export class TddService {
1047
1061
  properties: validatedProperties,
1048
1062
  errorMessage: error.message
1049
1063
  });
1050
- this.comparisons.push(result);
1064
+ this._upsertComparison(result);
1051
1065
  return result;
1052
1066
  }
1053
1067
  }
@@ -1389,7 +1403,7 @@ export class TddService {
1389
1403
  properties,
1390
1404
  signature
1391
1405
  };
1392
- this.comparisons.push(result);
1406
+ this._upsertComparison(result);
1393
1407
  output.info(`Baseline created for ${name}`);
1394
1408
  return result;
1395
1409
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly-testing/cli",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "description": "Visual review platform for UI developers and designers",
5
5
  "keywords": [
6
6
  "visual-testing",