diff --git a/package-lock.json b/package-lock.json index cab52b3265b..cad00ec1edd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -72,6 +72,7 @@ "@vue/vue2-jest": "^29.2.1", "babel-loader-exclude-node-modules-except": "^1.2.1", "babel-plugin-add-module-exports": "^1.0.4", + "flush-promises": "^1.0.2", "jest": "^29.2.2", "jest-environment-jsdom": "^29.3.1", "jest-localstorage-mock": "^2.4.26", @@ -8602,6 +8603,12 @@ "vue": "^2.6.10" } }, + "node_modules/flush-promises": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/flush-promises/-/flush-promises-1.0.2.tgz", + "integrity": "sha512-G0sYfLQERwKz4+4iOZYQEZVpOt9zQrlItIxQAAYAWpfby3gbHrx0osCHz5RLl/XoXevXk0xoN4hDFky/VV9TrA==", + "dev": true + }, "node_modules/focus-trap": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-7.1.0.tgz", @@ -26769,6 +26776,12 @@ "vue-resize": "^1.0.0" } }, + "flush-promises": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/flush-promises/-/flush-promises-1.0.2.tgz", + "integrity": "sha512-G0sYfLQERwKz4+4iOZYQEZVpOt9zQrlItIxQAAYAWpfby3gbHrx0osCHz5RLl/XoXevXk0xoN4hDFky/VV9TrA==", + "dev": true + }, "focus-trap": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-7.1.0.tgz", diff --git a/package.json b/package.json index f6cd504fa1e..db11434191a 100644 --- a/package.json +++ b/package.json @@ -80,6 +80,7 @@ "@vue/vue2-jest": "^29.2.1", "babel-loader-exclude-node-modules-except": "^1.2.1", "babel-plugin-add-module-exports": "^1.0.4", + "flush-promises": "^1.0.2", "jest": "^29.2.2", "jest-environment-jsdom": "^29.3.1", "jest-localstorage-mock": "^2.4.26", diff --git a/src/components/LeftSidebar/ConversationsList/Conversation.spec.js b/src/components/LeftSidebar/ConversationsList/Conversation.spec.js index 41a7ba882e6..73926db7c53 100644 --- a/src/components/LeftSidebar/ConversationsList/Conversation.spec.js +++ b/src/components/LeftSidebar/ConversationsList/Conversation.spec.js @@ -9,6 +9,9 @@ import { showSuccess, showError } from '@nextcloud/dialogs' import Conversation from './Conversation.vue' +// Update after migration to @vue/test-utils v2.0.0 +import flushPromises from 'flush-promises' + jest.mock('@nextcloud/dialogs', () => ({ showSuccess: jest.fn(), showError: jest.fn(), @@ -367,7 +370,8 @@ describe('Conversation.vue', () => { const action = shallowMountAndGetAction('Leave conversation') expect(action.exists()).toBe(true) - await action.find('button').trigger('click') + action.find('button').trigger('click') + await flushPromises() expect(actionHandler).toHaveBeenCalledWith(expect.anything(), { token: TOKEN }) expect(showError).toHaveBeenCalledWith(expect.stringContaining('promote')) diff --git a/src/components/LeftSidebar/ConversationsList/Conversation.vue b/src/components/LeftSidebar/ConversationsList/Conversation.vue index e153141df95..55f3f191d44 100644 --- a/src/components/LeftSidebar/ConversationsList/Conversation.vue +++ b/src/components/LeftSidebar/ConversationsList/Conversation.vue @@ -20,7 +20,8 @@ -->