Skip to content

Commit 606a720

Browse files
committed
test: added integration test for tracePage uppercase to lowercase trace ID normalization
Signed-off-by: Samar <hello.samar7@gmail.com>
1 parent 2e89daf commit 606a720

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (c) 2017 Uber Technologies, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
const mockNavigate = jest.fn();
5+
6+
jest.mock('react-router-dom-v5-compat', () => ({
7+
...jest.requireActual('react-router-dom-v5-compat'),
8+
useNavigate: () => mockNavigate,
9+
useLocation: () => ({ search: '', state: null }),
10+
}));
11+
12+
jest.mock('../../hooks/useConfig', () => ({
13+
useConfig: () => ({
14+
archiveEnabled: false,
15+
storageCapabilities: null,
16+
criticalPathEnabled: false,
17+
disableJsonView: false,
18+
traceGraph: null,
19+
useOpenTelemetryTerms: false,
20+
}),
21+
}));
22+
23+
jest.mock('../../utils/withRouteProps', () => ({
24+
__esModule: true,
25+
default: Component => Component,
26+
}));
27+
28+
jest.mock('react-redux', () => ({
29+
...jest.requireActual('react-redux'),
30+
connect: () => () => () => null,
31+
}));
32+
33+
import React from 'react';
34+
import { render, waitFor } from '@testing-library/react';
35+
import { MemoryRouter } from 'react-router-dom';
36+
37+
import TracePage from './index';
38+
39+
describe('TracePage URL normalization', () => {
40+
beforeEach(() => {
41+
mockNavigate.mockClear();
42+
});
43+
44+
it('normalizes uppercase trace IDs to lowercase in the URL', async () => {
45+
const uppercaseTraceId = 'ABC123DEF456';
46+
const lowercaseTraceId = uppercaseTraceId.toLowerCase();
47+
48+
render(
49+
<MemoryRouter>
50+
<TracePage params={{ id: uppercaseTraceId }} />
51+
</MemoryRouter>
52+
);
53+
54+
await waitFor(() => {
55+
expect(mockNavigate).toHaveBeenCalledWith(
56+
expect.stringContaining(lowercaseTraceId),
57+
expect.objectContaining({ replace: true })
58+
);
59+
});
60+
});
61+
});

0 commit comments

Comments
 (0)