From 3dadf8354b3a1eaad3694abed8475eec3f063bb8 Mon Sep 17 00:00:00 2001 From: jonathanedey Date: Thu, 23 Jul 2026 17:19:27 -0400 Subject: [PATCH 1/2] chore: fix race condition in auth tenant management tests --- test/integration/auth.spec.ts | 46 ++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/test/integration/auth.spec.ts b/test/integration/auth.spec.ts index 6e81eba5f7..830f964eb3 100644 --- a/test/integration/auth.spec.ts +++ b/test/integration/auth.spec.ts @@ -2398,30 +2398,32 @@ describe('admin.auth', () => { }); }); - it('deleteTenant() should successfully delete the provided tenant', () => { - const allTenantIds: string[] = []; - const listAllTenantIds = (tenantIds: string[], nextPageToken?: string): Promise => { - return getAuth().tenantManager().listTenants(100, nextPageToken) - .then((result) => { - result.tenants.forEach((tenant) => { - tenantIds.push(tenant.tenantId); + describe('tenant deletion operations', () => { + it('deleteTenant() should successfully delete the provided tenant', () => { + const allTenantIds: string[] = []; + const listAllTenantIds = (tenantIds: string[], nextPageToken?: string): Promise => { + return getAuth().tenantManager().listTenants(100, nextPageToken) + .then((result) => { + result.tenants.forEach((tenant) => { + tenantIds.push(tenant.tenantId); + }); + if (result.pageToken) { + return listAllTenantIds(tenantIds, result.pageToken); + } }); - if (result.pageToken) { - return listAllTenantIds(tenantIds, result.pageToken); - } - }); - }; + }; - return getAuth().tenantManager().deleteTenant(createdTenantId) - .then(() => { - // Use listTenants() instead of getTenant() to check that the tenant - // is no longer present, because Auth Emulator implicitly creates the - // tenant in getTenant() when it is not found - return listAllTenantIds(allTenantIds); - }) - .then(() => { - expect(allTenantIds).to.not.contain(createdTenantId); - }); + return getAuth().tenantManager().deleteTenant(createdTenantId) + .then(() => { + // Use listTenants() instead of getTenant() to check that the tenant + // is no longer present, because Auth Emulator implicitly creates the + // tenant in getTenant() when it is not found + return listAllTenantIds(allTenantIds); + }) + .then(() => { + expect(allTenantIds).to.not.contain(createdTenantId); + }); + }); }); }); From a723183f9dcc650703bfe1e43feeef24d178d132 Mon Sep 17 00:00:00 2001 From: jonathanedey Date: Thu, 23 Jul 2026 17:37:02 -0400 Subject: [PATCH 2/2] chore: apply gemini review --- test/integration/auth.spec.ts | 36 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/test/integration/auth.spec.ts b/test/integration/auth.spec.ts index 830f964eb3..66012bc389 100644 --- a/test/integration/auth.spec.ts +++ b/test/integration/auth.spec.ts @@ -2399,30 +2399,24 @@ describe('admin.auth', () => { }); describe('tenant deletion operations', () => { - it('deleteTenant() should successfully delete the provided tenant', () => { + it('deleteTenant() should successfully delete the provided tenant', async () => { const allTenantIds: string[] = []; - const listAllTenantIds = (tenantIds: string[], nextPageToken?: string): Promise => { - return getAuth().tenantManager().listTenants(100, nextPageToken) - .then((result) => { - result.tenants.forEach((tenant) => { - tenantIds.push(tenant.tenantId); - }); - if (result.pageToken) { - return listAllTenantIds(tenantIds, result.pageToken); - } - }); + const listAllTenantIds = async (tenantIds: string[], nextPageToken?: string): Promise => { + const result = await getAuth().tenantManager().listTenants(100, nextPageToken); + result.tenants.forEach((tenant) => { + tenantIds.push(tenant.tenantId); + }); + if (result.pageToken) { + await listAllTenantIds(tenantIds, result.pageToken); + } }; - return getAuth().tenantManager().deleteTenant(createdTenantId) - .then(() => { - // Use listTenants() instead of getTenant() to check that the tenant - // is no longer present, because Auth Emulator implicitly creates the - // tenant in getTenant() when it is not found - return listAllTenantIds(allTenantIds); - }) - .then(() => { - expect(allTenantIds).to.not.contain(createdTenantId); - }); + await getAuth().tenantManager().deleteTenant(createdTenantId); + // Use listTenants() instead of getTenant() to check that the tenant + // is no longer present, because Auth Emulator implicitly creates the + // tenant in getTenant() when it is not found + await listAllTenantIds(allTenantIds); + expect(allTenantIds).to.not.contain(createdTenantId); }); }); });