Skip to content

Commit c1073d1

Browse files
committed
fix(V2): address pre-push review findings
- Harden hasStagedDelete to check all diff.change elements, not just parsed[0], guarding against before/after array payloads - Assert non-deleted Graph B siblings survive after cascade commit to detect overly-aggressive cascades - Correct COMMIT_POLL_INTERVAL_MS comment: interval affects both live jobs and the per-iteration load is ~6.7x (two HTTP calls per loop), not ~3x - Annotate org-creation polling loops to explain why they intentionally do not use COMMIT_POLL_INTERVAL_MS
1 parent 34f4578 commit c1073d1

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

tests/v2/live-api/cascade-delete.live.spec.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('Cascade Delete Live API Tests', function () {
4848
}
4949
const data = row.diff?.change;
5050
const parsed = Array.isArray(data) ? data : [data];
51-
return parsed[0]?.[key] === value;
51+
return parsed.some((p) => p?.[key] === value);
5252
});
5353

5454
it('should cascade delete project and sub-entity children through commit', async function () {
@@ -214,5 +214,20 @@ describe('Cascade Delete Live API Tests', function () {
214214
const resp = await request.get(`${endpoint}/${id}`);
215215
expect([400, 404]).to.include(resp.status);
216216
}
217+
218+
// Verify non-deleted Graph B siblings are still present (guards against
219+
// overly-aggressive cascades that silently delete sibling entities)
220+
const survivingGraphB = [
221+
['/v2/project', projectBId],
222+
['/v2/project-methodology', pm1Id],
223+
['/v2/verification', ver2Id],
224+
['/v2/verification', ver3Id],
225+
['/v2/issuance', iss3Id],
226+
];
227+
228+
for (const [endpoint, id] of survivingGraphB) {
229+
const resp = await request.get(`${endpoint}/${id}`);
230+
expect(resp.status, `expected ${endpoint}/${id} to still exist after cascade`).to.equal(200);
231+
}
217232
});
218233
});

tests/v2/live-api/helpers/live-api-helpers.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import {
1111
} from './wallet-diagnostics.js';
1212

1313
// Reduced from 10 000 ms to cut idle wait time between blockchain commits.
14-
// Increases API call volume ~3x but stays well within the 30-minute suite timeout.
14+
// Each iteration calls two HTTP endpoints (org-synced + wallet-diagnostics),
15+
// so the total request rate increase across all live jobs is ~6.7× vs the old
16+
// 10 s interval. Both jobs (test-v2-live-api, test-v2-live-cascade-delete)
17+
// use this helper; the 30-minute suite timeout is not at risk.
1518
const COMMIT_POLL_INTERVAL_MS = 3000;
1619

1720
/**
@@ -1199,7 +1202,7 @@ export const getLiveApiRequest = async (options = {}) => {
11991202
export const waitForV2OrganizationReady = async (request, orgName = null, maxWaitTime = 900000, options = {}) => {
12001203
const { isUpgrade = false } = options;
12011204
const startTime = Date.now();
1202-
const interval = 10000;
1205+
const interval = 10000; // org-creation poller, not a commit poller — intentionally not COMMIT_POLL_INTERVAL_MS
12031206
const timestamp = getTimestamp();
12041207
const recoveryTracker = createRecoveryStuckTracker();
12051208
let lastDiagAt = 0;
@@ -1496,7 +1499,7 @@ export const waitForV2OrganizationReady = async (request, orgName = null, maxWai
14961499
*/
14971500
export const waitForV1OrganizationReady = async (request, orgName = null, maxWaitTime = 900000) => {
14981501
const startTime = Date.now();
1499-
const interval = 10000;
1502+
const interval = 10000; // org-creation poller, not a commit poller — intentionally not COMMIT_POLL_INTERVAL_MS
15001503
const timestamp = getTimestamp();
15011504
const recoveryTracker = createRecoveryStuckTracker();
15021505
let lastDiagAt = 0;

0 commit comments

Comments
 (0)