Skip to content

Commit eae9dc0

Browse files
committed
test: speed up request signature tab setup
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 0d0deeb commit eae9dc0

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/tests/components/RightSidebar/RequestSignatureTab.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import { describe, expect, it, beforeEach, vi } from 'vitest'
6+
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
77
import { shallowMount } from '@vue/test-utils'
88
import type { VueWrapper } from '@vue/test-utils'
99
import { createPinia, setActivePinia } from 'pinia'
1010
import axios from '@nextcloud/axios'
1111
import type { useFilesStore as useFilesStoreType } from '../../../store/files.js'
1212
let RequestSignatureTab: unknown
13+
let useFilesStore: typeof import('../../../store/files.js').useFilesStore
1314
import { FILE_STATUS } from '../../../constants.js'
1415

1516
const { generateUrlMock } = vi.hoisted(() => ({
@@ -78,6 +79,12 @@ vi.mock('@libresign/pdf-elements', () => ({
7879
describe('RequestSignatureTab - Critical Business Rules', () => {
7980
let wrapper: VueWrapper<any>
8081
let filesStore: ReturnType<typeof useFilesStoreType>
82+
83+
beforeAll(async () => {
84+
RequestSignatureTab = (await import('../../../components/RightSidebar/RequestSignatureTab.vue')).default
85+
;({ useFilesStore } = await import('../../../store/files.js'))
86+
})
87+
8188
const updateFile = async (patch: Record<string, unknown>) => {
8289
const current = filesStore.files[1] || { id: 1 }
8390
const hasSigners = Object.prototype.hasOwnProperty.call(patch, 'signers')
@@ -103,8 +110,6 @@ describe('RequestSignatureTab - Critical Business Rules', () => {
103110
setActivePinia(createPinia())
104111
generateUrlMock.mockClear()
105112
vi.mocked(axios.get).mockResolvedValue({ data: { ocs: { data: null } } } as Awaited<ReturnType<typeof axios.get>>)
106-
RequestSignatureTab = (await import('../../../components/RightSidebar/RequestSignatureTab.vue')).default
107-
const { useFilesStore } = await import('../../../store/files.js')
108113
filesStore = useFilesStore()
109114

110115
await filesStore.addFile({

0 commit comments

Comments
 (0)