new file: .env.local modified: .gitignore new file: docs/mock-audit.md modified: eslint.config.js modified: package-lock.json modified: package.json deleted: src/App.css modified: src/App.jsx deleted: src/assets/react.svg deleted: src/assets/vite.svg new file: src/components/RichTextEditor.jsx modified: src/components/calendar/AgendaMonthlyView.jsx modified: src/components/calendar/AgendaWeeklyView.jsx modified: src/components/ui.jsx modified: src/config/api.js modified: src/data/mockData.js new file: src/data/reportTemplates.js modified: src/hooks/useAgenda.js modified: src/mappers/appointmentMapper.js modified: src/pages/AgendaPage.jsx modified: src/pages/MedicalRecordsPage.jsx modified: src/pages/MessagesPage.jsx modified: src/pages/PatientsPage.jsx modified: src/pages/ProfilePage.jsx modified: src/pages/ReportsPage.jsx modified: src/pages/UsersPage.jsx modified: src/pages/VisitsPage.jsx modified: src/repositories/patientRepository.js modified: src/repositories/profileRepository.js modified: src/repositories/userRepository.js deleted: test.mjs deleted: test2.mjs deleted: test3.mjs deleted: test4.mjs deleted: test5.mjs new file: tests/mappers.test.mjs new file: tests/patientRepository.test.mjs new file: tests/permissions.test.mjs new file: tests/repositoryUtils.test.mjs
61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import test from 'node:test'
|
|
|
|
import { appointmentMapper } from '../src/mappers/appointmentMapper.js'
|
|
import { reportMapper } from '../src/mappers/reportMapper.js'
|
|
|
|
test('appointmentMapper envia valores aceitos pela API Supabase', () => {
|
|
const payload = appointmentMapper.toApi(
|
|
{
|
|
patientId: 'patient-1',
|
|
professionalId: 'doctor-1',
|
|
date: '2026-05-11',
|
|
time: '10:30',
|
|
mode: 'Teleconsulta',
|
|
status: 'Em triagem',
|
|
notes: '',
|
|
},
|
|
'supabase',
|
|
)
|
|
|
|
assert.equal(payload.patient_id, 'patient-1')
|
|
assert.equal(payload.doctor_id, 'doctor-1')
|
|
assert.equal(payload.appointment_type, 'telemedicina')
|
|
assert.equal(payload.status, 'checked_in')
|
|
assert.equal(payload.duration_minutes, 30)
|
|
assert.equal('notes' in payload, true)
|
|
})
|
|
|
|
test('appointmentMapper converte resposta da API para labels da agenda', () => {
|
|
const appointment = appointmentMapper.toUi({
|
|
id: 'appt-1',
|
|
status: 'confirmed',
|
|
appointment_type: 'telemedicina',
|
|
scheduled_at: '2026-05-11T13:30:00.000Z',
|
|
patients: { id: 'patient-1', full_name: 'Ana Souza' },
|
|
doctors: { id: 'doctor-1', full_name: 'Dra. Leticia' },
|
|
})
|
|
|
|
assert.equal(appointment.id, 'appt-1')
|
|
assert.equal(appointment.status, 'Confirmada')
|
|
assert.equal(appointment.mode, 'Teleconsulta')
|
|
assert.equal(appointment.patient, 'Ana Souza')
|
|
assert.equal(appointment.professional, 'Dra. Leticia')
|
|
})
|
|
|
|
test('reportMapper remove campos vazios e normaliza status', () => {
|
|
const payload = reportMapper.toApi({
|
|
patientId: 'patient-1',
|
|
status: 'finalized',
|
|
exam: '',
|
|
requestedBy: 'Dra. Leticia',
|
|
contentHtml: '<p>Conclusao clinica</p>',
|
|
})
|
|
|
|
assert.equal(payload.patient_id, 'patient-1')
|
|
assert.equal(payload.status, 'finalized')
|
|
assert.equal(payload.requested_by, 'Dra. Leticia')
|
|
assert.equal(payload.content_html, '<p>Conclusao clinica</p>')
|
|
assert.equal('exam' in payload, false)
|
|
})
|