Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Participant.spec.js « Participant « ParticipantsList « Participants « RightSidebar « components « src - github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 40ad1018d913c047c6ae17e7249db8520cbe2560 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
import Vuex from 'vuex'
import { createLocalVue, shallowMount } from '@vue/test-utils'
import { cloneDeep } from 'lodash'
import storeConfig from '../../../../../store/storeConfig'
import { ATTENDEE, PARTICIPANT } from '../../../../../constants'
import AvatarWrapper from '../../../../AvatarWrapper/AvatarWrapper'
import Microphone from 'vue-material-design-icons/Microphone'
import Phone from 'vue-material-design-icons/Phone'
import Video from 'vue-material-design-icons/Video'
import HandBackLeft from 'vue-material-design-icons/HandBackLeft'
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
import ActionText from '@nextcloud/vue/dist/Components/ActionText'
import { findActionButton } from '../../../../../test-helpers'

import Participant from './Participant'

describe('Participant.vue', () => {
	let conversation
	let participant
	let store
	let localVue
	let testStoreConfig
	let tooltipMock

	/**
	 * @param {object} wrapper Wrapper where the tooltip is mounted in
	 * @param {HTMLElement} htmlEl Tooltip to find
	 */
	async function getLastTooltipValue(wrapper, htmlEl) {
		tooltipMock.mockClear()
		await wrapper.vm.forceEnableTooltips()

		const filteredCalls = tooltipMock.mock.calls.filter((call) => {
			// only keep calls on wanted node
			return call[0] === htmlEl
		})

		if (filteredCalls.length) {
			return filteredCalls[filteredCalls.length - 1][1].value
		}

		return null
	}

	beforeEach(() => {
		localVue = createLocalVue()
		localVue.use(Vuex)

		tooltipMock = jest.fn()

		participant = {
			displayName: 'Alice',
			inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
			actorId: 'alice-actor-id',
			actorType: ATTENDEE.ACTOR_TYPE.USERS,
			participantType: PARTICIPANT.TYPE.USER,
			permissions: PARTICIPANT.PERMISSIONS.CALL_START
				| PARTICIPANT.PERMISSIONS.PUBLISH_AUDIO
				| PARTICIPANT.PERMISSIONS.PUBLISH_VIDEO,
			attendeeId: 'alice-attendee-id',
			status: '',
			statusIcon: '🌧️',
			statusMessage: 'rainy',
			sessionIds: [
				'session-id-alice',
			],
		}

		conversation = {
			token: 'current-token',
			participantType: PARTICIPANT.TYPE.USER,
		}

		const conversationGetterMock = jest.fn().mockReturnValue(conversation)

		testStoreConfig = cloneDeep(storeConfig)
		testStoreConfig.modules.tokenStore.getters.getToken = () => () => 'current-token'
		testStoreConfig.modules.conversationsStore.getters.conversation = () => conversationGetterMock
		store = new Vuex.Store(testStoreConfig)
	})

	afterEach(() => {
		jest.clearAllMocks()
	})

	/**
	 * @param {object} participant Participant with optional user status data
	 * @param {boolean} showUserStatus Whether or not the user status should be shown
	 */
	function mountParticipant(participant, showUserStatus = false) {
		return shallowMount(Participant, {
			localVue,
			store,
			propsData: {
				participant,
				showUserStatus,
			},
			stubs: {
				ActionButton,
			},
			directives: {
				tooltip: tooltipMock,
			},
			mixins: [{
				// force tooltip display for testing
				methods: {
					forceEnableTooltips() {
						this.isUserNameTooltipVisible = true
						this.isStatusTooltipVisible = true
					},
				},
			}],
		})
	}

	describe('avatar', () => {
		test('renders avatar', () => {
			const wrapper = mountParticipant(participant)
			const avatarEl = wrapper.findComponent(AvatarWrapper)
			expect(avatarEl.exists()).toBe(true)

			expect(avatarEl.props('id')).toBe('alice-actor-id')
			expect(avatarEl.props('disableTooltip')).toBe(true)
			expect(avatarEl.props('disableMenu')).toBe(false)
			expect(avatarEl.props('showUserStatus')).toBe(false)
			expect(avatarEl.props('preloadedUserStatus')).toStrictEqual({
				icon: '🌧️',
				message: 'rainy',
				status: null,
			})
			expect(avatarEl.props('name')).toBe('Alice')
			expect(avatarEl.props('source')).toBe(ATTENDEE.ACTOR_TYPE.USERS)
			expect(avatarEl.props('offline')).toBe(false)
		})

		test('renders avatar with enabled status', () => {
			const wrapper = mountParticipant(participant, true)
			const avatarEl = wrapper.findComponent(AvatarWrapper)
			expect(avatarEl.exists()).toBe(true)

			expect(avatarEl.props('showUserStatus')).toBe(true)
		})

		test('renders avatar with guest name when empty', () => {
			participant.displayName = ''
			participant.participantType = PARTICIPANT.TYPE.GUEST
			const wrapper = mountParticipant(participant)
			const avatarEl = wrapper.findComponent(AvatarWrapper)
			expect(avatarEl.exists()).toBe(true)

			expect(avatarEl.props('name')).toBe('Guest')
		})

		test('renders avatar with unknown name when empty', () => {
			participant.displayName = ''
			const wrapper = mountParticipant(participant, true)
			const avatarEl = wrapper.findComponent(AvatarWrapper)
			expect(avatarEl.exists()).toBe(true)

			expect(avatarEl.props('name')).toBe('Deleted user')
		})

		test('renders offline avatar when no sessions exist', () => {
			participant.sessionIds = []
			const wrapper = mountParticipant(participant, true)
			const avatarEl = wrapper.findComponent(AvatarWrapper)
			expect(avatarEl.exists()).toBe(true)

			expect(avatarEl.props('offline')).toBe(true)
		})

		test('renders avatar from search result', () => {
			participant.label = 'Name from label'
			participant.source = 'source-from-search'
			participant.id = 'id-from-search'
			const wrapper = mountParticipant(participant, true)
			const avatarEl = wrapper.findComponent(AvatarWrapper)
			expect(avatarEl.exists()).toBe(true)

			expect(avatarEl.props('id')).toBe('id-from-search')
			expect(avatarEl.props('name')).toBe('Name from label')
			expect(avatarEl.props('source')).toBe('source-from-search')
		})
	})

	describe('user name', () => {
		/**
		 * @param {object} wrapper Wrapper where the tooltip is mounted in
		 */
		async function getUserTooltip(wrapper) {
			const tooltipEl = wrapper.find('.participant-row__user-name').element
			return getLastTooltipValue(wrapper, tooltipEl)
		}

		beforeEach(() => {
			participant.statusIcon = ''
			participant.statusMessage = ''
		})

		test('renders plain user name for regular user', async () => {
			const wrapper = mountParticipant(participant)
			expect(wrapper.text()).toBe('Alice')
			expect(await getUserTooltip(wrapper)).toBe('Alice')
		})

		test('renders guest suffix for guests', async () => {
			participant.participantType = PARTICIPANT.TYPE.GUEST
			const wrapper = mountParticipant(participant)
			expect(wrapper.text()).toStrictEqual(expect.stringMatching(/^Alice\s+\(guest\)$/))
			expect(await getUserTooltip(wrapper)).toBe('Alice (guest)')
		})

		test('renders moderator suffix for moderators', async () => {
			participant.participantType = PARTICIPANT.TYPE.MODERATOR
			const wrapper = mountParticipant(participant)
			expect(wrapper.text()).toStrictEqual(expect.stringMatching(/^Alice\s+\(moderator\)$/))
			expect(await getUserTooltip(wrapper)).toBe('Alice (moderator)')
		})

		test('renders guest moderator suffix for guest moderators', async () => {
			participant.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
			const wrapper = mountParticipant(participant)
			expect(wrapper.text()).toStrictEqual(expect.stringMatching(/^Alice\s+\(moderator\)\s+\(guest\)$/))
			expect(await getUserTooltip(wrapper)).toBe('Alice (moderator) (guest)')
		})

		test('renders bot suffix for bots', async () => {
			participant.actorType = ATTENDEE.ACTOR_TYPE.USERS
			participant.actorId = ATTENDEE.BRIDGE_BOT_ID
			const wrapper = mountParticipant(participant)
			expect(wrapper.text()).toStrictEqual(expect.stringMatching(/^Alice\s+\(bot\)$/))
			expect(await getUserTooltip(wrapper)).toBe('Alice (bot)')
		})
	})

	describe('user status', () => {
		/**
		 * @param {object} wrapper Wrapper where the tooltip is mounted in
		 */
		async function getStatusTooltip(wrapper) {
			const tooltipEl = wrapper.find('.participant-row__status>span').element
			return getLastTooltipValue(wrapper, tooltipEl)
		}

		test('renders user status', async () => {
			const wrapper = mountParticipant(participant)
			expect(wrapper.find('.participant-row__status').text()).toBe('🌧️ rainy')
			expect(await getStatusTooltip(wrapper)).toBe('🌧️ rainy')
		})

		test('does not render user status when not set', () => {
			participant.statusIcon = ''
			participant.statusMessage = ''
			const wrapper = mountParticipant(participant)
			expect(wrapper.find('.participant-row__status').exists()).toBe(false)
		})

		test('renders dnd status', async () => {
			participant.statusMessage = ''
			participant.status = 'dnd'
			const wrapper = mountParticipant(participant)
			expect(wrapper.find('.participant-row__status').text()).toBe('🌧️ Do not disturb')
			expect(await getStatusTooltip(wrapper)).toBe('🌧️ Do not disturb')
		})

		test('renders away status', async () => {
			participant.statusMessage = ''
			participant.status = 'away'
			const wrapper = mountParticipant(participant)
			expect(wrapper.find('.participant-row__status').text()).toBe('🌧️ Away')
			expect(await getStatusTooltip(wrapper)).toBe('🌧️ Away')
		})
	})

	describe('call icons', () => {
		let getParticipantRaisedHandMock

		/**
		 * @param {object} wrapper Wrapper where the tooltip is mounted in
		 */
		async function getCallIconTooltip(wrapper) {
			const tooltipEl = wrapper.find('.participant-row__callstate-icon').element
			return getLastTooltipValue(wrapper, tooltipEl)
		}

		beforeEach(() => {
			getParticipantRaisedHandMock = jest.fn().mockReturnValue({ state: false })

			testStoreConfig = cloneDeep(storeConfig)
			testStoreConfig.modules.callViewStore.getters.getParticipantRaisedHand = () => getParticipantRaisedHandMock
			store = new Vuex.Store(testStoreConfig)
		})
		test('does not renders call icon when disconnected', () => {
			participant.inCall = PARTICIPANT.CALL_FLAG.DISCONNECTED
			const wrapper = mountParticipant(participant)
			expect(wrapper.findComponent(Video).exists()).toBe(false)
			expect(wrapper.findComponent(Phone).exists()).toBe(false)
			expect(wrapper.findComponent(Microphone).exists()).toBe(false)
			expect(wrapper.findComponent(HandBackLeft).exists()).toBe(false)
		})
		test('renders video call icon', async () => {
			participant.inCall = PARTICIPANT.CALL_FLAG.WITH_VIDEO
			const wrapper = mountParticipant(participant)
			expect(wrapper.findComponent(Video).exists()).toBe(true)
			expect(wrapper.findComponent(Phone).exists()).toBe(false)
			expect(wrapper.findComponent(Microphone).exists()).toBe(false)
			expect(wrapper.findComponent(HandBackLeft).exists()).toBe(false)

			expect(await getCallIconTooltip(wrapper)).toBe('Joined with video')
		})
		test('renders audio call icon', async () => {
			participant.inCall = PARTICIPANT.CALL_FLAG.WITH_AUDIO
			const wrapper = mountParticipant(participant)
			expect(wrapper.findComponent(Video).exists()).toBe(false)
			expect(wrapper.findComponent(Phone).exists()).toBe(false)
			expect(wrapper.findComponent(Microphone).exists()).toBe(true)
			expect(wrapper.findComponent(HandBackLeft).exists()).toBe(false)

			expect(await getCallIconTooltip(wrapper)).toBe('Joined with audio')
		})
		test('renders phone call icon', async () => {
			participant.inCall = PARTICIPANT.CALL_FLAG.WITH_PHONE
			const wrapper = mountParticipant(participant)
			expect(wrapper.findComponent(Video).exists()).toBe(false)
			expect(wrapper.findComponent(Phone).exists()).toBe(true)
			expect(wrapper.findComponent(Microphone).exists()).toBe(false)
			expect(wrapper.findComponent(HandBackLeft).exists()).toBe(false)

			expect(await getCallIconTooltip(wrapper)).toBe('Joined via phone')
		})
		test('renders hand raised icon', async () => {
			participant.inCall = PARTICIPANT.CALL_FLAG.WITH_VIDEO
			getParticipantRaisedHandMock = jest.fn().mockReturnValue({ state: true })

			const wrapper = mountParticipant(participant)
			expect(wrapper.findComponent(Video).exists()).toBe(false)
			expect(wrapper.findComponent(Phone).exists()).toBe(false)
			expect(wrapper.findComponent(Microphone).exists()).toBe(false)
			expect(wrapper.findComponent(HandBackLeft).exists()).toBe(true)

			expect(getParticipantRaisedHandMock).toHaveBeenCalledWith(['session-id-alice'])

			expect(await getCallIconTooltip(wrapper)).toBe('Raised their hand')
		})
		test('renders video call icon when joined with multiple', async () => {
			participant.inCall = PARTICIPANT.CALL_FLAG.WITH_VIDEO | PARTICIPANT.CALL_FLAG.WITH_PHONE
			const wrapper = mountParticipant(participant)
			expect(wrapper.findComponent(Video).exists()).toBe(true)
			expect(wrapper.findComponent(Phone).exists()).toBe(false)
			expect(wrapper.findComponent(Microphone).exists()).toBe(false)
			expect(wrapper.findComponent(HandBackLeft).exists()).toBe(false)

			expect(await getCallIconTooltip(wrapper)).toBe('Joined with video')
		})
		test('does not render hand raised icon when disconnected', () => {
			participant.inCall = PARTICIPANT.CALL_FLAG.DISCONNECTED
			getParticipantRaisedHandMock = jest.fn().mockReturnValue({ state: true })

			const wrapper = mountParticipant(participant)
			expect(wrapper.findComponent(HandBackLeft).exists()).toBe(false)

			expect(getParticipantRaisedHandMock).not.toHaveBeenCalled()
		})

		test('does not render hand raised icon when searched', () => {
			participant.inCall = PARTICIPANT.CALL_FLAG.WITH_VIDEO
			participant.label = 'searched result'
			getParticipantRaisedHandMock = jest.fn().mockReturnValue({ state: true })

			const wrapper = mountParticipant(participant)
			expect(wrapper.findComponent(HandBackLeft).exists()).toBe(false)

			expect(getParticipantRaisedHandMock).not.toHaveBeenCalled()
		})
	})

	describe('actions', () => {
		describe('demoting participant', () => {
			let demoteFromModeratorAction

			beforeEach(() => {
				demoteFromModeratorAction = jest.fn()

				testStoreConfig.modules.participantsStore.actions.demoteFromModerator = demoteFromModeratorAction
				store = new Vuex.Store(testStoreConfig)
			})

			/**
			 *
			 */
			async function testCanDemote() {
				const wrapper = mountParticipant(participant)
				const actionButton = findActionButton(wrapper, 'Demote from moderator')
				expect(actionButton.exists()).toBe(true)

				await actionButton.find('button').trigger('click')

				expect(demoteFromModeratorAction).toHaveBeenCalledWith(expect.anything(), {
					token: 'current-token',
					attendeeId: 'alice-attendee-id',
				})
			}

			/**
			 *
			 */
			async function testCannotDemote() {
				const wrapper = mountParticipant(participant)
				const actionButton = findActionButton(wrapper, 'Demote to moderator')
				expect(actionButton.exists()).toBe(false)
			}

			test('allows a moderator to demote a moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.participantType = PARTICIPANT.TYPE.MODERATOR
				await testCanDemote()
			})

			test('allows a moderator to demote a guest moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				await testCanDemote()
			})

			test('allows a guest moderator to demote a moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				participant.participantType = PARTICIPANT.TYPE.MODERATOR
				await testCanDemote()
			})

			test('allows a guest moderator to demote a guest moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				participant.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				await testCanDemote()
			})

			test('does not allow to demote an owner', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.participantType = PARTICIPANT.TYPE.OWNER
				await testCannotDemote()
			})

			test('does not allow demoting groups', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.actorType = ATTENDEE.ACTOR_TYPE.GROUPS
				await testCannotDemote()
			})

			test('does not allow demoting self', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				conversation.sessionId = 'current-session-id'
				participant.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.sessionIds = ['current-session-id', 'another-session-id']
				await testCannotDemote()
			})

			test('does not allow demoting self as guest', async () => {
				conversation.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				conversation.sessionId = 'current-session-id'
				participant.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				participant.sessionIds = ['current-session-id']
				await testCannotDemote()
			})

			test('does not allow a non-moderator to demote', async () => {
				conversation.participantType = PARTICIPANT.TYPE.USER
				await testCannotDemote()
			})
		})
		describe('promoting participant', () => {
			let promoteToModeratorAction

			beforeEach(() => {
				promoteToModeratorAction = jest.fn()

				testStoreConfig.modules.participantsStore.actions.promoteToModerator = promoteToModeratorAction
				store = new Vuex.Store(testStoreConfig)
			})

			/**
			 *
			 */
			async function testCanPromote() {
				const wrapper = mountParticipant(participant)
				const actionButton = findActionButton(wrapper, 'Promote to moderator')
				expect(actionButton.exists()).toBe(true)

				await actionButton.find('button').trigger('click')

				expect(promoteToModeratorAction).toHaveBeenCalledWith(expect.anything(), {
					token: 'current-token',
					attendeeId: 'alice-attendee-id',
				})
			}

			/**
			 *
			 */
			async function testCannotPromote() {
				const wrapper = mountParticipant(participant)
				const actionButton = findActionButton(wrapper, 'Promote to moderator')
				expect(actionButton.exists()).toBe(false)
			}

			test('allows a moderator to promote a user to moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				await testCanPromote()
			})

			test('allows a moderator to promote a self-joined user to moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.participantType = PARTICIPANT.TYPE.USER_SELF_JOINED
				await testCanPromote()
			})

			test('allows a moderator to promote a guest to moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.participantType = PARTICIPANT.TYPE.GUEST
				await testCanPromote()
			})

			test('allows a guest moderator to promote a user to moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				await testCanPromote()
			})

			test('allows a guest moderator to promote a guest to moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				participant.participantType = PARTICIPANT.TYPE.GUEST
				await testCanPromote()
			})

			test('does not allow to promote a moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.participantType = PARTICIPANT.TYPE.MODERATOR
				await testCannotPromote()
			})

			test('does not allow to promote a guest moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				await testCannotPromote()
			})

			test('does not allow promoting groups', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.actorType = ATTENDEE.ACTOR_TYPE.GROUPS
				await testCannotPromote()
			})

			test('does not allow promoting the bridge bot', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.actorType = ATTENDEE.ACTOR_TYPE.USERS
				participant.actorId = ATTENDEE.BRIDGE_BOT_ID
				await testCannotPromote()
			})

			test('does not allow a non-moderator to promote', async () => {
				conversation.participantType = PARTICIPANT.TYPE.USER
				await testCannotPromote()
			})
		})
		describe('resending invitations', () => {
			let resendInvitationsAction

			beforeEach(() => {
				resendInvitationsAction = jest.fn()

				testStoreConfig.modules.participantsStore.actions.resendInvitations = resendInvitationsAction
				store = new Vuex.Store(testStoreConfig)
			})

			test('allows moderators to resend invitations for email participants', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.actorType = ATTENDEE.ACTOR_TYPE.EMAILS
				const wrapper = mountParticipant(participant)
				const actionButton = findActionButton(wrapper, 'Resend invitation')
				expect(actionButton.exists()).toBe(true)

				await actionButton.find('button').trigger('click')

				expect(resendInvitationsAction).toHaveBeenCalledWith(expect.anything(), {
					token: 'current-token',
					attendeeId: 'alice-attendee-id',
				})
			})

			test('does not allow non-moderators to resend invitations', async () => {
				participant.actorType = ATTENDEE.ACTOR_TYPE.EMAILS
				const wrapper = mountParticipant(participant)
				const actionButton = findActionButton(wrapper, 'Resend invitation')
				expect(actionButton.exists()).toBe(false)
			})

			test('does not display resend invitations action when not an email actor', async () => {
				participant.actorType = ATTENDEE.ACTOR_TYPE.USERS
				const wrapper = mountParticipant(participant)
				const actionButton = findActionButton(wrapper, 'Resend invitation')
				expect(actionButton.exists()).toBe(false)
			})
		})
		describe('removing participant', () => {
			let removeAction

			beforeEach(() => {
				removeAction = jest.fn()

				testStoreConfig.modules.participantsStore.actions.removeParticipant = removeAction
				store = new Vuex.Store(testStoreConfig)
			})

			/**
			 * @param {string} buttonText Label of the remove action to find
			 */
			async function testCanRemove(buttonText = 'Remove participant') {
				const wrapper = mountParticipant(participant)
				const actionButton = findActionButton(wrapper, buttonText)
				expect(actionButton.exists()).toBe(true)

				await actionButton.find('button').trigger('click')

				expect(removeAction).toHaveBeenCalledWith(expect.anything(), {
					token: 'current-token',
					attendeeId: 'alice-attendee-id',
				})
			}

			/**
			 *
			 */
			async function testCannotRemove() {
				const wrapper = mountParticipant(participant)
				const actionButton = findActionButton(wrapper, 'Remove participant')
				expect(actionButton.exists()).toBe(false)
			}

			test('allows a moderator to remove a moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.participantType = PARTICIPANT.TYPE.MODERATOR
				await testCanRemove()
			})

			test('allows a moderator to remove a guest moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				await testCanRemove()
			})

			test('allows a guest moderator to remove a moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				participant.participantType = PARTICIPANT.TYPE.MODERATOR
				await testCanRemove()
			})

			test('allows a guest moderator to remove a guest moderator', async () => {
				conversation.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				participant.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				await testCanRemove()
			})

			test('allows a moderator to remove groups', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.actorType = ATTENDEE.ACTOR_TYPE.GROUPS
				await testCanRemove('Remove group and members')
			})

			test('does not allow to remove an owner', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.participantType = PARTICIPANT.TYPE.OWNER
				await testCannotRemove()
			})

			test('does not allow removing self', async () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				conversation.sessionId = 'current-session-id'
				participant.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.sessionIds = ['current-session-id']
				await testCannotRemove()
			})

			test('does not allow removing self as guest', async () => {
				conversation.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				conversation.sessionId = 'current-session-id'
				participant.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				participant.sessionIds = ['current-session-id']
				await testCannotRemove()
			})

			test('does not allow a non-moderator to remove', async () => {
				conversation.participantType = PARTICIPANT.TYPE.USER
				await testCannotRemove()
			})
		})
		describe('dial-in PIN', () => {
			/**
			 *
			 */
			function testPinVisible() {
				const wrapper = mountParticipant(participant)
				let actionTexts = wrapper.findAllComponents(ActionText)
				actionTexts = actionTexts.filter((actionText) => {
					return actionText.props('title').indexOf('PIN') >= 0
				})

				expect(actionTexts.exists()).toBe(true)
				expect(actionTexts.at(0).text()).toBe('123 456 78')
			}

			test('allows moderators to see dial-in PIN when available', () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.attendeePin = '12345678'
				testPinVisible()
			})

			test('allows guest moderators to see dial-in PIN when available', () => {
				conversation.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR
				participant.attendeePin = '12345678'
				testPinVisible()
			})

			test('does not allow non-moderators to see dial-in PIN', () => {
				conversation.participantType = PARTICIPANT.TYPE.USER
				participant.attendeePin = '12345678'
				const wrapper = mountParticipant(participant)
				let actionTexts = wrapper.findAllComponents(ActionText)
				actionTexts = actionTexts.filter((actionText) => {
					return actionText.props('title').indexOf('PIN') >= 0
				})

				expect(actionTexts.exists()).toBe(false)
			})

			test('does not show PIN field when not set', () => {
				conversation.participantType = PARTICIPANT.TYPE.MODERATOR
				participant.attendeePin = ''
				const wrapper = mountParticipant(participant)
				let actionTexts = wrapper.findAllComponents(ActionText)
				actionTexts = actionTexts.filter((actionText) => {
					return actionText.props('title').indexOf('PIN') >= 0
				})

				expect(actionTexts.exists()).toBe(false)
			})
		})
	})

	describe('as search result', () => {
		beforeEach(() => {
			participant.label = 'Alice Search'
			participant.source = 'users'
		})

		test('does not show actions for search results', () => {
			const wrapper = mountParticipant(participant)

			// no actions
			expect(wrapper.findAllComponents(ActionButton).exists()).toBe(false)
		})

		test('triggers event when clicking', async () => {
			const eventHandler = jest.fn()
			const wrapper = mountParticipant(participant)
			wrapper.vm.$on('click-participant', eventHandler)

			await wrapper.find('li').trigger('click')

			expect(eventHandler).toHaveBeenCalledWith(participant)
		})

		test('does not trigger click event when not a search result', async () => {
			const eventHandler = jest.fn()
			delete participant.label
			delete participant.source
			const wrapper = mountParticipant(participant)
			wrapper.vm.$on('click-participant', eventHandler)

			await wrapper.find('li').trigger('click')

			expect(eventHandler).not.toHaveBeenCalledWith(participant)
		})
	})

})