سامانه صدور فاکتور و حسابداری
test(ui): assert linked draft source rows hide unsafe mutation actions
davoodmehraban89 committed
Nov 22, 2026 at 17:02 UTC
1fb81b66d96d6b540ff5dffa74231eb2c40129d2
1 file changed
+44
scripts/accounting-document-workflow.spec.js
+44
@@ -1060,3 +1060,47 @@ test('P0 #229 linked journal draft stays draft for both sales and purchases',asy
1060
voucherStates:['draft','draft']
1061
});
1062
});
1063
+
1064
+
1065
+test('P0 #229 linked journal drafts do not advertise unsupported source-only edit or finalize buttons',async({page})=>{
1066
+ const server=fakeServer();
1067
+ await installHarness(page,server);
1068
+ await authenticatedMockBrowser(page);
1069
+ const observed=await page.evaluate(()=>{
1070
+ const ownerUserId=currentUser.id,companyId='QA_CO';
1071
+ const sale={id:'QA_SALE_LINKED_UI',ownerUserId,companyId,number:'QA-SALE-LINKED-UI',
1072
+ companyName:'QA Company',contactId:'QA_CONTACT',contactName:'QA Customer',
1073
+ date:'1405/07/19',kind:'formal',kindLabel:'رسمی',items:[],grandTotal:170,
1074
+ journalVoucherId:'QA_SALE_JV_LINKED_UI',accountingStatus:'draft',documentStatus:'draft'};
1075
+ const purchase={id:'QA_PUR_LINKED_UI',ownerUserId,companyId,number:'QA-PUR-LINKED-UI',
1076
+ supplierId:'QA_CONTACT',supplierName:'QA Supplier',date:'1405/07/19',
1077
+ items:[],grandTotal:170,journalVoucherId:'QA_PUR_JV_LINKED_UI',
1078
+ accountingStatus:'draft',documentStatus:'draft'};
1079
+ datastore.invoices.push(sale);
1080
+ datastore.purchases.push(purchase);
1081
+ datastore.journalVouchers.push(
1082
+ {id:sale.journalVoucherId,ownerUserId,companyId,status:'draft',sourceType:'sale',sourceId:sale.id},
1083
+ {id:purchase.journalVoucherId,ownerUserId,companyId,status:'draft',sourceType:'purchase',sourceId:purchase.id}
1084
+ );
1085
+ switchView('view-purchases');
1086
+ refreshAllSurfaces();
1087
+ renderInvoices();
1088
+ const purRow=[...document.querySelectorAll('#pur-list-body tr')].find(tr=>tr.textContent.includes(purchase.number));
1089
+ const saleRow=[...document.querySelectorAll('#invoice-archive-table-body tr')].find(tr=>tr.textContent.includes(sale.number));
1090
+ if(!purRow||!saleRow)throw Error('Linked draft source rows missing from browser DOM; fixture failure');
1091
+ return {
1092
+ purchaseStatus:purchaseDocumentStatus(purchase),
1093
+ saleStatus:invoiceDocumentStatus(sale),
1094
+ purchaseMessage:purRow.textContent.includes('سند موقت متصل'),
1095
+ purchaseActions:[...purRow.querySelectorAll('button')].map(b=>b.getAttribute('onclick')||''),
1096
+ saleActions:[...saleRow.querySelectorAll('button')].map(b=>b.getAttribute('onclick')||'')
1097
+ };
1098
+ });
1099
+ expect(observed.purchaseStatus).toBe('draft');
1100
+ expect(observed.saleStatus).toBe('draft');
1101
+ expect(observed.purchaseMessage).toBe(true);
1102
+ expect(observed.purchaseActions).toEqual([expect.stringContaining('purPrint(')]);
1103
+ expect(observed.saleActions).toContainEqual(expect.stringContaining('renderAndPrintDirect('));
1104
+ expect(observed.saleActions).not.toContainEqual(expect.stringContaining('editInvoice('));
1105
+ expect(observed.saleActions).not.toContainEqual(expect.stringContaining('beginInvoiceAmendment('));
1106
+});