سامانه صدور فاکتور و حسابداری
test(invoice): assert product hydration never clears unsaved form fields (#216)
davoodmehraban89 committed
Nov 22, 2026 at 01:53 UTC
4dcace37a416231d22ec748b3a682d9a492c1741
1 file changed
+17
scripts/phase0-invoice-persistence.spec.js
+17
@@ -106,6 +106,23 @@ async function fillInvoice(page,number,qty){
106
await page.locator('#invoice-items-table-body .row-quantity').first().dispatchEvent('input');
107
}
108
109
+test('late invoice product hydration preserves unsaved number, quantity and price',async({page})=>{
110
+ const server=fakeServer();await installHarness(page,server);await authenticatedMockBrowser(page);
111
+ await page.locator('#invoice-number').fill('UNSAVED-HYDRATION');
112
+ await page.locator('#invoice-items-table-body .row-quantity').first().fill('7');
113
+ await page.locator('#invoice-items-table-body .row-price').first().fill('2,500');
114
+ // Reproduce the pre-login placeholder after a user has already filled fields.
115
+ await page.evaluate(()=>{
116
+ const select=document.querySelector('#invoice-items-table-body .row-product-select');
117
+ while(select.options.length>1)select.remove(1);
118
+ renderInvoices();
119
+ });
120
+ await expect(page.locator('#invoice-items-table-body .row-product-select option[value="QA_PROD"]')).toHaveCount(1);
121
+ await expect(page.locator('#invoice-number')).toHaveValue('UNSAVED-HYDRATION');
122
+ await expect(page.locator('#invoice-items-table-body .row-quantity').first()).toHaveValue('7');
123
+ await expect(page.locator('#invoice-items-table-body .row-price').first()).toHaveValue('2,500');
124
+});
125
+
126
test('F0-03 isolated invoice save → mock-server sync → reload → edit → reload → print',async({page})=>{
127
const server=fakeServer();
128
await installHarness(page,server);