forked from Shared/esg
Implement normalized error handling with Persian translations across all exception types, replace legacy NestJS exceptions with AppException, and add unit, integration, and smoke tests. - Add error catalog with gateway-owned codes and Persian messages - Introduce AppException wrapping normalized error envelopes - Add translateError helper for automatic messageFa population - Remove claims module and update provider error normalization - Add unit tests for error contracts and helper functions - Add integration tests for admin and inquiry endpoints - Add smoke tests for real provider connectivity - Add test support utilities (auth mocks, assertions, app factory)
39 lines
988 B
TypeScript
39 lines
988 B
TypeScript
import { InquiryType } from '../../src/common/enums/inquiry-type.enum';
|
|
|
|
export interface TestClientConfig {
|
|
clientId: string;
|
|
apiKey: string;
|
|
providerBaseUrl: string;
|
|
credentials: Record<string, string>;
|
|
requiresVpn: boolean;
|
|
allowedInquiries: InquiryType[];
|
|
}
|
|
|
|
export function createClientConfig(
|
|
overrides: Partial<TestClientConfig> = {},
|
|
): TestClientConfig {
|
|
return {
|
|
clientId: 'default-client',
|
|
apiKey: 'test-api-key',
|
|
providerBaseUrl: 'https://provider.test',
|
|
credentials: {
|
|
username: 'provider-user',
|
|
password: 'provider-password',
|
|
},
|
|
requiresVpn: false,
|
|
allowedInquiries: Object.values(InquiryType),
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
export function resolveClientConfig(
|
|
clients: TestClientConfig[],
|
|
clientId: string,
|
|
): TestClientConfig {
|
|
const client = clients.find((candidate) => candidate.clientId === clientId);
|
|
if (!client) {
|
|
throw new Error(`No test client config found for ${clientId}`);
|
|
}
|
|
return client;
|
|
}
|