Skip to content

Commit a66fd8a

Browse files
committed
test(app-shell): the page header tile pin reaches the Setup posture through its route
Claude-Session: https://claude.ai/code/session_01L6bhgWCsFBKwcq7ocDfUhR Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2d61149 commit a66fd8a

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

‎ui/packages/app-shell/src/layout/__tests__/PageHeader.iconTile-35985.test.tsx‎

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,38 @@ import { describe, it, expect } from 'vitest';
1515
import { render, screen } from '@testing-library/react';
1616
import '@testing-library/jest-dom';
1717
import * as React from 'react';
18+
import { MemoryRouter, Routes, Route } from 'react-router-dom';
1819
import { ObjectIconTile } from '@object-ui/components';
1920
import { 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

2330
describe('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

Comments
 (0)