Web: seed auth session for e2e via test stub hook
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
|
||||
import { APP_INITIALIZER, ApplicationConfig } from '@angular/core';
|
||||
import { APP_INITIALIZER, ApplicationConfig } from '@angular/core';
|
||||
import { provideRouter } from '@angular/router';
|
||||
|
||||
import { routes } from './app.routes';
|
||||
@@ -25,8 +25,10 @@ import { RISK_API, MockRiskApi } from './core/api/risk.client';
|
||||
import { RISK_API_BASE_URL, RiskHttpClient } from './core/api/risk-http.client';
|
||||
import { AppConfigService } from './core/config/app-config.service';
|
||||
import { AuthHttpInterceptor } from './core/auth/auth-http.interceptor';
|
||||
import { AuthSessionStore } from './core/auth/auth-session.store';
|
||||
import { OperatorMetadataInterceptor } from './core/orchestrator/operator-metadata.interceptor';
|
||||
import { MockNotifyApiService } from './testing/mock-notify-api.service';
|
||||
import { seedAuthSession, type StubAuthSession } from './testing';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
@@ -73,6 +75,21 @@ export const appConfig: ApplicationConfig = {
|
||||
provide: AUTHORITY_CONSOLE_API,
|
||||
useExisting: AuthorityConsoleApiHttpClient,
|
||||
},
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
multi: true,
|
||||
deps: [AuthSessionStore],
|
||||
useFactory: (store: AuthSessionStore) => () => {
|
||||
if (typeof window === 'undefined') return;
|
||||
const stub = (window as any).__stellaopsTestSession as StubAuthSession | undefined;
|
||||
if (!stub) return;
|
||||
try {
|
||||
seedAuthSession(store, stub);
|
||||
} catch (err) {
|
||||
console.warn('Failed to seed test session', err);
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
provide: RISK_API_BASE_URL,
|
||||
deps: [AppConfigService],
|
||||
|
||||
Reference in New Issue
Block a user