Skip to content

Commit 8a941ae

Browse files
authored
Merge pull request #803 from fractal-analytics-platform/api-task-group-ordering
Dropped semver and used API task-groups ordering
2 parents b7de5af + 1bf5309 commit 8a941ae

File tree

27 files changed

+271
-768
lines changed

27 files changed

+271
-768
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
*Note: Numbers like (\#123) point to closed Pull Requests on the fractal-web repository.*
22

3+
# Unreleased
4+
5+
* Dropped semver and used API task-groups ordering (\#803);
6+
* Parsed timestamps in `admin/accounting` (\#803);
7+
38
# 1.18.2
49

510
* Retrieved image status from `__wftask_dataset_image_status__` attribute (\#801);

__tests__/v2/AddWorkflowTaskModal.test.js

Lines changed: 0 additions & 186 deletions
This file was deleted.
Lines changed: 41 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,67 @@
11
import { it, describe, expect } from 'vitest';
22
import {
33
buildTaskTableRows,
4-
buildWorkflowTaskTableRows,
5-
removeIdenticalTaskGroups
4+
buildWorkflowTaskTableRows
65
} from '../../src/lib/tasks/task_group_utilities.js';
76

87
describe('task_group_utilities', () => {
98
it('buildTaskTableRows', async () => {
109
const taskGroups = [
11-
{ id: 1, pkg_name: 'name', task_list: [{ id: 2 }, { id: 1 }], version: '1.0.0' },
12-
{ id: 2, pkg_name: 'name', task_list: [{ id: 3 }, { id: 4 }], version: '1.2.0' },
13-
// groups with empty task_list should be ignored
14-
{ id: 2, pkg_name: 'name', task_list: [], version: '1.2.1' }
10+
[
11+
'name',
12+
[
13+
{ id: 2, pkg_name: 'name', task_list: [{ id: 3 }, { id: 4 }], version: '1.2.0' },
14+
{ id: 1, pkg_name: 'name', task_list: [{ id: 2 }, { id: 1 }], version: '1.0.0' }
15+
]
16+
]
1517
];
1618
const result = buildTaskTableRows(taskGroups, 'pkg_name');
1719
// selects the latest version
1820
expect(result[0].selectedVersion).eq('1.2.0');
1921
// 1.2.1 should be ignored since it is empty
2022
expect(Object.keys(result[0].groups)).toHaveLength(2);
21-
// check that tasks are sorted by id
22-
expect(result[0].groups['1.0.0'].task_list[0].id).eq(1);
23-
expect(result[0].groups['1.0.0'].task_list[1].id).eq(2);
24-
expect(result[0].groups['1.2.0'].task_list[0].id).eq(3);
25-
expect(result[0].groups['1.2.0'].task_list[1].id).eq(4);
26-
});
27-
28-
it('removeIdenticalTaskGroups', () => {
29-
const user = {
30-
id: 1,
31-
group_ids_names: [
32-
[11, 'All'],
33-
[22, 'older team'],
34-
[33, 'recent team']
35-
]
36-
};
37-
38-
const taskGroups = [
39-
{ pkg_name: 'mypkg', version: '1.1.1', user_id: 1, user_group_id: null, task_list: [] },
40-
{ pkg_name: 'mypkg', version: '1.1.1', user_id: 2, user_group_id: 11, task_list: [] },
41-
{ pkg_name: 'mypkg', version: '1.1.1', user_id: 2, user_group_id: 22, task_list: [] },
42-
{ pkg_name: 'mypkg', version: '1.1.1', user_id: 2, user_group_id: 33, task_list: [] },
43-
{ pkg_name: 'mypkg', version: '2.2.2', user_id: 2, user_group_id: 11, task_list: [] },
44-
{ pkg_name: 'mypkg', version: '2.2.2', user_id: 2, user_group_id: 22, task_list: [] },
45-
{ pkg_name: 'mypkg', version: '2.2.2', user_id: 2, user_group_id: 33, task_list: [] },
46-
{ pkg_name: 'mypkg', version: '3.3.3', user_id: 2, user_group_id: 33, task_list: [] },
47-
{ pkg_name: 'mypkg', version: '3.3.3', user_id: 2, user_group_id: 22, task_list: [] },
48-
{ pkg_name: 'mypkg', version: null, user_id: 1, user_group_id: 11, task_list: [] },
49-
{ pkg_name: 'mypkg', version: null, user_id: 2, user_group_id: 11, task_list: [] }
50-
];
51-
52-
const filteredTaskGroups = removeIdenticalTaskGroups(taskGroups, user);
53-
54-
expect(filteredTaskGroups).toHaveLength(4);
55-
expect(filteredTaskGroups[0].version).eq('1.1.1');
56-
expect(filteredTaskGroups[1].version).eq('2.2.2');
57-
expect(filteredTaskGroups[2].version).eq('3.3.3');
58-
expect(filteredTaskGroups[3].version).eq(null);
23+
expect(result[0].groups[0].id).eq(2);
24+
expect(result[0].groups[1].id).eq(1);
5925
});
6026

6127
it('buildWorkflowTaskTableRows groups by pkg_name', async () => {
6228
const taskGroups = [
63-
{ id: 3, pkg_name: 'p2', task_list: [{ id: 6 }, { id: 5 }], version: '3.0.0' },
64-
{
65-
id: 1,
66-
pkg_name: 'p1',
67-
task_list: [
68-
{ id: 2, name: 'p1t2' },
69-
{ id: 1, name: 'p1t1' }
70-
],
71-
version: '1.0.0'
72-
},
73-
{
74-
id: 2,
75-
pkg_name: 'p1',
76-
task_list: [
77-
{ id: 4, name: 'p1t2' },
78-
{ id: 3, name: 'p1t1' }
79-
],
80-
version: '1.2.0'
81-
}
29+
[
30+
'p1',
31+
[
32+
{
33+
id: 2,
34+
pkg_name: 'p1',
35+
task_list: [
36+
{ id: 3, name: 'p1t1' },
37+
{ id: 4, name: 'p1t2' }
38+
],
39+
version: '1.2.0'
40+
},
41+
{
42+
id: 1,
43+
pkg_name: 'p1',
44+
task_list: [
45+
{ id: 1, name: 'p1t1' },
46+
{ id: 2, name: 'p1t2' }
47+
],
48+
version: '1.0.0'
49+
}
50+
]
51+
],
52+
['p2', [{ id: 3, pkg_name: 'p2', task_list: [{ id: 6 }, { id: 5 }], version: '3.0.0' }]]
8253
];
8354

84-
const result = buildWorkflowTaskTableRows(taskGroups, 'pkg_name');
85-
expect(result[0].groupTitle).eq('p1');
86-
expect(result[1].groupTitle).eq('p2');
55+
const result = buildWorkflowTaskTableRows(taskGroups);
56+
expect(result[0].pkg_name).eq('p1');
57+
expect(result[1].pkg_name).eq('p2');
8758
expect(result[0].tasks).toHaveLength(2);
8859
expect(result[1].tasks).toHaveLength(1);
8960
expect(result[0].tasks[0].selectedVersion).eq('1.2.0');
90-
expect(result[0].tasks[0].taskVersions['1.2.0'].task_name).eq('p1t1');
61+
expect(result[0].tasks[0].taskVersions[0].task_name).eq('p1t1');
62+
expect(result[0].tasks[0].taskVersions[1].task_name).eq('p1t1');
9163
expect(result[0].tasks[1].selectedVersion).eq('1.2.0');
92-
expect(result[0].tasks[1].taskVersions['1.2.0'].task_name).eq('p1t2');
64+
expect(result[0].tasks[1].taskVersions[0].task_name).eq('p1t2');
65+
expect(result[0].tasks[1].taskVersions[1].task_name).eq('p1t2');
9366
});
9467
});

0 commit comments

Comments
 (0)