Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e55ad46
feat(zipcode): soft-refresh storefront after session writes
hiagolcm May 27, 2026
effdf24
test(zipcode): assert targeted query-allowlist soft refresh
hiagolcm Jun 8, 2026
0682c61
feat(zipcode): targeted query-allowlist soft refresh
hiagolcm Jun 8, 2026
96a5c3e
docs(changelog): describe targeted query-allowlist soft refresh
hiagolcm Jun 8, 2026
625de8c
test(zipcode): assert fulfillment state update + modal close on soft …
hiagolcm Jun 8, 2026
8203ac7
feat(zipcode): sync fulfillment state and close modal on soft refresh
hiagolcm Jun 8, 2026
a02252b
test(zipcode): single loading cycle + full pagination reset on soft r…
hiagolcm Jun 10, 2026
a9a3a27
feat(zipcode): single loading cycle + first-page reset on soft refresh
hiagolcm Jun 10, 2026
7e8046c
test(zipcode): reload to page 1 on a deep-page soft refresh
hiagolcm Jun 10, 2026
85def45
feat(zipcode): reload on deep page so load-more resets to page 2
hiagolcm Jun 10, 2026
8be9df4
test(zipcode): assert session-write rollback restores state and relea…
hiagolcm Jun 11, 2026
dd20008
feat(zipcode): roll back optimistic state when session write fails
hiagolcm Jun 11, 2026
43f33bd
docs(changelog): collapse soft-refresh changes into a single entry
hiagolcm Jun 24, 2026
dc1636b
test(zipcode): harden soft-refresh reload-fallback tests against CI m…
hiagolcm Jun 24, 2026
304c159
fix(zipcode): call window.location.reload() in soft-refresh fallback
hiagolcm Jun 24, 2026
b2fe76e
test: drive Apollo client mock through a useApolloClient spy
hiagolcm Jun 24, 2026
dc36d60
fix tests
hiagolcm Jun 25, 2026
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Replace the full-page reload after zipcode / pickup / shipping-method session writes with a targeted soft refresh that refetches only the segment-dependent storefront queries (resetting search pagination to the first page through render-runtime), updates the fulfillment selection optimistically with rollback on a failed session write, closes the shipping-method modal, and falls back to `location.reload()` when Apollo is unavailable.

## [1.1.4] - 2026-06-11

### Deprecated
Expand Down
18 changes: 18 additions & 0 deletions react/ShippingMethodSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ function ShippingMethodSelector({
submitErrorMessage,
areThereUnavailableCartItems,
shippingMethodModalRequestId,
fulfillmentSelectionAppliedId,
} = useDeliveryPromiseState()

const dispatch = useDeliveryPromiseDispatch()
const lastHandledShippingMethodModalRequestId = useRef(0)
const lastHandledFulfillmentSelectionAppliedId = useRef(0)

useEffect(() => {
dispatch({
Expand Down Expand Up @@ -71,6 +73,22 @@ function ShippingMethodSelector({
shippingMethodModalRequestId,
])

// Close the modal once a fulfillment selection is applied. The old reload
// tore the modal down for free; with the soft refresh the tree stays alive.
useEffect(() => {
if (
fulfillmentSelectionAppliedId <=
lastHandledFulfillmentSelectionAppliedId.current
) {
return
}

lastHandledFulfillmentSelectionAppliedId.current =
fulfillmentSelectionAppliedId

setIsShippingMethodModalOpen(false)
}, [fulfillmentSelectionAppliedId])

const onSubmit = (zipcode: string, reload?: boolean) => {
dispatch({
type: 'UPDATE_ZIPCODE',
Expand Down
32 changes: 30 additions & 2 deletions react/__tests__/ShippingMethodSelector.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ jest.mock('../components/ShippingMethodModal/ShippingMethodSelector', () => ({
default: () => <div data-testid="shipping-method-control" />,
}))

let lastShippingMethodModalProps: { nonDismissibleModal?: boolean } = {}
let lastShippingMethodModalProps: {
nonDismissibleModal?: boolean
isOpen?: boolean
} = {}

jest.mock('../components/ShippingMethodModal', () => ({
__esModule: true,
default: (props: { nonDismissibleModal?: boolean }) => {
default: (props: { nonDismissibleModal?: boolean; isOpen?: boolean }) => {
lastShippingMethodModalProps = props

return <div data-testid="shipping-method-modal" />
Expand All @@ -39,6 +42,7 @@ const baseState = {
submitErrorMessage: undefined,
areThereUnavailableCartItems: false,
shippingMethodModalRequestId: 0,
fulfillmentSelectionAppliedId: 0,
}

describe('ShippingMethodSelector', () => {
Expand Down Expand Up @@ -91,4 +95,28 @@ describe('ShippingMethodSelector', () => {

expect(container.firstChild).toBeNull()
})

it('closes the shipping-method modal when a fulfillment selection is applied', () => {
// A modal-open request opens the modal (mirrors a sibling block / click).
mockUseDeliveryPromiseState.mockReturnValue({
...baseState,
shippingMethodModalRequestId: 1,
})

const { rerender } = render(<ShippingMethodSelector />)

expect(lastShippingMethodModalProps.isOpen).toBe(true)

// A selection is applied (delivery/pickup) → the modal must close even
// though there is no page reload to tear it down.
mockUseDeliveryPromiseState.mockReturnValue({
...baseState,
shippingMethodModalRequestId: 1,
fulfillmentSelectionAppliedId: 1,
})

rerender(<ShippingMethodSelector />)

expect(lastShippingMethodModalProps.isOpen).toBe(false)
})
})
Loading
Loading