Squash merge de develop vers master. Livrables principaux (ticket #101 et mise au point associée) : - Branchement du formulaire d'inscription parent sur POST /api/v1/auth/register/parent - Payload DTO (parents, enfants, photos base64, CGU) et services Auth - Parcours gestionnaire : cartes dossiers, wizard validation famille, images authentifiées - Scripts d'inscription test (Martin, Durand/Rousseau, Lecomte) ; .gitignore .cursor/ Inclut également les ajustements develop fusionnés dans ce lot (inscription AM, champs relais, etc.). Closes #101 Made-with: Cursor
127 lines
3.7 KiB
JavaScript
127 lines
3.7 KiB
JavaScript
/**
|
|
* POST /api/v1/auth/register/parent — jeu de test officiel famille MARTIN (docs/test-data + seed).
|
|
* Emails canoniques : claire.martin@ptits-pas.fr, thomas.martin@ptits-pas.fr
|
|
*
|
|
* Usage : node scripts/register-parent-martin-test.mjs [BASE_URL]
|
|
* Ex. : node scripts/register-parent-martin-test.mjs https://app.ptits-pas.fr
|
|
*/
|
|
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import https from 'https';
|
|
import http from 'http';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const repoRoot = path.join(__dirname, '..');
|
|
const photosDir = path.join(repoRoot, 'ressources', 'Photos');
|
|
|
|
function toDataUri(filePath) {
|
|
const buf = fs.readFileSync(filePath);
|
|
return `data:image/png;base64,${buf.toString('base64')}`;
|
|
}
|
|
|
|
const presentationDossier =
|
|
"Nous sommes Claire et Thomas MARTIN, parents d'Emma, Noah et Léa, triplés nés le 15 février 2023. " +
|
|
"Nous recherchons une assistante maternelle bienveillante et structurée pour accueillir nos trois enfants, " +
|
|
"avec une capacité d'accueil adaptée à la garde de plusieurs nourrissons. " +
|
|
"Nous habitons à Bezons ; nous tenons à remercier le service pour l'étude de notre dossier.";
|
|
|
|
const body = {
|
|
email: 'claire.martin@ptits-pas.fr',
|
|
prenom: 'Claire',
|
|
nom: 'MARTIN',
|
|
telephone: '0689567890',
|
|
adresse: '5 Avenue du Général de Gaulle',
|
|
code_postal: '95870',
|
|
ville: 'Bezons',
|
|
co_parent_email: 'thomas.martin@ptits-pas.fr',
|
|
co_parent_prenom: 'Thomas',
|
|
co_parent_nom: 'MARTIN',
|
|
co_parent_telephone: '0678456789',
|
|
co_parent_meme_adresse: true,
|
|
enfants: [
|
|
{
|
|
prenom: 'Emma',
|
|
nom: 'MARTIN',
|
|
date_naissance: '2023-02-15',
|
|
genre: 'F',
|
|
photo_base64: toDataUri(path.join(photosDir, 'C_Emma MARTIN.png')),
|
|
photo_filename: 'emma_martin.png',
|
|
grossesse_multiple: true,
|
|
},
|
|
{
|
|
prenom: 'Noah',
|
|
nom: 'MARTIN',
|
|
date_naissance: '2023-02-15',
|
|
genre: 'H',
|
|
photo_base64: toDataUri(path.join(photosDir, 'C_Noah MARTIN_2.png')),
|
|
photo_filename: 'noah_martin.png',
|
|
grossesse_multiple: true,
|
|
},
|
|
{
|
|
prenom: 'Léa',
|
|
nom: 'MARTIN',
|
|
date_naissance: '2023-02-15',
|
|
genre: 'F',
|
|
photo_base64: toDataUri(path.join(photosDir, 'C_Léa MMARTIN.png')),
|
|
photo_filename: 'lea_martin.png',
|
|
grossesse_multiple: true,
|
|
},
|
|
],
|
|
presentation_dossier: presentationDossier,
|
|
acceptation_cgu: true,
|
|
acceptation_privacy: true,
|
|
};
|
|
|
|
const json = JSON.stringify(body);
|
|
const baseArg = process.argv[2] || 'https://app.ptits-pas.fr';
|
|
const base = new URL(baseArg.endsWith('/') ? baseArg.slice(0, -1) : baseArg);
|
|
const url = new URL('/api/v1/auth/register/parent', `${base.protocol}//${base.host}`);
|
|
|
|
const opts = {
|
|
hostname: url.hostname,
|
|
port: url.port || (url.protocol === 'https:' ? 443 : 80),
|
|
path: url.pathname,
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
Accept: 'application/json',
|
|
'Content-Length': Buffer.byteLength(json, 'utf8'),
|
|
},
|
|
};
|
|
|
|
const lib = url.protocol === 'https:' ? https : http;
|
|
|
|
console.error(`POST ${url.href} (payload ~${Math.round(json.length / 1024)} Ko)`);
|
|
|
|
const req = lib.request(opts, (res) => {
|
|
let data = '';
|
|
res.on('data', (c) => {
|
|
data += c;
|
|
});
|
|
res.on('end', () => {
|
|
console.log('HTTP', res.statusCode);
|
|
try {
|
|
const j = JSON.parse(data);
|
|
console.log(JSON.stringify(j, null, 2));
|
|
} catch {
|
|
console.log(data.slice(0, 4000));
|
|
}
|
|
});
|
|
});
|
|
|
|
req.on('error', (e) => {
|
|
console.error('Erreur réseau:', e.message);
|
|
process.exit(1);
|
|
});
|
|
|
|
req.setTimeout(120000, () => {
|
|
req.destroy();
|
|
console.error('Timeout 120s');
|
|
process.exit(1);
|
|
});
|
|
|
|
req.write(json);
|
|
req.end();
|