@@ -15,21 +15,38 @@ import { describe, it, expect } from 'vitest';
1515import { render , screen } from '@testing-library/react' ;
1616import '@testing-library/jest-dom' ;
1717import * as React from 'react' ;
18+ import { MemoryRouter , Routes , Route } from 'react-router-dom' ;
1819import { ObjectIconTile } from '@object-ui/components' ;
1920import { PageHeader } from '../PageHeader' ;
2021
21- const postures = [ undefined , 'list' , 'setup' ] as const ;
22+ // The row and list postures come from the `posture` prop; Setup's is read off
23+ // the route (`/apps/setup/...`), so that case mounts the header under it.
24+ const postures = [
25+ { reached : 'row' , posture : undefined , app : 'crm' } ,
26+ { reached : 'list' , posture : 'list' , app : 'crm' } ,
27+ { reached : 'setup' , posture : undefined , app : 'setup' } ,
28+ ] as const ;
2229
2330describe ( 'PageHeader draws an object tile as given (objectstack#35985)' , ( ) => {
24- it . each ( postures ) ( 'posture %s: the tile sits directly in the title row, and `icon` is not drawn' , ( posture ) => {
25- render (
26- < PageHeader
27- title = "Accounts"
28- posture = { posture }
29- icon = { < svg data-testid = "line-icon" /> }
30- iconTile = { < ObjectIconTile icon = "building" color = "orange" /> }
31- /> ,
31+ it . each ( postures ) ( 'posture $reached: the tile sits directly in the title row, and `icon` is not drawn' , ( { reached, posture, app } ) => {
32+ const { container } = render (
33+ < MemoryRouter initialEntries = { [ `/apps/${ app } /x` ] } >
34+ < Routes >
35+ < Route
36+ path = "/apps/:appName/*"
37+ element = {
38+ < PageHeader
39+ title = "Accounts"
40+ posture = { posture }
41+ icon = { < svg data-testid = "line-icon" /> }
42+ iconTile = { < ObjectIconTile icon = "building" color = "orange" /> }
43+ />
44+ }
45+ />
46+ </ Routes >
47+ </ MemoryRouter > ,
3248 ) ;
49+ expect ( container . querySelector ( '[data-posture]' ) ) . toHaveAttribute ( 'data-posture' , reached ) ;
3350 const tile = document . querySelector ( '[data-object-icon-tile]' ) as HTMLElement ;
3451 expect ( tile ) . toHaveAttribute ( 'data-object-icon-tile' , 'orange' ) ;
3552 expect ( screen . queryByTestId ( 'line-icon' ) ) . toBeNull ( ) ;
0 commit comments