|
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 |
|
@@ -104,6 +105,17 @@ const mockRouter = { |
104 | 105 | push: vi.fn(), |
105 | 106 | } |
106 | 107 |
|
| 108 | +// Mock capabilities - show-confetti enabled by default so existing tests pass |
| 109 | +vi.mock('@nextcloud/capabilities', () => ({ |
| 110 | + getCapabilities: vi.fn(() => ({ |
| 111 | + libresign: { |
| 112 | + config: { |
| 113 | + 'show-confetti': true, |
| 114 | + }, |
| 115 | + }, |
| 116 | + })), |
| 117 | +})) |
| 118 | + |
107 | 119 | // Mock initial state |
108 | 120 | vi.mock('@nextcloud/initial-state', () => ({ |
109 | 121 | loadState: vi.fn((app, key, defaultValue) => defaultValue), |
@@ -654,6 +666,19 @@ describe('Validation.vue - Business Logic', () => { |
654 | 666 | wrapper.vm.handleValidationSuccess({ status: SIGNED_STATUS, signers: [] }) |
655 | 667 | expect(mockAddConfetti).not.toHaveBeenCalled() |
656 | 668 | }) |
| 669 | + |
| 670 | + it('does not fire confetti when show-confetti capability is disabled', async () => { |
| 671 | + vi.mocked(getCapabilities).mockReturnValueOnce({ |
| 672 | + libresign: { |
| 673 | + config: { |
| 674 | + 'show-confetti': false, |
| 675 | + }, |
| 676 | + }, |
| 677 | + } as ReturnType<typeof getCapabilities>) |
| 678 | + vi.spyOn(wrapper.vm, 'isAfterSigned', 'get').mockReturnValue(true) |
| 679 | + wrapper.vm.handleValidationSuccess({ status: SIGNED_STATUS, signers: [] }) |
| 680 | + expect(mockAddConfetti).not.toHaveBeenCalled() |
| 681 | + }) |
657 | 682 | }) |
658 | 683 |
|
659 | 684 | describe('handleSigningComplete method', () => { |
|
0 commit comments