2026-01-18 18:57:06 +04:00
|
|
|
import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection, isDevMode } from '@angular/core';
|
2026-02-19 01:23:25 +04:00
|
|
|
import { provideRouter, withInMemoryScrolling } from '@angular/router';
|
2026-07-26 19:05:58 +04:00
|
|
|
import { provideHttpClient, withInterceptors, withXhr } from '@angular/common/http';
|
2026-01-18 18:57:06 +04:00
|
|
|
|
|
|
|
|
import { routes } from './app.routes';
|
|
|
|
|
import { cacheInterceptor } from './interceptors/cache.interceptor';
|
2026-08-18 13:15:13 +04:00
|
|
|
import { apiErrorInterceptor } from './core/interceptors/api-error.interceptor';
|
2026-07-05 02:24:16 +04:00
|
|
|
import { apiBaseUrlInterceptor } from './interceptors/api-base-url.interceptor';
|
2026-02-28 17:42:36 +04:00
|
|
|
import { apiHeadersInterceptor } from './interceptors/api-headers.interceptor';
|
2026-03-01 02:43:14 +04:00
|
|
|
import { mockDataInterceptor } from './interceptors/mock-data.interceptor';
|
2026-08-18 01:05:16 +04:00
|
|
|
import { adminAuthHeadersInterceptor, Ed25519VerificationService, NoopEd25519VerificationService, AUTH_API_URL, TELEGRAM_BOT_USERNAME } from '@marketplaces/auth';
|
2026-01-18 18:57:06 +04:00
|
|
|
import { provideServiceWorker } from '@angular/service-worker';
|
2026-07-15 04:58:20 +04:00
|
|
|
import { MediaRepository } from './core/media/media-repository';
|
|
|
|
|
import { MockMediaRepository } from './core/media/mock-media-repository.service';
|
2026-08-20 14:23:12 +04:00
|
|
|
import { ApiConfigService } from './core/config/api-config.service';
|
2026-08-18 01:05:16 +04:00
|
|
|
import { environment } from '../environments/environment';
|
2026-01-18 18:57:06 +04:00
|
|
|
|
|
|
|
|
export const appConfig: ApplicationConfig = {
|
|
|
|
|
providers: [
|
|
|
|
|
provideBrowserGlobalErrorListeners(),
|
|
|
|
|
provideZoneChangeDetection({ eventCoalescing: true }),
|
|
|
|
|
provideRouter(
|
2026-02-19 01:23:25 +04:00
|
|
|
routes,
|
2026-01-18 18:57:06 +04:00
|
|
|
withInMemoryScrolling({ scrollPositionRestoration: 'top' })
|
|
|
|
|
),
|
2026-07-26 19:05:58 +04:00
|
|
|
provideHttpClient(withXhr(),
|
2026-08-18 13:15:13 +04:00
|
|
|
// apiErrorInterceptor sits last so it observes the response after every
|
|
|
|
|
// other interceptor has run, and normalizes whatever actually came back.
|
|
|
|
|
withInterceptors([mockDataInterceptor, apiBaseUrlInterceptor, apiHeadersInterceptor, adminAuthHeadersInterceptor, cacheInterceptor, apiErrorInterceptor])
|
2026-02-26 21:54:21 +04:00
|
|
|
),
|
2026-08-20 14:23:12 +04:00
|
|
|
{
|
|
|
|
|
provide: AUTH_API_URL,
|
|
|
|
|
useFactory: (apiConfig: ApiConfigService) => apiConfig.getBaseUrl(),
|
|
|
|
|
deps: [ApiConfigService]
|
|
|
|
|
},
|
2026-08-18 01:05:16 +04:00
|
|
|
{ provide: TELEGRAM_BOT_USERNAME, useValue: environment.telegramBot },
|
feat: stand up E2E harness, fix a real bootstrap bug it found
Track Q Q1/Q4 (docs/PRODUCT-PLAN-v3.1-DELIVERY-PLAN.md). No E2E existed
before this. Playwright chosen - no existing test runner preference, and it
needs zero extra infra beyond the dev server this repo already has.
- playwright.config.ts, package.json e2e/e2e:ui/e2e:report scripts
- e2e/smoke.spec.ts app boots, no console errors (network 404s from the
absent backend are filtered - expected, not a bug)
- e2e/currency-switch.spec.ts Track Q Q4: switching currency must change
the displayed price VALUE, not just the label next
to it. Written specifically so the upcoming
checkout money-truth rewrite (frontend backlog
F10-F16, which replaces client-side FX math with a
server-computed total) has a regression net under
it before that rewrite starts.
The first run found a real, current bug: @marketplaces/auth ships plain tsc
output (dist/index.js), not Angular Package Format, so it carries no compiled
Ivy DI metadata. Any class-based provider from it - not just the Ed25519
Noop stub, AuthService itself hit the same failure - forces Angular to
JIT-compile at runtime, which throws immediately when @angular/compiler
isn't loaded. That breaks app bootstrap outright, for real users, not just
this test.
Fixed here with the minimum honest scope:
- src/main.ts: import '@angular/compiler' before bootstrap, so JIT works
everywhere the package is injected, not just at one call site
- src/app/app.config.ts: useFactory instead of useClass for the Noop
Ed25519 provider, since it has zero constructor deps and doesn't need
Angular to derive metadata for it at all
- angular.json: raised the initial-bundle hard-error budget 1.5MB -> 1.8MB,
because the compiler import made a correct build refuse to complete. A
build that fails outright is worse than a bundle that's honestly larger
than it should be.
The real fix belongs in the vitanovaPackages auth repo: publish via
ng-packagr so consumers get Ivy-compiled output and none of this is
necessary. Do not remove the compiler import until that ships - see the
comment left in main.ts.
Also fixed a genuine test defect while getting this to a real green: the
page renders duplicate .currency-option elements (desktop/mobile variants of
the same selector), so the first attempt at this test clicked into a hidden
duplicate and silently no-opped. Scoped the click to .currency-dropdown.open
and added an explicit poll for the DOM to reflect the new currency before
reading it back, rather than trusting a fixed timeout.
Verified: 3/3 E2E green, 115/115 unit tests green, arch:check clean,
production build succeeds.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 13:46:43 +04:00
|
|
|
// useFactory, not useClass: @marketplaces/auth ships plain tsc output, not
|
|
|
|
|
// Angular Package Format, so it carries no baked-in Ivy DI metadata for
|
|
|
|
|
// this class. useClass forces Angular to JIT-compile it at runtime, which
|
|
|
|
|
// throws when @angular/compiler isn't loaded (true for this build). A
|
|
|
|
|
// factory sidesteps that - NoopEd25519VerificationService has zero
|
|
|
|
|
// constructor deps, so this is a correct fix, not a workaround.
|
|
|
|
|
// Real fix belongs in vitanovaPackages: publish with ng-packagr.
|
|
|
|
|
{ provide: Ed25519VerificationService, useFactory: () => new NoopEd25519VerificationService() },
|
2026-07-15 04:58:20 +04:00
|
|
|
{ provide: MediaRepository, useClass: MockMediaRepository },
|
2026-02-26 21:54:21 +04:00
|
|
|
provideServiceWorker('ngsw-worker.js', {
|
|
|
|
|
enabled: !isDevMode(),
|
|
|
|
|
registrationStrategy: 'registerWhenStable:30000'
|
|
|
|
|
})
|
2026-01-18 18:57:06 +04:00
|
|
|
]
|
2026-02-26 21:54:21 +04:00
|
|
|
};
|