Skip to content

Commit a582a48

Browse files
committed
test(frontend/plans): assert setPlanAccounts not called on create path
Add regression guards that will fail if PR #861 is reverted: the create path must not call setPlanAccounts (backend persists plan_accounts atomically from target_accounts in the POST body). Also assert the update path still calls setPlanAccounts, completing the behavioral contract.
1 parent ab84310 commit a582a48

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎frontend/src/__tests__/plans.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,11 +1109,14 @@ describe('Plans Module', () => {
11091109
await savePlan(event);
11101110

11111111
expect(api.createPlan).toHaveBeenCalled();
1112+
// PR #861: no follow-up setPlanAccounts on the create path.
1113+
expect(api.setPlanAccounts).not.toHaveBeenCalled();
11121114
expect(mockShowToast).toHaveBeenCalledWith(expect.objectContaining({ message: 'Plan created successfully' }));
11131115
});
11141116

11151117
test('updates existing plan when plan ID present', async () => {
11161118
(api.updatePlan as jest.Mock).mockResolvedValue({});
1119+
(api.setPlanAccounts as jest.Mock).mockResolvedValue(undefined);
11171120
(api.getPlans as jest.Mock).mockResolvedValue({ plans: [] });
11181121
(api.getPlannedPurchases as jest.Mock).mockResolvedValue({ purchases: [] });
11191122
(document.getElementById('plan-id') as HTMLInputElement).value = 'plan-123';
@@ -1122,6 +1125,8 @@ describe('Plans Module', () => {
11221125
await savePlan(event);
11231126

11241127
expect(api.updatePlan).toHaveBeenCalledWith('plan-123', expect.any(Object));
1128+
// PR #861: update path still calls setPlanAccounts (no atomic backend write on PUT).
1129+
expect(api.setPlanAccounts).toHaveBeenCalledWith('plan-123', expect.any(Array));
11251130
expect(mockShowToast).toHaveBeenCalledWith(expect.objectContaining({ message: 'Plan updated successfully' }));
11261131
});
11271132

@@ -1397,6 +1402,11 @@ describe('Plans Module', () => {
13971402
'22222222-2222-2222-2222-222222222222',
13981403
],
13991404
}));
1405+
// Regression guard for PR #861: the create path must NOT call
1406+
// setPlanAccounts -- the backend already persists plan_accounts
1407+
// atomically from target_accounts in the POST body (handler_plans.go
1408+
// createPlan). A follow-up PUT would be a redundant double-write.
1409+
expect(api.setPlanAccounts).not.toHaveBeenCalled();
14001410
});
14011411

14021412
// -------------------------------------------------------------------------

0 commit comments

Comments
 (0)