| name | flow-create |
| description | Creer un nouveau flow d'automatisation de formulaire complet, incluant exploration du site web, implementation et tests. (project) |
flow-create
Cree un nouveau flow d'automatisation de formulaire web complet.
Declenchement
/flow-create {platform} {product}
Exemples :
/flow-create alptis prevoyance-tns
/flow-create swisslifeone sante-famille
Journal de bord
IMPORTANT : Tout au long du processus, maintenir un fichier journal qui documente chaque action.
Fichier journal
.claude/flow-logs/{platform}-{product}-create.md
Format du journal
# Journal de creation : {platform} {product}
**Debut** : {date et heure}
**Branche** : flow/{platform}-{product}
**Status** : EN COURS | TERMINE | BLOQUE
---
## Phase 0 : Verification initiale
**Debut** : {timestamp}
- [x] Flow existe deja : NON
- [x] Credentials trouves : ALPTIS_TEST_USERNAME, ALPTIS_TEST_PASSWORD
- [x] Branche creee : flow/{platform}-{product}
**Fin** : {timestamp}
**Duree** : 2 min
---
## Phase 1 : Exploration
**Debut** : {timestamp}
### Actions
- Creation du test d'exploration : `e2e/{platform}/{product}/.detailed/explore-selectors.spec.ts`
- Lancement exploration headless...
### Resultats exploration
- Sections trouvees : 4
- Champs totaux : 18
- Selectors STABLE : 12
- Selectors UNSTABLE : 6
### Champs identifies
| Section | Champ | Type | Selector | Stabilite |
|---------|-------|------|----------|-----------|
| 1 | date_effet | date | input[placeholder='...'] | MODERATE |
| 2 | nom | text | #nom | STABLE |
| ... | ... | ... | ... | ... |
- Cartographie generee : `src/main/flows/cartography/{platform}/{platform}-{product}-exhaustive-mapping.json`
**Fin** : {timestamp}
**Duree** : 15 min
**Commit** : feat({platform}/{product}): add form cartography
---
## Phase 2 : Scaffolding
**Debut** : {timestamp}
### Fichiers crees
- `src/main/flows/config/products/{platform}-{product}.ts`
- `src/main/flows/platforms/{platform}/products/{product}/transformers/types.ts`
- `src/main/flows/platforms/{platform}/products/{product}/transformers/LeadTransformer.ts`
- ... (liste complete)
**Fin** : {timestamp}
**Duree** : 10 min
**Commit** : feat({platform}/{product}): scaffold flow structure
---
## Phase 3 : Implementation
**Debut** : {timestamp}
### Section 1 : Mise en place
- Selectors implementes : 3/3
- Operations utilisees : DateOperations, ToggleOperations
- Test detaille : PASS
- Commit : feat({platform}/{product}): implement section 1 - Mise en place
### Section 2 : Adherent
- Selectors implementes : 8/8
- Operations utilisees : DateOperations, DropdownOperations, RadioOperations
- Test detaille : PASS
- Commit : feat({platform}/{product}): implement section 2 - Adherent
### Section 3 : Conjoint (optionnel)
- Selectors implementes : 4/4
- Test detaille : PASS (avec lead conjoint)
- Commit : feat({platform}/{product}): implement section 3 - Conjoint
### Section 4 : Enfants (dynamique)
- Selectors implementes : 2/2 par enfant
- Logique dynamique : OK (jusqu'a 5 enfants)
- Test detaille : PASS
- Commit : feat({platform}/{product}): implement section 4 - Enfants
**Fin** : {timestamp}
**Duree** : 45 min
---
## Phase 4 : Integration
**Debut** : {timestamp}
- FormFillOrchestrator : OK
- Enregistrement PRODUCT_CONFIGS : OK
- Test single lead (LEAD_INDEX=0) : PASS
**Fin** : {timestamp}
**Duree** : 10 min
**Commit** : feat({platform}/{product}): integrate flow with FlowEngine
---
## Phase 5 : Tests bulk
**Debut** : {timestamp}
### Premier run
- Leads testes : 22
- Resultats : 18 PASS, 4 FAIL
- Problemes identifies :
- Lead #5 : profession non mappee "consultant senior"
- Lead #12 : date format invalide
- Lead #15, #18 : meme probleme profession
### Corrections
- Ajout mapping "consultant senior" -> PROFESSIONS_LIBERALES
- Fix parsing date avec format alternatif
### Second run
- Leads testes : 22
- Resultats : 22 PASS, 0 FAIL
**Fin** : {timestamp}
**Duree** : 20 min
**Commit** : test({platform}/{product}): add test fixtures and bulk validation
---
## Phase 6 : Validation
**Debut** : {timestamp}
### Status final
- Sections implementees : 4/4
- Tests bulk : 22/22 PASS (100%)
- Commits : 8
### En attente
- Review utilisateur
- Merge de la branche
**Fin** : {timestamp}
---
## Problemes rencontres
### Probleme 1 : Dropdown ville ne se charge pas
**Symptome** : Timeout sur selection ville
**Cause** : Le dropdown attend que le code postal soit valide
**Solution** : Ajouter waitForTimeout(2000) apres remplissage code postal
### Probleme 2 : Profession non mappee
**Symptome** : 4 leads en echec avec erreur "Unknown profession"
**Cause** : Mapping manquant pour "consultant senior"
**Solution** : Ajout dans profession-mapper.ts
---
## Resume
- **Temps total** : 1h42
- **Commits** : 8
- **Tests** : 22/22 PASS
- **Status** : PRET POUR REVIEW
Regles du journal
- Creer le fichier au debut de la Phase 0
- Mettre a jour en temps reel a chaque action importante
- Documenter les problemes rencontres et leurs solutions
- Inclure les timestamps pour chaque phase
- Lister tous les fichiers crees/modifies
- Noter les resultats de tests (PASS/FAIL avec details)
Workflow complet
Phase 0 : Verification initiale
-
Verifier si le flow existe deja
ls src/main/flows/config/products/{platform}-{product}.ts
Si le flow existe, suggerer /flow-fix a la place.
-
Verifier les credentials
grep -q "{PLATFORM}_USERNAME" .env && grep -q "{PLATFORM}_PASSWORD" .env
Variables requises :
- Pour Alptis :
ALPTIS_TEST_USERNAME, ALPTIS_TEST_PASSWORD
- Pour SwissLife :
SWISSLIFE_USERNAME, SWISSLIFE_PASSWORD
Si manquants, demander a l'utilisateur de les ajouter au fichier .env.
-
Creer la branche de travail
git checkout -b flow/{platform}-{product}
COMMIT : chore: create branch flow/{platform}-{product}
Phase 1 : Exploration du formulaire
L'exploration se fait en mode headless (pas de fenetre visible).
-
Creer le test d'exploration Playwright
Creer le fichier : e2e/{platform}/{product}/.detailed/explore-selectors.spec.ts
Template base sur : e2e/swisslifeone/slsis/.detailed/inspect-section6-selectors.spec.ts
import { test } from '@playwright/test';
import { create{Platform}Services } from '@/main/flows/engine/services';
import { get{Platform}Credentials } from '@/main/flows/config';
test.describe('Selector Exploration - {Product}', () => {
test('Explore all form sections', async ({ page }) => {
test.setTimeout(600000);
const services = create{Platform}Services(get{Platform}Credentials());
await services.auth.login(page);
await page.goto('{FORM_URL}');
await page.waitForLoadState('networkidle');
console.log('\n====== SECTION 1 ======');
snapshot1 = page.().();
.(, snapshot1.(, ));
inputs = page.().();
( input inputs) {
id = input.();
name = input.();
= input.();
placeholder = input.();
isVisible = input.();
(isVisible) {
stability = ;
(!id) stability = ;
(.(id)) stability = ;
.({ id, name, , placeholder, stability });
}
}
page.({
:
});
});
});
Phase 2 : Scaffolding
Creer l'arborescence complete :
src/main/flows/
├── config/products/{platform}-{product}.ts # ProductConfiguration
└── platforms/{platform}/products/{product}/
├── steps/
│ ├── form-fill/
│ │ ├── FormFillOrchestrator.ts
│ │ ├── index.ts
│ │ ├── selectors/
│ │ │ ├── section1.ts
│ │ │ ├── section2.ts
│ │ │ ├── common.ts
│ │ │ └── index.ts
│ │ ├── sections/
│ │ │ ├── Section1Fill.ts
│ │ │ └── Section2Fill.ts
│ │ └── operations/
│ │ ├── DateOperations.ts
│ │ ├── DropdownOperations.ts
│ │ ├── RadioOperations.ts
│ │ ├── ToggleOperations.ts
│ │ └── index.ts
│ └── navigation/
│ └── index.ts
└── transformers/
├── LeadTransformer.ts
├── types.ts
├── mappers/
│ ├── civilite-mapper.ts
│ ├── profession-mapper.ts
│ └── regime-mapper.ts
└── validators/
├── lead-validator.ts
└── eligibility-validator.ts
e2e/{platform}/{product}/
├── fixtures.ts
├── single-lead-journey.spec.ts
├── bulk-validation.spec.ts
└── .detailed/
├── explore-selectors.spec.ts
├── form-fill.section1.spec.ts
├── form-fill.section2.spec.ts
└── transformer.spec.ts
Fichiers de reference a copier/adapter :
| Type | Fichier de reference |
|---|
| ProductConfiguration | src/main/flows/config/products/alptis-sante-pro-plus.ts |
| FormFillOrchestrator | src/main/flows/platforms/alptis/products/sante-pro-plus/steps/form-fill/FormFillOrchestrator.ts |
| Selectors | src/main/flows/platforms/alptis/products/sante-pro-plus/steps/form-fill/selectors/section2.ts |
| Operations | src/main/flows/platforms/alptis/products/sante-pro-plus/steps/form-fill/operations/ |
| LeadTransformer | src/main/flows/platforms/alptis/products/sante-pro-plus/transformers/LeadTransformer.ts |
| Mappers | src/main/flows/platforms/alptis/products/sante-pro-plus/transformers/mappers/ |
| Fixtures e2e | e2e/alptis/fixtures.ts |
| Single lead test | e2e/alptis/sante-pro-plus/single-lead-journey.spec.ts |
COMMIT : feat({platform}/{product}): scaffold flow structure
Phase 3 : Implementation section par section
Pour chaque section du formulaire (en ordre) :
-
Types : Definir {Product}FormData base sur la cartographie
export type {Product}FormData = {
mise_en_place: {
remplacement_contrat: boolean;
date_effet: string;
};
adherent: {
civilite: 'M.' | 'Mme';
nom: string;
prenom: string;
date_naissance: string;
};
conjoint?: { ... };
enfants?: Array<{ ... }>;
};
-
Mappers : Creer un mapper pour chaque enum
const PROFESSION_MAPPING: Record<string, string> = {
'profession liberale': 'PROFESSIONS_LIBERALES',
"chef d'entreprise": 'CHEFS_D_ENTREPRISE',
};
export function mapProfession(value: string | undefined): string {
if (!value) return 'AUTRES';
return [value.().()] ?? ;
}
COMMIT apres chaque section : feat({platform}/{product}): implement section {n} - {name}
Phase 4 : Integration
-
Implementer le FormFillOrchestrator
export class FormFillOrchestrator {
private section1 = new Section1Fill();
private section2 = new Section2Fill();
async fillMiseEnPlace(page: Page, data: FormData, logger?: FlowLogger) {
await this.section1.fill(page, data, logger);
}
async fillAdherent(page: Page, data: FormData, logger?: FlowLogger) {
await this.section2.fill(page, data, logger);
}
}
-
Enregistrer dans PRODUCT_CONFIGS
Editer src/main/flows/config/products/index.ts :
import { {PLATFORM}_{PRODUCT} } from "./{platform}-{product}";
export const PRODUCT_CONFIGS: Record<string, > = {
[{}_{}.]: {}_{},
};
COMMIT : feat({platform}/{product}): integrate flow with FlowEngine
Phase 5 : Tests bulk et generation de leads
-
Tester sur tous les leads existants (headless)
npx playwright test e2e/{platform}/{product}/bulk-validation.spec.ts
-
Si aucun lead compatible : Generer des fixtures JSON programmatiquement
Creer dans src/main/__tests__/fixtures/emails/ :
email-{next}-solo.json : Lead sans conjoint ni enfants
email-{next}-conjoint.json : Lead avec conjoint
email-{next}-enfants.json : Lead avec enfants
email-{next}-both.json : Lead avec conjoint ET enfants
Format :
{
"id": "fixture-{product}-solo",
"subject": "Nouveau lead - {Product} Solo",
"from": "test@fixture.com",
"date": 1700000000000,
"text": "Civilite: M.\nNom: DUPONT\nPrenom: Jean\n..."
}
-
Iterer jusqu'a 100% de succes
- Si un test echoue : identifier le probleme, corriger, re-tester
- Repeter jusqu'a ce que bulk-validation passe a 100%
COMMIT : test({platform}/{product}): add test fixtures and bulk validation
Phase 6 : Validation utilisateur
Quand tous les tests passent OU si bloque :
Flow {platform}_{product} pret pour review.
Status:
- Sections implementees: {n}/{total}
- Tests bulk: {passed}/{total} leads
- Coverage: {percentage}%
Prochaines etapes:
1. Review du code
2. Merge de la branche
3. Test manuel si necessaire
Demander a l'utilisateur s'il veut :
- Merger la branche
- Faire des ajustements
- Voir les details d'un probleme
Conventions
Nommage
| Element | Pattern | Exemple |
|---|
| flowKey | {platform}_{product} | alptis_sante_select |
| Branche | flow/{platform}-{product} | flow/alptis-prevoyance-tns |
| Config file | {platform}-{product}.ts | alptis-prevoyance-tns.ts |
Pattern de selectors
{
primary: "#semantic-id",
alternative: ".class-selector",
byValue: (v) => `[value='${v}']`,
byRole: "combobox",
byPosition: ".item:nth(0)",
fallback: "label:has-text('...')",
stability: 'STABLE' | 'MODERATE' | 'UNSTABLE',
}
Format commits
{type}({platform}/{product}): {description}
- Detail 1
- Detail 2
Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Types : feat, fix, test, chore, docs
Checklist