Skip to content

Commit 1d320ab

Browse files
fix(frontend): use grpc base path
1 parent 6ee88a1 commit 1d320ab

2 files changed

Lines changed: 113 additions & 1 deletion

File tree

frontend/src/app.test.tsx

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/**
2+
* Copyright 2026 Redpanda Data, Inc.
3+
*
4+
* Use of this software is governed by the Business Source License
5+
* included in the file https://github.com/redpanda-data/redpanda/blob/dev/licenses/bsl.md
6+
*
7+
* As of the Change Date specified in that file, in accordance with
8+
* the Business Source License, use of this software will be governed
9+
* by the Apache License, Version 2.0
10+
*/
11+
12+
import { createConnectTransport } from '@connectrpc/connect-web';
13+
14+
import { getGrpcBasePath } from './config';
15+
16+
vi.mock('@connectrpc/connect-web', () => ({
17+
createConnectTransport: vi.fn(() => ({ kind: 'transport' })),
18+
}));
19+
20+
vi.mock('./config', () => ({
21+
setup: vi.fn(() => vi.fn()),
22+
getGrpcBasePath: vi.fn(() => '/redpanda-console'),
23+
addBearerTokenInterceptor: vi.fn((next) => async (request: unknown) => await next(request)),
24+
checkExpiredLicenseInterceptor: vi.fn((next) => async (request: unknown) => await next(request)),
25+
}));
26+
27+
vi.mock('@builder.io/sdk-react', () => ({
28+
Content: () => null,
29+
}));
30+
31+
vi.mock('@connectrpc/connect-query', () => ({
32+
TransportProvider: ({ children }: { children: React.ReactNode }) => children,
33+
}));
34+
35+
vi.mock('@redpanda-data/ui', () => ({
36+
ChakraProvider: ({ children }: { children: React.ReactNode }) => children,
37+
redpandaToastOptions: {},
38+
}));
39+
40+
vi.mock('@tanstack/react-query', () => ({
41+
QueryClientProvider: ({ children }: { children: React.ReactNode }) => children,
42+
}));
43+
44+
vi.mock('@tanstack/react-query-devtools', () => ({
45+
ReactQueryDevtools: () => null,
46+
}));
47+
48+
vi.mock('@tanstack/react-router', () => ({
49+
createRouter: vi.fn(() => ({})),
50+
RouterProvider: () => null,
51+
}));
52+
53+
vi.mock('components/builder-io/builder-custom-components', () => ({
54+
builderCustomComponents: [],
55+
}));
56+
57+
vi.mock('components/constants', () => ({
58+
BUILDER_API_KEY: 'test-key',
59+
}));
60+
61+
vi.mock('custom-feature-flag-provider', () => ({
62+
CustomFeatureFlagProvider: ({ children }: { children: React.ReactNode }) => children,
63+
}));
64+
65+
vi.mock('hooks/use-developer-view', () => ({
66+
default: () => false,
67+
}));
68+
69+
vi.mock('protobuf-registry', () => ({
70+
protobufRegistry: {},
71+
}));
72+
73+
vi.mock('query-client', () => ({
74+
default: {},
75+
}));
76+
77+
vi.mock('utils/env', () => ({
78+
getBasePath: () => '/redpanda-console',
79+
}));
80+
81+
vi.mock('utils/redpanda-theme', () => ({
82+
patchedRedpandaTheme: {},
83+
}));
84+
85+
vi.mock('./components/misc/not-found-page', () => ({
86+
NotFoundPage: () => null,
87+
}));
88+
89+
vi.mock('./routeTree.gen', () => ({
90+
routeTree: {},
91+
}));
92+
93+
vi.mock('./state/ui', () => ({
94+
installUISettingsSideEffects: vi.fn(() => vi.fn()),
95+
}));
96+
97+
describe('App dataplane transport', () => {
98+
beforeEach(() => {
99+
vi.clearAllMocks();
100+
});
101+
102+
test('uses the configured gRPC base path for Connect Query requests', async () => {
103+
await import('./app');
104+
105+
expect(getGrpcBasePath).toHaveBeenCalledWith();
106+
expect(createConnectTransport).toHaveBeenCalledWith(
107+
expect.objectContaining({
108+
baseUrl: '/redpanda-console',
109+
})
110+
);
111+
});
112+
});

frontend/src/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import { installUISettingsSideEffects } from './state/ui';
5555

5656
// Create transport before router so loaders can use it
5757
const dataplaneTransport = createConnectTransport({
58-
baseUrl: getGrpcBasePath(''), // Embedded mode handles the path separately.
58+
baseUrl: getGrpcBasePath(),
5959
interceptors: [addBearerTokenInterceptor, checkExpiredLicenseInterceptor],
6060
jsonOptions: {
6161
registry: protobufRegistry,

0 commit comments

Comments
 (0)