@@ -2,6 +2,25 @@ import { GroupManagePage } from '../pages/_app/group/manage.page';
22import { expect , test } from '../support/fixtures' ;
33
44test . describe ( 'group manage' , ( ) => {
5+ test ( 'should give a newly created group access to every uploaded instrument, so a manager has something to administer' , async ( {
6+ adminToken,
7+ apiRequestContext,
8+ uniqueId
9+ } ) => {
10+ // Deliberately not the `api.createGroup` fixture: that helper PATCHes the accessible instruments
11+ // in after creating the group, so it passes whether or not creation connected anything itself.
12+ // An uploaded instrument has no `sourceRepoId` key at all, and the selection query has to match
13+ // that as well as an explicit null.
14+ const response = await apiRequestContext . post ( '/api/v1/groups' , {
15+ data : { name : `RawGroup${ uniqueId } ` , type : 'CLINICAL' } ,
16+ headers : { Authorization : `Bearer ${ adminToken } ` }
17+ } ) ;
18+ expect ( response . status ( ) ) . toBe ( 201 ) ;
19+
20+ const group = ( await response . json ( ) ) as { accessibleInstrumentIds : string [ ] } ;
21+ expect ( group . accessibleInstrumentIds . length ) . toBeGreaterThan ( 0 ) ;
22+ } ) ;
23+
524 test ( 'should let a group manager preview an accessible instrument' , async ( { getPageModel } ) => {
625 const groupManagePage = await getPageModel ( '/group/manage' ) ;
726
@@ -31,8 +50,11 @@ test.describe('group manage', () => {
3150 await expect ( page ) . toHaveURL ( '/group/manage' ) ;
3251
3352 const groupManagePage = new GroupManagePage ( page ) ;
34- // A freshly created group has every non-repo instrument accessible already, so uncheck one to
35- // produce an observable, reversible change.
53+ // `api.createGroup` grants access to every instrument, so uncheck one to produce an observable,
54+ // reversible change. Assert it starts checked first: `uncheck()` is a no-op on an already-
55+ // unchecked box, so without this the rest of the test would still pass if the precondition
56+ // silently stopped holding.
57+ await expect ( groupManagePage . instrumentCheckbox ( 'Happiness Questionnaire' ) ) . toBeChecked ( ) ;
3658 await groupManagePage . instrumentCheckbox ( 'Happiness Questionnaire' ) . uncheck ( ) ;
3759 await groupManagePage . subjectIdDisplayLengthInput . fill ( '6' ) ;
3860 await groupManagePage . submitButton . click ( ) ;
0 commit comments