cozy-sharing 28.5.0 → 28.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/SharingProvider.js +186 -87
- package/dist/SharingProvider.spec.js +152 -0
- package/dist/components/Recipient/LinkRecipient.js +27 -8
- package/dist/components/Recipient/LinkRecipient.stories.js +0 -1
- package/dist/components/Recipient/LinkRecipientPermissions.js +62 -15
- package/dist/components/Recipient/MemberRecipient.spec.js +13 -0
- package/dist/components/Recipient/MemberRecipientPermissions.js +80 -20
- package/dist/components/Recipient/MemberRecipientPermissions.spec.js +214 -0
- package/dist/components/Recipient/actions/revokeLink.js +34 -0
- package/dist/components/Recipient/actions/setReadOnlySharedPermission.js +0 -1
- package/dist/components/Recipient/actions/setReadOnlySharedPermission.spec.js +72 -0
- package/dist/components/Recipient/actions/setReadWriteSharedPermission.js +0 -1
- package/dist/components/Recipient/actions/setReadWriteSharedPermission.spec.js +72 -0
- package/dist/components/ShareDialogCozyToCozy.spec.js +9 -0
- package/dist/components/WhoHasAccess.js +0 -1
- package/locales/en.json +4 -1
- package/locales/fr.json +4 -1
- package/locales/ru.json +4 -1
- package/locales/vi.json +4 -1
- package/package.json +2 -2
- package/src/SharingProvider.jsx +52 -1
- package/src/SharingProvider.spec.jsx +94 -0
- package/src/components/Recipient/LinkRecipient.jsx +30 -7
- package/src/components/Recipient/LinkRecipient.stories.jsx +0 -1
- package/src/components/Recipient/LinkRecipientPermissions.jsx +54 -16
- package/src/components/Recipient/MemberRecipient.spec.jsx +11 -0
- package/src/components/Recipient/MemberRecipientPermissions.jsx +69 -16
- package/src/components/Recipient/MemberRecipientPermissions.spec.jsx +165 -0
- package/src/components/Recipient/actions/revokeLink.js +33 -0
- package/src/components/Recipient/actions/setReadOnlySharedPermission.js +1 -1
- package/src/components/Recipient/actions/setReadOnlySharedPermission.spec.jsx +95 -0
- package/src/components/Recipient/actions/setReadWriteSharedPermission.js +1 -1
- package/src/components/Recipient/actions/setReadWriteSharedPermission.spec.jsx +95 -0
- package/src/components/ShareDialogCozyToCozy.spec.jsx +6 -0
- package/src/components/WhoHasAccess.jsx +0 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from '@testing-library/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { setReadWriteSharedPermission } from './setReadWriteSharedPermission'
|
|
5
|
+
import AppLike from '../../../../test/AppLike'
|
|
6
|
+
|
|
7
|
+
const mockT = key => {
|
|
8
|
+
const translations = {
|
|
9
|
+
'Share.type.one-way': 'Can view',
|
|
10
|
+
'Share.type.two-way': 'Can change'
|
|
11
|
+
}
|
|
12
|
+
return translations[key] || key
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe('setReadWriteSharedPermission', () => {
|
|
16
|
+
let setType
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
setType = jest.fn()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('should return correct action structure', () => {
|
|
23
|
+
const action = setReadWriteSharedPermission({
|
|
24
|
+
t: mockT,
|
|
25
|
+
type: 'two-way',
|
|
26
|
+
setType
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
expect(action.name).toBe('setReadWriteSharedPermission')
|
|
30
|
+
expect(action.label).toBe('Can change')
|
|
31
|
+
expect(action.icon).toBeNull()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('should call setType with two-way when action is triggered', () => {
|
|
35
|
+
const action = setReadWriteSharedPermission({
|
|
36
|
+
t: mockT,
|
|
37
|
+
type: 'one-way',
|
|
38
|
+
setType
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
action.action()
|
|
42
|
+
|
|
43
|
+
expect(setType).toHaveBeenCalledWith('two-way')
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('should render radio as checked when type is two-way', () => {
|
|
47
|
+
const { Component } = setReadWriteSharedPermission({
|
|
48
|
+
t: mockT,
|
|
49
|
+
type: 'two-way',
|
|
50
|
+
setType
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
render(
|
|
54
|
+
<AppLike>
|
|
55
|
+
<Component />
|
|
56
|
+
</AppLike>
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
expect(screen.getByRole('radio')).toBeChecked()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('should render radio as unchecked when type is one-way', () => {
|
|
63
|
+
const { Component } = setReadWriteSharedPermission({
|
|
64
|
+
t: mockT,
|
|
65
|
+
type: 'one-way',
|
|
66
|
+
setType
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
render(
|
|
70
|
+
<AppLike>
|
|
71
|
+
<Component />
|
|
72
|
+
</AppLike>
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
expect(screen.getByRole('radio')).not.toBeChecked()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('should call setType with two-way when the component is clicked', () => {
|
|
79
|
+
const { Component } = setReadWriteSharedPermission({
|
|
80
|
+
t: mockT,
|
|
81
|
+
type: 'one-way',
|
|
82
|
+
setType
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
render(
|
|
86
|
+
<AppLike>
|
|
87
|
+
<Component />
|
|
88
|
+
</AppLike>
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
fireEvent.click(screen.getByText('Can change'))
|
|
92
|
+
|
|
93
|
+
expect(setType).toHaveBeenCalledWith('two-way')
|
|
94
|
+
})
|
|
95
|
+
})
|
|
@@ -14,6 +14,12 @@ jest.mock('cozy-client', () => ({
|
|
|
14
14
|
useClient: () => ({ options: { uri: mockRecipientAlice.instance } })
|
|
15
15
|
}))
|
|
16
16
|
|
|
17
|
+
jest.mock('../hooks/useSharingContext', () => ({
|
|
18
|
+
useSharingContext: () => ({
|
|
19
|
+
updateSharingMemberType: jest.fn()
|
|
20
|
+
})
|
|
21
|
+
}))
|
|
22
|
+
|
|
17
23
|
describe('ShareDialogCozyToCozy', () => {
|
|
18
24
|
const client = createMockClient({})
|
|
19
25
|
client.options = {
|