fix(ssr): apply theme CSS vars during SSR and enable client hydration
CI Pipeline / backend-test (push) Successful in 9m4s
CI Pipeline / frontend-test (push) Successful in 24s
CI Pipeline / frontend-build (push) Successful in 32s
CI Pipeline / backend-lint (push) Successful in 14s
CI Pipeline / backend-test (pull_request) Successful in 9m17s
CI Pipeline / frontend-test (pull_request) Successful in 24s
CI Pipeline / frontend-build (pull_request) Successful in 30s
CI Pipeline / backend-lint (pull_request) Successful in 10s
CI Pipeline / quality-gate (push) Successful in 2s
CI Pipeline / quality-gate (pull_request) Successful in 2s
CI Pipeline / backend-test (push) Successful in 9m4s
CI Pipeline / frontend-test (push) Successful in 24s
CI Pipeline / frontend-build (push) Successful in 32s
CI Pipeline / backend-lint (push) Successful in 14s
CI Pipeline / backend-test (pull_request) Successful in 9m17s
CI Pipeline / frontend-test (pull_request) Successful in 24s
CI Pipeline / frontend-build (pull_request) Successful in 30s
CI Pipeline / backend-lint (pull_request) Successful in 10s
CI Pipeline / quality-gate (push) Successful in 2s
CI Pipeline / quality-gate (pull_request) Successful in 2s
- ThemeService: remove isPlatformBrowser guard so CSS custom properties are applied during SSR/prerender — server-rendered HTML now carries the correct color scheme and gradients (fixes missing colors on test site). - main.ts: add provideClientHydration() so Angular preserves the server- rendered DOM on the client instead of destroying and rebuilding it (fixes jarring full-page reload between static and dynamic versions). - Tests: update theme.service.spec.ts to match new behaviour, expand coverage with gradient tests and empty-value handling (9 tests). Fix structured-data.component.spec.ts import paths. All 54 tests pass.
This commit is contained in:
1 parent
2d26269c1a
commit
e95a158d57
10 files changed
+551
-16
No files matched your search
@@ -0,0 +1,59 @@
|
||||
// Load the JIT compiler BEFORE any Angular router/common imports
|
||||
import '@angular/compiler';
|
||||
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { Injector } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { EventService } from './event.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
// Mock the app-config service
|
||||
vi.mock('./app-config.service', () => ({
|
||||
getAppConfig: () => ({ apiBaseUrl: 'http://localhost:8000' }),
|
||||
}));
|
||||
|
||||
describe('EventService — SSR error handling', () => {
|
||||
let httpMock: any;
|
||||
let service: EventService;
|
||||
|
||||
beforeEach(() => {
|
||||
httpMock = {
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
put: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
};
|
||||
|
||||
const injector = Injector.create({
|
||||
providers: [
|
||||
{ provide: HttpClient, useValue: httpMock },
|
||||
EventService,
|
||||
],
|
||||
});
|
||||
service = injector.get(EventService);
|
||||
});
|
||||
|
||||
it('should return empty array when API fails (SSR fallback)', async () => {
|
||||
const { throwError } = await import('rxjs');
|
||||
httpMock.get.mockReturnValue(throwError(() => new Error('Network error')));
|
||||
|
||||
const result = await firstValueFrom(service.getEvents());
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
it('should return empty array when API fails with active filter', async () => {
|
||||
const { throwError } = await import('rxjs');
|
||||
httpMock.get.mockReturnValue(throwError(() => new Error('Network error')));
|
||||
|
||||
const result = await firstValueFrom(service.getEvents(true));
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
it('should call the API endpoint', async () => {
|
||||
const { of } = await import('rxjs');
|
||||
httpMock.get.mockReturnValue(of([{ id: 1, name: 'Test Event' }]));
|
||||
|
||||
await firstValueFrom(service.getEvents());
|
||||
expect(httpMock.get).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user