TASKS-1823 WebManager module

This commit is contained in:
Igor Martyniuk
2026-08-28 08:35:58 +00:00
parent fdb2cf3837
commit c93d8c025b
654 changed files with 26232 additions and 6075 deletions
+37
View File
@@ -0,0 +1,37 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
import { siteUrl } from '#web-runtime/lib/site-url';
afterEach(() => {
vi.unstubAllEnvs();
vi.restoreAllMocks();
});
describe('siteUrl', () => {
it('uses SITE_URL, trimming stray whitespace', () => {
vi.stubEnv('SITE_URL', ' https://crux.example.com ');
expect(siteUrl().origin).toBe('https://crux.example.com');
});
it('falls back to localhost for local development', () => {
vi.stubEnv('SITE_URL', '');
vi.stubEnv('NODE_ENV', 'development');
expect(siteUrl().origin).toBe('http://localhost:3000');
});
it('complains loudly when a production build has none, since the symptom is silent', () => {
const error = vi.spyOn(console, 'error').mockImplementation(() => {});
vi.stubEnv('SITE_URL', '');
vi.stubEnv('NODE_ENV', 'production');
expect(siteUrl().origin).toBe('http://localhost:3000');
expect(error).toHaveBeenCalledOnce();
});
it('throws on a malformed SITE_URL rather than building wrong canonicals', () => {
vi.stubEnv('SITE_URL', 'crux.example.com');
expect(() => siteUrl()).toThrow();
});
});