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:
@@ -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);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user