|
1 | 1 | import test from 'node:test'; |
2 | 2 | import assert from 'node:assert/strict'; |
3 | | -import { groupArtifactsByType } from '../src/api/resources/artifacts.js'; |
| 3 | +import { |
| 4 | + groupArtifactsByType, |
| 5 | + mergeGroupedArtifacts, |
| 6 | +} from '../src/api/resources/artifacts.js'; |
4 | 7 | import type { CiArtifact } from '../src/api/types.js'; |
5 | 8 |
|
6 | 9 | test('groupArtifactsByType classifies known artifact types', () => { |
7 | 10 | const groupedArtifacts = groupArtifactsByType([ |
8 | 11 | createArtifact('1', 'LOG'), |
9 | | - createArtifact('2', 'SCREENSHOT'), |
10 | | - createArtifact('3', 'VIDEO'), |
11 | | - createArtifact('4', 'RESULT_BUNDLE'), |
12 | | - createArtifact('5', 'TEST_PRODUCTS'), |
13 | | - createArtifact('6', 'ARCHIVE'), |
| 12 | + createArtifact('2', 'LOG_BUNDLE'), |
| 13 | + createArtifact('3', 'SCREENSHOT'), |
| 14 | + createArtifact('4', 'VIDEO'), |
| 15 | + createArtifact('5', 'RESULT_BUNDLE'), |
| 16 | + createArtifact('6', 'TEST_PRODUCTS'), |
| 17 | + createArtifact('7', 'ARCHIVE'), |
14 | 18 | ]); |
15 | 19 |
|
16 | | - assert.equal(groupedArtifacts.logs.length, 1); |
| 20 | + assert.equal(groupedArtifacts.logs.length, 2); |
17 | 21 | assert.equal(groupedArtifacts.screenshots.length, 1); |
18 | 22 | assert.equal(groupedArtifacts.videos.length, 1); |
19 | 23 | assert.equal(groupedArtifacts.resultBundles.length, 1); |
20 | 24 | assert.equal(groupedArtifacts.testProducts.length, 1); |
21 | 25 | assert.equal(groupedArtifacts.archives.length, 1); |
22 | 26 | }); |
23 | 27 |
|
| 28 | +test('mergeGroupedArtifacts combines action artifact groups', () => { |
| 29 | + const mergedArtifacts = mergeGroupedArtifacts([ |
| 30 | + groupArtifactsByType([ |
| 31 | + createArtifact('1', 'LOG'), |
| 32 | + createArtifact('2', 'SCREENSHOT'), |
| 33 | + ]), |
| 34 | + groupArtifactsByType([ |
| 35 | + createArtifact('3', 'LOG'), |
| 36 | + createArtifact('4', 'RESULT_BUNDLE'), |
| 37 | + ]), |
| 38 | + ]); |
| 39 | + |
| 40 | + assert.equal(mergedArtifacts.logs.length, 2); |
| 41 | + assert.equal(mergedArtifacts.screenshots.length, 1); |
| 42 | + assert.equal(mergedArtifacts.resultBundles.length, 1); |
| 43 | +}); |
| 44 | + |
24 | 45 | function createArtifact( |
25 | 46 | id: string, |
26 | 47 | fileType: CiArtifact['attributes']['fileType'], |
|
0 commit comments