4NK_IA_front/tests/ExtractionView.tabs.test.tsx
4NK IA aad52027c1 ci: docker_tag=dev-test
- Alignement backend: seules 4 entités retournées (persons, companies, addresses, contractual)
- Version API mise à jour à 1.0.1 dans /api/health
- Interface onglets d entités: Personnes, Adresses, Entreprises, Contractuel
- Correction erreurs TypeScript pour build stricte
- Tests et documentation mis à jour
- CHANGELOG.md mis à jour avec version 1.1.1
2025-09-18 20:07:08 +00:00

64 lines
2.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, it, expect } from 'vitest'
import { render, screen, fireEvent } from '@testing-library/react'
import React from 'react'
import { Provider } from 'react-redux'
import { configureStore } from '@reduxjs/toolkit'
import ExtractionView from '../src/views/ExtractionView'
import { documentReducer } from '../src/store/documentSlice'
import { appReducer } from '../src/store/appSlice'
type UnknownRecord = Record<string, unknown>
function makeStore(initialState: UnknownRecord) {
return configureStore({
reducer: { app: appReducer, document: documentReducer },
preloadedState: initialState as any,
})
}
describe('ExtractionView - Onglets entités', () => {
it('affiche les 4 onglets attendus et permet de changer donglet', () => {
const initialState: UnknownRecord = {
app: {},
document: {
folderResults: [
{
fileHash: 'fh',
document: { fileName: 'a.pdf', mimeType: 'application/pdf', fileSize: 1, uploadTimestamp: new Date().toISOString() },
classification: { documentType: 'Document', confidence: 1, subType: '', language: 'fr', pageCount: 1 },
extraction: {
text: { raw: 'abc', processed: 'abc', wordCount: 1, characterCount: 3, confidence: 1 },
entities: {
persons: [{ id: 'p1', firstName: 'A', lastName: 'B', description: '' }],
addresses: [{ id: 'a1', street: 'r', postalCode: 'p', city: 'c', country: 'fr', description: '' }],
companies: [{ id: 'c1', name: 'X', description: '' }],
contractual: { clauses: [{ title: 'T', text: 'txt' }], signatures: [{ signer: 'S', status: 'ok' }] },
},
},
metadata: { processing: {}, quality: { globalConfidence: 0.9, textExtractionConfidence: 0.9, entityExtractionConfidence: 0.9, classificationConfidence: 0.9 } },
status: { success: true, errors: [], warnings: [], timestamp: new Date().toISOString() },
},
],
currentResultIndex: 0,
loading: false,
currentFolderHash: 'fh1',
},
}
const store = makeStore(initialState)
render(
<Provider store={store}>
<ExtractionView />
</Provider>
)
expect(screen.getByText(/Personnes \(/)).toBeTruthy()
expect(screen.getByText(/Adresses \(/)).toBeTruthy()
expect(screen.getByText(/Entreprises \(/)).toBeTruthy()
expect(screen.getByText(/Contractuel \(/)).toBeTruthy()
fireEvent.click(screen.getByText(/Adresses \(/))
expect(screen.getByText('Adresses')).toBeTruthy()
})
})