2026-01-07 09:33:52 +00:00
|
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
|
|
|
import { commerceService } from './commerceService';
|
|
|
|
|
|
|
|
|
|
describe('commerceService', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
vi.clearAllMocks();
|
|
|
|
|
});
|
|
|
|
|
|
fix(tests): cycles 12–18 – corrections services, mocks et design tokens
- chatService: getChannels → getServers
- commerceService: getOrders/getOrderDetails/getSalesStats → getPurchases/getSellerStats
- marketplaceService: mock réponse, params API, getDownloadLink → listOrders
- config/env.test: vi.stubEnv, import dynamique
- useAuth.test: mock useAuthStore
- TrackStatsDisplay, UploadQuota: mock du bon service (analyticsService, uploadService)
- TrackListEmpty, TrackListRow, TrackSearch: design tokens, assertions
- trackDownloadService, chunkedUploadService: MSW/server.use
- trackListService, trackSearchService, trackShareService: assertions
- ErrorBoundary, LoginForm, PlaylistErrorBoundary, PlaylistRecommendations
- RAPPORT_RESOLUTION_TESTS_CYCLE1.md
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-11 08:43:55 +00:00
|
|
|
describe('getPurchases', () => {
|
|
|
|
|
it('should return purchases', async () => {
|
|
|
|
|
const purchases = await commerceService.getPurchases();
|
|
|
|
|
|
|
|
|
|
expect(purchases).toBeDefined();
|
|
|
|
|
expect(Array.isArray(purchases)).toBe(true);
|
|
|
|
|
if (purchases.length > 0) {
|
|
|
|
|
expect(purchases[0]).toHaveProperty('id');
|
|
|
|
|
expect(purchases[0]).toHaveProperty('status');
|
|
|
|
|
}
|
2026-01-07 09:33:52 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
fix(tests): cycles 12–18 – corrections services, mocks et design tokens
- chatService: getChannels → getServers
- commerceService: getOrders/getOrderDetails/getSalesStats → getPurchases/getSellerStats
- marketplaceService: mock réponse, params API, getDownloadLink → listOrders
- config/env.test: vi.stubEnv, import dynamique
- useAuth.test: mock useAuthStore
- TrackStatsDisplay, UploadQuota: mock du bon service (analyticsService, uploadService)
- TrackListEmpty, TrackListRow, TrackSearch: design tokens, assertions
- trackDownloadService, chunkedUploadService: MSW/server.use
- trackListService, trackSearchService, trackShareService: assertions
- ErrorBoundary, LoginForm, PlaylistErrorBoundary, PlaylistRecommendations
- RAPPORT_RESOLUTION_TESTS_CYCLE1.md
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-11 08:43:55 +00:00
|
|
|
describe('getSellerStats', () => {
|
2026-01-07 09:33:52 +00:00
|
|
|
it('should return sales statistics', async () => {
|
fix(tests): cycles 12–18 – corrections services, mocks et design tokens
- chatService: getChannels → getServers
- commerceService: getOrders/getOrderDetails/getSalesStats → getPurchases/getSellerStats
- marketplaceService: mock réponse, params API, getDownloadLink → listOrders
- config/env.test: vi.stubEnv, import dynamique
- useAuth.test: mock useAuthStore
- TrackStatsDisplay, UploadQuota: mock du bon service (analyticsService, uploadService)
- TrackListEmpty, TrackListRow, TrackSearch: design tokens, assertions
- trackDownloadService, chunkedUploadService: MSW/server.use
- trackListService, trackSearchService, trackShareService: assertions
- ErrorBoundary, LoginForm, PlaylistErrorBoundary, PlaylistRecommendations
- RAPPORT_RESOLUTION_TESTS_CYCLE1.md
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-11 08:43:55 +00:00
|
|
|
const stats = await commerceService.getSellerStats();
|
2026-01-13 18:47:57 +00:00
|
|
|
|
2026-01-07 09:33:52 +00:00
|
|
|
expect(stats).toBeDefined();
|
fix(tests): cycles 12–18 – corrections services, mocks et design tokens
- chatService: getChannels → getServers
- commerceService: getOrders/getOrderDetails/getSalesStats → getPurchases/getSellerStats
- marketplaceService: mock réponse, params API, getDownloadLink → listOrders
- config/env.test: vi.stubEnv, import dynamique
- useAuth.test: mock useAuthStore
- TrackStatsDisplay, UploadQuota: mock du bon service (analyticsService, uploadService)
- TrackListEmpty, TrackListRow, TrackSearch: design tokens, assertions
- trackDownloadService, chunkedUploadService: MSW/server.use
- trackListService, trackSearchService, trackShareService: assertions
- ErrorBoundary, LoginForm, PlaylistErrorBoundary, PlaylistRecommendations
- RAPPORT_RESOLUTION_TESTS_CYCLE1.md
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-11 08:43:55 +00:00
|
|
|
expect(stats).toHaveProperty('revenue');
|
|
|
|
|
expect(stats).toHaveProperty('sales');
|
2026-01-07 09:33:52 +00:00
|
|
|
expect(stats).toHaveProperty('views');
|
|
|
|
|
expect(stats).toHaveProperty('conversion');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('requestRefund', () => {
|
|
|
|
|
it('should request refund successfully', async () => {
|
2026-01-13 18:47:57 +00:00
|
|
|
const result = await commerceService.requestRefund(
|
|
|
|
|
'order-1',
|
|
|
|
|
'Defective product',
|
|
|
|
|
);
|
|
|
|
|
|
2026-01-07 09:33:52 +00:00
|
|
|
expect(result).toBeDefined();
|
|
|
|
|
expect(result.success).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|