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
5 changes: 5 additions & 0 deletions .changeset/revert-pickup-customer-names.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@godaddy/react': patch
---

Restore pickup customer name collection to the existing billing fields and remove unsupported pickup handling from Stripe and GoDaddy express checkout.
Original file line number Diff line number Diff line change
Expand Up @@ -263,30 +263,28 @@ describe('Checkout address behavior', () => {
});
});

it('syncs only billing names in onlyNames mode without clearing billing address', async () => {
it('syncs only billing names in onlyNames mode without stale address fields', async () => {
const draftOrder = buildDraftOrder({
totals: {
subTotal: { value: 2500, currencyCode: 'USD' },
subTotal: { value: 0, currencyCode: 'USD' },
discountTotal: { value: 0, currencyCode: 'USD' },
shippingTotal: { value: 0, currencyCode: 'USD' },
taxTotal: { value: 0, currencyCode: 'USD' },
feeTotal: { value: 0, currencyCode: 'USD' },
total: { value: 2500, currencyCode: 'USD' },
total: { value: 0, currencyCode: 'USD' },
},
lineItems: [
{
fulfillmentMode: 'PICKUP',
unitAmount: { value: 2500, currencyCode: 'USD' },
unitAmount: { value: 0, currencyCode: 'USD' },
},
],
billing: {
firstName: '',
lastName: '',
phone: '',
email: 'jane@example.com',
address: buildBillingAddress({
addressLine1: 'Paid Pickup Billing St',
}),
address: buildBillingAddress({ addressLine1: 'Stale Billing St' }),
},
});
const { user } = renderCheckout({
Expand All @@ -312,7 +310,9 @@ describe('Checkout address behavior', () => {
lastName: 'Buyer',
},
});
expect(getLastUpdateInput()?.billing).not.toHaveProperty('address');
expect(getLastUpdateInput()?.billing ?? {}).not.toMatchObject({
address: expect.objectContaining({ addressLine1: 'Stale Billing St' }),
});
});

it('does not sync the address until country, state, city, and postal-code are valid', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,8 @@ describe('Checkout draft-order field sync', () => {
await waitForOperation('UpdateCheckoutSessionDraftOrder');

expect(getLastUpdateInput()).toMatchObject({
billing: { firstName: 'Only', lastName: 'Names' },
billing: { firstName: 'Only', lastName: 'Names', address: null },
});
expect(getLastUpdateInput()?.billing).not.toHaveProperty('address');
expect(getLastUpdateInput()?.billing).not.toMatchObject({
addressLine1: expect.anything(),
postalCode: expect.anything(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { enUs } from '@godaddy/localizations';
import { screen, waitFor } from '@testing-library/react';
import { useFormContext } from 'react-hook-form';
import { describe, expect, it, vi } from 'vitest';
import { PaymentProvider } from '@/types';
import { PaymentMethodType, PaymentProvider } from '@/types';
import {
buildDraftOrder,
buildLineItem,
Expand Down Expand Up @@ -42,6 +42,7 @@ function _offlinePaymentMethods() {
mercadopago: null,
ccavenue: null,
offline: {
type: PaymentMethodType.OFFLINE,
processor: PaymentProvider.OFFLINE,
checkoutTypes: ['standard'],
},
Expand All @@ -51,6 +52,7 @@ function _offlinePaymentMethods() {
function stripeOnlyPaymentMethods() {
return {
card: {
type: PaymentMethodType.CREDIT_CARD,
processor: PaymentProvider.STRIPE,
checkoutTypes: ['standard'],
},
Expand Down Expand Up @@ -161,42 +163,6 @@ describe('Checkout form validation', () => {
expect(getOperations('ConfirmCheckoutSession')).toHaveLength(0);
});

it('requires pickup customer names for paid pickup with offline payment', async () => {
const draftOrder = makePaidPickupOrder({
billing: {
firstName: '',
lastName: '',
address: buildShippingAddress({ addressLine1: '' }),
},
});
const { user } = renderCheckout({
draftOrder,
sessionOverrides: {
draftOrder,
paymentMethods: {
...stripeOnlyPaymentMethods(),
card: null as never,
offline: {
processor: PaymentProvider.OFFLINE,
checkoutTypes: ['standard'],
},
},
enableShipping: false,
enableLocalPickup: true,
enableTaxCollection: false,
},
});
await waitForCheckoutReady();
clearOperations();

await user.click(await clickSubmitButton(/complete your order/i));

await waitFor(() => {
expect(document.body).toHaveTextContent(enUs.validation.enterFirstName);
});
expect(getOperations('ConfirmCheckoutSession')).toHaveLength(0);
});

it('pins current paid pickup card behavior when the billing address line is empty', async () => {
const draftOrder = makePaidPickupOrder();
const { user } = renderCheckout({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import { screen } from '@testing-library/react';
import { screen, waitFor } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import {
advanceCheckoutDebounce,
buildCheckoutSession,
buildDraftOrder,
buildShippingRates,
clearOperations,
getOperationOrder,
getOperations,
renderCheckout,
typeIntoNamedField,
waitForCheckoutReady,
waitForOperation,
} from './checkout-test-env';
import {
getLastConfirmInput,
getLastUpdateInput,
} from './checkout-test-fixtures';
import { getLastConfirmInput } from './checkout-test-fixtures';

function buildFreeDraftOrder(
overrides: Parameters<typeof buildDraftOrder>[0] = {}
Expand Down Expand Up @@ -58,7 +53,7 @@ async function submitFreeOrder(
}

describe('Checkout FreePaymentForm integration', () => {
it('renders pickup customer names in the pickup section for a free pickup order', async () => {
it('renders names-only billing for a free pickup order without a billing address', async () => {
const draftOrder = buildFreeDraftOrder({
lineItems: [{ fulfillmentMode: 'PICKUP' }],
billing: {
Expand Down Expand Up @@ -88,9 +83,6 @@ describe('Checkout FreePaymentForm integration', () => {
expect(document.querySelector('input[name="billingLastName"]')).toHaveValue(
'Pickup'
);
expect(
document.querySelectorAll('input[name="billingFirstName"]')
).toHaveLength(1);
expect(
document.querySelector('input[name="billingAddressLine1"]')
).not.toBeInTheDocument();
Expand Down Expand Up @@ -187,49 +179,4 @@ describe('Checkout FreePaymentForm integration', () => {
document.querySelector('input[name="shippingAddressLine1"]')
).not.toBeInTheDocument();
});

it('persists pickup billing names before free-order confirmation without waiting for debounce', async () => {
const draftOrder = buildFreeDraftOrder({
lineItems: [{ fulfillmentMode: 'PICKUP' }],
billing: {
firstName: '',
lastName: '',
phone: '',
email: 'jane@example.com',
address: null,
},
});
const session = buildCheckoutSession({
draftOrder,
enableShipping: false,
enableLocalPickup: true,
enableTaxCollection: false,
});

const { user } = renderCheckout({ session, draftOrder });
await waitForCheckoutReady();

await typeIntoNamedField(user, 'billingFirstName', 'Immediate');
await typeIntoNamedField(user, 'billingLastName', 'Pickup');

clearOperations();
await user.click(
await screen.findByRole('button', { name: /complete your free order/i })
);
await waitForOperation('ConfirmCheckoutSession');

const [updateIdx, confirmIdx] = getOperationOrder([
'UpdateCheckoutSessionDraftOrder',
'ConfirmCheckoutSession',
]);
expect(updateIdx).toBeGreaterThanOrEqual(0);
expect(confirmIdx).toBeGreaterThan(updateIdx);
expect(getLastUpdateInput()).toMatchObject({
billing: {
firstName: 'Immediate',
lastName: 'Pickup',
},
});
expect(getLastUpdateInput()?.billing).not.toHaveProperty('address');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,69 +10,6 @@ import {
} from './checkout-test-env';

describe('Checkout pickup behavior', () => {
it('shows customer name fields in the pickup section', async () => {
const { user } = renderCheckout();
await waitForCheckoutReady();

await user.click(screen.getByRole('radio', { name: /local pickup/i }));
await waitForOperation('ApplyCheckoutSessionFulfillmentLocation');

expect(
document.querySelector('input[name="billingFirstName"]')
).toBeInTheDocument();
expect(
document.querySelector('input[name="billingLastName"]')
).toBeInTheDocument();
});

it('keeps a single set of name fields for paid pickup with credit-card billing', async () => {
renderCheckout({
draftOrderOverrides: {
lineItems: [{ fulfillmentMode: 'PICKUP' }],
},
sessionOverrides: {
enableShipping: false,
enableLocalPickup: true,
enableBillingAddressCollection: true,
},
});
await waitForCheckoutReady();

expect(
document.querySelectorAll('input[name="billingFirstName"]')
).toHaveLength(1);
expect(
document.querySelectorAll('input[name="billingLastName"]')
).toHaveLength(1);
expect(
document.querySelector('input[name="billingAddressLine1"]')
).toBeInTheDocument();
});

it('keeps a single set of name fields for paid pickup when billing address collection is disabled', async () => {
renderCheckout({
draftOrderOverrides: {
lineItems: [{ fulfillmentMode: 'PICKUP' }],
},
sessionOverrides: {
enableShipping: false,
enableLocalPickup: true,
enableBillingAddressCollection: false,
},
});
await waitForCheckoutReady();

expect(
document.querySelectorAll('input[name="billingFirstName"]')
).toHaveLength(1);
expect(
document.querySelectorAll('input[name="billingLastName"]')
).toHaveLength(1);
expect(
document.querySelector('input[name="billingAddressLine1"]')
).not.toBeInTheDocument();
});

it('switches from shipping to pickup and calculates taxes with pickup location', async () => {
const { user } = renderCheckout();
await waitForCheckoutReady();
Expand Down
Loading