fix(checkout): lock modifications after transfer submission

This commit is contained in:
2026-08-21 15:50:18 -03:00
parent 195ac73aed
commit 21e89805d0
3 changed files with 23 additions and 3 deletions

View File

@@ -51,7 +51,7 @@
[allowModify]="true"
[showModifyWhenReadonly]="true"
[modifyAsAction]="true"
[editingDisabled]="isCancellingPurchase()"
[editingDisabled]="isPurchaseModificationDisabled()"
backgroundColor="transparent"
(modify)="onModifyPurchase()"
/>

View File

@@ -211,6 +211,22 @@ describe('CheckoutPageComponent payment validation', () => {
expect(routerStub.navigate).not.toHaveBeenCalled();
});
it('prevents modifying the purchase after Ya transferí is clicked', async () => {
const { component } = createComponent();
component.selectedPaymentMethod.set('transfer');
await component.onComplete();
expect(component.hasSubmittedTransfer()).toBe(true);
expect(component.isPurchaseModificationDisabled()).toBe(true);
await component.onModifyPurchase();
expect(checkoutServiceStub.cancelPurchase).not.toHaveBeenCalled();
expect(globalLoadingServiceStub.start).not.toHaveBeenCalled();
expect(routerStub.navigate).not.toHaveBeenCalled();
});
it('navigates after a transfer is confirmed as paid', async () => {
checkoutServiceStub.getPurchase.mockResolvedValue({ status: 'paid' });
const { component } = createComponent();
@@ -508,7 +524,6 @@ describe('CheckoutPageComponent payment validation', () => {
expect(globalLoadingServiceStub.stop).toHaveBeenCalledOnce();
await component.canDeactivate();
});
it('updates customer data on the existing purchase before payment', async () => {

View File

@@ -122,6 +122,10 @@ export class CheckoutPageComponent implements OnInit, OnDestroy {
protected readonly isUpdatingPurchase = signal(false);
protected readonly isCancellingPurchase = signal(false);
protected readonly hasSubmittedTransfer = signal(false);
protected readonly isPurchaseModificationDisabled = computed(
() => this.isCancellingPurchase() || this.hasSubmittedTransfer(),
);
protected readonly createdPurchaseId = signal<number | null>(null);
protected readonly isGeneratingIntent = signal(false);
protected readonly isPaymentLoading = computed(() => this.isGeneratingIntent());
@@ -187,7 +191,7 @@ export class CheckoutPageComponent implements OnInit, OnDestroy {
}
protected async onModifyPurchase(): Promise<void> {
if (this.isCancellingPurchase()) {
if (this.isPurchaseModificationDisabled()) {
return;
}
@@ -413,6 +417,7 @@ export class CheckoutPageComponent implements OnInit, OnDestroy {
}
this.stopTransferPolling();
this.hasSubmittedTransfer.set(true);
this.transferValidationStatus.set('checking');
this.transferPollingAttempts = 0;