mirror of
https://github.com/Komediruzecki/token-circles.git
synced 2026-10-20 09:46:43 +02:00
The Loans page is rebuilt around one question: what happens to this loan if I pay more, or the rate moves? Scenarios are computed in the browser from the shared engine (shared/loanSchedule.ts, shared/loanScenarios.ts), live in the URL and cost no request. - Overview: a summary strip and one card per loan, with What if on every loan that is not paid off. - A page per loan (#loans/<id>/compare|schedule|extras). Compare puts "As planned" beside a what-if built from templates: more each month, round the installment up, a one-off payment, a yearly bonus, an extra installment a year, done by a date, a rate change. Two modes, "Finish sooner" and "Pay less each month", side by side if wanted. Month by month is the amortisation table with CSV export. Extra payments are changed in place or removed. - Extra payments keep one stored id in both runtimes, and PUT /api/loans/:id/prepayments/:prepayId changes one by that id; a missing one is "Extra payment not found" in both. The route is on the CRUD contract. - Round the installment up takes no mode, and a target at or under the installment says that nothing extra goes to the loan. - Each Worker contract scenario gets a minute: the profile scenarios take 12-16s on CI against the 20s default.
31 lines
1.5 KiB
TypeScript
31 lines
1.5 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
import { login, navigateToRoute } from './test-helpers'
|
|
|
|
test.describe('Loan Amortization Table', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'loans')
|
|
})
|
|
|
|
test('should display the amortization schedule on the Month by month tab', async ({ page }) => {
|
|
// The relayout moved the schedule from a panel under the card to the loan's own page: its
|
|
// name opens the Month by month tab, still wrapped in the `loans-amortization` container.
|
|
const name = page.getByTestId('loans-item-name').first()
|
|
await expect(name).toBeVisible({ timeout: 10000 })
|
|
await name.click()
|
|
await expect(page.getByTestId('loans-tab-schedule')).toHaveAttribute('aria-selected', 'true')
|
|
|
|
const amortization = page.getByTestId('loans-amortization')
|
|
await expect(amortization).toBeVisible({ timeout: 10000 })
|
|
// The summary line is the point of the copy assertion, so matching its words is correct.
|
|
const summary = amortization.getByTestId('loans-schedule-summary')
|
|
await expect(summary).toContainText(/\d+ payments, the last on/)
|
|
await expect(summary).toContainText('Interest in all')
|
|
await expect(amortization.getByTestId('loans-schedule-export')).toBeVisible()
|
|
|
|
// The schedule itself: one row per payment of the seeded 60-month loan.
|
|
await expect(amortization.getByTestId('loans-schedule-table')).toBeVisible()
|
|
await expect(amortization.getByTestId('loans-schedule-row')).toHaveCount(60)
|
|
})
|
|
})
|