feat(ui) : état readonly visuel sur InputUpload (+ prop readonly)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-03 15:05:48 +02:00
parent c934019260
commit fd3e3a7922
2 changed files with 55 additions and 10 deletions
@@ -12,6 +12,7 @@ type InputUploadProps = {
labelClass?: string
groupClass?: string
disabled?: boolean
readonly?: boolean
hint?: string
error?: string
success?: string
@@ -204,4 +205,34 @@ describe('MalioInputUpload', () => {
expect(wrapper.find('[data-test="required-mark"]').exists()).toBe(false)
})
it('readonly : bordure noire même vide, pas de grow/bleu', () => {
const wrapper = mountComponent({label: 'Champ', readonly: true})
const field = wrapper.get('input[type="text"]')
expect(field.classes()).toContain('border-black')
expect(field.classes()).not.toContain('border-m-muted')
expect(field.classes()).not.toContain('grow-height')
expect(field.classes()).not.toContain('focus:border-m-primary')
})
it('readonly vide : label gris, pas de bleu', () => {
const wrapper = mountComponent({label: 'Champ', readonly: true})
const label = wrapper.get('label')
expect(label.classes()).not.toContain('peer-focus:text-m-primary')
expect(label.classes()).toContain('text-m-muted')
})
it('readonly rempli : label noir + icône noire', () => {
const wrapper = mountComponent({label: 'Champ', readonly: true, modelValue: 'fichier.pdf'})
expect(wrapper.get('label').classes()).toContain('text-black')
expect(wrapper.get('[data-test="icon"]').classes()).toContain('text-black')
})
it('readonly empêche l\'ouverture du sélecteur de fichier', async () => {
const wrapper = mountComponent({label: 'Champ', readonly: true})
// openFilePicker doit être un no-op : cliquer le champ ne déclenche pas l'input file caché.
// Vérifie au minimum que le champ visible reste readonly et qu'aucune erreur n'est levée.
await wrapper.get('input[type="text"]').trigger('click')
expect(wrapper.get('input[type="text"]').attributes('readonly')).toBeDefined()
})
})