سامانه صدور فاکتور و حسابداری
test: cover cloud-late products, search popup visibility and selected line metadata
davoodmehraban89 committed
Oct 11, 2026 at 14:39 UTC
cec51ee51b280c2d637939edae84ba0e88d4a555
1 file changed
+55
-3
scripts/ux-hardening-r2.spec.js
+55
-3
@@ -57,7 +57,59 @@ test('product combobox searches one field by code, name and specification',async
57
await page.addScriptTag({content:"var currentUser={id:'U1'},datastore={settings:[{ownerUserId:'U1'}],products:[{id:'B10',code:'BLK-310',name:'بلوک سایز ۱۰',spec:'سبک AAC'},{id:'C3',code:'CEM-003',name:'سیمان تیپ ۲',spec:'پاکتی'}],contacts:[],companies:[{id:'C1',ownerUserId:'U1'}],accounts:[],projects:[],invoices:[],purchases:[],cheques:[],journalVouchers:[]};var FINORA_MODULES={settings:{groups:[]}};function getMySettings(){return datastore.settings[0]}function getMyCompanies(){return datastore.companies}function getMyProducts(){return datastore.products}function getMyContacts(){return datastore.contacts}function getMyAccounts(){return datastore.accounts}function getMyGlobalProjects(){return datastore.projects}function requireWrite(){return true}function saveDatastore(){}function toggleAccordion(){}function esc(v){return String(v)}"});
58
await page.addScriptTag({path:path.resolve('js/ux-hardening-r2.js')});await page.evaluate(()=>document.dispatchEvent(new Event('DOMContentLoaded')));
59
const input=page.locator('#product-search').locator('xpath=..').locator('.finora-combobox-input');
60
- await input.fill('310');await expect(page.locator('#product-search').locator('xpath=..').locator('.finora-combobox-option')).toContainText('بلوک سایز ۱۰');
61
- await input.fill('AAC');await expect(page.locator('#product-search').locator('xpath=..').locator('.finora-combobox-option')).toContainText('بلوک سایز ۱۰');
62
- await input.fill('سیمان');await expect(page.locator('#product-search').locator('xpath=..').locator('.finora-combobox-option')).toContainText('سیمان تیپ ۲');
60
+ await input.fill('310');await expect(page.locator('body > .finora-combobox-list .finora-combobox-option')).toContainText('بلوک سایز ۱۰');
61
+ await input.fill('AAC');await expect(page.locator('body > .finora-combobox-list .finora-combobox-option')).toContainText('بلوک سایز ۱۰');
62
+ await input.fill('سیمان');await expect(page.locator('body > .finora-combobox-list .finora-combobox-option')).toContainText('سیمان تیپ ۲');
63
+});
64
+
65
+
66
+test('existing invoice row rehydrates after cloud data arrives, displays an unclipped list and fills price/unit',async({page})=>{
67
+ await page.setViewportSize({width:1280,height:800});
68
+ await page.setContent(`<!doctype html><html lang="fa" dir="rtl"><head><style>
69
+ body{font-family:Tahoma,sans-serif;background:#f8fafc;padding:26px;color:#1e293b}h2{margin:12px 0 16px}
70
+ .invoice-card{border:1px solid #d8e0e8;background:white;border-radius:12px;padding:20px;max-width:1120px}
71
+ .table-clip{overflow:hidden;border:1px solid #d5dae0;border-radius:8px;max-height:130px}
72
+ table{width:100%;border-collapse:collapse;text-align:right}td,th{padding:15px 12px;border-bottom:1px solid #e2e8f0}
73
+ .form-control{width:100%;box-sizing:border-box;height:44px;border:1px solid #b3c1d1;border-radius:7px;padding:9px;text-align:right;font:inherit}
74
+ </style></head><body><section id="view-settings"></section>
75
+ <section id="view-invoices" class="view-pane active"><div class="invoice-card"><h2>صدور سند تجاری — اقلام کالا یا خدمات</h2>
76
+ <p>جستجوی کالا با نام، کد یا مشخصه</p>
77
+ <div class="table-clip"><table><thead><tr><th>شرح کالا / خدمات</th><th>واحد</th><th>قیمت واحد (ریال)</th></tr></thead><tbody><tr>
78
+ <td style="width:65%"><select class="form-control row-product-select" id="rehydrate-product"><option value="">-- انتخاب کالا / خدمات --</option></select></td>
79
+ <td><input id="result-unit" class="form-control" readonly></td><td><input id="result-price" class="form-control" readonly></td>
80
+ </tr></tbody></table></div></div></section></body></html>`);
81
+ await page.addScriptTag({content:`var currentUser={id:'U1'},datastore={settings:[{ownerUserId:'U1',ui_theme:'light'}],products:[],contacts:[],companies:[{id:'C1',ownerUserId:'U1'}],invoices:[],purchases:[],cheques:[],accounts:[],projects:[],journalVouchers:[]};var FINORA_MODULES={settings:{groups:[]}};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}function getMyAccounts(){return datastore.accounts}function getMyGlobalProjects(){return datastore.projects}function requireWrite(){return true}function saveDatastore(){}function toggleAccordion(){}function esc(v){return String(v)};document.getElementById('rehydrate-product').addEventListener('change',e=>{const o=e.target.selectedOptions[0];document.getElementById('result-price').value=o.dataset.price||'';document.getElementById('result-unit').value=o.dataset.unit||'';});`});
82
+ await page.addScriptTag({path:path.resolve('js/ux-hardening-r2.js')});
83
+ await page.evaluate(()=>document.dispatchEvent(new Event('DOMContentLoaded')));
84
+ const input=page.locator('#rehydrate-product').locator('xpath=..').locator('.finora-combobox-input');
85
+ await expect(page.locator('#rehydrate-product option')).toHaveCount(1);
86
+ await page.evaluate(()=>{datastore.products=[
87
+ {id:'B10',ownerUserId:'U1',name:'بلوک سیمانی ۱۰ سانتی',code:'310001',spec:'سبک',unit:'عدد',sale_price:85000},
88
+ {id:'B15',ownerUserId:'U1',name:'بلوک سبک ۱۵ سانتی',code:'310002',spec:'AAC',unit:'عدد',sale_price:110000},
89
+ {id:'C3',ownerUserId:'U1',name:'سیمان تیپ ۲',code:'220003',spec:'پاکتی ۵۰ کیلو',unit:'کیسه',sale_price:150000},
90
+ {id:'Evil',ownerUserId:'OTHER_USER',name:'سیمان محرمانه',code:'555',unit:'عدد',sale_price:1}
91
+ ]});
92
+ await input.click();
93
+ await expect(page.locator('body > .finora-combobox-list')).toBeVisible();
94
+ await expect(page.locator('body > .finora-combobox-list .finora-combobox-option')).toHaveCount(3);
95
+ await input.fill('بلوک');
96
+ await expect(page.locator('body > .finora-combobox-list .finora-combobox-option')).toHaveCount(2);
97
+ await expect(page.locator('body > .finora-combobox-list')).toContainText('بلوک سیمانی');
98
+ if(process.env.FINORA_PRODUCT_SEARCH_SCREENSHOT){
99
+ await page.screenshot({path:process.env.FINORA_PRODUCT_SEARCH_SCREENSHOT+'_block.png',fullPage:false});
100
+ }
101
+ await input.fill('سيــمان'.replace(/ـ/g,''));
102
+ await expect(page.locator('body > .finora-combobox-list .finora-combobox-option')).toHaveCount(1);
103
+ await expect(page.locator('body > .finora-combobox-list')).toContainText('سیمان تیپ ۲');
104
+ if(process.env.FINORA_PRODUCT_SEARCH_SCREENSHOT){
105
+ await page.screenshot({path:process.env.FINORA_PRODUCT_SEARCH_SCREENSHOT+'_cement.png',fullPage:false});
106
+ }
107
+ await page.locator('body > .finora-combobox-list .finora-combobox-option').click();
108
+ await expect(page.locator('#rehydrate-product')).toHaveValue('C3');
109
+ await expect(page.locator('#result-unit')).toHaveValue('کیسه');
110
+ await expect(page.locator('#result-price')).toHaveValue('150000');
111
+ await input.click();await input.fill('محرمانه');
112
+ await expect(page.locator('body > .finora-combobox-list .finora-combobox-empty')).toContainText('موردی پیدا نشد');
113
+ await page.keyboard.press('Escape');
114
+ await expect(page.locator('body > .finora-combobox-list')).toHaveCount(0);
115
});