سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 20:45 UTC
Phase 0: verify Pages invoice product and buyer filters without writes (#153)
* docs: record real product lookup PASS, buyer lookup pending and guarded Pages fixture plan * test: assert Pages invoice product and buyer search filters with no selection or save * docs: record 122 of 122 hardened Pages invoice selector QA and outstanding real-user gate
davoodmehraban89 committed
Oct 15, 2026 at 21:57 UTC
700846635d5a6a213885a32bbd9f9164e42c731d
2 files changed
+112
PROJECT_STATE.md
+12
@@ -761,3 +761,15 @@ Owner reports login blocked with generic 'check internet/VPN' network error on l
761
- **Production-hardened Pages differential test released:** [PR #150](https://github.com/davoodmehraban89/Factor-easy/pull/150), merge SHA `928493f695eef8b5b6facbdca85dc96f3c9f67d9`. Added synthetic Chromium test `Published Pages CSP event bindings open Commerce and the top-bar sales invoice menu` against generated `_site` CSP-safe event handlers, with actual button clicks, quick menu aria toggle and invoice-page navigation. 121/121 Chromium tests PASS in QA job `116567441821` at initial test head; final PR head `64eb58adfdcd35f907fd2afe883fd3d4f2c90b98` Quality `38777656678` SUCCESS, Security `38777656686` SUCCESS. Exact protected main merge Quality [`38778221013`](https://github.com/davoodmehraban89/Factor-easy/actions/runs/38778221013) SUCCESS, Security [`38778220937`](https://github.com/davoodmehraban89/Factor-easy/actions/runs/38778220937) SUCCESS, Release gate [`38778697708`](https://github.com/davoodmehraban89/Factor-easy/actions/runs/38778697708) SUCCESS, gated Pages [`38778783998`](https://github.com/davoodmehraban89/Factor-easy/actions/runs/38778783998) SUCCESS. A superseded duplicate release-gate job was cancelled; accepted gate and Pages on exact SHA succeeded.
762
- **Disposition/security:** no further production navigation code change indicated by current tests. No Supabase Auth, license, schema/RLS/role, tenancy, financial records, payments, Stripe, Cloudflare, GitHub credential or paid service touched. Existing validated license fix remains CLOSED for observed test-account flow.
763
- **Remaining Phase 0 / release blockers:** F0-01 fresh first sign-in and fluctuating load on owner's affected internet/actual device **NOT VERIFIED**; F0-02 sales invoice product/customer search against actual authorized company **NOT VERIFIED**; F0-03 real persistent invoice-safe scope/physical print **NOT VERIFIED**. No-card encrypted production DB backup, independent offline copy and restore **NOT RUN**. Next safe path: owner-supplied read-only screenshot or scoped browser recording showing commerce navigation + existing product search; independent client/network diagnostics before any code change; no live invoice creation without explicit safe test scope.
764
+
765
+
766
+### 2026-10-15 F0-02 production product search PASS / buyer filtering acceptance still open — TEST STARTED
767
+- **Current owner continuation:** test-work account read-only browser [run `43e95484-3ecf-4576-a4b1-528cac50a8eb`](https://agent.tinyfish.ai/runs/43e95484-3ecf-4576-a4b1-528cac50a8eb) reached Commerce/Invoices by clicking visible Persian tab; the agent's claim that DOM `data-module` attributes are absent contradicts canonical source `index.html` and synthetic Chromium, so **do not adopt the unverified explanation as root cause**.
768
+- **Real saved test-work session targeted [run `341e1f6d-a792-4b5e-b0b9-69908056b460`](https://agent.tinyfish.ai/runs/341e1f6d-a792-4b5e-b0b9-69908056b460) COMPLETE:** Commerce Sales Invoice form reached; first existing item product combobox filter `بلوک` returned **three** options; buyer combobox/search input visible. No item selected, no invoice saved, no production data mutated. F0-02 real product lookup **PASS** for this path, but buyer filtering and metadata acceptance were only visually observed (no actual filtered buyer result).
769
+- **Contradictory next agent run [`a31d48d6-34ea-4b6d-91b3-7d28a0c817f5`](https://agent.tinyfish.ai/runs/a31d48d6-34ea-4b6d-91b3-7d28a0c817f5):** could not reach invoice, so buyer-filter and product metadata still **NOT VERIFIED** in that run. Treat intermittent browser agent navigation as a separate reproducibility issue, not proof of failing app; hardened Pages navigation regression #150 PASS 121/121.
770
+- **Planned bounded corrective QA:** extend generated hardened `_site` Pages Playwright with isolated synthetic customer/product records for own and another user; open Commerce, filter product `بلوک`, filter buyer `شرکت` without choosing; assert matching scoped options only and source select values unchanged, expected unit/price metadata on product options, zero calls to `saveDatastore`, no production Supabase write. No production schema/Auth/RLS/financial/data change or external charges.
771
+- **Exact repository baseline:** protected `main` after documentation PR #151 `b7d287ac15f7f7a6e6db1f9bc1b2778afa9193d9`. Required acceptance: new isolated browser test + full quality/security, protected merge, guarded Pages release; real buyer search remains open pending authentic read-only evidence. Rollback: revert test/docs PR; no DB change.
772
+
773
+
774
+- **TEST PASS on exact initial PR code head `f7128b21c3b65e03d1a418e07a1818a8aa98abda`:** [PR #153](https://github.com/davoodmehraban89/Factor-easy/pull/153), Quality [`38784715204`](https://github.com/davoodmehraban89/Factor-easy/actions/runs/38784715204) SUCCESS, Security [`38784715247`](https://github.com/davoodmehraban89/Factor-easy/actions/runs/38784715247) SUCCESS. Job `116593641627` logs **122/122 Chromium PASS** (new `scripts/pages-artifact.spec.js:185` test at [72/122]), all disposable DB D1, C8, identity jobs SUCCESS. The generated Pages CSP-safe product filter for `بلوک` and buyer filter for `شرکت` each returns only TWO synthetic own-user records, no cross-user options, and product `data-unit`/`data-price` metadata stays available; neither selects a different product/buyer, invokes `saveDatastore` nor creates invoice. This proves **synthetic filter behavior only**, not real buyer search or persisted invoice correctness.
775
+- **Exact next work:** await final PR head Quality/Security checks after appending this evidence, squash merge #153 if green, recheck protected-main Quality/Security/Release Gate/Pages exact SHA. Keep F0-02 real buyer filter NOT VERIFIED, affected owner ISP cold sign-in NOT VERIFIED, production backup+restore NOT RUN. Avoid additional paid-agent browsing absent a reliable way to reach the real buyer dropdown; no financial actions were taken.
scripts/pages-artifact.spec.js
+100
@@ -180,3 +180,103 @@ test('Published Pages CSP event bindings open Commerce and the top-bar sales inv
180
await expect(quick).toHaveAttribute('aria-expanded','false');
181
expect(pageErrors).toEqual([]);
182
});
183
+
184
+
185
+test('Published Pages invoice product and buyer filters stay scoped and do not persist draft edits',async({page})=>{
186
+ const pageErrors=[];
187
+ page.on('pageerror',e=>pageErrors.push(e.message));
188
+ await page.goto(base,{waitUntil:'domcontentloaded'});
189
+ await page.waitForFunction(()=>window.FinoraLoginActionsBound===true&&
190
+ typeof window.applyLicensedModuleUI==='function'&&
191
+ typeof window.finoraRefreshSearchableSelect==='function'&&
192
+ typeof window.renderContacts==='function'&&
193
+ window.FinoraStartupStatus?.extensionsReady===true,{timeout:20000});
194
+ const initial=await page.evaluate(()=>{
195
+ // All records are synthetic and live ONLY in this local browser process.
196
+ const uid='qa-pages-selectors';
197
+ currentUser={id:uid,role:'accountant',modules:['full_suite'],
198
+ subscription:{type:'lifetime',status:'active',endDate:'2099-01-01'}};
199
+ const product=(id,name,unit,price,ownerUserId=uid)=>({
200
+ id,ownerUserId,code:id,name,spec:'آزمایشی',unit,sale_price:price
201
+ });
202
+ datastore.settings=[{ownerUserId:uid,default_company_id:'QA_CO',ui_theme:'light'}];
203
+ datastore.companies=[{id:'QA_CO',ownerUserId:uid,name:'شرکت آزمون مستقل'}];
204
+ datastore.products=[
205
+ product('QA_P10','بلوک سبک ۱۰','عدد',11000),
206
+ product('QA_P15','بلوک سبک ۱۵','بسته',15000),
207
+ product('QA_H1','هارد آزمایشی','عدد',20000),
208
+ product('OTHER_P','بلوک محرمانه','عدد',1,'OTHER_USER')
209
+ ];
210
+ datastore.contacts=[
211
+ {id:'QA_C1',ownerUserId:uid,name:'شرکت آزمایشی الف',role:'customer',balance:0},
212
+ {id:'QA_C2',ownerUserId:uid,name:'شرکت آزمایشی ب',role:'both',balance:0},
213
+ {id:'QA_C3',ownerUserId:uid,name:'آزمایش شخص حقیقی',role:'customer',balance:0},
214
+ {id:'OTHER_C',ownerUserId:'OTHER_USER',name:'شرکت محرمانه',role:'customer',balance:0}
215
+ ];
216
+ datastore.invoices=[];datastore.purchases=[];
217
+ document.querySelector('#auth-screen').style.display='none';
218
+ applyLicensedModuleUI();
219
+ renderContacts();
220
+ finoraEnsureInitialInvoiceRow();
221
+ const goods=document.querySelector('#invoice-items-table-body .row-product-select');
222
+ const buyer=document.querySelector('#invoice-contact-id');
223
+ if(!goods||!buyer)throw new Error('Missing invoice product/customer controls');
224
+ finoraRefreshSearchableSelect(goods);
225
+ finoraRefreshSearchableSelect(buyer);
226
+ window.__qaPersistedWrites=0;
227
+ window.saveDatastore=()=>{
228
+ window.__qaPersistedWrites++;
229
+ throw new Error('Unexpected saveDatastore during filter-only QA');
230
+ };
231
+ return {goods:goods.value,buyer:buyer.value,
232
+ products:[...goods.options].filter(o=>o.value).map(o=>o.value),
233
+ customers:[...buyer.options].filter(o=>o.value).map(o=>o.value)};
234
+ });
235
+ expect(initial.products).toEqual(['QA_P10','QA_P15','QA_H1']);
236
+ expect(initial.customers).toEqual(['QA_C1','QA_C2','QA_C3']);
237
+ await page.locator('#module-rail [data-module="commerce"]').click();
238
+ await expect(page.locator('#view-invoices')).toHaveClass(/active/);
239
+ await expect(page.locator('#module-panel-title')).toHaveText('بازرگانی');
240
+
241
+ const productSelect=page.locator('#invoice-items-table-body .row-product-select').first();
242
+ const productInput=productSelect.locator('xpath=..').locator('.finora-combobox-input');
243
+ await productInput.click();
244
+ await productInput.fill('بلوک');
245
+ const productList=page.locator('body > .finora-combobox-list:visible');
246
+ await expect(productList.locator('[role="option"]')).toHaveCount(2);
247
+ await expect(productList).not.toContainText('محرمانه');
248
+ expect(await page.evaluate(()=>{
249
+ const sel=document.querySelector('#invoice-items-table-body .row-product-select');
250
+ return [...sel.options].filter(o=>o.value).map(o=>({id:o.value,unit:o.dataset.unit,price:o.dataset.price}));
251
+ })).toEqual([
252
+ {id:'QA_P10',unit:'عدد',price:'11000'},
253
+ {id:'QA_P15',unit:'بسته',price:'15000'},
254
+ {id:'QA_H1',unit:'عدد',price:'20000'}
255
+ ]);
256
+ await productInput.press('Escape');
257
+ await expect(productSelect).toHaveValue(initial.goods);
258
+
259
+ const buyerSelect=page.locator('#invoice-contact-id');
260
+ const buyerInput=buyerSelect.locator('xpath=..').locator('.finora-combobox-input');
261
+ await buyerInput.click();
262
+ await buyerInput.fill('شرکت');
263
+ const buyerList=buyerSelect.locator('xpath=..').locator('.finora-combobox-list');
264
+ await expect(buyerList.locator('[role="option"]')).toHaveCount(2);
265
+ await expect(buyerList).not.toContainText('محرمانه');
266
+ await expect(buyerSelect).toHaveValue(initial.buyer);
267
+ await buyerInput.press('Escape');
268
+
269
+ const final=await page.evaluate(()=>({
270
+ saves:window.__qaPersistedWrites,
271
+ productId:document.querySelector('#invoice-items-table-body .row-product-select').value,
272
+ buyerId:document.querySelector('#invoice-contact-id').value,
273
+ invoices:datastore.invoices.length,
274
+ crossUserProduct:getMyProducts().some(p=>p.id==='OTHER_P'),
275
+ crossUserBuyer:getMyContacts().some(c=>c.id==='OTHER_C')
276
+ }));
277
+ expect(final).toEqual({
278
+ saves:0,productId:initial.goods,buyerId:initial.buyer,invoices:0,
279
+ crossUserProduct:false,crossUserBuyer:false
280
+ });
281
+ expect(pageErrors).toEqual([]);
282
+});