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

test(phase0): stress >1200 account, project and contract selector options safely in Chromium

davoodmehraban89 committed Oct 12, 2026 at 12:13 UTC 99be1b33ea6b8792f1be85e82a08367352bae223
1 file changed +73
scripts/phase0-selector-stress.spec.js
+73
@@ -60,3 +60,76 @@ test('F0-05 people: 1206 choices and 11-digit metadata filter with no implicit w
60 await expect(page.locator('#invoice-contact-id')).toHaveValue('C1199');
61 expect(await page.evaluate(()=>[window.__saves,window.__posted])).toEqual([0,0]);
62 });
63 +
64 +
65 +test('F0-05 1200+ account, project and contract comboboxes: scoped metadata, keyboard, no writes',async({page})=>{
66 + await fixture(page);
67 + await page.evaluate(()=>{
68 + // All records are disposable fixture records. Ownership is resolved BEFORE
69 + // option construction; this is not a substitute for real Supabase RLS.
70 + const own=(prefix,label,codefield,number)=>Array.from({length:number},(_,i)=>({
71 + id:prefix+i,ownerUserId:'QA',companyId:'ORG',name:label+' '+String(i).padStart(4,'0'),
72 + code:prefix+'-'+String(i).padStart(5,'0'),
73 + title:label+' '+String(i).padStart(4,'0')
74 + }));
75 + datastore.accounts=own('A','حساب آزمایشی','code',1205);
76 + datastore.accounts.push({id:'AX',ownerUserId:'QA',companyId:'ORG',code:'442201',title:'حساب کنترل بانک',name:'حساب کنترل بانک'});
77 + datastore.accounts.push({id:'HIDDEN_ACCOUNT',ownerUserId:'OTHER',companyId:'OTHER',code:'999999',title:'حساب شرکت محرمانه'});
78 + datastore.projects=own('J','پروژه آزمایشی','code',1205);
79 + datastore.projects.push({id:'JX',ownerUserId:'QA',companyId:'ORG',code:'PRJ-SPEC-44',floatingCode:'F-4444',name:'پروژه سیمانی ویژه'});
80 + datastore.projects.push({id:'HIDDEN_PROJECT',ownerUserId:'OTHER',companyId:'OTHER',code:'OTHER-PRJ',name:'پروژه شرکت محرمانه'});
81 + datastore.contracts=own('T','پیمان آزمایشی','code',1205);
82 + datastore.contracts.push({id:'TX',ownerUserId:'QA',companyId:'ORG',code:'CNT-XL-2026',name:'پیمان خاص آبان'});
83 + datastore.contracts.push({id:'HIDDEN_CONTRACT',ownerUserId:'OTHER',companyId:'OTHER',code:'OTHER-CNT',name:'پیمان شرکت محرمانه'});
84 + const targets=[
85 + {id:'af-rule-account',rows:datastore.accounts,heading:'انتخاب حساب'},
86 + {id:'invoice-project-id',rows:datastore.projects,heading:'انتخاب پروژه'},
87 + {id:'f0-contract-synthetic',rows:datastore.contracts,heading:'انتخاب پیمان'}
88 + ];
89 + for(const target of targets){
90 + let s=document.getElementById(target.id);
91 + if(!s){s=document.createElement('select');s.id=target.id;document.getElementById('view-invoices').appendChild(s)}
92 + s.replaceChildren(new Option(target.heading,''));
93 + target.rows.filter(x=>x.ownerUserId==='QA'&&x.companyId==='ORG').forEach(x=>{
94 + const o=new Option(x.title||x.name,x.id);
95 + o.dataset.search=[x.code,x.floatingCode].filter(Boolean).join(' ');
96 + s.appendChild(o);
97 + });
98 + finoraRefreshSearchableSelect(s);
99 + }
100 + });
101 + const listFor=id=>page.locator('#'+id).locator('xpath=..').locator('.finora-combobox-list');
102 + const inputFor=id=>page.locator('#'+id).locator('xpath=..').locator('.finora-combobox-input');
103 + const specs=[
104 + {id:'af-rule-account',special:'442201',selected:'AX',other:'HIDDEN_ACCOUNT',name:'account',ordinary:'حساب آزمایشی 1199'},
105 + {id:'invoice-project-id',special:'F-4444',selected:'JX',other:'HIDDEN_PROJECT',name:'project',ordinary:'پروژه آزمایشی 1199'},
106 + {id:'f0-contract-synthetic',special:'CNT-XL-2026',selected:'TX',other:'HIDDEN_CONTRACT',name:'contract',ordinary:'پیمان آزمایشی 1199'}
107 + ];
108 + for(const spec of specs){
109 + const input=inputFor(spec.id),list=listFor(spec.id),select=page.locator('#'+spec.id);
110 + await input.click();
111 + await expect(list.locator('[role="option"]')).toHaveCount(1206);
112 + await expect(list.locator('[data-value="'+spec.other+'"]')).toHaveCount(0);
113 + const elapsed=await page.evaluate(({id,q})=>{
114 + const e=document.getElementById(id).parentElement.querySelector('.finora-combobox-input');
115 + const t=performance.now();e.value=q;e.dispatchEvent(new Event('input',{bubbles:true}));return performance.now()-t;
116 + },{id:spec.id,q:spec.special});
117 + console.info('F0-05 '+spec.name+' filter browser ms:',elapsed.toFixed(1));
118 + expect(elapsed,spec.name+' synthetic filter latency').toBeLessThan(5000);
119 + await expect(list.locator('[role="option"]')).toHaveCount(1);
120 + await input.press('Enter');
121 + await expect(select).toHaveValue(spec.selected);
122 + await input.click();
123 + await input.fill('عبارت ناموجود');
124 + await expect(list.locator('.finora-combobox-empty')).toContainText('موردی پیدا نشد');
125 + await input.press('Escape');
126 + await expect(select).toHaveValue(spec.selected);
127 + await input.click();
128 + await input.fill(spec.ordinary);
129 + await expect(list.locator('[role="option"]')).toHaveCount(1);
130 + await input.press('End');
131 + await input.press('Enter');
132 + await expect(select).not.toHaveValue(spec.selected);
133 + expect(await page.evaluate(()=>[window.__saves,window.__posted])).toEqual([0,0]);
134 + }
135 +});