@@ -112,6 +112,13 @@ describe("File upload", () => {
112112 expect ( CoreDate . from ( file . expiresAt ) . isSame ( defaultDate ) ) . toBe ( true ) ;
113113 } ) ;
114114
115+ test ( "can upload a file with tags" , async ( ) => {
116+ const response = await transportServices1 . files . uploadOwnFile ( await makeUploadRequest ( { tags : [ "tag1" , "tag2" ] } ) ) ;
117+ expect ( response ) . toBeSuccessful ( ) ;
118+
119+ expect ( response . value . tags ) . toStrictEqual ( [ "tag1" , "tag2" ] ) ;
120+ } ) ;
121+
115122 test ( "cannot upload a file with expiry date in the past" , async ( ) => {
116123 const response = await transportServices1 . files . uploadOwnFile ( await makeUploadRequest ( { expiresAt : "1970" } ) ) ;
117124 expect ( response ) . toBeAnError ( "'expiresAt' must be in the future" , "error.runtime.validation.invalidPropertyValue" ) ;
@@ -136,6 +143,39 @@ describe("Get file", () => {
136143 expect ( response . value ) . toMatchObject ( file ) ;
137144 } ) ;
138145
146+ test ( "can get file by tags" , async ( ) => {
147+ const uploadFileResult = await transportServices1 . files . uploadOwnFile (
148+ await makeUploadRequest ( {
149+ tags : [ "aTag" , "anotherTag" ]
150+ } )
151+ ) ;
152+ const file = uploadFileResult . value ;
153+
154+ const uploadFileResult2 = await transportServices1 . files . uploadOwnFile (
155+ await makeUploadRequest ( {
156+ tags : [ "aThirdTag" , "aFourthTag" ]
157+ } )
158+ ) ;
159+ const file2 = uploadFileResult2 . value ;
160+
161+ const getResult = await transportServices1 . files . getFiles ( { query : { tags : [ "aTag" ] } } ) ;
162+
163+ expect ( getResult ) . toBeSuccessful ( ) ;
164+ expect ( getResult . value [ 0 ] . id ) . toStrictEqual ( file . id ) ;
165+
166+ const getResult2 = await transportServices1 . files . getFiles ( { query : { tags : [ "aTag" , "anotherTag" ] } } ) ;
167+
168+ expect ( getResult2 ) . toBeSuccessful ( ) ;
169+ expect ( getResult2 . value [ 0 ] . id ) . toStrictEqual ( file . id ) ;
170+
171+ const getResult3 = await transportServices1 . files . getFiles ( { query : { tags : [ "aTag" , "aThirdTag" ] } } ) ;
172+
173+ expect ( getResult3 ) . toBeSuccessful ( ) ;
174+ const result3Ids = getResult3 . value . map ( ( file ) => file . id ) ;
175+ expect ( result3Ids ) . toContain ( file . id ) ;
176+ expect ( result3Ids ) . toContain ( file2 . id ) ;
177+ } ) ;
178+
139179 test ( "accessing not existing file id causes an error" , async ( ) => {
140180 const response = await transportServices1 . files . getFile ( { id : UNKNOWN_FILE_ID } ) ;
141181 expect ( response ) . toBeAnError ( "File not found. Make sure the ID exists and the record is not expired." , "error.runtime.recordNotFound" ) ;
@@ -295,6 +335,18 @@ describe("Load peer file with token reference", () => {
295335 expect ( response . value ) . toContainEqual ( { ...file , isOwn : false } ) ;
296336 } ) ;
297337
338+ test ( "should load a peer file with its tags" , async ( ) => {
339+ const uploadOwnFileResult = await transportServices1 . files . uploadOwnFile (
340+ await makeUploadRequest ( {
341+ tags : [ "tag1" , "tag2" ]
342+ } )
343+ ) ;
344+ const token = ( await transportServices1 . files . createTokenForFile ( { fileId : uploadOwnFileResult . value . id } ) ) . value ;
345+ const loadFileResult = await transportServices2 . files . getOrLoadFile ( { reference : token . truncatedReference } ) ;
346+
347+ expect ( loadFileResult . value . tags ) . toStrictEqual ( [ "tag1" , "tag2" ] ) ;
348+ } ) ;
349+
298350 test ( "cannot pass token id as truncated token reference" , async ( ) => {
299351 const file = await uploadFile ( transportServices1 ) ;
300352 const token = ( await transportServices1 . files . createTokenForFile ( { fileId : file . id } ) ) . value ;
0 commit comments