| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /**
- * Integration test for multi-platform concurrent requests
- *
- * This test validates concurrent request handling across multiple platforms
- * Tests MUST FAIL until implementation is complete.
- */
- import { describe, test, expect, beforeEach, jest } from '@jest/globals'
- // Import types that will be implemented
- import type { IUniversalHttpClient, HttpClientRequest, BatchResult } from '@/types/httpClientCore'
- describe('Multi-Platform Concurrent Requests Integration', () => {
- let httpClient: IUniversalHttpClient
- beforeEach(async () => {
- // This will fail until IUniversalHttpClient is implemented
- // eslint-disable-next-line @typescript-eslint/no-require-imports
- const { HttpClientCore } = require('@/core/http-client/HttpClientCore')
- httpClient = new HttpClientCore()
- // Register all platform adapters
- const platforms = ['pacifica', 'binance', 'aster']
- for (const platform of platforms) {
- // eslint-disable-next-line @typescript-eslint/no-require-imports
- const AdapterClass = require(`@/adapters/${platform}/${platform.charAt(0).toUpperCase() + platform.slice(1)}HttpAdapter`)
- const adapter = new AdapterClass[`${platform.charAt(0).toUpperCase() + platform.slice(1)}HttpAdapter`]({
- platform,
- baseUrl: `https://api.${platform}.com`
- })
- httpClient.registerPlatform(platform, adapter)
- }
- })
- test('should handle concurrent requests across multiple platforms', async () => {
- const requests: HttpClientRequest[] = [
- {
- platform: 'pacifica',
- accountId: 'pacifica-account',
- method: 'GET',
- url: '/api/v1/account/info'
- },
- {
- platform: 'binance',
- accountId: 'binance-account',
- method: 'GET',
- url: '/api/v3/account'
- },
- {
- platform: 'aster',
- accountId: 'aster-account',
- method: 'GET',
- url: '/api/balances'
- }
- ]
- const startTime = Date.now()
- const batchResult: BatchResult = await httpClient.batchRequest(requests)
- const duration = Date.now() - startTime
- expect(batchResult).toBeDefined()
- expect(batchResult.results).toHaveLength(3)
- expect(batchResult.summary.successful).toBe(3)
- expect(duration).toBeLessThan(500) // Should be much faster than sequential
- })
- })
|