Skip to content

Commit daccd2a

Browse files
committed
fix(V2): scope live-api empty-db check to home org
Enabling GOVERNANCE_BODY_ID in the v2 live-api job makes the node sync in data owned by other organizations. checkDatabaseEmpty counted every record across all tables, so the synced non-home data tripped the POST phase's empty-database precondition and aborted the whole run before any data tests executed. Query each table with orgUid=me so the precondition only considers home-org-owned records (leftover test state), ignoring legitimately synced foreign data.
1 parent 29c6003 commit daccd2a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,10 @@ export const checkDatabaseEmpty = async (request) => {
501501

502502
for (const table of dataTables) {
503503
try {
504-
const response = await request.get(`/v2/${table}`).query({ page: 1, limit: 1000 });
504+
// Scope to home-org-owned records only. When governance sync is enabled,
505+
// the node legitimately syncs in data owned by other organizations; that
506+
// data is not leftover test state and must not fail the empty check.
507+
const response = await request.get(`/v2/${table}`).query({ page: 1, limit: 1000, orgUid: 'me' });
505508
const data = response.body?.data || [];
506509

507510
if (response.status === 200 && Array.isArray(data) && data.length > 0) {
@@ -513,11 +516,11 @@ export const checkDatabaseEmpty = async (request) => {
513516
}
514517

515518
if (nonEmptyTables.length > 0) {
516-
const errorMsg = `Database is not empty. Found data in:\n${nonEmptyTables.map(({ table, count }) => ` - ${table}: ${count} record(s)`).join('\n')}\nPlease clear the database before running tests.`;
519+
const errorMsg = `Database is not empty. Found home-org data in:\n${nonEmptyTables.map(({ table, count }) => ` - ${table}: ${count} record(s)`).join('\n')}\nPlease clear the database before running tests.`;
517520
throw new Error(errorMsg);
518521
}
519522

520-
console.log('✓ Database is empty (except home org)');
523+
console.log('✓ Database is empty of home-org data (synced non-home data ignored)');
521524
};
522525

523526
/**

0 commit comments

Comments
 (0)