سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 15:45 UTC
test(phase0): enforce F0-05 1200+ selector regressions
Synthetic product/contact stress, bounded Chromium timing, isolated tenant negative checks, required QA gate and phase ledger. Quality 38203000078: 83/83 Playwright pass; Security 38203000075 green. No runtime or Supabase mutations.
davoodmehraban89 committed
Oct 12, 2026 at 07:47 UTC
a3c7dac165d1c451c635546eecff47e0aaaf562e
4 files changed
+84
-1
.github/workflows/quality.yml
+1
-1
@@ -117,7 +117,7 @@ jobs:
117
- name: Real DOM smoke
118
run: |
119
python3 -m http.server 4173 >/tmp/finora-http.log 2>&1 &
120
- npx playwright test scripts/dom-smoke.spec.js scripts/platform-office.spec.js scripts/enterprise-license.spec.js scripts/enterprise-role.spec.js scripts/enterprise-invitation.spec.js scripts/enterprise-org-ux.spec.js scripts/identity-wave5a.spec.js scripts/identity-wave5b.spec.js scripts/identity-wave5c.spec.js scripts/branding-login.spec.js scripts/login-connectivity.spec.js scripts/shell-scroll-ownership.spec.js scripts/office-slice-c1.spec.js scripts/office-slice-c2.spec.js scripts/office-slice-c3.spec.js scripts/office-slice-c4.spec.js scripts/office-slice-c5.spec.js scripts/office-slice-c6.spec.js scripts/office-slice-c7.spec.js scripts/office-slice-c8.spec.js scripts/office-slice-c8-runtime.spec.js scripts/request-workflow-d2.spec.js scripts/request-workflow-d3b.spec.js scripts/request-workflow-d3c.spec.js scripts/request-workflow-d4a.spec.js scripts/taxpayer-print.spec.js scripts/chart-completeness.spec.js scripts/accounting-p0-journal.spec.js scripts/ux-hardening-r2.spec.js scripts/ux-keyboard-f2.spec.js scripts/phase0-invoice-persistence.spec.js scripts/phase0-modal-dashboard.spec.js scripts/accounting-document-workflow.spec.js scripts/admin-provisioning.spec.js scripts/pages-artifact.spec.js --reporter=line --workers=1
120
+ npx playwright test scripts/dom-smoke.spec.js scripts/platform-office.spec.js scripts/enterprise-license.spec.js scripts/enterprise-role.spec.js scripts/enterprise-invitation.spec.js scripts/enterprise-org-ux.spec.js scripts/identity-wave5a.spec.js scripts/identity-wave5b.spec.js scripts/identity-wave5c.spec.js scripts/branding-login.spec.js scripts/login-connectivity.spec.js scripts/shell-scroll-ownership.spec.js scripts/office-slice-c1.spec.js scripts/office-slice-c2.spec.js scripts/office-slice-c3.spec.js scripts/office-slice-c4.spec.js scripts/office-slice-c5.spec.js scripts/office-slice-c6.spec.js scripts/office-slice-c7.spec.js scripts/office-slice-c8.spec.js scripts/office-slice-c8-runtime.spec.js scripts/request-workflow-d2.spec.js scripts/request-workflow-d3b.spec.js scripts/request-workflow-d3c.spec.js scripts/request-workflow-d4a.spec.js scripts/taxpayer-print.spec.js scripts/chart-completeness.spec.js scripts/accounting-p0-journal.spec.js scripts/ux-hardening-r2.spec.js scripts/ux-keyboard-f2.spec.js scripts/phase0-selector-stress.spec.js scripts/phase0-invoice-persistence.spec.js scripts/phase0-modal-dashboard.spec.js scripts/accounting-document-workflow.spec.js scripts/admin-provisioning.spec.js scripts/pages-artifact.spec.js --reporter=line --workers=1
121
122
identity-wave5a-database:
123
runs-on: ubuntu-latest
PROJECT_STATE.md
+15
@@ -236,3 +236,18 @@ Owner reports login blocked with generic 'check internet/VPN' network error on l
236
- F2 routes the active entry view through existing dedicated validation/save handlers (sales invoice, purchases, goods/services, contacts, cheques, expenses, accounting draft journal, default settings, company form when focused). Missing rows, missing product/contact names, invalid native controls and unsupported views explain the block. An active modal is not silently approved via keyboard; modal-specific confirmation must use its own safe action. **Sales F2 creates a draft only; it never finalizes the accounting posting.** Purchases currently auto-post when saved in existing code, so F2 **requires explicit user confirmation** before invoking purchase Save; refusal performs no operation. Ctrl+S and Ctrl+Enter remain available.
237
- Independent Remote Desktop Commander `DESKTOP-71SJ63M`, cloned exact branch commit `cd5e04408d81eacaf66be97ee9d2b89d85e22915`, `node scripts/ux-hardening-r2-check.mjs` PASS, `node scripts/syntax-check.mjs` PASS (55 JS/52 MJS), Chromium `npx playwright test scripts/ux-keyboard-f2.spec.js scripts/ux-hardening-r2.spec.js scripts/accounting-document-workflow.spec.js --reporter=line --workers=1` **14/14 PASS (19.7 s)**. Real app invoice fixture verifies F2 rejects empty line and saves one formal **draft** with zero journal vouchers. Other tests cover product/person matching, Arrow+Enter selected not first, 48-product wheel/PageDown/Home/End, Escape, F2 form/unsupported modal/company/default settings/purchase explicit confirmation. Synthetic QA data only; no owner accounts or financial writes.
238
- **IMPLEMENTED / MERGED / PROTECTED-MAIN CI & RELEASE / DEPLOYED / READ-ONLY LIVE ASSET VERIFIED.** PR #83 merged to `main` SHA `641b68669057ef429ae158744a86cba9a00dca31`; exact-SHA main Quality `38173607090` SUCCESS, Security `38173607091` SUCCESS, Release gate `38173716820` SUCCESS, gated Pages `38173732898` SUCCESS (skipped/cancelled duplicate workflow runs were not used as evidence). Independent Desktop Commander `DESKTOP-71SJ63M` real Chromium after checkout of **exact main merge commit**: `scripts/ux-keyboard-f2.spec.js` + `scripts/ux-hardening-r2.spec.js` **PASS 12/12 (6.0s)**; `node scripts/ux-hardening-r2-check.mjs` PASS; `node scripts/syntax-check.mjs` PASS (55 JS + 52 MJS). Remote GET `https://factoreasy.ir/?keyboardQa=20261011` HTTP 200 and exact referenced deployed `js/ux-hardening-r2.js?v=20261011-combo-keyboard-f2-v5` HTTP 200; JS body verified `finoraConfirmActiveFormF2`, active-option ARIA, wheel, PageDown and F2 listener all present. **User-authenticated actual existing-goods list and physical keyboard on owner's browser remain UNVERIFIED**, and not every optional module has an unambiguous save action: when F2 cannot safely determine one, it explains the reason instead of triggering posting/destructive actions. No schema/RLS/auth/roles/posts/customer financial data changed. Rollback: revert PR #83 and redeploy previous UX bundle `v=20261011-modal-close-v4`.
239
+
240
+
241
+## 2026-10-12 Phase 0 F0-05 independent 1000+ selector stress — PLANNED
242
+- **Owner request:** Continue approved Phase 0 without repeating PR #83 or changing production data. Baseline `main` SHA `27170e0291496997a6118b0e72978f852e015a86`; historical PR #83 keyboard/F2 is already deployed. Phase 0 remains OPEN.
243
+- **Accountable owner:** QA/Validation. Scope: disposable Chromium fixture with 1,200+ tenant-scoped product and contact choices; Persian/Arabic normalization; code/spec lookup; Arrow/Enter/Home/End/wheel/Escape; selection persistence; absent and cross-tenant negative cases; measured browser interaction responsiveness. Chapters: 14, 251, 259, 260 (with 252/253 security/event contracts).
244
+- **In scope:** `scripts/phase0-selector-stress.spec.js` and Quality workflow gate; minimum source UX correction only if the test reproduces a defect. **Out of scope:** Supabase writes/migrations, Auth/RLS/roles, secrets, actual user or financial data, postings, invoice finalization and live user-session claims.
245
+- **Acceptance/evidence:** Run new Chromium test, syntax/static/regression checks, GitHub PR Quality + Security; report observed time budgets, exact SHA/run and any failures. Controlled browser PASS does not close F0-05 owner-authenticated acceptance. Rollback: revert isolated QA PR; no operational/DB rollback required.
246
+- **Status:** SPECIFIED / implementation and CI pending. Next action: add bounded independent stress regression, execute and triage failures.
247
+
248
+
249
+### 2026-10-12 F0-05 initial Chromium/CI verification — CONTROLLED_QA_PASSED; OWNER E2E OPEN
250
+- Baseline protected `main`: `27170e0291496997a6118b0e72978f852e015a86`. GitHub official connector verified current repo and approved Phase 0; master 260-chapter DOCX SHA-256 `f445ec30b395319aece8bd7eb7d98e80bd4655eff6cc81b0253688b551bbc29b` matched handoff. Chapters 251/259/260 and related scope consulted. Previous PR #81, #82, #83 and #84 independently confirmed merged; no feature recreated.
251
+- Live read-only Supabase project `hcsixhqbyuhpshfwqpjx`: ACTIVE_HEALTHY, **81** migration history rows, newest `20261011174445 posted_source_idempotency_index`; security advisors 21 authenticated SECURITY DEFINER WARN, 3 private C8 RLS/no-policy INFO, 1 Auth leaked-password WARN. Warnings not treated as exploitable without detailed review.
252
+- PR #86 `qa/phase0-f005-selector-stress-20261012`: adds synthetic 1,208-product and 1,206-contact negative/positive browser regression + required CI gate; no product runtime, Supabase, credentials or financial mutation. Initial head `193b03ddcef33aa06f5dfc936d14626d875be7f7`: GitHub Quality run `38202818187`, static job `114659716442`, **83/83 real Chromium tests PASS (55.8s)** including both F0-05 cases; three disposable database jobs SUCCESS. Security run `38202818169`: CodeQL + release safety PASS; dependency review skipped due disabled graph. Measured interaction latencies now logged by revised test for next run.
253
+- Acceptance boundary: F0-05 **CONTROLLED_QA_PASSED**, not AUTHENTICATED_E2E_PASSED / RELEASED / OWNER_ACCEPTED. Actual owner network, tenant catalog, real printer, dual-role access and safe server invoice persistence remain independent Phase 0/1 gates. No claim that 260 chapters are implemented. Rollback: revert QA-only PR. Next: confirm revised-head CI; merge reviewed QA-only test if green; keep Phase 0 OPEN.
docs/FINORA_PHASE0_BASELINE_2026-10-11.md
+6
@@ -41,3 +41,9 @@ All items remain **OPEN or UNVERIFIED** unless specifically shown otherwise. Fix
41
- Exact source test: `scripts/phase0-invoice-persistence.spec.js`. Remote `DESKTOP-71SJ63M` Playwright **2/2 PASS** (25.31s), with real app JS and real UI, simulated in-memory server records and RPC; confirms source invoice persistence through reload, edit totals, print and retry idempotence after transient RPC failure. Both tests use the operational `pre_invoice` type (no journal posting). Simulated Supabase response and session are explicit; this test **does not establish actual production database write success**.
42
- Earlier browser test failures were a fixture mistake: the old native form selects are hidden by the unified combobox. This is not evidence of a customer bug. Fixed by dispatching existing DOM change handlers.
43
- F0-03 remains open for authorized real-account production-safe smoke. All prior Phase 0 issues remain open until accepted; no data migration or security modification approved.
44
+
45
+
46
+## 2026-10-12 F0-05 regression checkpoint — controlled only
47
+- Source: `scripts/phase0-selector-stress.spec.js`; 1,208 scoped product and 1,206 contact options; metadata/Persian matching, Arrow+Enter, no cross-tenant product, selection preservation, no save/post. Typing-to-render safety budget 5,000 ms; measured Chromium latencies are emitted in CI logs for review, not declared a universal production SLA.
48
+- PR #86 initial Quality run `38202818187`: all **83/83 Chromium tests passed (55.8 s)**, including both F0-05 cases. Disposable D1/C8/identity DB jobs SUCCESS; Security `38202818169`: CodeQL and release-safety SUCCESS (dependency review skipped under disabled graph).
49
+- Product implementation remains unchanged; F0-05 is **CONTROLLED_QA_PASSED only**, with full-account/large real tenant data, browser/ISP hardware variation and owner acceptance still OPEN. Final revised-head CI and merge/promotion to be recorded separately. No production data, permissions or credentials used.
scripts/phase0-selector-stress.spec.js
new
+62
@@ -0,0 +1,62 @@
1
+// F0-05: standalone controlled browser stress; never uses user or production data.
2
+const {test,expect}=require('@playwright/test');
3
+const path=require('node:path');
4
+
5
+async function fixture(page){
6
+ const people=Array.from({length:1205},(_,i)=>({id:'C'+i,ownerUserId:'QA',name:'شرکت آزمایشی شماره '+String(i).padStart(4,'0'),mobile:'0912'+String(i).padStart(7,'0')}));
7
+ people.push({id:'CVIP',ownerUserId:'QA',name:'شرکت توسعه هارد',mobile:'09120009999'});
8
+ const choices=people.map(c=>'<option value="'+c.id+'">'+c.name+'</option>').join('');
9
+ await page.setContent('<!doctype html><html lang="fa" dir="rtl"><head><style>.view-pane{display:none}.view-pane.active{display:block}.finora-combobox{width:420px!important}.finora-combobox-list{max-height:220px!important}</style></head><body><section id="view-settings"></section><section id="view-invoices" class="view-pane active"><select id="stress-products" class="row-product-select"><option value="">انتخاب کالا</option></select><select id="invoice-contact-id"><option value="">انتخاب شخص</option>'+choices+'</select></section></body></html>');
10
+ await page.addScriptTag({content:'var currentUser={id:"QA"};var datastore={settings:[{ownerUserId:"QA",ui_theme:"light"}],companies:[{id:"ORG",ownerUserId:"QA"}],products:[],contacts:[],projects:[],accounts:[],invoices:[],purchases:[],cheques:[],journalVouchers:[]};var FINORA_MODULES={settings:{groups:[]}};window.__saves=0;window.__posted=0;function getMySettings(){return datastore.settings[0]}function getMyCompanies(){return datastore.companies}function getMyProducts(){return datastore.products.filter(p=>p.ownerUserId===currentUser.id)}function getMyContacts(){return datastore.contacts.filter(c=>c.ownerUserId===currentUser.id)}function getMyAccounts(){return datastore.accounts}function getMyGlobalProjects(){return datastore.projects}function requireWrite(){return true}function saveDatastore(){window.__saves++}function toggleAccordion(){}function esc(v){return String(v)}function jePostSourceRecord(){window.__posted++}'});
11
+ await page.evaluate(people=>{datastore.contacts=people;datastore.products=Array.from({length:1205},(_,i)=>({id:'P'+i,ownerUserId:'QA',code:String(100000+i),name:'کالا آزمایشی شماره '+String(i).padStart(4,'0'),spec:'رده عمومی',unit:'عدد',sale_price:1000+i}));datastore.products.push({id:'B10',ownerUserId:'QA',code:'310001',name:'بلوک سیمانی ۱۰',spec:'سبک',unit:'عدد',sale_price:10000},{id:'B15',ownerUserId:'QA',code:'310002',name:'بلوک سبک ۱۵',spec:'AAC',unit:'عدد',sale_price:12000},{id:'H1',ownerUserId:'QA',code:'910001',name:'هارد اکسترنال',spec:'دو ترابایت',unit:'عدد',sale_price:20000},{id:'SECRET',ownerUserId:'OTHER',code:'777777',name:'هارد محرمانه',spec:'فقط شرکت دیگر',unit:'عدد',sale_price:1});},people);
12
+ await page.addScriptTag({path:path.resolve('js/ux-hardening-r2.js')});
13
+ await page.evaluate(()=>{finoraRefreshSearchableSelect(document.querySelector('#stress-products'));finoraRefreshSearchableSelect(document.querySelector('#invoice-contact-id'))});
14
+ return {product:page.locator('#stress-products').locator('xpath=..').locator('.finora-combobox-input'),person:page.locator('#invoice-contact-id').locator('xpath=..').locator('.finora-combobox-input')};
15
+}
16
+
17
+test('F0-05 products: 1208 choices, Persian variants, keyboard and cross-tenant negative control',async({page})=>{
18
+ const {product}=await fixture(page);
19
+ await product.click();
20
+ const list=page.locator('body > .finora-combobox-list');
21
+ await expect(list.locator('[role="option"]')).toHaveCount(1208);
22
+ const elapsed=await page.evaluate(()=>{const e=document.querySelector('#stress-products').parentElement.querySelector('input');const t=performance.now();e.value='کالا آزمایشی شماره 1204';e.dispatchEvent(new Event('input',{bubbles:true}));return performance.now()-t});
23
+ console.info('F0-05 product filter browser ms:',elapsed.toFixed(1));
24
+ expect(elapsed,'product filter took '+elapsed.toFixed(0)+'ms').toBeLessThan(5000);
25
+ await expect(list.locator('[role="option"]')).toHaveCount(1);
26
+ await expect(list).toContainText('1204');
27
+ await product.fill('بلوك');
28
+ await expect(list.locator('[role="option"]')).toHaveCount(2);
29
+ await product.press('ArrowDown');
30
+ await expect(list.locator('[aria-selected="true"]')).toContainText('بلوک سبک ۱۵');
31
+ await product.press('Enter');
32
+ await expect(page.locator('#stress-products')).toHaveValue('B15');
33
+ await product.click();await product.fill('هارد');
34
+ await expect(list.locator('[role="option"]')).toHaveCount(1);
35
+ await expect(list).not.toContainText('محرمانه');
36
+ await product.fill('دو ترابایت');
37
+ await expect(list.locator('[role="option"]')).toHaveCount(1);
38
+ await product.fill('عبارت ناموجود');
39
+ await expect(list.locator('.finora-combobox-empty')).toContainText('موردی پیدا نشد');
40
+ await product.press('Escape');
41
+ await expect(page.locator('#stress-products')).toHaveValue('B15');
42
+ expect(await page.evaluate(()=>[window.__saves,window.__posted])).toEqual([0,0]);
43
+});
44
+
45
+test('F0-05 people: 1206 choices and 11-digit metadata filter with no implicit writes',async({page})=>{
46
+ const {person}=await fixture(page);
47
+ await person.click();
48
+ const list=page.locator('#invoice-contact-id').locator('xpath=..').locator('.finora-combobox-list');
49
+ await expect(list.locator('[role="option"]')).toHaveCount(1206);
50
+ const elapsed=await page.evaluate(()=>{const e=document.querySelector('#invoice-contact-id').parentElement.querySelector('input');const t=performance.now();e.value='09120009999';e.dispatchEvent(new Event('input',{bubbles:true}));return performance.now()-t});
51
+ console.info('F0-05 contact filter browser ms:',elapsed.toFixed(1));
52
+ expect(elapsed,'contact filter took '+elapsed.toFixed(0)+'ms').toBeLessThan(5000);
53
+ await expect(list.locator('[role="option"]')).toHaveCount(1);
54
+ await expect(list).toContainText('شرکت توسعه هارد');
55
+ await person.press('Enter');
56
+ await expect(page.locator('#invoice-contact-id')).toHaveValue('CVIP');
57
+ await person.click();await person.fill('شرکت آزمایشی شماره 1199');
58
+ await expect(list.locator('[role="option"]')).toHaveCount(1);
59
+ await person.press('Enter');
60
+ await expect(page.locator('#invoice-contact-id')).toHaveValue('C1199');
61
+ expect(await page.evaluate(()=>[window.__saves,window.__posted])).toEqual([0,0]);
62
+});