Merge pull request #6612 from nextcloud/bugfix/6610/correctly-populate-the-modal-with-default-permissions

Correctly populate the modal with default permissions
This commit is contained in:
Joas Schilling 2021-11-25 11:52:49 +01:00 коммит произвёл GitHub
Родитель 63ea703b45 6172d1d4c5
Коммит 2a6abc446d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 37 добавлений и 8 удалений

Просмотреть файл

@ -147,6 +147,15 @@ export default {
})
} else throw Error('you need to fill either the conversationName or the displayName props')
},
permissionsWithDefault() {
if (this.permissions !== PERMISSIONS.DEFAULT) {
return this.permissions
}
return PERMISSIONS.MAX_DEFAULT & ~PERMISSIONS.LOBBY_IGNORE
},
/**
* The number of the edited permissions during the editing of the form.
* We use this to compare it with the actual permissions of the
@ -167,12 +176,16 @@ export default {
* disabled.
*/
submitButtonDisabled() {
return this.permissions === this.formPermissions
return (!!(this.permissionsWithDefault & PERMISSIONS.CALL_START)) === this.callStart
&& !!(this.permissionsWithDefault & PERMISSIONS.LOBBY_IGNORE) === this.lobbyIgnore
&& !!(this.permissionsWithDefault & PERMISSIONS.PUBLISH_AUDIO) === this.publishAudio
&& !!(this.permissionsWithDefault & PERMISSIONS.PUBLISH_VIDEO) === this.publishVideo
&& !!(this.permissionsWithDefault & PERMISSIONS.PUBLISH_SCREEN) === this.publishScreen
},
},
mounted() {
this.writePermissionsToComponent(this.permissions)
this.writePermissionsToComponent(this.permissionsWithDefault)
},
methods: {

Просмотреть файл

@ -26,7 +26,8 @@ describe('ParticipantPermissionsEditor.vue', () => {
participantType: PARTICIPANT.TYPE.USER,
attendeePermissions: PARTICIPANT.PERMISSIONS.CALL_START
| PARTICIPANT.PERMISSIONS.PUBLISH_AUDIO
| PARTICIPANT.PERMISSIONS.PUBLISH_VIDEO,
| PARTICIPANT.PERMISSIONS.PUBLISH_VIDEO
| PARTICIPANT.PERMISSIONS.CUSTOM,
attendeeId: 'alice-attendee-id',
status: '',
statusIcon: '🌧️',
@ -95,15 +96,30 @@ describe('ParticipantPermissionsEditor.vue', () => {
const publishScreenCheckbox = wrapper.findComponent(PermissionsEditor).findComponent({ ref: 'publishScreen' })
expect(publishScreenCheckbox.vm.$options.propsData.checked).toBe(false)
})
test('Properly renders the checkboxes with default permissions', async () => {
participant.attendeePermissions = PARTICIPANT.PERMISSIONS.DEFAULT
const wrapper = await mountParticipantPermissionsEditor(participant)
const callStartCheckbox = wrapper.findComponent(PermissionsEditor).findComponent({ ref: 'callStart' })
expect(callStartCheckbox.vm.$options.propsData.checked).toBe(true)
const lobbyIgnoreCheckbox = wrapper.findComponent(PermissionsEditor).findComponent({ ref: 'lobbyIgnore' })
expect(lobbyIgnoreCheckbox.vm.$options.propsData.checked).toBe(false)
const publishAudioCheckbox = wrapper.findComponent(PermissionsEditor).findComponent({ ref: 'publishAudio' })
expect(publishAudioCheckbox.vm.$options.propsData.checked).toBe(true)
const publishVideoCheckbox = wrapper.findComponent(PermissionsEditor).findComponent({ ref: 'publishVideo' })
expect(publishVideoCheckbox.vm.$options.propsData.checked).toBe(true)
const publishScreenCheckbox = wrapper.findComponent(PermissionsEditor).findComponent({ ref: 'publishScreen' })
expect(publishScreenCheckbox.vm.$options.propsData.checked).toBe(true)
})
})
describe('Dispatches the aciton to set the right permissions', async () => {
describe('Dispatches the action to set the right permissions', async () => {
test('Dispatches setPermissions with the correct permissions value when a permission is subtracted', async () => {
test('Dispatches setPermissions with the correct permissions value when a permission is added', async () => {
const wrapper = await mountParticipantPermissionsEditor(participant)
// Add a permission
wrapper.findComponent(PermissionsEditor).setData({ lobbyIgnore: true })
await wrapper.findComponent(PermissionsEditor).setData({ lobbyIgnore: true })
// Click the submit button
await wrapper.findComponent(PermissionsEditor).find({ ref: 'submit' }).trigger('click')
@ -121,11 +137,11 @@ describe('ParticipantPermissionsEditor.vue', () => {
)
})
test('Dispatches setPermissions with the correct permissions value when a permission is added', async () => {
test('Dispatches setPermissions with the correct permissions value when a permission is substracted', async () => {
const wrapper = mountParticipantPermissionsEditor(participant)
// Remove a permission
wrapper.findComponent(PermissionsEditor).setData({ publishAudio: false })
await wrapper.findComponent(PermissionsEditor).setData({ publishAudio: false })
// Click the submit button
await wrapper.findComponent(PermissionsEditor).find({ ref: 'submit' }).trigger('click')