Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion frontend/src/__tests__/plans.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,12 @@ describe('Plans Module', () => {

await new Promise(resolve => setTimeout(resolve, 50));

expect(mockConfirmDialog).toHaveBeenCalled();
// The action cancels this scheduled purchase AND disables its plan
// (backend deletePlannedPurchase), so the dialog must say both.
expect(mockConfirmDialog).toHaveBeenCalledWith(expect.objectContaining({
title: 'Cancel this scheduled purchase?',
body: expect.stringContaining('plan will be disabled'),
}));
expect(api.deletePlannedPurchase).toHaveBeenCalledWith('purchase-1');
// Issue #774: after disable the Plans page must refresh so the toggle
// reflects the backend's new enabled=false. getPlans is the API call
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/plans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ function renderPlannedPurchaseRow(purchase: PlannedPurchase): string {
${canPauseOrResumePurchase && isPending ? `<button data-action="pause" data-id="${escapeHtmlAttr(purchase.id)}" class="btn-small" title="Pause">⏸</button>` : ''}
${canPauseOrResumePurchase && isPaused ? `<button data-action="resume" data-id="${escapeHtmlAttr(purchase.id)}" class="btn-small" title="Resume">⏵</button>` : ''}
${canEditPlan ? `<button data-action="edit" data-id="${escapeHtmlAttr(purchase.id)}" data-plan-id="${escapeHtmlAttr(purchase.plan_id)}" class="btn-small" title="Edit Plan">✎</button>` : ''}
${canDisablePlan ? `<button data-action="disable" data-id="${escapeHtmlAttr(purchase.id)}" class="btn-small danger" title="Disable Plan">✕</button>` : ''}
${canDisablePlan ? `<button data-action="disable" data-id="${escapeHtmlAttr(purchase.id)}" class="btn-small danger" title="Cancel this purchase and disable its plan">✕</button>` : ''}
</td>
</tr>
`;
Expand Down Expand Up @@ -823,9 +823,10 @@ async function handlePlannedPurchaseAction(action: string, purchaseId: string, p
case 'disable': {
// Use styled async dialog (11-L2) instead of blocking browser confirm().
const disableOk = await confirmDialog({
title: 'Disable this plan?',
body: 'The plan will be paused and no purchases will be scheduled. You can re-enable it later from the Plans list.',
confirmLabel: 'Disable plan',
title: 'Cancel this scheduled purchase?',
body: 'This scheduled purchase will be canceled, and its plan will be disabled so no further purchases are scheduled from it. You can re-enable the plan later from the Plans list.',
confirmLabel: 'Cancel purchase and disable plan',
cancelLabel: 'Keep it',
destructive: true,
});
if (disableOk) {
Expand Down
Loading