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

Decompose settings into focused task routes

davoodmehraban89 committed Sep 29, 2026 at 23:42 UTC b2fff1284074f3236f944924dbfbaaed6c56d939
4 files changed +10 -10
PROJECT_STATE.md
+1 -1
@@ -34,7 +34,7 @@ Before doing any project work:
34 ## Current change ledger
35 | Date | Request / decision | Status | Evidence / next action |
36 |---|---|---|---|
37 -| 2026-09-29 | Owner rejected the current workspace-dump navigation. Redesign Finora around the approved two-tier enterprise shell shown in the canonical screenshot: primary module rail + rich contextual subsystem menu; replace `خانه` with `داشبورد`; keep owner-approved domain grouping such as sales/purchases/contacts under بازرگانی; give accounting and every major module organized groups (e.g. پایه/عملیات/دفاتر و گزارش‌ها/ابزارها) with one clear action/view per menu item. Before implementation, research multiple Iranian accounting/ERP products (not one vendor), official product structures/demos plus user/accounting-community feedback, synthesize patterns without copying a vendor, then migrate existing working views into the hierarchy without feature loss or fake modules. | IN PROGRESS | Research completed across the approved screenshot, live shell, Sepidar official system/accounting pages and training UI, Rahkaran/System Group module structure, Holoo task/report material, Gheyas/user feedback and independent review feedback. Synthesis is recorded in `docs/FINORA_INFORMATION_ARCHITECTURE_V2.md`: nine primary business modules, rich grouped contextual menus, task-level navigation, no `خانه`, no standalone `کالا`, no generic `ERP`, and no fake future modules. IA contract committed at `9631f6ef`. This implementation checkpoint replaces the rail with Dashboard/Accounting/Commerce/Treasury/Projects/Inventory/Fixed Assets/Reports/Settings; removes `خانه`, standalone `کالا` and generic `ERP`; expands Accounting into grouped base/operations/books-report commands; and introduces task-level workspace focusing so account chart, floating dimensions, rules, fiscal years, branches, projects, journal entry/register, reports, inventory/assets/data-center tasks no longer dump unrelated cards together. Commerce retains contacts/products/sales/purchases. Real-DOM gates are extended to verify the new hierarchy and focused task behavior. Pre-CI review found and corrected one contradictory legacy `erp` rail assertion, added task-aware command-search routing/context, and hides the empty fiscal/branch grid wrapper when another accounting task is focused. Quality run `36624026541` on `dcb0d4ab` proved JavaScript syntax PASS but exposed a stale Phase 5 gate that still required every Phase 5 view to map to the removed generic `erp` module. The gate is updated in this checkpoint to verify the new canonical ownership (`inventory`, `assets`, accounting currency, settings data/integrations), reject deprecated `home/catalog/erp` rail entries, and require the new accounting hierarchy. Dashboard is also rebuilt in this checkpoint to match the approved analytical direction without fabricated values: white enterprise KPI cards for assets/cash/receivables/payables, six-month cash-in/out SVG from actual payment records, account-status bars, task-level quick access and latest journal vouchers. All values are derived from the existing ledger/operational data and remain zero/empty when no production accounting data exists. Quality run `36624183478` on the pre-dashboard `c254e5f1` passed syntax, application invariants, Phase 2–6, Golden Journey and browser installation; Real-DOM alone failed because `openModule()` rendered the selected task and then `switchView()` reset the contextual panel before the non-rerendering navigation returned. The product navigation state bug is fixed here by making `openModule()` complete the canonical task navigation/rerender path. The analytical dashboard checkpoint `96adf600` is retained. Direct-view compatibility is hardened: switchView clears any previous task filter; task navigation then reapplies the requested focus. Real-DOM verifies focused mode and reset-to-full-view behavior. CI verification is required next. |
37 +| 2026-09-29 | Owner rejected the current workspace-dump navigation. Redesign Finora around the approved two-tier enterprise shell shown in the canonical screenshot: primary module rail + rich contextual subsystem menu; replace `خانه` with `داشبورد`; keep owner-approved domain grouping such as sales/purchases/contacts under بازرگانی; give accounting and every major module organized groups (e.g. پایه/عملیات/دفاتر و گزارش‌ها/ابزارها) with one clear action/view per menu item. Before implementation, research multiple Iranian accounting/ERP products (not one vendor), official product structures/demos plus user/accounting-community feedback, synthesize patterns without copying a vendor, then migrate existing working views into the hierarchy without feature loss or fake modules. | IN PROGRESS | Research completed across the approved screenshot, live shell, Sepidar official system/accounting pages and training UI, Rahkaran/System Group module structure, Holoo task/report material, Gheyas/user feedback and independent review feedback. Synthesis is recorded in `docs/FINORA_INFORMATION_ARCHITECTURE_V2.md`: nine primary business modules, rich grouped contextual menus, task-level navigation, no `خانه`, no standalone `کالا`, no generic `ERP`, and no fake future modules. IA contract committed at `9631f6ef`. This implementation checkpoint replaces the rail with Dashboard/Accounting/Commerce/Treasury/Projects/Inventory/Fixed Assets/Reports/Settings; removes `خانه`, standalone `کالا` and generic `ERP`; expands Accounting into grouped base/operations/books-report commands; and introduces task-level workspace focusing so account chart, floating dimensions, rules, fiscal years, branches, projects, journal entry/register, reports, inventory/assets/data-center tasks no longer dump unrelated cards together. Commerce retains contacts/products/sales/purchases. Real-DOM gates are extended to verify the new hierarchy and focused task behavior. Pre-CI review found and corrected one contradictory legacy `erp` rail assertion, added task-aware command-search routing/context, and hides the empty fiscal/branch grid wrapper when another accounting task is focused. Quality run `36624026541` on `dcb0d4ab` proved JavaScript syntax PASS but exposed a stale Phase 5 gate that still required every Phase 5 view to map to the removed generic `erp` module. The gate is updated in this checkpoint to verify the new canonical ownership (`inventory`, `assets`, accounting currency, settings data/integrations), reject deprecated `home/catalog/erp` rail entries, and require the new accounting hierarchy. Dashboard is also rebuilt in this checkpoint to match the approved analytical direction without fabricated values: white enterprise KPI cards for assets/cash/receivables/payables, six-month cash-in/out SVG from actual payment records, account-status bars, task-level quick access and latest journal vouchers. All values are derived from the existing ledger/operational data and remain zero/empty when no production accounting data exists. Quality run `36624183478` on the pre-dashboard `c254e5f1` passed syntax, application invariants, Phase 2–6, Golden Journey and browser installation; Real-DOM alone failed because `openModule()` rendered the selected task and then `switchView()` reset the contextual panel before the non-rerendering navigation returned. The product navigation state bug is fixed here by making `openModule()` complete the canonical task navigation/rerender path. The analytical dashboard checkpoint `96adf600` is retained. Direct-view compatibility is hardened: switchView clears any previous task filter; task navigation then reapplies the requested focus. Real-DOM verifies focused mode and reset-to-full-view behavior. Settings is also decomposed into task-level routes: company, account/password, invoice defaults, operational settings, data/backup, integrations, about, and admin/license. Topbar company and fiscal-year pills now deep-link directly to their canonical tasks instead of dumping the full settings page. Real-DOM adds a focused company-settings assertion. CI verification is required next. |
38 | 2026-09-29 | Continue post-release hardening after the executable accounting/database fixes; close remaining verifiable acceptance gaps without claiming external/manual checks. | IN PROGRESS | Browser checkpoint `2c6bab32` adds real-Chromium expired-license enforcement: expired subscription renders expired, `canWrite()` is false and `requireWrite()` blocks mutation. This checkpoint also adds a deterministic 20,008-line Phase 6 reporting workload covering rollup/trial-balance equality, P&L correctness, ledger row preservation and a 5-second CI regression ceiling. Pre-CI review caught that the dated ledger filter correctly excludes the two February seed lines, so the expected January workload is 20,006 rather than 20,008; the assertion is corrected in this checkpoint before acceptance. Latest executable code head is `9822bad8`: it corrects the dated performance expectation before acceptance. The prior superseded run `36621990092` on `b992e486` confirms syntax, application invariants and Phase 2–5 (including depreciation reversal) all PASS, then fails only on the now-corrected January ledger-row expectation before Golden/DOM steps. Additional live production rollback-only security QA exercised all three admin license mutation RPCs (`cancel`, `extend`, `set`) under a non-admin authenticated JWT; all were denied with the shared internal admin guard, while `is_admin=false`; transaction rolled back. Supabase performance advisor remains clean; security advisor still reports the five intentional SECURITY DEFINER-callability warnings plus leaked-password protection disabled. Latest `9822bad8` push-run ID remains unavailable through the connector and no failure notification has appeared yet, so combined Quality/real-DOM remains NOT VERIFIED. |
39 | 2026-09-29 | Owner supplied another GitHub Actions failure (`golden-accounting-core-check.mjs`: `revenue report mismatch`) and asked for exact current progress plus continuous diagnosis/fix until the hardening work reaches a verified conclusion. Treat repeated run failures as blockers, distinguish superseded-run failures from current-head failures, and do not stop after a single fix while executable work remains. | IMPLEMENTATION COMPLETE / FINAL EXTERNAL VERIFICATION REMAINS | The supplied failure at `19:25:15Z` maps to the custom-chart transition around `d6b293e4`, not the later documentation head. Root accounting/report defect identified: Phase 6 `rollup()` discarded the account-master `accountType`, so `financials()` could not actually use the explicit classification promised by the earlier custom-chart hardening and silently fell back to code/title heuristics. This checkpoint preserves `accountType/systemRole` in report rollups, makes cash-flow use the explicit cash system role, and strengthens the Golden Journey with neutral arbitrary account titles plus diagnostic expected/actual values. CI run `36620001387` on `768f97ab` proves JavaScript syntax, application invariants, Phase 2–6 behavior, Golden Accounting Journey and browser-runtime install all PASS. Its only failure was the new print DOM assertion using Playwright `toContainText()` on a `<style>` element; GitHub log showed the style element actually contained `A4 landscape`. Commit `9d0a3122` corrected the assertion to inspect style `innerHTML`, archived/applied production migrations under exact versions `20260929193348` and `20260929193357`, and production rollback-only QA proved settled-cheque immutability plus case-insensitive account-code uniqueness with zero QA rows left. Depreciation reversal was then implemented without weakening immutable source history at `e70b07a1`; run `36620902948` exposed only a Node-VM harness omission (`getMyJournalVouchers` absent), corrected at `521b0de7`. No GitHub failure notification for `521b0de7` was present in the connected mailbox after the normal failure-notification window, but the exact push-run ID is unavailable through the current connector, so latest-head CI/real-DOM is NOT VERIFIED rather than assumed PASS. |
40 | 2026-09-29 | Owner reported repeated GitHub Actions `run failed` notifications and supplied a Quality log failing on stale static needle `v.status==='posted'`. Diagnose the live CI failure first, repair the gate without weakening accounting safety, verify current CI, then continue the approved hardening backlog. Reduce avoidable CI churn by batching subsequent related durable changes where practical. | FIXED / CI VERIFICATION PENDING | Root cause confirmed: `journal-engine.js` was intentionally hardened from posted-only source locking to posted+reversed locking, while `quality-check.mjs` still searched for the obsolete literal `v.status==='posted'`. The gate is being corrected to require `jeSourceLocked` plus `['posted','reversed'].includes`, which is stronger and matches live semantics. Fix commit `78c6a071` replaced the obsolete posted-only literal with the stronger `jeSourceLocked` + posted/reversed invariant. Follow-up inspection exposed a hidden Phase 2 test-script syntax defect (duplicate `const companies`) that the old syntax gate could not detect because it only parsed `js/*.js`; the next batched checkpoint removes that duplicate, makes syntax CI check every `scripts/*.mjs`, and removes duplicate Phase 6 behavior execution from `quality-check.mjs` now that Phase 6 has its own named workflow step. Root cause fixed at `78c6a071`; follow-up CI repair `20294e31` removed the hidden duplicate Phase 2 declaration, checks syntax of all MJS gates and avoids duplicate Phase 6 execution. `18ea5c8b` added Quality/Security concurrency cancellation plus real-Chromium A4/A5 pagination/page-break checks, reducing superseded-run noise. Subsequent requirement hardening: legacy-company starter-chart fix `3b3ffba2`; custom-chart system posting roles + arbitrary-code Golden Journey `d6b293e4`; role-aware AR/AP/cash-flow/project-contract reporting and prepared role uniqueness `dbe9170c`; incremental self-healing posting profiles `73bd9f3f`. Push-run IDs remain unavailable through the current connector, so latest CI/real-DOM is still NOT VERIFIED; any new failure log must be diagnosed before acceptance. |
index.html
+7 -7
@@ -269,8 +269,8 @@ body{background:#f6f9fc}
269 <div id="command-search-results" class="command-results"></div>
270 </div>
271 <div class="topbar-actions">
272 - <button class="topbar-pill fiscal-pill" id="topbar-fiscal-year" onclick="switchView('view-settings')" title="سال مالی">سال مالی جاری</button>
273 - <button class="topbar-pill" id="topbar-company" onclick="switchView('view-settings')" title="شرکت فعال">شرکت فعال</button>
272 + <button class="topbar-pill fiscal-pill" id="topbar-fiscal-year" onclick="navigateShell('accounting','view-accounting-foundation','fiscal')" title="سال مالی">سال مالی جاری</button>
273 + <button class="topbar-pill" id="topbar-company" onclick="navigateShell('settings','view-settings','company')" title="شرکت فعال">شرکت فعال</button>
274 <button class="topbar-pill" onclick="startNewInvoice()" title="عملیات سریع">+ عملیات سریع</button>
275 </div>
276 </header>
@@ -601,7 +601,7 @@ body{background:#f6f9fc}
601 <button class="btn btn-danger btn-inline no-print" style="padding:6px 12px;font-size:12px;min-height:32px" onclick="handleLogout()">🚪 خروج از حساب کاربری</button>
602 </div>
603
604 -<div class="accordion-item">
604 +<div class="accordion-item" data-finora-task="account">
605 <div class="accordion-header" onclick="toggleAccordion(this)"><span>🔐 حساب کاربری و رمز عبور</span><span>▼</span></div>
606 <div class="accordion-body">
607 <p style="font-size:13px;color:var(--text-muted);margin-bottom:10px">با تعیین رمز عبور، دفعات بعد می‌توانید علاوه بر ورود با گوگل، مستقیم با ایمیل و رمز عبور هم وارد سامانه شوید.</p>
@@ -613,7 +613,7 @@ body{background:#f6f9fc}
613 </div>
614 </div>
615
616 -<div class="accordion-item open">
616 +<div class="accordion-item open" data-finora-task="company">
617 <div class="accordion-header" onclick="toggleAccordion(this)"><span>🏢 اطلاعات فروشگاه و چاپ (مدیریت شرکت‌ها)</span><span>▼</span></div>
618 <div class="accordion-body">
619 <div class="form-row">
@@ -639,7 +639,7 @@ body{background:#f6f9fc}
639 </div>
640 </div>
641
642 -<div class="accordion-item">
642 +<div class="accordion-item" data-finora-task="invoice-defaults">
643 <div class="accordion-header" onclick="toggleAccordion(this)"><span>⚙️ مالیات، تخفیف و واحد پول (پیش‌فرض فاکتور جدید)</span><span>▼</span></div>
644 <div class="accordion-body">
645 <div class="form-row">
@@ -655,7 +655,7 @@ body{background:#f6f9fc}
655 </div>
656 </div>
657
658 -<div class="accordion-item">
658 +<div class="accordion-item" data-finora-task="legacy-backup">
659 <div class="accordion-header" onclick="toggleAccordion(this)"><span>💾 دیتابیس و پشتیبان‌گیری</span><span>▼</span></div>
660 <div class="accordion-body">
661 <p style="font-size:13px;color:var(--text-muted);margin-bottom:12px">وضعیت دیتابیس: <span class="badge badge-success">تفکیک کاربر فعال</span></p>
@@ -666,7 +666,7 @@ body{background:#f6f9fc}
666 </div>
667 </div>
668
669 -<div class="accordion-item">
669 +<div class="accordion-item" data-finora-task="about">
670 <div class="accordion-header" onclick="toggleAccordion(this)"><span>ℹ️ درباره نرم‌افزار</span><span>▼</span></div>
671 <div class="accordion-body">
672 <h3 style="font-size:16px;font-weight:bold">فینورا - Finora</h3>
js/ui.js
+1 -1
@@ -73,7 +73,7 @@ const FINORA_MODULES={
73 inventory:{title:'انبار',context:'انبار، گردش، شمارش و بهای موجودی',groups:[{title:'اطلاعات پایه',items:[['تعریف انبار','view-inventory','▦','','warehouse']]},{title:'عملیات',items:[['گردش انبار','view-inventory','⇄','','movement'],['انبارگردانی','view-inventory','✓','','count']]},{title:'گزارش و کنترل',items:[['موجودی و بهای میانگین','view-inventory','▥','','stock']]}]},
74 assets:{title:'دارایی ثابت',context:'دارایی، استهلاک و ارزش دفتری',groups:[{title:'اطلاعات پایه',items:[['ثبت دارایی','view-assets','◆','','asset-new']]},{title:'عملیات و دفاتر',items:[['دفتر دارایی‌ها','view-assets','▤','','asset-register'],['استهلاک و سوابق','view-assets','◷','','depreciation']]}]},
75 reports:{title:'گزارش‌ها',context:'گزارش‌های حسابداری و مدیریتی',groups:[{title:'مدیریتی',items:[['گزارش‌های عملیاتی','view-reports','▥']]},{title:'حسابداری',items:[['تراز آزمایشی','view-accounting-reports','▥','','trial'],['دفاتر حسابداری','view-accounting-reports','▤','','ledger'],['صورت‌های مالی','view-accounting-reports','◫','','financials'],['جریان وجوه نقد','view-accounting-reports','↕','','cashflow'],['سن مطالبات / بدهی','view-accounting-reports','◷','','aging'],['پروژه / پیمان','view-accounting-reports','▧','','projects']]}]},
76 - settings:{title:'تنظیمات',context:'شرکت، داده، دسترسی و یکپارچه‌سازی',groups:[{title:'شرکت و عملیات',items:[['شرکت‌ها و تنظیمات عمومی','view-settings','⚙'],['تنظیمات عملیاتی','view-data-center','◌','','ops-settings']]},{title:'داده و پشتیبان',items:[['ورود/خروج داده و پشتیبان','view-data-center','⇅','','data-backup']]},{title:'یکپارچه‌سازی',items:[['اتصالات و API','view-integrations','⇆']]},{title:'مدیریت',items:[['کاربران و لایسنس','view-admin','♙','admin']]}]}
76 + settings:{title:'تنظیمات',context:'شرکت، داده، دسترسی و یکپارچه‌سازی',groups:[{title:'حساب و شرکت',items:[['شرکت‌ها','view-settings','▦','','company'],['حساب کاربری و رمز','view-settings','♙','','account'],['پیش‌فرض فاکتور','view-settings','▤','','invoice-defaults']]},{title:'عملیات و داده',items:[['تنظیمات عملیاتی','view-data-center','◌','','ops-settings'],['ورود/خروج داده و پشتیبان','view-data-center','⇅','','data-backup']]},{title:'یکپارچه‌سازی',items:[['اتصالات و API','view-integrations','⇆']]},{title:'سیستم',items:[['درباره فینورا','view-settings','ⓘ','','about'],['کاربران و لایسنس','view-admin','♙','admin']]}]}
77 };
78 const FINORA_VIEW_HOME={
79 'view-dashboard':'dashboard','view-journal':'accounting','view-accounting-foundation':'accounting','view-accounting-reports':'accounting','view-currency':'accounting',
scripts/dom-smoke.spec.js
+1 -1
@@ -1,5 +1,5 @@
1 const {test,expect}=require('@playwright/test');
2 -test('real DOM shell and post-login smoke',async({page})=>{const errs=[];page.on('pageerror',e=>errs.push(String(e)));await page.goto('http://127.0.0.1:4173/index.html',{waitUntil:'domcontentloaded'});await expect(page.locator('#auth-screen')).toBeVisible();await expect(page.locator('[data-module="projects"]')).toHaveCount(1);await expect(page.locator('[data-module="dashboard"]')).toContainText('داشبورد');await expect(page.locator('[data-module="home"]')).toHaveCount(0);await expect(page.locator('[data-module="catalog"]')).toHaveCount(0);await expect(page.locator('[data-module="erp"]')).toHaveCount(0);await expect(page.locator('#view-contracting')).toHaveCount(1);await expect(page.locator('[data-module="inventory"]')).toHaveCount(1);await expect(page.locator('[data-module="assets"]')).toHaveCount(1);for(const id of ['view-inventory','view-assets','view-currency','view-data-center','view-integrations'])await expect(page.locator('#'+id)).toHaveCount(1);expect(await page.evaluate(()=>{const a=[...document.querySelectorAll('[id]')].map(x=>x.id),s=new Set(),d=[];for(const id of a){if(s.has(id))d.push(id);s.add(id)}return d})).toEqual([]);await page.evaluate(async()=>{fetchCurrentUser=async()=>({id:'smoke-user',email:'smoke@example.test',fullName:'Smoke Admin',username:'smoke',role:'admin',subscription:{type:'lifetime',status:'active',endDate:'2099-01-01'}});pullAll=async()=>{};refreshAllSurfaces=()=>{window.__smokeRefresh=true};maybeMigrateLegacyData=()=>{window.__smokeMigrate=true};await enterApp({id:'smoke-user'});});await expect(page.locator('#auth-screen')).toBeHidden();await expect(page.locator('body')).toHaveClass(/is-admin/);await expect(page.locator('#logged-user-label')).toContainText('Smoke Admin');await page.evaluate(()=>openModule('accounting','view-accounting-foundation','accounts'));await expect(page.locator('#module-panel-links')).toContainText('اطلاعات پایه');await expect(page.locator('#module-panel-links')).toContainText('عملیات حسابداری');await expect(page.locator('#module-panel-links')).toContainText('دفاتر و گزارش‌ها');await expect(page.locator('#module-panel-links [data-task="accounts"]')).toHaveClass(/active/);await page.fill('#global-command-search','تراز آزمایشی');await expect(page.locator('#command-search-results')).toContainText('تراز آزمایشی');await expect(page.locator('#view-accounting-foundation [data-finora-task="accounts"]')).toBeVisible();await expect(page.locator('#view-accounting-foundation [data-finora-task="dimensions"]')).toBeHidden();await page.evaluate(()=>switchView('view-accounting-foundation'));await expect(page.locator('#view-accounting-foundation [data-finora-task="dimensions"]')).toBeVisible();await page.evaluate(()=>navigateShell('accounting','view-accounting-foundation','accounts'));await page.evaluate(()=>navigateShell('accounting','view-journal','new'));await expect(page.locator('#view-journal [data-finora-task="new"]')).toBeVisible();await expect(page.locator('#view-journal [data-finora-task="register"]')).toBeHidden();await page.evaluate(()=>navigateShell('accounting','view-journal','register'));await expect(page.locator('#view-journal [data-finora-task="register"]')).toBeVisible();await expect(page.locator('#view-journal [data-finora-task="new"]')).toBeHidden();await page.evaluate(()=>navigateShell('accounting','view-accounting-reports','trial'));await expect(page.locator('#p6-reporting-root [data-finora-task="trial"]')).toBeVisible();await expect(page.locator('#p6-reporting-root [data-finora-task="ledger"]')).toBeHidden();expect(await page.evaluate(()=>({refresh:window.__smokeRefresh,migrate:window.__smokeMigrate,admin:canShowShellCommand({guard:'admin'})}))).toEqual({refresh:true,migrate:true,admin:true});await page.evaluate(()=>{saveDatastore=()=>{};datastore.companies=[{id:'C1',ownerUserId:'smoke-user',name:'Smoke Co'}];datastore.settings=[{ownerUserId:'smoke-user',default_company_id:'C1'}];datastore.products=[{id:'P1',ownerUserId:'smoke-user',companyId:'C1',code:'1',name:'Smoke Product',type:'good',unit:'عدد',buy_price:100,sale_price:150,stock:0}];for(const k of ['warehouses','stockMovements','inventoryCounts','fixedAssets','assetDepreciations','currencies','exchangeRates','costCenters','importBatches','integrationConnections','integrationOutbox','phase5Audit'])datastore[k]=[];switchView('view-inventory');p5Render('view-inventory');});await page.evaluate(()=>{switchView('view-accounting-foundation');renderAccountingFoundation();});await expect(page.locator('#view-accounting-foundation')).toContainText('ورود کدینگ از Excel');await expect(page.locator('#view-accounting-foundation')).toContainText('شناور ۴ قرارداد/پیمان');await expect(page.locator('#af-account-type')).toHaveCount(1);await expect(page.locator('#af-account-role')).toHaveCount(1);await expect(page.locator('#af-dim-source option[value="contract"]')).toHaveCount(1);await page.evaluate(()=>{switchView('view-inventory');p5Render('view-inventory');});await expect(page.locator('#p5-inventory-root')).toContainText('انبار اصلی');await expect(page.locator('#p5-inventory-root')).toContainText('Smoke Product');await page.evaluate(()=>{switchView('view-accounting-reports');P6Reports.render();});await expect(page.locator('#p6-reporting-root')).toContainText('تراز آزمایشی');await expect(page.locator('#p6-reporting-root')).toContainText('صورت جریان وجوه نقد');expect(await page.evaluate(()=>{const a=[...document.querySelectorAll('[id]')].map(x=>x.id),s=new Set(),d=[];for(const id of a){if(s.has(id))d.push(id);s.add(id)}return d})).toEqual([]);await page.evaluate(()=>{window.print=()=>{};const items=Array.from({length:25},(_,i)=>({prodName:'Item '+(i+1),qty:1,unit:'عدد',price:100,lineTotal:100}));datastore.invoices=[{id:'PRINT_FORMAL',ownerUserId:'smoke-user',companyId:'C1',contactId:'',kind:'formal',number:'F-1',date:'1405/07/07',items,subtotal:2500,discount:0,vat:250,grandTotal:2750,paymentMethod:'cash'}];renderAndPrintDirect('PRINT_FORMAL');});await expect(page.locator('#printable-invoice .invoice-a4-page')).toHaveCount(3);expect(await page.locator('#dynamic-print-orientation').evaluate(el=>el.innerHTML.includes('A4 landscape'))).toBe(true);await page.emulateMedia({media:'print'});expect(await page.locator('#printable-invoice .invoice-a4-page').first().evaluate(el=>getComputedStyle(el).breakAfter)).toBe('page');await page.emulateMedia({media:'screen'});await page.evaluate(()=>{datastore.invoices[0].id='PRINT_NONFORMAL';datastore.invoices[0].kind='informal';renderAndPrintDirect('PRINT_NONFORMAL');});await expect(page.locator('#printable-invoice .invoice-a4-page')).toHaveCount(3);expect(await page.locator('#dynamic-print-orientation').evaluate(el=>el.innerHTML.includes('A5 landscape'))).toBe(true);expect(errs.filter(x=>!x.includes('ResizeObserver'))).toEqual([]);});
2 +test('real DOM shell and post-login smoke',async({page})=>{const errs=[];page.on('pageerror',e=>errs.push(String(e)));await page.goto('http://127.0.0.1:4173/index.html',{waitUntil:'domcontentloaded'});await expect(page.locator('#auth-screen')).toBeVisible();await expect(page.locator('[data-module="projects"]')).toHaveCount(1);await expect(page.locator('[data-module="dashboard"]')).toContainText('داشبورد');await expect(page.locator('[data-module="home"]')).toHaveCount(0);await expect(page.locator('[data-module="catalog"]')).toHaveCount(0);await expect(page.locator('[data-module="erp"]')).toHaveCount(0);await expect(page.locator('#view-contracting')).toHaveCount(1);await expect(page.locator('[data-module="inventory"]')).toHaveCount(1);await expect(page.locator('[data-module="assets"]')).toHaveCount(1);for(const id of ['view-inventory','view-assets','view-currency','view-data-center','view-integrations'])await expect(page.locator('#'+id)).toHaveCount(1);expect(await page.evaluate(()=>{const a=[...document.querySelectorAll('[id]')].map(x=>x.id),s=new Set(),d=[];for(const id of a){if(s.has(id))d.push(id);s.add(id)}return d})).toEqual([]);await page.evaluate(async()=>{fetchCurrentUser=async()=>({id:'smoke-user',email:'smoke@example.test',fullName:'Smoke Admin',username:'smoke',role:'admin',subscription:{type:'lifetime',status:'active',endDate:'2099-01-01'}});pullAll=async()=>{};refreshAllSurfaces=()=>{window.__smokeRefresh=true};maybeMigrateLegacyData=()=>{window.__smokeMigrate=true};await enterApp({id:'smoke-user'});});await expect(page.locator('#auth-screen')).toBeHidden();await expect(page.locator('body')).toHaveClass(/is-admin/);await expect(page.locator('#logged-user-label')).toContainText('Smoke Admin');await page.evaluate(()=>openModule('accounting','view-accounting-foundation','accounts'));await expect(page.locator('#module-panel-links')).toContainText('اطلاعات پایه');await expect(page.locator('#module-panel-links')).toContainText('عملیات حسابداری');await expect(page.locator('#module-panel-links')).toContainText('دفاتر و گزارش‌ها');await expect(page.locator('#module-panel-links [data-task="accounts"]')).toHaveClass(/active/);await page.fill('#global-command-search','تراز آزمایشی');await expect(page.locator('#command-search-results')).toContainText('تراز آزمایشی');await expect(page.locator('#view-accounting-foundation [data-finora-task="accounts"]')).toBeVisible();await expect(page.locator('#view-accounting-foundation [data-finora-task="dimensions"]')).toBeHidden();await page.evaluate(()=>switchView('view-accounting-foundation'));await expect(page.locator('#view-accounting-foundation [data-finora-task="dimensions"]')).toBeVisible();await page.evaluate(()=>navigateShell('accounting','view-accounting-foundation','accounts'));await page.evaluate(()=>navigateShell('settings','view-settings','company'));await expect(page.locator('#view-settings [data-finora-task="company"]')).toBeVisible();await expect(page.locator('#view-settings [data-finora-task="account"]')).toBeHidden();await page.evaluate(()=>navigateShell('accounting','view-journal','new'));await expect(page.locator('#view-journal [data-finora-task="new"]')).toBeVisible();await expect(page.locator('#view-journal [data-finora-task="register"]')).toBeHidden();await page.evaluate(()=>navigateShell('accounting','view-journal','register'));await expect(page.locator('#view-journal [data-finora-task="register"]')).toBeVisible();await expect(page.locator('#view-journal [data-finora-task="new"]')).toBeHidden();await page.evaluate(()=>navigateShell('accounting','view-accounting-reports','trial'));await expect(page.locator('#p6-reporting-root [data-finora-task="trial"]')).toBeVisible();await expect(page.locator('#p6-reporting-root [data-finora-task="ledger"]')).toBeHidden();expect(await page.evaluate(()=>({refresh:window.__smokeRefresh,migrate:window.__smokeMigrate,admin:canShowShellCommand({guard:'admin'})}))).toEqual({refresh:true,migrate:true,admin:true});await page.evaluate(()=>{saveDatastore=()=>{};datastore.companies=[{id:'C1',ownerUserId:'smoke-user',name:'Smoke Co'}];datastore.settings=[{ownerUserId:'smoke-user',default_company_id:'C1'}];datastore.products=[{id:'P1',ownerUserId:'smoke-user',companyId:'C1',code:'1',name:'Smoke Product',type:'good',unit:'عدد',buy_price:100,sale_price:150,stock:0}];for(const k of ['warehouses','stockMovements','inventoryCounts','fixedAssets','assetDepreciations','currencies','exchangeRates','costCenters','importBatches','integrationConnections','integrationOutbox','phase5Audit'])datastore[k]=[];switchView('view-inventory');p5Render('view-inventory');});await page.evaluate(()=>{switchView('view-accounting-foundation');renderAccountingFoundation();});await expect(page.locator('#view-accounting-foundation')).toContainText('ورود کدینگ از Excel');await expect(page.locator('#view-accounting-foundation')).toContainText('شناور ۴ قرارداد/پیمان');await expect(page.locator('#af-account-type')).toHaveCount(1);await expect(page.locator('#af-account-role')).toHaveCount(1);await expect(page.locator('#af-dim-source option[value="contract"]')).toHaveCount(1);await page.evaluate(()=>{switchView('view-inventory');p5Render('view-inventory');});await expect(page.locator('#p5-inventory-root')).toContainText('انبار اصلی');await expect(page.locator('#p5-inventory-root')).toContainText('Smoke Product');await page.evaluate(()=>{switchView('view-accounting-reports');P6Reports.render();});await expect(page.locator('#p6-reporting-root')).toContainText('تراز آزمایشی');await expect(page.locator('#p6-reporting-root')).toContainText('صورت جریان وجوه نقد');expect(await page.evaluate(()=>{const a=[...document.querySelectorAll('[id]')].map(x=>x.id),s=new Set(),d=[];for(const id of a){if(s.has(id))d.push(id);s.add(id)}return d})).toEqual([]);await page.evaluate(()=>{window.print=()=>{};const items=Array.from({length:25},(_,i)=>({prodName:'Item '+(i+1),qty:1,unit:'عدد',price:100,lineTotal:100}));datastore.invoices=[{id:'PRINT_FORMAL',ownerUserId:'smoke-user',companyId:'C1',contactId:'',kind:'formal',number:'F-1',date:'1405/07/07',items,subtotal:2500,discount:0,vat:250,grandTotal:2750,paymentMethod:'cash'}];renderAndPrintDirect('PRINT_FORMAL');});await expect(page.locator('#printable-invoice .invoice-a4-page')).toHaveCount(3);expect(await page.locator('#dynamic-print-orientation').evaluate(el=>el.innerHTML.includes('A4 landscape'))).toBe(true);await page.emulateMedia({media:'print'});expect(await page.locator('#printable-invoice .invoice-a4-page').first().evaluate(el=>getComputedStyle(el).breakAfter)).toBe('page');await page.emulateMedia({media:'screen'});await page.evaluate(()=>{datastore.invoices[0].id='PRINT_NONFORMAL';datastore.invoices[0].kind='informal';renderAndPrintDirect('PRINT_NONFORMAL');});await expect(page.locator('#printable-invoice .invoice-a4-page')).toHaveCount(3);expect(await page.locator('#dynamic-print-orientation').evaluate(el=>el.innerHTML.includes('A5 landscape'))).toBe(true);expect(errs.filter(x=>!x.includes('ResizeObserver'))).toEqual([]);});
3
4
5 test('expired license browser enforcement',async({page})=>{const errs=[];page.on('pageerror',e=>errs.push(String(e)));await page.goto('http://127.0.0.1:4173/index.html',{waitUntil:'domcontentloaded'});await page.evaluate(async()=>{window.__licenseAlerts=[];window.alert=m=>window.__licenseAlerts.push(String(m));fetchCurrentUser=async()=>({id:'expired-user',email:'expired@example.test',fullName:'Expired User',username:'expired',role:'user',subscription:{type:'monthly',status:'active',startDate:'2025-01-01',endDate:'2025-01-31'}});pullAll=async()=>{};refreshAllSurfaces=()=>{updateLicenseDisplay(currentUser)};maybeMigrateLegacyData=()=>{};await enterApp({id:'expired-user'});});await expect(page.locator('#auth-screen')).toBeHidden();await expect(page.locator('#user-license-status-badge')).toContainText('منقضی شده');expect(await page.evaluate(()=>canWrite())).toBe(false);expect(await page.evaluate(()=>requireWrite())).toBe(false);expect(await page.evaluate(()=>window.__licenseAlerts.some(x=>x.includes('منقضی')&&x.includes('امکان ثبت یا ویرایش')))).toBe(true);expect(errs.filter(x=>!x.includes('ResizeObserver'))).toEqual([]);});