Skip to content

Commit 362a9c9

Browse files
authored
Merge pull request #870 from fractal-analytics-platform/default-group-configurable
Handled FRACTAL_DEFAULT_GROUP_NAME environment variable
2 parents 0a1d02f + 69e8099 commit 362a9c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+375
-161
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ FRACTAL_RUNNER_BACKEND=local
2323
#NEWS_INFO_PATH=/path/to/news.md
2424

2525
BODY_SIZE_LIMIT=5000000
26+
27+
FRACTAL_DEFAULT_GROUP_NAME=All

.env.development

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ LOG_LEVEL_CONSOLE=info
2020
FRACTAL_RUNNER_BACKEND=local
2121
#WARNING_BANNER_PATH=/path/to/banner.txt
2222
#NEWS_INFO_PATH=/path/to/news.md
23+
24+
FRACTAL_DEFAULT_GROUP_NAME=All

.github/workflows/end_to_end_tests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
run: npx playwright test
7474
env:
7575
FRACTAL_RUNNER_BACKEND: local
76+
FRACTAL_DEFAULT_GROUP_NAME: All
7677

7778
- name: Archive test results
7879
if: always()

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* Handled user without profile as not verified users (\#862);
1717
* Added support for oneOf and discriminator (\#867);
1818
* Added resource filter on admin task and task-group pages (\#867);
19+
* Handled `FRACTAL_DEFAULT_GROUP_NAME` environment variable, to specify if a default group is used (\#870);
1920

2021
# 1.20.0
2122

__tests__/user_utilities.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { it, expect } from 'vitest';
22
import {
33
sortUsers,
4-
sortGroupByNameAllFirstComparator,
4+
getSortGroupByNameAllFirstComparator,
55
sortUserToImportSettings
66
} from '$lib/components/admin/user_utilities';
77
import { mockGroup, mockUser } from './mock/mock-types';
@@ -43,7 +43,7 @@ it('should sort groups by name, but keeping the All group first', () => {
4343
mockGroup({ id: 3, name: 'g3' })
4444
];
4545

46-
groups.sort(sortGroupByNameAllFirstComparator);
46+
groups.sort(getSortGroupByNameAllFirstComparator('All'));
4747

4848
expect(groups[0].name).eq('All');
4949
expect(groups[1].name).eq('g2');

__tests__/v2/AddSingleTask.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ describe('AddSingleTask', () => {
3333
render(AddSingleTask, {
3434
props: {
3535
user: mockedUser,
36-
addNewTasks: vi.fn()
36+
addNewTasks: vi.fn(),
37+
defaultGroupName: 'All'
3738
}
3839
});
3940

@@ -68,7 +69,8 @@ describe('AddSingleTask', () => {
6869
render(AddSingleTask, {
6970
props: {
7071
user: mockedUser,
71-
addNewTasks: vi.fn()
72+
addNewTasks: vi.fn(),
73+
defaultGroupName: 'All'
7274
}
7375
});
7476

__tests__/v2/TaskCollection.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('TaskCollection', () => {
6262
});
6363

6464
render(TaskCollection, {
65-
props: { user: mockedUser }
65+
props: { user: mockedUser, defaultGroupName: 'All' }
6666
});
6767

6868
await user.type(screen.getByRole('textbox', { name: 'Package' }), 'test-task');
@@ -94,7 +94,7 @@ describe('TaskCollection', () => {
9494
});
9595

9696
render(TaskCollection, {
97-
props: { user: mockedUser }
97+
props: { user: mockedUser, defaultGroupName: 'All' }
9898
});
9999

100100
await user.type(screen.getByRole('textbox', { name: 'Package' }), 'test-task');
@@ -124,7 +124,7 @@ describe('TaskCollection', () => {
124124
});
125125

126126
render(TaskCollection, {
127-
props: { user: mockedUser }
127+
props: { user: mockedUser, defaultGroupName: 'All' }
128128
});
129129

130130
const addPpvBtn = screen.getByRole('button', { name: 'Add pinned package version' });
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { render, screen } from '@testing-library/svelte';
3+
4+
import TaskGroupSelector from '../../src/lib/components/v2/tasks/TaskGroupSelector.svelte';
5+
6+
describe('TaskGroupSelector', () => {
7+
it('Default group is selected', async () => {
8+
render(TaskGroupSelector, {
9+
props: {
10+
id: 'test',
11+
groupIdsNames: [
12+
[2, 'group2'],
13+
[1, 'All']
14+
],
15+
defaultGroupName: 'All'
16+
}
17+
});
18+
expect(screen.getByRole('combobox')).toHaveValue('1');
19+
});
20+
21+
it('Validate required group', async () => {
22+
const { component } = render(TaskGroupSelector, {
23+
props: {
24+
id: 'test',
25+
groupIdsNames: [],
26+
defaultGroupName: null
27+
}
28+
});
29+
30+
component.validate();
31+
32+
expect(await screen.findByText('Shared tasks must be associated with a group')).toBeVisible();
33+
});
34+
35+
it('The only present group is selected', async () => {
36+
render(TaskGroupSelector, {
37+
props: {
38+
id: 'test',
39+
groupIdsNames: [[1, 'group1']],
40+
defaultGroupName: null
41+
}
42+
});
43+
expect(screen.getByRole('combobox')).toHaveValue('1');
44+
});
45+
});

__tests__/v2/UserEditor.test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ describe('UserEditor', () => {
6363
slurm_accounts: [],
6464
project_dir: null
6565
},
66-
saveUser: mockSaveUser
66+
saveUser: mockSaveUser,
67+
defaultGroupName: 'All'
6768
}
6869
});
6970

@@ -109,7 +110,8 @@ describe('UserEditor', () => {
109110
slurm_accounts: [],
110111
project_dir: null
111112
},
112-
saveUser: mockSaveUser
113+
saveUser: mockSaveUser,
114+
defaultGroupName: 'All'
113115
}
114116
});
115117

@@ -144,7 +146,8 @@ describe('UserEditor', () => {
144146
slurm_accounts: [],
145147
project_dir: '/path/to/project/dir'
146148
},
147-
saveUser: mockSaveUser
149+
saveUser: mockSaveUser,
150+
defaultGroupName: 'All'
148151
}
149152
});
150153

@@ -185,7 +188,8 @@ describe('UserEditor', () => {
185188
slurm_accounts: ['foo', 'bar'],
186189
project_dir: '/path/to/project/dir'
187190
},
188-
saveUser: mockSaveUser
191+
saveUser: mockSaveUser,
192+
defaultGroupName: 'All'
189193
}
190194
});
191195

components/__tests__/jschema/jschema_adapter.test.js

Lines changed: 87 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -278,67 +278,97 @@ describe('jschema_adapter', () => {
278278
title: 'ProcessTask'
279279
});
280280

281-
expect(JSON.stringify(cleanJschema)).eq(
282-
JSON.stringify({
283-
$defs: {
284-
ProcessAModel: {
285-
description: 'A process model with the same parameter name as ProcessBModel.',
286-
properties: {
287-
step: {
288-
const: 'ProcessA',
289-
title: 'Step',
290-
type: 'string',
291-
description: 'A literal to identify the process type.'
292-
},
293-
parameter1: {
294-
title: 'Parameter1',
295-
type: 'number',
296-
description: 'An integer parameter in A.'
297-
}
281+
expect(cleanJschema).deep.eq({
282+
$defs: {
283+
ProcessAModel: {
284+
description: 'A process model with the same parameter name as ProcessBModel.',
285+
properties: {
286+
step: {
287+
const: 'ProcessA',
288+
title: 'Step',
289+
type: 'string',
290+
description: 'A literal to identify the process type.'
298291
},
299-
required: ['step', 'parameter1'],
300-
title: 'ProcessAModel',
301-
type: 'object'
292+
parameter1: {
293+
title: 'Parameter1',
294+
type: 'number',
295+
description: 'An integer parameter in A.'
296+
}
302297
},
303-
ProcessBModel: {
304-
description: 'B process model with the same parameter name as ProcessAModel.',
305-
properties: {
306-
step: {
307-
const: 'ProcessB',
308-
title: 'Step',
309-
type: 'string',
310-
description: 'A literal to identify the process type.'
311-
},
312-
parameter1: {
313-
title: 'Parameter1',
314-
type: 'number',
315-
description: 'An integer parameter in B.'
316-
}
298+
required: ['step', 'parameter1'],
299+
title: 'ProcessAModel',
300+
type: 'object'
301+
},
302+
ProcessBModel: {
303+
description: 'B process model with the same parameter name as ProcessAModel.',
304+
properties: {
305+
step: {
306+
const: 'ProcessB',
307+
title: 'Step',
308+
type: 'string',
309+
description: 'A literal to identify the process type.'
310+
},
311+
parameter1: {
312+
title: 'Parameter1',
313+
type: 'number',
314+
description: 'An integer parameter in B.'
315+
}
316+
},
317+
required: ['step', 'parameter1'],
318+
title: 'ProcessBModel',
319+
type: 'object'
320+
}
321+
},
322+
additionalProperties: false,
323+
properties: {
324+
proc_step: {
325+
oneOf: [
326+
{
327+
$ref: '#/$defs/ProcessAModel'
317328
},
318-
required: ['step', 'parameter1'],
319-
title: 'ProcessBModel',
320-
type: 'object'
329+
{
330+
$ref: '#/$defs/ProcessBModel'
331+
}
332+
],
333+
title: 'Proc Step',
334+
description: 'The processing step to apply.'
335+
}
336+
},
337+
required: ['proc_step'],
338+
type: 'object',
339+
title: 'ProcessTask'
340+
});
341+
});
342+
343+
it('Strip discriminator, schema with default null value (ref #871)', () => {
344+
const schema = stripDiscriminator({
345+
properties: {
346+
advanced_options: {
347+
type: 'object',
348+
properties: {
349+
position_scale: { type: 'number' }
350+
},
351+
default: {
352+
position_scale: null
321353
}
322-
},
323-
additionalProperties: false,
324-
properties: {
325-
proc_step: {
326-
oneOf: [
327-
{
328-
$ref: '#/$defs/ProcessAModel'
329-
},
330-
{
331-
$ref: '#/$defs/ProcessBModel'
332-
}
333-
],
334-
title: 'Proc Step',
335-
description: 'The processing step to apply.'
354+
}
355+
},
356+
type: 'object'
357+
});
358+
359+
expect(schema).deep.eq({
360+
properties: {
361+
advanced_options: {
362+
type: 'object',
363+
properties: {
364+
position_scale: { type: 'number' }
365+
},
366+
default: {
367+
position_scale: null
336368
}
337-
},
338-
required: ['proc_step'],
339-
type: 'object',
340-
title: 'ProcessTask'
341-
})
342-
);
369+
}
370+
},
371+
type: 'object'
372+
});
343373
});
344374
});

0 commit comments

Comments
 (0)