mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 19:46:16 -08:00
* feat(web-backend): add self-hosted proxy app * feat(web): enable runtime PWA configuration * test(web-e2e): cover self-hosted backend proxy * test(web-e2e): clean self-hosted lint warnings * fix(web-backend): validate proxied provider URLs * fix(web-backend): proxy through registered provider targets * fix(web-backend): document CodeQL SSRF validation boundary * test(web-e2e): mock provider target registration * fix(web): address self-hosted review feedback
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { resolveBackendUrl, shouldEnableServiceWorker } from './runtime-config';
|
|
|
|
describe('runtime config helpers', () => {
|
|
it('uses runtime BACKEND_URL when provided', () => {
|
|
expect(
|
|
resolveBackendUrl(
|
|
{ BACKEND_URL: ' http://self-hosted.local/api ' },
|
|
'https://fallback.example'
|
|
)
|
|
).toBe('http://self-hosted.local/api');
|
|
});
|
|
|
|
it('falls back to the build-time backend URL when runtime config is missing or blank', () => {
|
|
expect(resolveBackendUrl(undefined, 'https://fallback.example')).toBe(
|
|
'https://fallback.example'
|
|
);
|
|
expect(resolveBackendUrl({}, 'https://fallback.example')).toBe(
|
|
'https://fallback.example'
|
|
);
|
|
expect(
|
|
resolveBackendUrl(
|
|
{ BACKEND_URL: ' ' },
|
|
'https://fallback.example'
|
|
)
|
|
).toBe('https://fallback.example');
|
|
});
|
|
|
|
it('enables service worker only for production builds with browser support', () => {
|
|
expect(
|
|
shouldEnableServiceWorker(true, {
|
|
serviceWorker: {},
|
|
} as Navigator)
|
|
).toBe(true);
|
|
expect(
|
|
shouldEnableServiceWorker(false, { serviceWorker: {} } as Navigator)
|
|
).toBe(false);
|
|
expect(shouldEnableServiceWorker(true, {} as Navigator)).toBe(false);
|
|
});
|
|
});
|