سامانه صدور فاکتور و حسابداری
test(phase0): add 1200+ selector stress and tenant-negative browser checks
davoodmehraban89 committed
Oct 12, 2026 at 07:41 UTC
9523b0434b23f3f616003fa04525af717e6e50ed
1 file changed
+60
scripts/phase0-selector-stress.spec.js
new
+60
@@ -0,0 +1,60 @@
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
+ expect(elapsed,'product filter took '+elapsed.toFixed(0)+'ms').toBeLessThan(5000);
24
+ await expect(list.locator('[role="option"]')).toHaveCount(1);
25
+ await expect(list).toContainText('1204');
26
+ await product.fill('بلوك');
27
+ await expect(list.locator('[role="option"]')).toHaveCount(2);
28
+ await product.press('ArrowDown');
29
+ await expect(list.locator('[aria-selected="true"]')).toContainText('بلوک سبک ۱۵');
30
+ await product.press('Enter');
31
+ await expect(page.locator('#stress-products')).toHaveValue('B15');
32
+ await product.click();await product.fill('هارد');
33
+ await expect(list.locator('[role="option"]')).toHaveCount(1);
34
+ await expect(list).not.toContainText('محرمانه');
35
+ await product.fill('دو ترابایت');
36
+ await expect(list.locator('[role="option"]')).toHaveCount(1);
37
+ await product.fill('عبارت ناموجود');
38
+ await expect(list.locator('.finora-combobox-empty')).toContainText('موردی پیدا نشد');
39
+ await product.press('Escape');
40
+ await expect(page.locator('#stress-products')).toHaveValue('B15');
41
+ expect(await page.evaluate(()=>[window.__saves,window.__posted])).toEqual([0,0]);
42
+});
43
+
44
+test('F0-05 people: 1206 choices and 11-digit metadata filter with no implicit writes',async({page})=>{
45
+ const {person}=await fixture(page);
46
+ await person.click();
47
+ const list=page.locator('#invoice-contact-id').locator('xpath=..').locator('.finora-combobox-list');
48
+ await expect(list.locator('[role="option"]')).toHaveCount(1206);
49
+ 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});
50
+ expect(elapsed,'contact filter took '+elapsed.toFixed(0)+'ms').toBeLessThan(5000);
51
+ await expect(list.locator('[role="option"]')).toHaveCount(1);
52
+ await expect(list).toContainText('شرکت توسعه هارد');
53
+ await person.press('Enter');
54
+ await expect(page.locator('#invoice-contact-id')).toHaveValue('CVIP');
55
+ await person.click();await person.fill('شرکت آزمایشی شماره 1199');
56
+ await expect(list.locator('[role="option"]')).toHaveCount(1);
57
+ await person.press('Enter');
58
+ await expect(page.locator('#invoice-contact-id')).toHaveValue('C1199');
59
+ expect(await page.evaluate(()=>[window.__saves,window.__posted])).toEqual([0,0]);
60
+});