|
| 1 | +import { describe, expect, it } from 'vitest'; |
| 2 | + |
| 3 | +import { processLogData } from './useLogData'; |
| 4 | + |
| 5 | +describe('processLogData', () => { |
| 6 | + it('maps build fields and defaults status to NULL when missing', () => { |
| 7 | + const result = processLogData('build-1', { |
| 8 | + type: 'build', |
| 9 | + git_commit_name: 'Fix scheduler race', |
| 10 | + misc: { platform: 'qemu-x86' }, |
| 11 | + output_files: [{ name: 'other_file', url: 'https://example.com/other' }], |
| 12 | + }); |
| 13 | + |
| 14 | + expect(result).toMatchObject({ |
| 15 | + id: 'build-1', |
| 16 | + type: 'build', |
| 17 | + title: 'Fix scheduler race', |
| 18 | + status: 'NULL', |
| 19 | + hardware: 'qemu-x86', |
| 20 | + log_excerpt: undefined, |
| 21 | + }); |
| 22 | + }); |
| 23 | + |
| 24 | + it('maps test fields and picks first hardware candidate from buildHardwareArray', () => { |
| 25 | + const result = processLogData('test-1', { |
| 26 | + type: 'test', |
| 27 | + path: 'boot/smoke', |
| 28 | + status: 'PASS', |
| 29 | + environment_misc: { platform: 'rk3399' }, |
| 30 | + environment_compatible: ['arm64', 'lab-board'], |
| 31 | + }); |
| 32 | + |
| 33 | + expect(result).toMatchObject({ |
| 34 | + id: 'test-1', |
| 35 | + type: 'test', |
| 36 | + title: 'boot/smoke', |
| 37 | + status: 'PASS', |
| 38 | + hardware: 'rk3399', |
| 39 | + }); |
| 40 | + }); |
| 41 | + |
| 42 | + it('extracts log excerpt URL from output_files when present', () => { |
| 43 | + const result = processLogData('build-2', { |
| 44 | + type: 'build', |
| 45 | + status: 'FAIL', |
| 46 | + output_files: [ |
| 47 | + { name: 'artifact', url: 'https://example.com/artifact' }, |
| 48 | + { name: 'log_excerpt', url: 'https://example.com/log-excerpt' }, |
| 49 | + ], |
| 50 | + }); |
| 51 | + |
| 52 | + expect(result.log_excerpt).toBe('https://example.com/log-excerpt'); |
| 53 | + }); |
| 54 | +}); |
0 commit comments