@@ -25,6 +25,11 @@ test.describe('files_sharing: Sharing limited to members of the same group', ()
2525
2626 test . beforeAll ( async ( ) => {
2727 await runOcc ( [ 'config:app:set' , '--value' , 'yes' , 'core' , 'shareapi_only_share_with_group_members' ] )
28+ // The groups are shared by both tests, so create them once here rather than
29+ // spending two container round-trips inside every test's own timeout.
30+ for ( const group of groups ) {
31+ await runOcc ( [ 'group:add' , group ] , { failOnError : false } )
32+ }
2833 } )
2934
3035 test . afterAll ( async ( ) => {
@@ -34,36 +39,6 @@ test.describe('files_sharing: Sharing limited to members of the same group', ()
3439 }
3540 } )
3641
37- /**
38- * Put both accounts in two shared groups, then share a file each way.
39- *
40- * @returns the file names, `fromUser` shared by `user`, `fromRecipient` by `recipient`
41- */
42- async function seedMutualShares (
43- user : User ,
44- recipient : User ,
45- userRequest : Parameters < typeof createShare > [ 0 ] ,
46- recipientRequest : Parameters < typeof createShare > [ 0 ] ,
47- ) : Promise < { fromUser : string , fromRecipient : string } > {
48- for ( const group of groups ) {
49- await runOcc ( [ 'group:add' , group ] , { failOnError : false } )
50- await runOcc ( [ 'group:adduser' , group , user . userId ] )
51- await runOcc ( [ 'group:adduser' , group , recipient . userId ] )
52- }
53-
54- const fromUser = 'shared-by-user.txt'
55- const fromRecipient = 'shared-by-recipient.txt'
56- await uploadContent ( userRequest , user , 'share to recipient' , 'text/plain' , `/${ fromUser } ` )
57- await uploadContent ( recipientRequest , recipient , 'share to user' , 'text/plain' , `/${ fromRecipient } ` )
58- await createShare ( userRequest , `/${ fromUser } ` , recipient . userId )
59- await createShare ( recipientRequest , `/${ fromRecipient } ` , user . userId )
60-
61- await waitForShare ( recipientRequest , recipient , '' , fromUser )
62- await waitForShare ( userRequest , user , '' , fromRecipient )
63-
64- return { fromUser, fromRecipient }
65- }
66-
6742 test ( 'keeps the shares while one common group is left' , async ( { page, user, recipient, recipientRequest, filesListPage } ) => {
6843 const { fromUser, fromRecipient } = await seedMutualShares ( user , recipient , page . request , recipientRequest )
6944
@@ -92,4 +67,33 @@ test.describe('files_sharing: Sharing limited to members of the same group', ()
9267 await filesListPage . open ( )
9368 await expect ( filesListPage . getRowForFile ( fromUser ) ) . toHaveCount ( 0 )
9469 } )
70+
71+ /**
72+ * Put both accounts in two shared groups, then share a file each way.
73+ *
74+ * @returns the file names, `fromUser` shared by `user`, `fromRecipient` by `recipient`
75+ */
76+ async function seedMutualShares (
77+ user : User ,
78+ recipient : User ,
79+ userRequest : Parameters < typeof createShare > [ 0 ] ,
80+ recipientRequest : Parameters < typeof createShare > [ 0 ] ,
81+ ) : Promise < { fromUser : string , fromRecipient : string } > {
82+ for ( const group of groups ) {
83+ await runOcc ( [ 'group:adduser' , group , user . userId ] )
84+ await runOcc ( [ 'group:adduser' , group , recipient . userId ] )
85+ }
86+
87+ const fromUser = 'shared-by-user.txt'
88+ const fromRecipient = 'shared-by-recipient.txt'
89+ await uploadContent ( userRequest , user , 'share to recipient' , 'text/plain' , `/${ fromUser } ` )
90+ await uploadContent ( recipientRequest , recipient , 'share to user' , 'text/plain' , `/${ fromRecipient } ` )
91+ await createShare ( userRequest , `/${ fromUser } ` , recipient . userId )
92+ await createShare ( recipientRequest , `/${ fromRecipient } ` , user . userId )
93+
94+ await waitForShare ( recipientRequest , recipient , '' , fromUser )
95+ await waitForShare ( userRequest , user , '' , fromRecipient )
96+
97+ return { fromUser, fromRecipient }
98+ }
9599} )
0 commit comments