سامانه صدور فاکتور و حسابداری

QA: stabilize Phase 0 invoice mock after async bootstrap (#161)

* docs: register Phase 0 final CI fixture timing failure and scoped QA correction * test: stabilize isolated invoice fixture after async ERP bootstrap

davoodmehraban89 committed Oct 16, 2026 at 11:18 UTC bccd474433b4188e43aae345773498ea6fc65209
2 files changed +10 -1
PROJECT_STATE.md
+4
@@ -34,3 +34,7 @@
34 ## ۶. ثبت پایان این نوبت
35 - درخواست مالک در ۱۴۰۵/۰۷/۲۴: «پرامپت را کامل مبنا بگیر؛ **فقط فاز ۰** را اجرا کن و بعد از پایان گزارش خلاصه بده؛ ادامه فاز ۱ با دستور جداگانه».
36 - شروع از `main` SHA بالا، ایجاد شاخه `audit/finora-master-prompt-phase0-20261016`، آرشیو کامل و گزارش‌ها تولید شد. **وضعیت QA این شاخه باید از GitHub PR-head جدا بررسی شود**؛ تایید نهایی فاز فقط با قبولی آن و ادغام مستندات معتبر است.
37 +
38 +### 2026-10-16 Phase 0 post-merge Chromium intermittent fixture (QA-only follow-up; NOT application defect proven)
39 +- **Original Phase 0 PR:** #160 merged exact-main `67be4fbfa6161156b10ce6279445266c989e97d3`. PR-head Quality `38867730181` 123/123 Chromium PASS, isolated DB and Security PASS. Protected main Quality `38868319174` attempt 1 **FAIL 122/123** at `scripts/phase0-invoice-persistence.spec.js:52`, `#auth-screen` remained visible for 5 seconds; all three DB jobs and Security `38868319200` succeeded. Same-SHA failed-job rerun attempt 2 was requested; result must be verified separately. Neither result proves actual production financial persistence or login failure.
40 +- **Source-reproduced test harness race:** `authenticatedMockBrowser` waits only for `enterApp`, `commitSaveInvoice`, `pullAll` functions before installing a fake authenticated identity; asynchronously loaded `organization-rbac` wrapper can supersede the fake identity. Prior `scripts/accounting-document-workflow.spec.js:36–43` already fixes the identical fixture ordering issue by waiting for `FinoraStartupStatus.extensionsReady`, zero failed extensions, and `authChecked`. Apply the same pre-mock readiness condition **only in this synthetic invoice test**; preserve all UI, Supabase/Auth/RLS, financial accounting and live record behavior. Require Quality 123/123, Security and all three disposable DB on exact repair SHA; then controlled protected merge and same-main checks. Rollback is a test-only revert. All owner-ISP and real invoice E2E remain NOT VERIFIED.
scripts/phase0-invoice-persistence.spec.js
+6 -1
@@ -28,7 +28,12 @@ async function installHarness(page,server){
28 }
29 async function authenticatedMockBrowser(page){
30 await page.goto(BASE,{waitUntil:'domcontentloaded'});
31 - await page.waitForFunction(()=>typeof enterApp==='function'&&typeof commitSaveInvoice==='function'&&typeof pullAll==='function');
31 + // Mock identity must be injected only after the async organization wrapper
32 + // and all ERP extensions have finished installing. Test-only readiness guard.
33 + await page.waitForFunction(()=>typeof enterApp==='function'&&typeof commitSaveInvoice==='function'&&
34 + typeof pullAll==='function'&&window.FinoraStartupStatus?.extensionsReady===true&&
35 + window.FinoraStartupStatus?.failedExtensionCount===0&&
36 + window.FinoraStartupStatus?.authChecked===true,{timeout:20000});
37 await page.evaluate(async()=>{
38 window.__FINORA_PRINT_TEST_MODE=true;
39 window.__f0Alerts=[];