|
4 | 4 | cleanClickHouseExpression, |
5 | 5 | getFilterStateEntry, |
6 | 6 | groupFacetsByBaseName, |
| 7 | + sortNestedFacetKeys, |
7 | 8 | toClickHouseKeyExpression, |
8 | 9 | toQuotedClickHouseKeyExpression, |
9 | 10 | } from './utils'; |
@@ -77,6 +78,34 @@ describe('groupFacetsByBaseName — dot/bracket de-duplication', () => { |
77 | 78 | }); |
78 | 79 | }); |
79 | 80 |
|
| 81 | +describe('sortNestedFacetKeys', () => { |
| 82 | + it('sorts keys A–Z within each nested group without reordering groups or other facets', () => { |
| 83 | + const facets = [ |
| 84 | + 'SeverityText', |
| 85 | + "ResourceAttributes['service.name']", |
| 86 | + "LogAttributes['user.id']", |
| 87 | + 'ServiceName', |
| 88 | + "ResourceAttributes['host.name']", |
| 89 | + "LogAttributes['attr10']", |
| 90 | + 'LogAttributes.http.method', |
| 91 | + "LogAttributes['attr9']", |
| 92 | + ].map(key => ({ key })); |
| 93 | + |
| 94 | + sortNestedFacetKeys(facets); |
| 95 | + |
| 96 | + expect(facets.map(f => f.key)).toEqual([ |
| 97 | + 'SeverityText', |
| 98 | + 'ServiceName', |
| 99 | + "ResourceAttributes['host.name']", |
| 100 | + "ResourceAttributes['service.name']", |
| 101 | + "LogAttributes['attr9']", |
| 102 | + "LogAttributes['attr10']", |
| 103 | + 'LogAttributes.http.method', |
| 104 | + "LogAttributes['user.id']", |
| 105 | + ]); |
| 106 | + }); |
| 107 | +}); |
| 108 | + |
80 | 109 | describe('getFilterStateEntry', () => { |
81 | 110 | const makeEntry = (included: string[]): FilterState[string] => ({ |
82 | 111 | included: new Set<string | boolean>(included), |
|
0 commit comments