Skip to content

Commit 55f738b

Browse files
authored
Merge pull request #7282 from LibreSign/backport/7280/stable33
[stable33] test: avoid async hook imports in request signature tab spec
2 parents 03238c9 + 7aba078 commit 55f738b

File tree

4 files changed

+10
-32
lines changed

4 files changed

+10
-32
lines changed

src/tests/components/LeftSidebar/LeftSidebar.spec.ts

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

6-
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
6+
import { beforeEach, describe, expect, it, vi } from 'vitest'
77
import { createL10nMock } from '../../testHelpers/l10n.js'
88
import { mount } from '@vue/test-utils'
9+
import LeftSidebar from '../../../components/LeftSidebar/LeftSidebar.vue'
910

1011
const loadStateMock = vi.fn()
1112
const getCurrentUserMock = vi.fn()
@@ -27,12 +28,6 @@ vi.mock('../../../store/files.js', () => ({
2728
}),
2829
}))
2930

30-
let LeftSidebar: unknown
31-
32-
beforeAll(async () => {
33-
;({ default: LeftSidebar } = await import('../../../components/LeftSidebar/LeftSidebar.vue'))
34-
})
35-
3631
describe('LeftSidebar', () => {
3732
beforeEach(() => {
3833
loadStateMock.mockReset()
@@ -53,7 +48,7 @@ describe('LeftSidebar', () => {
5348
})
5449
getCurrentUserMock.mockReturnValue({ isAdmin: true })
5550

56-
const wrapper = mount(LeftSidebar as never, {
51+
const wrapper = mount(LeftSidebar, {
5752
global: {
5853
stubs: {
5954
NcAppNavigation: {

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

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

6-
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
6+
import { 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'
12-
let RequestSignatureTab: unknown
13-
let useFilesStore: typeof import('../../../store/files.js').useFilesStore
12+
import RequestSignatureTab from '../../../components/RightSidebar/RequestSignatureTab.vue'
13+
import { useFilesStore } from '../../../store/files.js'
1414
import { FILE_STATUS } from '../../../constants.js'
1515

1616
const { generateUrlMock } = vi.hoisted(() => ({
@@ -80,11 +80,6 @@ describe('RequestSignatureTab - Critical Business Rules', () => {
8080
let wrapper: VueWrapper<any>
8181
let filesStore: ReturnType<typeof useFilesStoreType>
8282

83-
beforeAll(async () => {
84-
RequestSignatureTab = (await import('../../../components/RightSidebar/RequestSignatureTab.vue')).default
85-
;({ useFilesStore } = await import('../../../store/files.js'))
86-
})
87-
8883
const updateFile = async (patch: Record<string, unknown>) => {
8984
const current = filesStore.files[1] || { id: 1 }
9085
const hasSigners = Object.prototype.hasOwnProperty.call(patch, 'signers')

src/tests/components/Signers/Signer.spec.ts

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

6-
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
6+
import { beforeEach, describe, expect, it, vi } from 'vitest'
77
import { createL10nMock } from '../../testHelpers/l10n.js'
88
import type { MockedFunction } from 'vitest'
99
import { mount } from '@vue/test-utils'
1010
import type { VueWrapper } from '@vue/test-utils'
1111
import { createPinia, setActivePinia } from 'pinia'
1212
import { mdiCheckCircle, mdiClockOutline, mdiCircleOutline } from '@mdi/js'
1313
import type { TranslationFunction, PluralTranslationFunction } from '../../test-types'
14+
import Signer from '../../../components/Signers/Signer.vue'
1415
import { useFilesStore } from '../../../store/files.js'
1516

16-
type SignerComponent = typeof import('../../../components/Signers/Signer.vue').default
17-
1817
type FileSigner = {
1918
signed?: boolean
2019
identifyMethods?: Array<{ method: string }>
@@ -67,8 +66,6 @@ const { t, n } = vi.hoisted(() => {
6766
return { t, n }
6867
})
6968

70-
let Signer: SignerComponent
71-
7269
vi.mock('@nextcloud/initial-state', () => ({
7370
loadState: vi.fn((app, key, defaultValue) => {
7471
if (key === 'can_request_sign') return true
@@ -89,10 +86,6 @@ vi.mock('@nextcloud/l10n', () => createL10nMock())
8986

9087
import { emit } from '@nextcloud/event-bus'
9188

92-
beforeAll(async () => {
93-
;({ default: Signer } = await import('../../../components/Signers/Signer.vue'))
94-
})
95-
9689
describe('Signer', () => {
9790
let wrapper: SignerWrapper | null
9891
let filesStore: FilesStoreMock

src/tests/components/Signers/Signers.spec.ts

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

6-
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
6+
import { 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 type { Pinia } from 'pinia'
11-
type SignersComponent = typeof import('../../../components/Signers/Signers.vue').default
12-
let Signers: SignersComponent
11+
import Signers from '../../../components/Signers/Signers.vue'
1312
import { useFilesStore } from '../../../store/files.js'
1413
import type { SignatureFlowValue } from '../../../types/index'
1514

@@ -49,10 +48,6 @@ vi.mock('@nextcloud/initial-state', () => ({
4948
loadState: vi.fn(),
5049
}))
5150

52-
beforeAll(async () => {
53-
;({ default: Signers } = await import('../../../components/Signers/Signers.vue'))
54-
})
55-
5651

5752
describe('Signers', () => {
5853
let wrapper: SignersWrapper | null

0 commit comments

Comments
 (0)