|
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2026 LibreSign contributors |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +import { describe, expect, it } from 'vitest' |
| 7 | +import { nextTick } from 'vue' |
| 8 | +import { getFilePickerBuilder, showError, showSuccess, showWarning } from '@nextcloud/dialogs' |
| 9 | + |
| 10 | +describe('dialogs v8 integration', () => { |
| 11 | + it.each([ |
| 12 | + ['success', showSuccess, 'status'], |
| 13 | + ['warning', showWarning, 'status'], |
| 14 | + ['error', showError, 'alert'], |
| 15 | + ] as const)('renders and dismisses a %s toast', async (type, showToast, role) => { |
| 16 | + const message = `LibreSign ${type} feedback` |
| 17 | + const toast = showToast(message, { timeout: -1 }) |
| 18 | + await nextTick() |
| 19 | + const notification = [...document.querySelectorAll(`[role="${role}"]`)] |
| 20 | + .find(element => element.textContent?.includes(message)) |
| 21 | + expect(notification).toBeDefined() |
| 22 | + toast.hideToast() |
| 23 | + await nextTick() |
| 24 | + expect(notification?.isConnected).toBe(false) |
| 25 | + }) |
| 26 | + |
| 27 | + it('provides the file picker API used by LibreSign', () => { |
| 28 | + const picker = getFilePickerBuilder('Select your file') |
| 29 | + .setMultiSelect(false) |
| 30 | + .setMimeTypeFilter(['application/pdf']) |
| 31 | + .addButton({ label: 'Choose', callback: () => undefined }) |
| 32 | + .build() |
| 33 | + expect(typeof picker.pick).toBe('function') |
| 34 | + }) |
| 35 | +}) |
0 commit comments