|
7 | 7 | * network helpers (those are covered by api-* tests). |
8 | 8 | */ |
9 | 9 |
|
| 10 | +// approval-details.ts now reads getAmortizeUpfront() from state at render |
| 11 | +// time. Mock it to return false (default: non-amortized) so existing tests |
| 12 | +// continue to verify the base column layout. |
| 13 | +jest.mock('../state', () => ({ |
| 14 | + getAmortizeUpfront: jest.fn(() => false), |
| 15 | +})); |
| 16 | + |
10 | 17 | import { |
11 | 18 | computeEffectiveSavingsPct, |
12 | 19 | formatAccountLabel, |
@@ -82,13 +89,13 @@ describe('renderApprovalDetailsBody', () => { |
82 | 89 | expect(text).toContain('Accounts'); |
83 | 90 | }); |
84 | 91 |
|
85 | | - it('renders the per-rec table with all 12 columns', () => { |
| 92 | + it('renders the per-rec table with all 13 columns (Monthly cost added by issue #1112)', () => { |
86 | 93 | const rec = makeRec({}); |
87 | 94 | const body = renderApprovalDetailsBody(makeDetails([rec]), new Map()); |
88 | 95 | const headers = Array.from(body.querySelectorAll('.approval-details-table thead th')).map(th => th.textContent); |
89 | 96 | expect(headers).toEqual([ |
90 | 97 | 'Account', 'Provider', 'Service', 'Resource', 'Engine', 'Region', |
91 | | - 'Count', 'Term', 'Payment', 'Upfront', 'Monthly savings', 'Eff. savings %', |
| 98 | + 'Count', 'Term', 'Payment', 'Upfront', 'Monthly cost', 'Monthly savings', 'Eff. savings %', |
92 | 99 | ]); |
93 | 100 | }); |
94 | 101 |
|
@@ -149,17 +156,19 @@ describe('renderApprovalDetailsBody', () => { |
149 | 156 | const rec = makeRec({ upfront_cost: 4567.89, savings: 12.5 }); |
150 | 157 | const body = renderApprovalDetailsBody(makeDetails([rec]), new Map()); |
151 | 158 | const cells = body.querySelectorAll('.approval-details-table tbody td'); |
| 159 | + // col 9 = Upfront, col 10 = Monthly cost (issue #1112), col 11 = Monthly savings |
152 | 160 | expect(cells[9]?.textContent).toBe('$4,568'); |
153 | | - expect(cells[10]?.textContent).toBe('$13'); |
| 161 | + expect(cells[11]?.textContent).toBe('$13'); |
154 | 162 | }); |
155 | 163 |
|
156 | 164 | it('computes effective savings % when on_demand_cost is set, "—" otherwise', () => { |
157 | 165 | const withBaseline = makeRec({ savings: 30, on_demand_cost: 100 }); |
158 | 166 | const withoutBaseline = makeRec({ id: 'rec-2', savings: 30, on_demand_cost: null, monthly_cost: null }); |
159 | 167 | const body = renderApprovalDetailsBody(makeDetails([withBaseline, withoutBaseline]), new Map()); |
160 | 168 | const rows = body.querySelectorAll('.approval-details-table tbody tr'); |
161 | | - expect(rows[0]?.querySelectorAll('td')[11]?.textContent).toBe('30.0%'); |
162 | | - expect(rows[1]?.querySelectorAll('td')[11]?.textContent).toBe('—'); |
| 169 | + // col 12 = Eff. savings % (shifted by +1 due to the new Monthly cost col at index 10) |
| 170 | + expect(rows[0]?.querySelectorAll('td')[12]?.textContent).toBe('30.0%'); |
| 171 | + expect(rows[1]?.querySelectorAll('td')[12]?.textContent).toBe('—'); |
163 | 172 | }); |
164 | 173 |
|
165 | 174 | it('annual-savings tooltip does NOT fire on floating-point rounding noise', () => { |
|
0 commit comments