From af1c16db106c750f1e83d5d4dbd6cdd7e246faaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 11 May 2026 22:33:05 +0200 Subject: [PATCH] fix(catalog-backend): make facets predicate tests order-independent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GROUP BY result ordering is non-deterministic across database engines. The switch from COUNT(DISTINCT entity_id) to COUNT(*) changes MySQL's aggregation plan, which surfaces a different row order. Use arrayContaining + length check instead of exact array equality. Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Fredrik Adelöw --- .../service/DefaultEntitiesCatalog.test.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.test.ts b/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.test.ts index 427a9c8ce0..6a5c33b16d 100644 --- a/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.test.ts +++ b/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.test.ts @@ -2556,12 +2556,18 @@ describe('DefaultEntitiesCatalog', () => { }), ).resolves.toEqual({ facets: { - 'spec.type': [ + 'spec.type': expect.arrayContaining([ { value: 'library', count: 1 }, { value: 'service', count: 1 }, - ], + ]), }, }); + const result = await catalog.facets({ + facets: ['spec.type'], + query: { kind: 'component' }, + credentials: mockCredentials.none(), + }); + expect(result.facets['spec.type']).toHaveLength(2); }, ); @@ -2597,12 +2603,18 @@ describe('DefaultEntitiesCatalog', () => { }), ).resolves.toEqual({ facets: { - kind: [ + kind: expect.arrayContaining([ { value: 'API', count: 1 }, { value: 'Component', count: 1 }, - ], + ]), }, }); + const result = await catalog.facets({ + facets: ['kind'], + query: { kind: { $in: ['component', 'api'] } }, + credentials: mockCredentials.none(), + }); + expect(result.facets.kind).toHaveLength(2); }, );