forked from Yara724/api
fanavaran sales integration docs
This commit is contained in:
90
docs/fanavaran/10-testing.md
Normal file
90
docs/fanavaran/10-testing.md
Normal file
@@ -0,0 +1,90 @@
|
||||
---
|
||||
last_updated: 2026-08-08
|
||||
tags: [fanavaran, testing]
|
||||
source: fanavaran-module-docs
|
||||
---
|
||||
|
||||
# 10 — Testing
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. `FANAVARAN_CLIENT=parsian` (or target tenant)
|
||||
2. Valid tenant credentials in Mongo / seed
|
||||
3. `INSURANCE_CORP_ID` matching that tenant’s insurance-corp Caption
|
||||
4. Network access to `apimanager.iraneit.com`
|
||||
5. Optional: warm lookups via first `GET /lookups/fanavaran/{name}` or auth script
|
||||
|
||||
## Auth smoke test
|
||||
|
||||
```bash
|
||||
scripts/fanavaran-auth.sh parsian
|
||||
source files/fanavaran-auth/parsian/tokens.env
|
||||
# then curl a lookup — see docs/external-api-curls.md
|
||||
```
|
||||
|
||||
## Unit / service specs
|
||||
|
||||
| Spec | Focus |
|
||||
|------|-------|
|
||||
| `src/fanavaran/fanavaran-auth.service.spec.ts` | Token cache / midnight / backoff |
|
||||
| `src/claim-request-management/fanavaran-policy-selection.spec.ts` | Latest active policy selection |
|
||||
|
||||
Prefer mocks for Fanavaran HTTP in unit tests; use live calls only in controlled integration.
|
||||
|
||||
## Manual E2E (Parsian template)
|
||||
|
||||
1. Create THIRD_PARTY claim with guilty party national code that has an **active** Fanavaran policy.
|
||||
2. Confirm history `FANAVARAN_EARLY_AUTO_SUBMIT_SUCCEEDED` and `claimId`/`claimNo`.
|
||||
3. Select outer parts → `dmgCaseId` set.
|
||||
4. Upload images → attachment file ids under `fanavaranSync.attachments`.
|
||||
5. Submit expert pricing → `expertiseId`.
|
||||
6. Cross-check `fanavaranAuditLogs` for each stage.
|
||||
|
||||
Preview first if debugging:
|
||||
|
||||
```http
|
||||
GET /v2/fanavaran/parsian/claim-cases/{id}/base-claim/preview?debug=true
|
||||
GET /v2/fanavaran/parsian/claim-cases/{id}/damage-case/preview
|
||||
GET /v2/fanavaran/parsian/claim-cases/{id}/attachments/preview
|
||||
GET /v2/fanavaran/parsian/claim-cases/{id}/expertise/preview
|
||||
```
|
||||
|
||||
## Success scenarios
|
||||
|
||||
| Scenario | Expect |
|
||||
|----------|--------|
|
||||
| Happy path Parsian | All four stages succeed |
|
||||
| Re-preview after PolicyId cached | No new policy inquiry |
|
||||
| Soft-ensure | Damage submit creates base if missing |
|
||||
| Skip duplicate base | Second auto-submit skipped when claimId exists |
|
||||
|
||||
## Error scenarios
|
||||
|
||||
| Scenario | Expect |
|
||||
|----------|--------|
|
||||
| Expired policy | Clear BadRequest; no create |
|
||||
| Wrong FileTypeId (e.g. 70 on Parsian) | Attachment fail message about lookup |
|
||||
| Transient try-later | Backoff; delayed retry; no login storm |
|
||||
| Fanavaran down on auto-submit | Local claim continues; history FAILED; manual retry path in warning |
|
||||
|
||||
## Proven reference case (Parsian)
|
||||
|
||||
| Local | Fanavaran |
|
||||
|-------|-----------|
|
||||
| `CL68535` / `A00153` / `_id` `6a707a3a8f4c6fbd851cfa75` | — |
|
||||
| Base | `claimId=4909952`, `claimNo=1632`, `policyId=13764408` |
|
||||
| Damage | `dmgCaseId=427594`, `DriverId=2426953` |
|
||||
| Attachments | FileTypeId **63**; file ids `4629737`… |
|
||||
| Expertise | `expertiseId=403144`, assessor `29` |
|
||||
|
||||
Defaults used: GEN.03 expert `154`, GEN.08 `29`, Location `210050`, InsuranceCorpId `329`, VehicleKindId `6704`.
|
||||
|
||||
## Mocks
|
||||
|
||||
- Mock `HttpService` / axios for auth + submit in unit tests.
|
||||
- Offline plate/driver seeds for local payload builds without live inquiry (used in proven Parsian offline+live mix).
|
||||
- Do not commit live tokens.
|
||||
|
||||
## Curl catalogue
|
||||
|
||||
Operational curl sequences (auth, lookups, sample submits): [`docs/external-api-curls.md`](../external-api-curls.md).
|
||||
Reference in New Issue
Block a user