remove crypto rate display from cart
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
import { DeliveryMode } from '../../product/types/DeliveryMode';
|
||||
import type { StorefrontProductsService } from '../../storefrontProduct/services/StorefrontProductsService';
|
||||
import type { ExchangeRateService } from '../../exchangeRate/services/ExchangeRateService';
|
||||
import { PaymentMethod } from '../../payment/types/PaymentMethod';
|
||||
import type { CookieCartLineExtended } from '../types/CookieCartLineExtended';
|
||||
import type { StorefrontDiscountService } from './StorefrontDiscountService';
|
||||
import { StorefrontCartService } from './StorefrontCartService';
|
||||
@@ -30,9 +28,6 @@ describe('StorefrontCartService', () => {
|
||||
getStorefrontVariantsByIds: jest.Mock;
|
||||
getStorefrontVariant: jest.Mock;
|
||||
};
|
||||
let exchangeRateService: {
|
||||
getLiveFiatPerCrypto: jest.Mock;
|
||||
};
|
||||
let discountService: {
|
||||
getDiscountStateForCart: jest.Mock;
|
||||
applyDiscountCode: jest.Mock;
|
||||
@@ -44,10 +39,6 @@ describe('StorefrontCartService', () => {
|
||||
getStorefrontVariant: jest.fn().mockResolvedValue(buildVariant())
|
||||
};
|
||||
|
||||
exchangeRateService = {
|
||||
getLiveFiatPerCrypto: jest.fn().mockReturnValue(150)
|
||||
};
|
||||
|
||||
discountService = {
|
||||
getDiscountStateForCart: jest.fn().mockResolvedValue({
|
||||
discounts: [],
|
||||
@@ -59,7 +50,6 @@ describe('StorefrontCartService', () => {
|
||||
|
||||
service = new StorefrontCartService(
|
||||
productsService as unknown as StorefrontProductsService,
|
||||
exchangeRateService as unknown as ExchangeRateService,
|
||||
discountService as unknown as StorefrontDiscountService
|
||||
);
|
||||
});
|
||||
@@ -99,8 +89,6 @@ describe('StorefrontCartService', () => {
|
||||
discounts: [],
|
||||
cartDiscountTotal: 0,
|
||||
cartTotalPrice: 0,
|
||||
cartTotalXmr: null,
|
||||
fiatPerXmr: null,
|
||||
hasManualLines: false,
|
||||
hasAutoLines: false,
|
||||
cartTotalIssueMessage: null,
|
||||
@@ -108,23 +96,13 @@ describe('StorefrontCartService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('converts the discounted total to XMR when a live rate is available', async () => {
|
||||
it('returns cart totals and delivery flags', async () => {
|
||||
const summary = await service.getCartSummary([{ variantId, qty: 1 }], []);
|
||||
|
||||
expect(summary.cartSubtotal).toBe(10);
|
||||
expect(summary.cartTotalPrice).toBe(10);
|
||||
expect(summary.fiatPerXmr).toBe(150);
|
||||
expect(summary.cartTotalXmr).toBe('0.06666667');
|
||||
expect(summary.hasAutoLines).toBe(true);
|
||||
});
|
||||
|
||||
it('leaves cartTotalXmr null when no live rate is available', async () => {
|
||||
exchangeRateService.getLiveFiatPerCrypto.mockReturnValue(null);
|
||||
|
||||
const summary = await service.getCartSummary([{ variantId, qty: 1 }], []);
|
||||
|
||||
expect(summary.cartTotalXmr).toBeNull();
|
||||
expect(summary.fiatPerXmr).toBeNull();
|
||||
expect(summary.hasIssues).toBe(false);
|
||||
});
|
||||
|
||||
it('flags manual and auto delivery lines separately', async () => {
|
||||
|
||||
@@ -7,9 +7,6 @@ import type { CookieCart } from '../../storefrontCore/types/cart/CookieCart';
|
||||
import { getQtyByVariantIdFromCart } from '../../../utils/cart/getQtyByVariantIdFromCart';
|
||||
import { DeliveryMode } from '../../product/types/DeliveryMode';
|
||||
import { StorefrontProductsService } from '../../storefrontProduct/services/StorefrontProductsService';
|
||||
import { ExchangeRateService } from '../../exchangeRate/services/ExchangeRateService';
|
||||
import { PaymentMethod } from '../../payment/types/PaymentMethod';
|
||||
import { convertFiatToXmr } from '../../../utils/monero/convertFiatToXmr';
|
||||
import { CookieCartLineDto } from '../dto/CookieCartLineDto';
|
||||
import type { CookieCartExtended } from '../types/CookieCartExtended';
|
||||
import type { CookieCartLineExtended } from '../types/CookieCartLineExtended';
|
||||
@@ -23,7 +20,6 @@ import { StorefrontDiscountService } from './StorefrontDiscountService';
|
||||
export class StorefrontCartService {
|
||||
constructor(
|
||||
private readonly productsService: StorefrontProductsService,
|
||||
private readonly exchangeRateService: ExchangeRateService,
|
||||
private readonly discountService: StorefrontDiscountService
|
||||
) {}
|
||||
|
||||
@@ -67,8 +63,6 @@ export class StorefrontCartService {
|
||||
discounts: [],
|
||||
cartDiscountTotal: 0,
|
||||
cartTotalPrice: 0,
|
||||
cartTotalXmr: null,
|
||||
fiatPerXmr: null,
|
||||
hasManualLines: false,
|
||||
hasAutoLines: false,
|
||||
cartTotalIssueMessage: null,
|
||||
@@ -78,8 +72,6 @@ export class StorefrontCartService {
|
||||
|
||||
const cartSubtotal = sumByKey(cartExtended, 'lineSubtotal');
|
||||
const discountState = await this.discountService.getDiscountStateForCart(discountCodes, cartExtended);
|
||||
const fiatPerXmr = this.exchangeRateService.getLiveFiatPerCrypto(PaymentMethod.Xmr);
|
||||
const cartTotalXmr = fiatPerXmr !== null ? convertFiatToXmr(discountState.cartTotalPrice, fiatPerXmr) : null;
|
||||
const hasManualLines = cartExtended.some(line => line.deliveryMode === DeliveryMode.Manual);
|
||||
const hasAutoLines = cartExtended.some(line => line.deliveryMode === DeliveryMode.Auto);
|
||||
const cartTotalIssueMessage = getZeroCartTotalIssue(discountState.cartTotalPrice, cartExtended.length > 0);
|
||||
@@ -92,8 +84,6 @@ export class StorefrontCartService {
|
||||
cartExtended,
|
||||
cartSubtotal,
|
||||
...discountState,
|
||||
cartTotalXmr,
|
||||
fiatPerXmr,
|
||||
hasManualLines,
|
||||
hasAutoLines,
|
||||
cartTotalIssueMessage,
|
||||
|
||||
@@ -52,13 +52,6 @@
|
||||
{{cartTotalPrice}}
|
||||
{{shopFiatCurrency}}
|
||||
</p>
|
||||
{{#if cartTotalXmr}}
|
||||
<p class='sf-text-muted'>= {{cartTotalXmr}} XMR</p>
|
||||
{{else}}
|
||||
<p class='sf-text-muted'>
|
||||
We couldn't determine the XMR rate right now. Please try again later.
|
||||
</p>
|
||||
{{/if}}
|
||||
|
||||
<form class='sf-form-row' method='post' action='/shop/cart/discount'>
|
||||
<label class='sf-field'>
|
||||
@@ -73,7 +66,6 @@
|
||||
{{/if}}
|
||||
|
||||
<div class='sf-stack sf-mt-4'>
|
||||
{{#if cartTotalXmr}}
|
||||
{{#unless hasIssues}}
|
||||
<form class='sf-form-col' method='post' action='/shop/checkout/pay'>
|
||||
<div>{{{captchaSvg}}}</div>
|
||||
@@ -87,8 +79,8 @@
|
||||
<button type='button' class='sf-btn sf-btn--primary' disabled title='Resolve cart issues before paying'>Pay with XMR</button>
|
||||
{{/unless}}
|
||||
{{else}}
|
||||
<button type='button' class='sf-btn sf-btn--primary' disabled title='XMR rate unavailable'>Pay with XMR</button>
|
||||
{{/if}}
|
||||
<button type='button' class='sf-btn sf-btn--primary' disabled title='Resolve cart issues before paying'>Continue to payment</button>
|
||||
{{/unless}}
|
||||
|
||||
{{> manual-shipping-info}}
|
||||
{{> auto-delivery-info}}
|
||||
|
||||
Reference in New Issue
Block a user