From 2bab709ac442566c313d70c189d09fa9fb980074 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 2 Jul 2026 17:12:58 +0530 Subject: [PATCH] test: scope date range, reload invoice, strengthen total-row check --- .../test_sales_person_commission_summary.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/erpnext/selling/report/sales_person_commission_summary/test_sales_person_commission_summary.py b/erpnext/selling/report/sales_person_commission_summary/test_sales_person_commission_summary.py index e807d33f506..b1385ca4f09 100644 --- a/erpnext/selling/report/sales_person_commission_summary/test_sales_person_commission_summary.py +++ b/erpnext/selling/report/sales_person_commission_summary/test_sales_person_commission_summary.py @@ -31,11 +31,20 @@ class TestSalesPersonCommissionSummary(ERPNextTestSuite): ) si.insert() si.submit() + si.reload() # reflect any values recomputed on submit return si def run_report(self, **extra): filters = frappe._dict( - {"company": "_Test Company", "doc_type": "Sales Invoice", "sales_person": self.sales_person} + { + "company": "_Test Company", + "doc_type": "Sales Invoice", + "sales_person": self.sales_person, + # scope to this test's posting date so the query isn't unbounded over + # every invoice for the shared sales person + "from_date": "2026-06-01", + "to_date": "2026-06-01", + } ) filters.update(extra) return execute(filters)[1] @@ -64,8 +73,9 @@ class TestSalesPersonCommissionSummary(ERPNextTestSuite): def test_appends_total_row(self): self.make_invoice_with_commission() rows = self.run_report() - # the report appends a blank total row after the data rows - self.assertTrue(rows) + # the report appends a blank total row after one or more real data rows + self.assertGreaterEqual(len(rows), 2) + self.assertTrue(any(r[0] for r in rows[:-1]), "expected real data rows before the total row") self.assertEqual(rows[-1], [""] * len(rows[0])) def test_sales_person_filter_scopes_rows(self):