fix(catalog-backend): make facets predicate tests order-independent

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) <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2026-05-11 22:33:05 +02:00
parent 387ea7dd75
commit af1c16db10
@@ -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);
},
);