diff options
author | Joas Schilling <coding@schilljs.com> | 2021-08-23 16:47:50 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-08-23 16:47:50 +0300 |
commit | 228aeb4dd17c89b6698b6d28aea91873147df55c (patch) | |
tree | 0287f2555a4a911bce74e369ff37dc3f4179dc39 /src/store | |
parent | 4891e8017f4d4e837a7cde52c164abc61c1a72a7 (diff) |
Autofixes
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/actorStore.js | 1 | ||||
-rw-r--r-- | src/store/callViewStore.spec.js | 4 | ||||
-rw-r--r-- | src/store/conversationsStore.js | 10 | ||||
-rw-r--r-- | src/store/conversationsStore.spec.js | 40 | ||||
-rw-r--r-- | src/store/fileUploadStore.js | 21 | ||||
-rw-r--r-- | src/store/fileUploadStore.spec.js | 16 | ||||
-rw-r--r-- | src/store/guestNameStore.js | 4 | ||||
-rw-r--r-- | src/store/messagesStore.js | 45 | ||||
-rw-r--r-- | src/store/messagesStore.spec.js | 100 | ||||
-rw-r--r-- | src/store/newGroupConversationStore.js | 8 | ||||
-rw-r--r-- | src/store/participantsStore.js | 20 | ||||
-rw-r--r-- | src/store/participantsStore.spec.js | 44 | ||||
-rw-r--r-- | src/store/sidebarStore.js | 2 | ||||
-rw-r--r-- | src/store/tokenStore.js | 2 |
14 files changed, 210 insertions, 107 deletions
diff --git a/src/store/actorStore.js b/src/store/actorStore.js index 4caace794..a4e72f72f 100644 --- a/src/store/actorStore.js +++ b/src/store/actorStore.js @@ -150,6 +150,7 @@ const actions = { }, /** * Sets displayName only, we currently use this for guests user names. + * * @param {object} context default store context; * @param {string} displayName the display name to be set; */ diff --git a/src/store/callViewStore.spec.js b/src/store/callViewStore.spec.js index 02f333447..c787e865d 100644 --- a/src/store/callViewStore.spec.js +++ b/src/store/callViewStore.spec.js @@ -114,6 +114,10 @@ describe('callViewStore', () => { expect(store.getters.isStripeOpen).toBe(true) }) + /** + * @param conversationType + * @param state + */ function testDefaultGridState(conversationType, state) { localStorage.getItem.mockReturnValueOnce(null) diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js index a4c9f0457..ae59dcc20 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -76,9 +76,10 @@ const getters = { conversationsList: state => Object.values(state.conversations), /** * Get a conversation providing it's token + * * @param {object} state state object - * @returns {function} The callback function - * @returns {object} The conversation object + * @return {Function} The callback function + * @return {object} The conversation object */ conversation: state => token => state.conversations[token], dummyConversation: state => Object.assign({}, DUMMY_CONVERSATION), @@ -96,6 +97,7 @@ const mutations = { }, /** * Deletes a conversation from the store. + * * @param {object} state current store state; * @param {object} token the token of the conversation to delete; */ @@ -104,6 +106,7 @@ const mutations = { }, /** * Resets the store to it's original state + * * @param {object} state current store state; */ purgeConversationsStore(state) { @@ -189,6 +192,7 @@ const actions = { * Delete a conversation from the server. * * @param {object} context default store context; + * @param token.token * @param {object} token the token of the conversation to be deleted; */ async deleteConversationFromServer(context, { token }) { @@ -201,6 +205,7 @@ const actions = { * Delete all the messages from a conversation. * * @param {object} context default store context; + * @param token.token * @param {object} token the token of the conversation whose history is * to be cleared; */ @@ -218,6 +223,7 @@ const actions = { /** * Resets the store to it's original state. + * * @param {object} context default store context; */ purgeConversationsStore(context) { diff --git a/src/store/conversationsStore.spec.js b/src/store/conversationsStore.spec.js index a193c1b8d..770026dae 100644 --- a/src/store/conversationsStore.spec.js +++ b/src/store/conversationsStore.spec.js @@ -187,7 +187,7 @@ describe('conversationsStore', () => { expect(store.getters.conversationsList).toStrictEqual([]) }) - test('deletes conversation from server', async() => { + test('deletes conversation from server', async () => { store.dispatch('addConversation', testConversation) await store.dispatch('deleteConversationFromServer', { token: testToken }) @@ -197,7 +197,7 @@ describe('conversationsStore', () => { expect(store.getters.conversation(testToken)).toBeUndefined() }) - test('fetches a single conversation', async() => { + test('fetches a single conversation', async () => { const response = { data: { ocs: { @@ -219,7 +219,7 @@ describe('conversationsStore', () => { expect(updateTalkVersionHashAction).toHaveBeenCalledWith(expect.anything(), response) }) - test('fetches all conversations and adds them after purging', async() => { + test('fetches all conversations and adds them after purging', async () => { const testConversations = [ { token: 'one_token', @@ -253,7 +253,7 @@ describe('conversationsStore', () => { expect(updateTalkVersionHashAction).toHaveBeenCalledWith(expect.anything(), response) }) - test('fetch conversation failure checks for maintenance mode', async() => { + test('fetch conversation failure checks for maintenance mode', async () => { const response = { status: 503 } fetchConversation.mockRejectedValue({ response }) @@ -262,7 +262,7 @@ describe('conversationsStore', () => { expect(checkMaintenanceModeAction).toHaveBeenCalledWith(expect.anything(), response) }) - test('fetch conversations failure checks for maintenance mode', async() => { + test('fetch conversations failure checks for maintenance mode', async () => { const response = { status: 503 } fetchConversations.mockRejectedValue({ response }) @@ -278,7 +278,7 @@ describe('conversationsStore', () => { store = new Vuex.Store(testStoreConfig) }) - test('make public', async() => { + test('make public', async () => { testConversation.type = CONVERSATION.TYPE.GROUP store.dispatch('addConversation', testConversation) @@ -296,7 +296,7 @@ describe('conversationsStore', () => { expect(changedConversation.type).toEqual(CONVERSATION.TYPE.PUBLIC) }) - test('make non-public', async() => { + test('make non-public', async () => { testConversation.type = CONVERSATION.TYPE.PUBLIC store.dispatch('addConversation', testConversation) @@ -314,7 +314,7 @@ describe('conversationsStore', () => { expect(changedConversation.type).toEqual(CONVERSATION.TYPE.GROUP) }) - test('set favorite', async() => { + test('set favorite', async () => { testConversation.isFavorite = false store.dispatch('addConversation', testConversation) @@ -332,7 +332,7 @@ describe('conversationsStore', () => { expect(changedConversation.isFavorite).toBe(true) }) - test('unset favorite', async() => { + test('unset favorite', async () => { testConversation.isFavorite = true store.dispatch('addConversation', testConversation) @@ -350,7 +350,7 @@ describe('conversationsStore', () => { expect(changedConversation.isFavorite).toBe(false) }) - test('enable lobby', async() => { + test('enable lobby', async () => { testConversation.lobbyState = WEBINAR.LOBBY.NONE store.dispatch('addConversation', testConversation) @@ -368,7 +368,7 @@ describe('conversationsStore', () => { expect(changedConversation.lobbyState).toBe(WEBINAR.LOBBY.NON_MODERATORS) }) - test('disable lobby', async() => { + test('disable lobby', async () => { testConversation.lobbyState = WEBINAR.LOBBY.NON_MODERATORS store.dispatch('addConversation', testConversation) @@ -386,7 +386,7 @@ describe('conversationsStore', () => { expect(changedConversation.lobbyState).toBe(WEBINAR.LOBBY.NONE) }) - test('set conversation name', async() => { + test('set conversation name', async () => { testConversation.displayName = 'initial name' store.dispatch('addConversation', testConversation) @@ -404,7 +404,7 @@ describe('conversationsStore', () => { expect(changedConversation.displayName).toBe('new name') }) - test('set conversation description', async() => { + test('set conversation description', async () => { testConversation.description = 'initial description' store.dispatch('addConversation', testConversation) @@ -422,7 +422,7 @@ describe('conversationsStore', () => { expect(changedConversation.description).toBe('new description') }) - test('enable read-only', async() => { + test('enable read-only', async () => { testConversation.readOnly = CONVERSATION.STATE.READ_WRITE store.dispatch('addConversation', testConversation) @@ -440,7 +440,7 @@ describe('conversationsStore', () => { expect(changedConversation.readOnly).toBe(CONVERSATION.STATE.READ_ONLY) }) - test('disable read-only', async() => { + test('disable read-only', async () => { testConversation.readOnly = CONVERSATION.STATE.READ_ONLY store.dispatch('addConversation', testConversation) @@ -458,7 +458,7 @@ describe('conversationsStore', () => { expect(changedConversation.readOnly).toBe(CONVERSATION.STATE.READ_WRITE) }) - test('set listable flag', async() => { + test('set listable flag', async () => { testConversation.readOnly = CONVERSATION.LISTABLE.NONE store.dispatch('addConversation', testConversation) @@ -476,7 +476,7 @@ describe('conversationsStore', () => { expect(changedConversation.listable).toBe(CONVERSATION.LISTABLE.ALL) }) - test('set lobby timer', async() => { + test('set lobby timer', async () => { testConversation.lobbyState = WEBINAR.LOBBY.NON_MODERATORS testConversation.lobbyTimer = 1200300 @@ -495,7 +495,7 @@ describe('conversationsStore', () => { expect(changedConversation.lobbyTimer).toBe(2300400) }) - test('set SIP enabled', async() => { + test('set SIP enabled', async () => { testConversation.sipEnabled = false store.dispatch('addConversation', testConversation) @@ -513,7 +513,7 @@ describe('conversationsStore', () => { expect(changedConversation.sipEnabled).toBe(true) }) - test('set notification level', async() => { + test('set notification level', async () => { testConversation.notificationLevel = 1 store.dispatch('addConversation', testConversation) @@ -586,7 +586,7 @@ describe('conversationsStore', () => { }) describe('creating conversations', () => { - test('creates one to one conversation', async() => { + test('creates one to one conversation', async () => { const newConversation = { id: 999, token: 'new-token', diff --git a/src/store/fileUploadStore.js b/src/store/fileUploadStore.js index 41583d19b..ca11d271e 100644 --- a/src/store/fileUploadStore.js +++ b/src/store/fileUploadStore.js @@ -189,6 +189,8 @@ const actions = { /** * Initialises uploads and shares files to a conversation * + * @param files.commit + * @param files.dispatch * @param {object} files the files to be processed * @param {string} token the conversation's token where to share the files * @param {number} uploadId a unique id for the upload operation indexing @@ -230,8 +232,12 @@ const actions = { /** * Discards an upload + * * @param {object} param0 Commit and state + * @param param0.commit + * @param param0.state * @param {object} uploadId The unique uploadId + * @param param0.getters */ discardUpload({ commit, state, getters }, uploadId) { if (state.currentUploadId === uploadId) { @@ -243,8 +249,13 @@ const actions = { /** * Uploads the files to the root directory of the user + * * @param {object} param0 Commit, state and getters + * @param param0.commit + * @param param0.dispatch * @param {object} uploadId The unique uploadId + * @param param0.state + * @param param0.getters */ async uploadFiles({ commit, dispatch, state, getters }, uploadId) { if (state.currentUploadId === uploadId) { @@ -354,8 +365,13 @@ const actions = { /** * Mark a file as shared + * * @param {object} context default store context; * @param {object} param1 The unique upload id original file index + * @param context.commit + * @param context.state + * @param param1.uploadId + * @param param1.index * @throws {Error} when the item is already being shared by another async call */ markFileAsSharing({ commit, state }, { uploadId, index }) { @@ -367,8 +383,11 @@ const actions = { /** * Mark a file as shared + * * @param {object} context default store context; * @param {object} param1 The unique upload id original file index + * @param param1.uploadId + * @param param1.index */ markFileAsShared(context, { uploadId, index }) { context.commit('markFileAsShared', { uploadId, index }) @@ -376,7 +395,9 @@ const actions = { /** * Mark a file as shared + * * @param {object} context default store context; + * @param context.commit * @param {string} temporaryMessageId message id of the temporary message associated to the file to remove */ removeFileFromSelection({ commit }, temporaryMessageId) { diff --git a/src/store/fileUploadStore.spec.js b/src/store/fileUploadStore.spec.js index ebcdeaecd..fe065366e 100644 --- a/src/store/fileUploadStore.spec.js +++ b/src/store/fileUploadStore.spec.js @@ -89,7 +89,7 @@ describe('fileUploadStore', () => { restoreConsole() }) - test('initialises upload for given files', async() => { + test('initialises upload for given files', async () => { const files = [ { name: 'pngimage.png', @@ -132,7 +132,7 @@ describe('fileUploadStore', () => { expect(mockedActions.createTemporaryMessage.mock.calls[2][1].localUrl).toBe('icon-url:text/plain') }) - test('performs upload by uploading then sharing', async() => { + test('performs upload by uploading then sharing', async () => { const files = [ { name: 'pngimage.png', @@ -181,7 +181,7 @@ describe('fileUploadStore', () => { expect(store.getters.currentUploadId).not.toBeDefined() }) - test('marks temporary message as failed in case of upload error', async() => { + test('marks temporary message as failed in case of upload error', async () => { const files = [ { name: 'pngimage.png', @@ -218,7 +218,7 @@ describe('fileUploadStore', () => { expect(console.error).toHaveBeenCalled() }) - test('marks temporary message as failed in case of sharing error', async() => { + test('marks temporary message as failed in case of sharing error', async () => { const files = [ { name: 'pngimage.png', @@ -256,7 +256,7 @@ describe('fileUploadStore', () => { expect(console.error).toHaveBeenCalled() }) - test('removes file from selection', async() => { + test('removes file from selection', async () => { const files = [ { name: 'pngimage.png', @@ -287,7 +287,7 @@ describe('fileUploadStore', () => { expect(Object.values(uploads)[0].file).toBe(files[0]) }) - test('discard an entire upload', async() => { + test('discard an entire upload', async () => { const files = [ { name: 'pngimage.png', @@ -317,7 +317,7 @@ describe('fileUploadStore', () => { expect(store.getters.currentUploadId).not.toBeDefined() }) - test('autorenames files using timestamps when requested', async() => { + test('autorenames files using timestamps when requested', async () => { const files = [ { name: 'pngimage.png', @@ -349,7 +349,7 @@ describe('fileUploadStore', () => { }) }) - test('set attachment folder', async() => { + test('set attachment folder', async () => { store = new Vuex.Store(storeConfig) setAttachmentFolder.mockResolvedValue() diff --git a/src/store/guestNameStore.js b/src/store/guestNameStore.js index 53e3ff014..759568649 100644 --- a/src/store/guestNameStore.js +++ b/src/store/guestNameStore.js @@ -29,8 +29,9 @@ const state = { const getters = { /** * Gets the participants array + * * @param {object} state the state object. - * @returns {array} the participants array (if there are participants in the store) + * @return {Array} the participants array (if there are participants in the store) */ getGuestName: (state) => (token, actorId) => { if (state.guestNames[token] && state.guestNames[token][actorId]) { @@ -43,6 +44,7 @@ const getters = { const mutations = { /** * Adds a guest name to the store + * * @param {object} state current store state * @param {boolean} noUpdate Only set the guest name if it was not set before * @param {string} token the token of the conversation diff --git a/src/store/messagesStore.js b/src/store/messagesStore.js index 6b878ad1c..c00736c7c 100644 --- a/src/store/messagesStore.js +++ b/src/store/messagesStore.js @@ -40,9 +40,9 @@ import { * Returns whether the given message contains a mention to self, directly * or indirectly through a global mention. * - * @param {Object} context store context - * @param {Object} message message object - * @returns {bool} true if the message contains a mention to self or all, + * @param {object} context store context + * @param {object} message message object + * @return {bool} true if the message contains a mention to self or all, * false otherwise */ function hasMentionToSelf(context, message) { @@ -118,7 +118,7 @@ const getters = { * * @param {object} state the state object. * @param {object} getters the getters object. - * @returns {bool} true if more messages exist that needs loading, false otherwise + * @return {bool} true if more messages exist that needs loading, false otherwise */ hasMoreMessagesToLoad: (state, getters) => (token) => { const conversation = getters.conversation(token) @@ -131,8 +131,9 @@ const getters = { /** * Gets the messages array + * * @param {object} state the state object. - * @returns {array} the messages array (if there are messages in the store) + * @return {Array} the messages array (if there are messages in the store) */ messagesList: (state) => (token) => { if (state.messages[token]) { @@ -142,9 +143,10 @@ const getters = { }, /** * Gets the messages object + * * @param {object} state the state object. * @param {string} token the conversation token. - * @returns {object} the messages object (if there are messages in the store) + * @return {object} the messages object (if there are messages in the store) */ messages: (state) => (token) => { if (state.messages[token]) { @@ -154,10 +156,11 @@ const getters = { }, /** * Gets a single message object + * * @param {object} state the state object. * @param {string} token the conversation token. * @param {string} id the message id. - * @returns {object} the message object (if the message is found in the store) + * @return {object} the message object (if the message is found in the store) */ message: (state) => (token, id) => { if (state.messages[token][id]) { @@ -227,6 +230,7 @@ const mutations = { /** * Adds a message to the store. + * * @param {object} state current store state; * @param {object} message the message; */ @@ -244,6 +248,7 @@ const mutations = { }, /** * Deletes a message from the store. + * * @param {object} state current store state; * @param {object} message the message; */ @@ -255,9 +260,12 @@ const mutations = { /** * Deletes a message from the store. + * * @param {object} state current store state; + * @param message.message * @param {object} message the message; * @param {string} placeholder Placeholder message until deleting finished + * @param message.placeholder */ markMessageAsDeleting(state, { message, placeholder }) { Vue.set(state.messages[message.token][message.id], 'messageType', 'comment_deleted') @@ -265,6 +273,7 @@ const mutations = { }, /** * Adds a temporary message to the store. + * * @param {object} state current store state; * @param {object} message the temporary message; */ @@ -277,9 +286,12 @@ const mutations = { /** * Adds a temporary message to the store. + * * @param {object} state current store state; + * @param message.message * @param {object} message the temporary message; * @param {string} reason the reason the temporary message failed; + * @param message.reason */ markTemporaryMessageAsFailed(state, { message, reason }) { if (state.messages[message.token][message.id]) { @@ -367,8 +379,10 @@ const actions = { * Delete a message * * @param {object} context default store context; + * @param message.message * @param {object} message the message to be deleted; * @param {string} placeholder Placeholder message until deleting finished + * @param message.placeholder */ async deleteMessage(context, { message, placeholder }) { const messageObject = Object.assign({}, context.getters.message(message.token, message.id)) @@ -405,7 +419,7 @@ const actions = { * @param {int} index index; * @param {object} file file to upload; * @param {string} localUrl local URL of file to upload; - * @returns {object} temporary message + * @return {object} temporary message */ createTemporaryMessage(context, { text, token, uploadId, index, file, localUrl, isVoiceMessage }) { const messageToBeReplied = context.getters.getMessageToBeReplied(token) @@ -470,8 +484,10 @@ const actions = { * Mark a temporary message as failed to allow retrying it again * * @param {object} context default store context; + * @param message.message * @param {object} message the temporary message; * @param {string} reason the reason the temporary message failed; + * @param message.reason */ markTemporaryMessageAsFailed(context, { message, reason }) { context.commit('markTemporaryMessageAsFailed', { message, reason }) @@ -529,8 +545,10 @@ const actions = { * in the conversation. * * @param {object} context default store context; + * @param token.token * @param {object} token the token of the conversation to be updated; * @param {bool} updateVisually whether to also clear the marker visually in the UI; + * @param token.updateVisually */ async clearLastReadMessage(context, { token, updateVisually = false }) { const conversation = context.getters.conversations[token] @@ -547,9 +565,12 @@ const actions = { * Optionally also updated the marker visually in the UI if specified. * * @param {object} context default store context; + * @param token.token * @param {object} token the token of the conversation to be updated; * @param {number} id the id of the message on which to set the read marker; * @param {bool} updateVisually whether to also update the marker visually in the UI; + * @param token.id + * @param token.updateVisually */ async updateLastReadMessage(context, { token, id = 0, updateVisually = false }) { const conversation = context.getters.conversations[token] @@ -642,7 +663,7 @@ const actions = { * Cancels a previously running "fetchMessages" action if applicable. * * @param {object} context default store context; - * @returns {bool} true if a request got cancelled, false otherwise + * @return {bool} true if a request got cancelled, false otherwise */ cancelFetchMessages(context) { if (context.state.cancelFetchMessages) { @@ -751,7 +772,7 @@ const actions = { * * @param {object} context default store context; * @param {string} requestId request id - * @returns {bool} true if a request got cancelled, false otherwise + * @return {bool} true if a request got cancelled, false otherwise */ cancelLookForNewMessages(context, { requestId }) { if (context.state.cancelLookForNewMessages[requestId]) { @@ -865,7 +886,7 @@ const actions = { * * @param {object} context default store context; * @param {string} messageId the message id for which to cancel; - * @returns {bool} true if a request got cancelled, false otherwise + * @return {bool} true if a request got cancelled, false otherwise */ cancelPostNewMessage(context, { messageId }) { if (context.state.cancelPostNewMessage[messageId]) { @@ -878,9 +899,11 @@ const actions = { /** * Posts a simple text message to a room + * * @param {object} context default store context; * will be forwarded; * @param {object} message the message object; + * @param message.messageToBeForwarded */ async forwardMessage(context, { messageToBeForwarded }) { const response = await postNewMessage(messageToBeForwarded) diff --git a/src/store/messagesStore.spec.js b/src/store/messagesStore.spec.js index 6d96be7b6..8d416fb30 100644 --- a/src/store/messagesStore.spec.js +++ b/src/store/messagesStore.spec.js @@ -164,7 +164,7 @@ describe('messagesStore', () => { store.dispatch('processMessage', message) }) - test('deletes from server and replaces with returned system message', async() => { + test('deletes from server and replaces with returned system message', async () => { deleteMessage.mockResolvedValueOnce({ status: 200, data: { @@ -191,7 +191,7 @@ describe('messagesStore', () => { }]) }) - test('deletes from server and replaces with returned system message including parent', async() => { + test('deletes from server and replaces with returned system message including parent', async () => { deleteMessage.mockResolvedValueOnce({ status: 200, data: { @@ -285,7 +285,7 @@ describe('messagesStore', () => { store = new Vuex.Store(testStoreConfig) }) - test('creates temporary message', async() => { + test('creates temporary message', async () => { const temporaryMessage = await store.dispatch('createTemporaryMessage', { text: 'blah', token: TOKEN, @@ -317,7 +317,7 @@ describe('messagesStore', () => { }) }) - test('creates temporary message with message to be replied', async() => { + test('creates temporary message with message to be replied', async () => { getMessageToBeRepliedMock.mockReset() getMessageToBeRepliedMock.mockReturnValue(() => ({ id: 123, @@ -350,7 +350,7 @@ describe('messagesStore', () => { }) }) - test('creates temporary message with file', async() => { + test('creates temporary message with file', async () => { const file = { type: 'text/plain', name: 'original-name.txt', @@ -393,7 +393,7 @@ describe('messagesStore', () => { }) }) - test('adds temporary message to the list', async() => { + test('adds temporary message to the list', async () => { const temporaryMessage = await store.dispatch('createTemporaryMessage', { text: 'blah', token: TOKEN, @@ -444,7 +444,7 @@ describe('messagesStore', () => { }]) }) - test('marks temporary message as failed', async() => { + test('marks temporary message as failed', async () => { const temporaryMessage = await store.dispatch('createTemporaryMessage', { text: 'blah', token: TOKEN, @@ -477,7 +477,7 @@ describe('messagesStore', () => { }]) }) - test('removeTemporaryMessageFromStore', async() => { + test('removeTemporaryMessageFromStore', async () => { const temporaryMessage = await store.dispatch('createTemporaryMessage', { text: 'blah', token: TOKEN, @@ -493,7 +493,7 @@ describe('messagesStore', () => { expect(store.getters.messagesList(TOKEN)).toStrictEqual([]) }) - test('gets temporary message by reference', async() => { + test('gets temporary message by reference', async () => { const temporaryMessage = await store.dispatch('createTemporaryMessage', { text: 'blah', token: TOKEN, @@ -574,7 +574,7 @@ describe('messagesStore', () => { expect(store.getters.getVisualLastReadMessageId('token-2')).toBe(2) }) - test('clears last read message', async() => { + test('clears last read message', async () => { getUserIdMock.mockReturnValue(() => 'user-1') store.dispatch('setVisualLastReadMessageId', { token: TOKEN, id: 100 }) @@ -595,7 +595,7 @@ describe('messagesStore', () => { expect(store.getters.getVisualLastReadMessageId(TOKEN)).toBe(100) }) - test('clears last read message and update visually', async() => { + test('clears last read message and update visually', async () => { getUserIdMock.mockReturnValue(() => 'user-1') store.dispatch('setVisualLastReadMessageId', { token: TOKEN, id: 100 }) @@ -616,7 +616,7 @@ describe('messagesStore', () => { expect(store.getters.getVisualLastReadMessageId(TOKEN)).toBe(123) }) - test('clears last read message for guests', async() => { + test('clears last read message for guests', async () => { getUserIdMock.mockReturnValue(() => null) store.dispatch('setVisualLastReadMessageId', { token: TOKEN, id: 100 }) @@ -637,7 +637,7 @@ describe('messagesStore', () => { expect(store.getters.getVisualLastReadMessageId(TOKEN)).toBe(123) }) - test('updates last read message', async() => { + test('updates last read message', async () => { getUserIdMock.mockReturnValue(() => 'user-1') store.dispatch('setVisualLastReadMessageId', { token: TOKEN, id: 100 }) @@ -659,7 +659,7 @@ describe('messagesStore', () => { expect(store.getters.getVisualLastReadMessageId(TOKEN)).toBe(100) }) - test('updates last read message and update visually', async() => { + test('updates last read message and update visually', async () => { getUserIdMock.mockReturnValue(() => 'user-1') store.dispatch('setVisualLastReadMessageId', { token: TOKEN, id: 100 }) @@ -681,7 +681,7 @@ describe('messagesStore', () => { expect(store.getters.getVisualLastReadMessageId(TOKEN)).toBe(200) }) - test('updates last read message for guests', async() => { + test('updates last read message for guests', async () => { getUserIdMock.mockReturnValue(() => null) store.dispatch('setVisualLastReadMessageId', { token: TOKEN, id: 100 }) @@ -728,7 +728,7 @@ describe('messagesStore', () => { store = new Vuex.Store(testStoreConfig) }) - test('fetches messages from server including last known', async() => { + test('fetches messages from server including last known', async () => { const messages = [{ id: 1, token: TOKEN, @@ -779,7 +779,7 @@ describe('messagesStore', () => { expect(store.getters.getLastKnownMessageId(TOKEN)).toBe(2) }) - test('fetches messages from server excluding last known', async() => { + test('fetches messages from server excluding last known', async () => { const messages = [{ id: 1, token: TOKEN, @@ -847,7 +847,7 @@ describe('messagesStore', () => { expect(store.state.cancelFetchMessages).toBe(null) }) - test('cancels fetching messages when fetching again', async() => { + test('cancels fetching messages when fetching again', async () => { store.dispatch('fetchMessages', { token: TOKEN, lastKnownMessageId: 100, @@ -899,7 +899,7 @@ describe('messagesStore', () => { store = new Vuex.Store(testStoreConfig) }) - test('looks for new messages', async() => { + test('looks for new messages', async () => { const messages = [{ id: 1, token: TOKEN, @@ -958,7 +958,7 @@ describe('messagesStore', () => { expect(store.getters.getFirstKnownMessageId(TOKEN)).toBe(null) }) - test('looks for new messages does not update last message if lower', async() => { + test('looks for new messages does not update last message if lower', async () => { const messages = [{ id: 1, token: TOKEN, @@ -998,7 +998,7 @@ describe('messagesStore', () => { expect(store.getters.getLastKnownMessageId(TOKEN)).toBe(null) }) - test('cancels look for new messages', async() => { + test('cancels look for new messages', async () => { store.dispatch('lookForNewMessages', { token: TOKEN, requestId: 'request1', @@ -1012,7 +1012,7 @@ describe('messagesStore', () => { expect(cancelFunctionMocks[0]).toHaveBeenCalledWith('canceled') }) - test('cancels look for new messages when called again', async() => { + test('cancels look for new messages when called again', async () => { store.dispatch('lookForNewMessages', { token: TOKEN, requestId: 'request1', @@ -1028,7 +1028,7 @@ describe('messagesStore', () => { expect(cancelFunctionMocks[0]).toHaveBeenCalledWith('canceled') }) - test('cancels look for new messages call individually', async() => { + test('cancels look for new messages call individually', async () => { store.dispatch('lookForNewMessages', { token: TOKEN, requestId: 'request1', @@ -1061,6 +1061,10 @@ describe('messagesStore', () => { } }) + /** + * @param messages + * @param expectedPayload + */ async function testUpdateMessageCounters(messages, expectedPayload) { const response = { headers: { @@ -1092,7 +1096,7 @@ describe('messagesStore', () => { } describe('updating unread messages counter', () => { - test('updates unread message counter for regular messages', async() => { + test('updates unread message counter for regular messages', async () => { const messages = [{ id: 101, token: TOKEN, @@ -1110,7 +1114,7 @@ describe('messagesStore', () => { await testUpdateMessageCounters(messages, expectedPayload) }) - test('skips system messages when counting unread messages', async() => { + test('skips system messages when counting unread messages', async () => { const messages = [{ id: 101, token: TOKEN, @@ -1129,7 +1133,7 @@ describe('messagesStore', () => { await testUpdateMessageCounters(messages, expectedPayload) }) - test('only counts unread messages from the last unread message', async() => { + test('only counts unread messages from the last unread message', async () => { const messages = [{ id: 99, token: TOKEN, @@ -1156,7 +1160,7 @@ describe('messagesStore', () => { await testUpdateMessageCounters(messages, expectedPayload) }) - test('does not update counter if no new messages were found', async() => { + test('does not update counter if no new messages were found', async () => { const messages = [{ // this one is the last read message so doesn't count id: 100, @@ -1166,7 +1170,7 @@ describe('messagesStore', () => { await testUpdateMessageCounters(messages, null) }) - test('does not update counter if the conversation store is already in sync', async() => { + test('does not update counter if the conversation store is already in sync', async () => { // same as the retrieved message, conversation is in sync testConversation.lastMessage.id = 102 const messages = [{ @@ -1198,6 +1202,10 @@ describe('messagesStore', () => { store = new Vuex.Store(testStoreConfig) }) + /** + * @param messageParameters + * @param expectedValue + */ async function testMentionFlag(messageParameters, expectedValue) { const messages = [{ id: 101, @@ -1213,7 +1221,7 @@ describe('messagesStore', () => { await testUpdateMessageCounters(messages, expectedPayload) } - test('updates unread mention flag for global message', async() => { + test('updates unread mention flag for global message', async () => { await testMentionFlag({ 'mention-1': { type: 'call', @@ -1221,7 +1229,7 @@ describe('messagesStore', () => { }, true) }) - test('updates unread mention flag for guest mention', async() => { + test('updates unread mention flag for guest mention', async () => { getActorIdMock.mockReturnValue(() => 'me_as_guest') getActorTypeMock.mockReturnValue(() => ATTENDEE.ACTOR_TYPE.GUESTS) await testMentionFlag({ @@ -1236,7 +1244,7 @@ describe('messagesStore', () => { }, true) }) - test('does not update unread mention flag for a different guest mention', async() => { + test('does not update unread mention flag for a different guest mention', async () => { getActorIdMock.mockReturnValue(() => 'me_as_guest') getActorTypeMock.mockReturnValue(() => ATTENDEE.ACTOR_TYPE.GUESTS) await testMentionFlag({ @@ -1247,7 +1255,7 @@ describe('messagesStore', () => { }, undefined) }) - test('updates unread mention flag for user mention', async() => { + test('updates unread mention flag for user mention', async () => { getUserIdMock.mockReturnValue(() => 'me_as_user') getActorTypeMock.mockReturnValue(() => ATTENDEE.ACTOR_TYPE.USERS) await testMentionFlag({ @@ -1262,7 +1270,7 @@ describe('messagesStore', () => { }, true) }) - test('does not update unread mention flag for another user mention', async() => { + test('does not update unread mention flag for another user mention', async () => { getUserIdMock.mockReturnValue(() => 'me_as_user') getActorTypeMock.mockReturnValue(() => ATTENDEE.ACTOR_TYPE.USERS) await testMentionFlag({ @@ -1273,12 +1281,12 @@ describe('messagesStore', () => { }, undefined) }) - test('does not update unread mention flag when no params', async() => { + test('does not update unread mention flag when no params', async () => { await testMentionFlag({}, undefined) await testMentionFlag(null, undefined) }) - test('does not update unread mention flag when already set', async() => { + test('does not update unread mention flag when already set', async () => { testConversation.unreadMention = true await testMentionFlag({ 'mention-1': { @@ -1287,7 +1295,7 @@ describe('messagesStore', () => { }, undefined) }) - test('does not update unread mention flag for non-mention parameter', async() => { + test('does not update unread mention flag for non-mention parameter', async () => { testConversation.unreadMention = true await testMentionFlag({ 'file-1': { @@ -1296,7 +1304,7 @@ describe('messagesStore', () => { }, undefined) }) - test('does not update unread mention flag for previously read messages', async() => { + test('does not update unread mention flag for previously read messages', async () => { const messages = [{ // this message was already read id: 100, @@ -1373,7 +1381,7 @@ describe('messagesStore', () => { restoreConsole() }) - test('posts new message', async() => { + test('posts new message', async () => { const temporaryMessage = { id: 'temp-123', message: 'blah', @@ -1477,6 +1485,10 @@ describe('messagesStore', () => { expect(store.getters.isSendingMessages).toBe(false) }) + /** + * @param statusCode + * @param reasonCode + */ async function testMarkMessageErrors(statusCode, reasonCode) { const temporaryMessage = { id: 'temp-123', @@ -1512,15 +1524,15 @@ describe('messagesStore', () => { expect(console.error).toHaveBeenCalled() } - test('marks message as failed on permission denied', async() => { + test('marks message as failed on permission denied', async () => { await testMarkMessageErrors(403, 'read-only') }) - test('marks message as failed when lobby enabled', async() => { + test('marks message as failed when lobby enabled', async () => { await testMarkMessageErrors(412, 'lobby') }) - test('marks message as failed with generic error', async() => { + test('marks message as failed with generic error', async () => { await testMarkMessageErrors(500, 'other') }) @@ -1550,7 +1562,7 @@ describe('messagesStore', () => { ]) }) - test('does not timeout after request returns', async() => { + test('does not timeout after request returns', async () => { const temporaryMessage = { id: 'temp-123', message: 'blah', @@ -1584,6 +1596,10 @@ describe('messagesStore', () => { }) describe('hasMoreMessagesToLoad', () => { + /** + * @param lastKnownMessageId + * @param lastConversationMessageId + */ function setupWithValues(lastKnownMessageId, lastConversationMessageId) { store.dispatch('setLastKnownMessageId', { token: TOKEN, id: 123 }) const conversationMock = jest.fn().mockReturnValue({ diff --git a/src/store/newGroupConversationStore.js b/src/store/newGroupConversationStore.js index 1f9b6d818..7029939bf 100644 --- a/src/store/newGroupConversationStore.js +++ b/src/store/newGroupConversationStore.js @@ -34,8 +34,9 @@ const getDefaultState = () => { const getters = { /** * Gets the selected participants array + * * @param {object} state the state object. - * @returns {array} the selected participants array + * @return {Array} the selected participants array */ selectedParticipants: (state) => { if (state.selectedParticipants) { @@ -48,6 +49,7 @@ const getters = { const mutations = { /** * Adds a the selected participants to the store. + * * @param {object} state current store state; * @param {object} participant the selected participant; */ @@ -57,6 +59,7 @@ const mutations = { /** * Adds a the selected participants to the store. + * * @param {object} state current store state; * @param {object} participant the selected participants */ @@ -68,6 +71,7 @@ const mutations = { /** * Purges the store + * * @param {object} state current store state; */ purgeNewGroupConversationStore(state) { @@ -81,6 +85,8 @@ const actions = { * Adds or removes the participant to the selected participants array * * @param {object} context default store context; + * @param context.commit + * @param context.state * @param {object} participant the clicked participant; */ updateSelectedParticipants({ commit, state }, participant) { diff --git a/src/store/participantsStore.js b/src/store/participantsStore.js index 24ad4dafa..4539dd379 100644 --- a/src/store/participantsStore.js +++ b/src/store/participantsStore.js @@ -61,8 +61,9 @@ const getters = { }, /** * Gets the participants array + * * @param {object} state the state object. - * @returns {array} the participants array (if there are participants in the store) + * @return {Array} the participants array (if there are participants in the store) */ participantsList: (state) => (token) => { if (state.participants[token]) { @@ -109,9 +110,12 @@ const getters = { const mutations = { /** * Adds a message to the store. + * * @param {object} state current store state; + * @param token.token * @param {object} token the token of the conversation; * @param {object} participant the participant; + * @param token.participant */ addParticipant(state, { token, participant }) { if (!state.participants[token]) { @@ -161,6 +165,7 @@ const mutations = { }, /** * Purges a given conversation from the previously added participants + * * @param {object} state current store state; * @param {string} token the conversation to purge; */ @@ -191,6 +196,7 @@ const actions = { * Only call this after purgeParticipantsStore, otherwise use addParticipantOnce * * @param {object} context default store context; + * @param context.commit * @param {string} token the conversation to add the participant; * @param {object} participant the participant; */ @@ -201,6 +207,8 @@ const actions = { * Only add a participant when they are not there yet * * @param {object} context default store context; + * @param context.commit + * @param context.getters * @param {string} token the conversation to add the participant; * @param {object} participant the participant; */ @@ -255,7 +263,9 @@ const actions = { }, /** * Purges a given conversation from the previously added participants + * * @param {object} context default store context; + * @param context.commit * @param {string} token the conversation to purge; */ purgeParticipantsStore({ commit }, token) { @@ -358,7 +368,7 @@ const actions = { * Resends email invitations for the given conversation. * If no userId is set, send to all applicable participants. * - * @param {Object} _ unused + * @param {object} _ unused * @param {string} token conversation token * @param {int} attendeeId attendee id to target, or null for all */ @@ -369,7 +379,7 @@ const actions = { /** * Makes the current user active in the given conversation. * - * @param {Object} context unused + * @param {object} context unused * @param {string} token conversation token */ async joinConversation(context, { token }) { @@ -457,7 +467,7 @@ const actions = { /** * Makes the current user inactive in the given conversation. * - * @param {Object} context unused + * @param {object} context unused * @param {string} token conversation token */ async leaveConversation(context, { token }) { @@ -468,7 +478,7 @@ const actions = { * Removes the current user from the conversation, which * means the user is not a participant any more. * - * @param {Object} context unused + * @param {object} context unused * @param {string} token conversation token */ async removeCurrentUserFromConversation(context, { token }) { diff --git a/src/store/participantsStore.spec.js b/src/store/participantsStore.spec.js index 3dd943ad9..4ba6c39e6 100644 --- a/src/store/participantsStore.spec.js +++ b/src/store/participantsStore.spec.js @@ -88,7 +88,7 @@ describe('participantsStore', () => { expect(removeAttendeeFromConversation).not.toHaveBeenCalled() }) - test('removes participant', async() => { + test('removes participant', async () => { store.dispatch('addParticipant', { token: TOKEN, participant: { attendeeId: 1 }, }) @@ -209,6 +209,10 @@ describe('participantsStore', () => { expect(promoteToModerator).not.toHaveBeenCalled() }) + /** + * @param participantType + * @param expectedParticipantType + */ async function testPromoteModerator(participantType, expectedParticipantType) { promoteToModerator.mockResolvedValue() @@ -234,10 +238,10 @@ describe('participantsStore', () => { ]) } - test('promotes given user to moderator', async() => { + test('promotes given user to moderator', async () => { await testPromoteModerator(PARTICIPANT.TYPE.USER, PARTICIPANT.TYPE.MODERATOR) }) - test('promotes given guest to guest moderator', async() => { + test('promotes given guest to guest moderator', async () => { await testPromoteModerator(PARTICIPANT.TYPE.GUEST, PARTICIPANT.TYPE.GUEST_MODERATOR) }) }) @@ -252,6 +256,10 @@ describe('participantsStore', () => { expect(demoteFromModerator).not.toHaveBeenCalled() }) + /** + * @param participantType + * @param expectedParticipantType + */ async function testDemoteModerator(participantType, expectedParticipantType) { promoteToModerator.mockResolvedValue() @@ -277,10 +285,10 @@ describe('participantsStore', () => { ]) } - test('demotes given moderator to user', async() => { + test('demotes given moderator to user', async () => { await testDemoteModerator(PARTICIPANT.TYPE.MODERATOR, PARTICIPANT.TYPE.USER) }) - test('promotes given guest to guest moderator', async() => { + test('promotes given guest to guest moderator', async () => { await testDemoteModerator(PARTICIPANT.TYPE.GUEST_MODERATOR, PARTICIPANT.TYPE.GUEST) }) }) @@ -324,7 +332,7 @@ describe('participantsStore', () => { store = new Vuex.Store(testStoreConfig) }) - test('joins call', async() => { + test('joins call', async () => { store.dispatch('addParticipant', { token: TOKEN, participant: { @@ -373,7 +381,7 @@ describe('participantsStore', () => { }) }) - test('joins and leaves call', async() => { + test('joins and leaves call', async () => { store.dispatch('addParticipant', { token: TOKEN, participant: { @@ -443,7 +451,7 @@ describe('participantsStore', () => { ]) }) - test('resends invitations', async() => { + test('resends invitations', async () => { resendInvitations.mockResolvedValue() await store.dispatch('resendInvitations', { @@ -484,7 +492,7 @@ describe('participantsStore', () => { }) }) - test('joins conversation', async() => { + test('joins conversation', async () => { store = new Vuex.Store(testStoreConfig) const response = { status: 200, @@ -512,7 +520,7 @@ describe('participantsStore', () => { expect(joinedConversationEventMock).toHaveBeenCalledWith({ token: TOKEN }) }) - test('force join conversation', async() => { + test('force join conversation', async () => { store = new Vuex.Store(testStoreConfig) const updatedParticipantData = Object.assign({}, participantData, { sessionId: 'another-session-id' }) const response = { @@ -560,6 +568,10 @@ describe('participantsStore', () => { restoreConsole() }) + /** + * @param lastPingAge + * @param inCall + */ function prepareTestJoinWithMaxPingAge(lastPingAge, inCall) { const mockDate = new Date('2020-01-01 20:00:00') participantData.lastPing = mockDate.getTime() / 1000 - lastPingAge @@ -580,7 +592,7 @@ describe('participantsStore', () => { } describe('when not in call', () => { - test('forces join when max ping age > 40s', async() => { + test('forces join when max ping age > 40s', async () => { prepareTestJoinWithMaxPingAge(41, PARTICIPANT.CALL_FLAG.DISCONNECTED) testStoreConfig.actions.forceJoinConversation = jest.fn() @@ -593,7 +605,7 @@ describe('participantsStore', () => { expect(testStoreConfig.actions.forceJoinConversation).toHaveBeenCalledWith(expect.anything(), { token: TOKEN }) }) - test('shows force when max ping age <= 40s', async() => { + test('shows force when max ping age <= 40s', async () => { prepareTestJoinWithMaxPingAge(40, PARTICIPANT.CALL_FLAG.DISCONNECTED) testStoreConfig.actions.forceJoinConversation = jest.fn() @@ -608,7 +620,7 @@ describe('participantsStore', () => { }) describe('when in call', () => { - test('forces join when max ping age > 60s', async() => { + test('forces join when max ping age > 60s', async () => { prepareTestJoinWithMaxPingAge(61, PARTICIPANT.CALL_FLAG.IN_CALL) testStoreConfig.actions.forceJoinConversation = jest.fn() @@ -621,7 +633,7 @@ describe('participantsStore', () => { expect(testStoreConfig.actions.forceJoinConversation).toHaveBeenCalledWith(expect.anything(), { token: TOKEN }) }) - test('shows force when max ping age <= 60s', async() => { + test('shows force when max ping age <= 60s', async () => { prepareTestJoinWithMaxPingAge(60, PARTICIPANT.CALL_FLAG.IN_CALL) testStoreConfig.actions.forceJoinConversation = jest.fn() @@ -637,7 +649,7 @@ describe('participantsStore', () => { }) }) - test('leaves conversation', async() => { + test('leaves conversation', async () => { leaveConversation.mockResolvedValue() await store.dispatch('leaveConversation', { token: TOKEN }) @@ -645,7 +657,7 @@ describe('participantsStore', () => { expect(leaveConversation).toHaveBeenCalledWith(TOKEN) }) - test('removes current user from conversation', async() => { + test('removes current user from conversation', async () => { removeCurrentUserFromConversation.mockResolvedValue() testStoreConfig = cloneDeep(participantsStore) diff --git a/src/store/sidebarStore.js b/src/store/sidebarStore.js index 8e8a3a936..4a75b0510 100644 --- a/src/store/sidebarStore.js +++ b/src/store/sidebarStore.js @@ -55,6 +55,7 @@ const mutations = { }, /** * Renaming state of the conversation + * * @param {object} state current store state; * @param {boolean} boolean the state of the renaming action; */ @@ -91,6 +92,7 @@ const actions = { }, /** * Renaming state of the conversation + * * @param {object} context default store context; * @param {boolean} boolean the state of the renaming action; */ diff --git a/src/store/tokenStore.js b/src/store/tokenStore.js index 29a785349..2eccd7342 100644 --- a/src/store/tokenStore.js +++ b/src/store/tokenStore.js @@ -29,7 +29,7 @@ const state = { * might have a window of time in which we might be in * conversation B in talk's UI while still leaving conversation * A in the signaling server. - **/ + */ lastJoinedConversationToken: '', } |