fix(checkout): lock modifications after transfer submission
This commit is contained in:
@@ -51,7 +51,7 @@
|
|||||||
[allowModify]="true"
|
[allowModify]="true"
|
||||||
[showModifyWhenReadonly]="true"
|
[showModifyWhenReadonly]="true"
|
||||||
[modifyAsAction]="true"
|
[modifyAsAction]="true"
|
||||||
[editingDisabled]="isCancellingPurchase()"
|
[editingDisabled]="isPurchaseModificationDisabled()"
|
||||||
backgroundColor="transparent"
|
backgroundColor="transparent"
|
||||||
(modify)="onModifyPurchase()"
|
(modify)="onModifyPurchase()"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -211,6 +211,22 @@ describe('CheckoutPageComponent payment validation', () => {
|
|||||||
expect(routerStub.navigate).not.toHaveBeenCalled();
|
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 () => {
|
it('navigates after a transfer is confirmed as paid', async () => {
|
||||||
checkoutServiceStub.getPurchase.mockResolvedValue({ status: 'paid' });
|
checkoutServiceStub.getPurchase.mockResolvedValue({ status: 'paid' });
|
||||||
const { component } = createComponent();
|
const { component } = createComponent();
|
||||||
@@ -508,7 +524,6 @@ describe('CheckoutPageComponent payment validation', () => {
|
|||||||
expect(globalLoadingServiceStub.stop).toHaveBeenCalledOnce();
|
expect(globalLoadingServiceStub.stop).toHaveBeenCalledOnce();
|
||||||
|
|
||||||
await component.canDeactivate();
|
await component.canDeactivate();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('updates customer data on the existing purchase before payment', async () => {
|
it('updates customer data on the existing purchase before payment', async () => {
|
||||||
|
|||||||
@@ -122,6 +122,10 @@ export class CheckoutPageComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
protected readonly isUpdatingPurchase = signal(false);
|
protected readonly isUpdatingPurchase = signal(false);
|
||||||
protected readonly isCancellingPurchase = 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 createdPurchaseId = signal<number | null>(null);
|
||||||
protected readonly isGeneratingIntent = signal(false);
|
protected readonly isGeneratingIntent = signal(false);
|
||||||
protected readonly isPaymentLoading = computed(() => this.isGeneratingIntent());
|
protected readonly isPaymentLoading = computed(() => this.isGeneratingIntent());
|
||||||
@@ -187,7 +191,7 @@ export class CheckoutPageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async onModifyPurchase(): Promise<void> {
|
protected async onModifyPurchase(): Promise<void> {
|
||||||
if (this.isCancellingPurchase()) {
|
if (this.isPurchaseModificationDisabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,6 +417,7 @@ export class CheckoutPageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.stopTransferPolling();
|
this.stopTransferPolling();
|
||||||
|
this.hasSubmittedTransfer.set(true);
|
||||||
this.transferValidationStatus.set('checking');
|
this.transferValidationStatus.set('checking');
|
||||||
this.transferPollingAttempts = 0;
|
this.transferPollingAttempts = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user