Skip to content

Commit 6a1fd05

Browse files
committed
test(validation): mock show-confetti capability and add disabled scenario test
Signed-off-by: Vitor Mattos <[email protected]>
1 parent bcde85b commit 6a1fd05

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/tests/views/Validation.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { afterEach, describe, expect, it, beforeEach, vi } from 'vitest'
77
import { shallowMount } from '@vue/test-utils'
88
import axios from '@nextcloud/axios'
9+
import { getCapabilities } from '@nextcloud/capabilities'
910
import JSConfetti from 'js-confetti'
1011
import Validation from '../../views/Validation.vue'
1112

@@ -97,6 +98,17 @@ const mockRouter = {
9798
push: vi.fn(),
9899
}
99100

101+
// Mock capabilities - show-confetti enabled by default so existing tests pass
102+
vi.mock('@nextcloud/capabilities', () => ({
103+
getCapabilities: vi.fn(() => ({
104+
libresign: {
105+
config: {
106+
'show-confetti': true,
107+
},
108+
},
109+
})),
110+
}))
111+
100112
// Mock initial state
101113
vi.mock('@nextcloud/initial-state', () => ({
102114
loadState: vi.fn((app, key, defaultValue) => defaultValue),
@@ -647,6 +659,19 @@ describe('Validation.vue - Business Logic', () => {
647659
wrapper.vm.handleValidationSuccess({ status: SIGNED_STATUS, signers: [] })
648660
expect(mockAddConfetti).not.toHaveBeenCalled()
649661
})
662+
663+
it('does not fire confetti when show-confetti capability is disabled', async () => {
664+
vi.mocked(getCapabilities).mockReturnValueOnce({
665+
libresign: {
666+
config: {
667+
'show-confetti': false,
668+
},
669+
},
670+
} as ReturnType<typeof getCapabilities>)
671+
vi.spyOn(wrapper.vm, 'isAfterSigned', 'get').mockReturnValue(true)
672+
wrapper.vm.handleValidationSuccess({ status: SIGNED_STATUS, signers: [] })
673+
expect(mockAddConfetti).not.toHaveBeenCalled()
674+
})
650675
})
651676

652677
describe('handleSigningComplete method', () => {

0 commit comments

Comments
 (0)