/**
* SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { createLocalVue, shallowMount } from '@vue/test-utils'
import { cloneDeep } from 'lodash'
import Vuex from 'vuex'
import HandBackLeft from 'vue-material-design-icons/HandBackLeft.vue'
import Microphone from 'vue-material-design-icons/Microphone.vue'
import Phone from 'vue-material-design-icons/Phone.vue'
import VideoIcon from 'vue-material-design-icons/Video.vue'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActionText from '@nextcloud/vue/dist/Components/NcActionText.js'
import Participant from './Participant.vue'
import AvatarWrapper from '../../AvatarWrapper/AvatarWrapper.vue'
import { ATTENDEE, PARTICIPANT } from '../../../constants.js'
import storeConfig from '../../../store/storeConfig.js'
import { findNcActionButton } from '../../../test-helpers.js'
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.at(-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<