Skip to content

Commit f5df7c7

Browse files
authored
fix(e2e): treat falsy values as equivalent in staging validator (#8110)
1 parent ce67184 commit f5df7c7

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

.changeset/warm-foxes-glow.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

scripts/validate-staging-instances.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ function diffObjects(a, b, path = '') {
103103
const mismatches = [];
104104

105105
if (a === b) return mismatches;
106+
// Treat falsy values as equivalent (e.g. undefined vs false)
107+
if (!a && !b) return mismatches;
106108
if (a == null || b == null || typeof a !== typeof b) {
107109
mismatches.push({ path, prod: a, staging: b });
108110
return mismatches;

scripts/validate-staging-instances.test.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ describe('diffObjects', () => {
158158
expect(result).toEqual([{ path: 'a', prod: 1, staging: undefined }]);
159159
});
160160

161+
it('treats undefined and false as equivalent', () => {
162+
expect(diffObjects({ a: undefined }, { a: false })).toEqual([]);
163+
expect(diffObjects({ a: false }, { a: undefined })).toEqual([]);
164+
expect(diffObjects({ a: null }, { a: false })).toEqual([]);
165+
expect(diffObjects({ a: 0 }, { a: false })).toEqual([]);
166+
});
167+
161168
it('detects nested mismatches with correct paths', () => {
162169
const result = diffObjects({ a: { b: { c: 1 } } }, { a: { b: { c: 2 } } });
163170
expect(result).toEqual([{ path: 'a.b.c', prod: 1, staging: 2 }]);

0 commit comments

Comments
 (0)