@@ -3,10 +3,52 @@ import { Resource, SpaceResource } from '@ownclouders/web-client'
3
3
import { getIndicators } from '../../../src/helpers/statusIndicators'
4
4
import { User } from '@ownclouders/web-client/graph/generated'
5
5
import { AncestorMetaDataValue } from '../../../src/types'
6
+ import { ResourceIndicator } from '../../../src/helpers'
7
+ import { createTestingPinia } from '@ownclouders/web-test-helpers'
8
+ import {
9
+ ResourceIndicatorExtension ,
10
+ useExtensionRegistry
11
+ } from '../../../src/composables/piniaStores/extensionRegistry'
6
12
7
13
describe ( 'status indicators' , ( ) => {
8
14
const user = mock < User > ( )
9
15
16
+ createTestingPinia ( )
17
+
18
+ describe ( 'indicator extensions' , ( ) => {
19
+ it ( 'should be requested from the extension registry' , ( ) => {
20
+ const space = mock < SpaceResource > ( { driveType : 'project' } )
21
+ const resource = mock < Resource > ( { id : 'resource' } )
22
+
23
+ const { requestExtensions } = useExtensionRegistry ( )
24
+ vi . mocked ( requestExtensions < ResourceIndicatorExtension > ) . mockReturnValue ( [
25
+ {
26
+ id : 'test.files.resource-indicator.stub' ,
27
+ type : 'resourceIndicator' ,
28
+ extensionPointIds : [ 'global.files.resource-indicator' ] ,
29
+ getResourceIndicators : ( resource : Resource ) : ResourceIndicator [ ] => {
30
+ return [
31
+ {
32
+ id : 'some-id' ,
33
+ accessibleDescription : 'some accessible description' ,
34
+ label : 'some label' ,
35
+ icon : 'check_box_outline_blank' ,
36
+ fillType : 'line' ,
37
+ type : 'some-type' ,
38
+ category : 'system'
39
+ }
40
+ ]
41
+ }
42
+ } satisfies ResourceIndicatorExtension
43
+ ] )
44
+
45
+ const indicators = getIndicators ( { space, resource, ancestorMetaData : { } , user } )
46
+
47
+ expect ( requestExtensions ) . toHaveBeenCalled ( )
48
+ expect ( indicators . some ( ( { id } ) => id === 'some-id' ) ) . toBeTruthy ( )
49
+ } )
50
+ } )
51
+
10
52
describe ( 'locked indicator' , ( ) => {
11
53
it . each ( [ true , false ] ) ( 'should only be present if the file is locked' , ( locked ) => {
12
54
const space = mock < SpaceResource > ( { id : 'space' } )
0 commit comments