|
1 | 1 | import { describe, expect, it } from 'vitest'; |
2 | 2 |
|
3 | | -import { EXPLORER_API_BASE, EXPLORER_BASE_PATH, explorerHref, explorerRelativePath } from './paths'; |
| 3 | +import { |
| 4 | + EXPLORER_API_BASE, |
| 5 | + EXPLORER_BASE_PATH, |
| 6 | + explorerHref, |
| 7 | + explorerRelativePath, |
| 8 | + versionQuery, |
| 9 | + withVersion, |
| 10 | +} from './paths'; |
4 | 11 |
|
5 | 12 | describe('explorerHref', () => { |
6 | 13 | it('maps the explorer root to the base path in each locale', () => { |
@@ -37,3 +44,32 @@ it('keeps the page and API prefixes aligned with the route directories', () => { |
37 | 44 | expect(EXPLORER_BASE_PATH).toBe('/agentic-workload-explorer'); |
38 | 45 | expect(EXPLORER_API_BASE).toBe('/api/v1/agentic-workload-explorer'); |
39 | 46 | }); |
| 47 | + |
| 48 | +describe('versionQuery', () => { |
| 49 | + it('carries the trace-version selection across explorer links', () => { |
| 50 | + expect(versionQuery(null)).toBe(''); |
| 51 | + expect(versionQuery(undefined)).toBe(''); |
| 52 | + expect(versionQuery('all')).toBe('?version=all'); |
| 53 | + expect(versionQuery(['all', '2'])).toBe('?version=all'); |
| 54 | + }); |
| 55 | +}); |
| 56 | + |
| 57 | +describe('withVersion', () => { |
| 58 | + it('leaves the href alone without a selection', () => { |
| 59 | + expect(withVersion('/agentic-workload-explorer/sessions', null)).toBe( |
| 60 | + '/agentic-workload-explorer/sessions', |
| 61 | + ); |
| 62 | + }); |
| 63 | + |
| 64 | + it('merges into an existing query and keeps the fragment', () => { |
| 65 | + expect(withVersion('/agentic-workload-explorer/sessions/a/conversation#req-1', 'all')).toBe( |
| 66 | + '/agentic-workload-explorer/sessions/a/conversation?version=all#req-1', |
| 67 | + ); |
| 68 | + expect(withVersion('/agentic-workload-explorer/sessions?sort=cost', 'all')).toBe( |
| 69 | + '/agentic-workload-explorer/sessions?sort=cost&version=all', |
| 70 | + ); |
| 71 | + expect(withVersion('/agentic-workload-explorer/sessions?version=2', 'all')).toBe( |
| 72 | + '/agentic-workload-explorer/sessions?version=2', |
| 73 | + ); |
| 74 | + }); |
| 75 | +}); |
0 commit comments