feat: update cart service and components to handle productVariantId, improve item removal and addition feedback
This commit is contained in:
@@ -59,7 +59,7 @@ describe('ProductDetailPageComponent', () => {
|
||||
navigate: vi.fn()
|
||||
};
|
||||
cartServiceStub = {
|
||||
addItem: vi.fn().mockReturnValue(of({}))
|
||||
addItem: vi.fn().mockReturnValue(of({ message: 'Producto agregado al carrito' }))
|
||||
};
|
||||
toastServiceStub = {
|
||||
success: vi.fn(),
|
||||
@@ -277,6 +277,8 @@ describe('ProductDetailPageComponent', () => {
|
||||
it('keeps quantity at a minimum of one and increments locally', async () => {
|
||||
await configureTestingModule();
|
||||
const fixture = TestBed.createComponent(ProductDetailPageComponent);
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.componentInstance['selectedVariant'].set({
|
||||
variant_id: 1,
|
||||
cantidad_maxima: 10,
|
||||
|
||||
@@ -230,8 +230,9 @@ export class ProductDetailPageComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.addingToCart.set(true);
|
||||
this.cartService.addItem(variant.variant_id, this.quantity()).subscribe({
|
||||
next: () => {
|
||||
this.toastService.success('Producto agregado al carrito');
|
||||
next: (res) => {
|
||||
const msg = res.message || 'Producto agregado al carrito';
|
||||
this.toastService.success(msg);
|
||||
this.addingToCart.set(false);
|
||||
},
|
||||
error: (err: HttpErrorResponse) => {
|
||||
|
||||
Reference in New Issue
Block a user