@@ -239,6 +239,122 @@ describe('Handles order with missing or partial data gracefully', () => {
239239 } )
240240} )
241241
242+ // Helper to setup order details page with mock order data
243+ const setupOrderDetailsPage = ( mockOrder ) => {
244+ global . server . use (
245+ rest . get ( '*/orders/:orderNo' , ( req , res , ctx ) => {
246+ return res ( ctx . delay ( 0 ) , ctx . json ( mockOrder ) )
247+ } )
248+ )
249+ window . history . pushState (
250+ { } ,
251+ 'Order Details' ,
252+ createPathWithDefaults ( `/account/orders/${ mockOrder . orderNo } ` )
253+ )
254+ renderWithProviders ( < MockedComponent history = { history } /> , {
255+ wrapperProps : { siteAlias : 'uk' , appConfig : mockConfig . app }
256+ } )
257+ }
258+
259+ describe ( 'Order with ECOM status (non-OMS)' , ( ) => {
260+ beforeEach ( async ( ) => {
261+ const ecomOrder = {
262+ ...mockOrderHistory . data [ 0 ] ,
263+ status : 'new'
264+ }
265+ setupOrderDetailsPage ( ecomOrder )
266+ } )
267+
268+ test ( 'should display ECOM status when present' , async ( ) => {
269+ const statusBadge = await screen . findByText ( 'new' )
270+ expect ( statusBadge ) . toBeInTheDocument ( )
271+ } )
272+ } )
273+
274+ describe ( 'Order with OMS data' , ( ) => {
275+ beforeEach ( async ( ) => {
276+ const omsOrder = {
277+ ...mockOrderHistory . data [ 0 ] ,
278+ status : undefined ,
279+ omsData : { status : 'SHIPPED' }
280+ }
281+ setupOrderDetailsPage ( omsOrder )
282+ } )
283+
284+ test ( 'should display OMS status when ECOM status is not present' , async ( ) => {
285+ const statusBadge = await screen . findByText ( 'SHIPPED' )
286+ expect ( statusBadge ) . toBeInTheDocument ( )
287+ } )
288+ } )
289+
290+ describe ( 'Order without payment data' , ( ) => {
291+ beforeEach ( async ( ) => {
292+ const orderWithoutPayment = {
293+ ...mockOrderHistory . data [ 0 ] ,
294+ paymentInstruments : [ ]
295+ }
296+ setupOrderDetailsPage ( orderWithoutPayment )
297+ } )
298+
299+ test ( 'should render order details page' , async ( ) => {
300+ expect ( await screen . findByTestId ( 'account-order-details-page' ) ) . toBeInTheDocument ( )
301+ } )
302+
303+ test ( 'should not display payment method section' , async ( ) => {
304+ await screen . findByTestId ( 'account-order-details-page' )
305+ expect ( screen . queryByText ( / p a y m e n t m e t h o d / i) ) . not . toBeInTheDocument ( )
306+ } )
307+ } )
308+
309+ describe ( 'Order with firstName and lastName for shipping address' , ( ) => {
310+ beforeEach ( async ( ) => {
311+ const orderWithNames = {
312+ ...mockOrderHistory . data [ 0 ] ,
313+ shipments : [
314+ {
315+ ...mockOrderHistory . data [ 0 ] . shipments [ 0 ] ,
316+ shippingAddress : {
317+ ...mockOrderHistory . data [ 0 ] . shipments [ 0 ] . shippingAddress ,
318+ firstName : 'Jane' ,
319+ lastName : 'Doe' ,
320+ fullName : 'Should Not Display'
321+ }
322+ }
323+ ]
324+ }
325+ setupOrderDetailsPage ( orderWithNames )
326+ } )
327+
328+ test ( 'should display firstName + lastName when both present' , async ( ) => {
329+ expect ( await screen . findByText ( / J a n e D o e / i) ) . toBeInTheDocument ( )
330+ expect ( screen . queryByText ( / S h o u l d N o t D i s p l a y / i) ) . not . toBeInTheDocument ( )
331+ } )
332+ } )
333+
334+ describe ( 'Order with fullName fallback for shipping address' , ( ) => {
335+ beforeEach ( async ( ) => {
336+ const orderWithFullName = {
337+ ...mockOrderHistory . data [ 0 ] ,
338+ shipments : [
339+ {
340+ ...mockOrderHistory . data [ 0 ] . shipments [ 0 ] ,
341+ shippingAddress : {
342+ ...mockOrderHistory . data [ 0 ] . shipments [ 0 ] . shippingAddress ,
343+ firstName : undefined ,
344+ lastName : undefined ,
345+ fullName : 'John Smith'
346+ }
347+ }
348+ ]
349+ }
350+ setupOrderDetailsPage ( orderWithFullName )
351+ } )
352+
353+ test ( 'should display fullName when firstName and lastName are not present' , async ( ) => {
354+ expect ( await screen . findByText ( / J o h n S m i t h / i) ) . toBeInTheDocument ( )
355+ } )
356+ } )
357+
242358describe ( 'Order with multiple shipments (pickup and delivery)' , ( ) => {
243359 let orderNo
244360
0 commit comments