|
6 | 6 | import { afterEach, describe, expect, it, beforeEach, vi } from 'vitest' |
7 | 7 | import { shallowMount } from '@vue/test-utils' |
8 | 8 | import axios from '@nextcloud/axios' |
| 9 | +import { getCapabilities } from '@nextcloud/capabilities' |
9 | 10 | import JSConfetti from 'js-confetti' |
10 | 11 | import Validation from '../../views/Validation.vue' |
11 | 12 |
|
@@ -97,6 +98,17 @@ const mockRouter = { |
97 | 98 | push: vi.fn(), |
98 | 99 | } |
99 | 100 |
|
| 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 | + |
100 | 112 | // Mock initial state |
101 | 113 | vi.mock('@nextcloud/initial-state', () => ({ |
102 | 114 | loadState: vi.fn((app, key, defaultValue) => defaultValue), |
@@ -647,6 +659,19 @@ describe('Validation.vue - Business Logic', () => { |
647 | 659 | wrapper.vm.handleValidationSuccess({ status: SIGNED_STATUS, signers: [] }) |
648 | 660 | expect(mockAddConfetti).not.toHaveBeenCalled() |
649 | 661 | }) |
| 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 | + }) |
650 | 675 | }) |
651 | 676 |
|
652 | 677 | describe('handleSigningComplete method', () => { |
|
0 commit comments