Skip to content
Open
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
19 changes: 12 additions & 7 deletions packages/ui/components/Settings.compactDisplay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const hasDom = typeof document !== 'undefined';
let host: HTMLDivElement | null = null;
let root: Root | null = null;

async function openDisplayTab(isCompactTouchLayout: boolean): Promise<void> {
async function openAppearanceTab(isCompactTouchLayout: boolean): Promise<void> {
host = document.createElement('div');
document.body.appendChild(host);
root = createRoot(host);
Expand All @@ -30,10 +30,15 @@ async function openDisplayTab(isCompactTouchLayout: boolean): Promise<void> {
);
});

const displayTab = Array.from(document.querySelectorAll<HTMLButtonElement>('button'))
const appearanceTab = Array.from(document.querySelectorAll<HTMLButtonElement>('button'))
.find((button) => button.textContent?.trim() === 'Appearance');
if (!appearanceTab) throw new Error('review appearance tab did not render');
await act(async () => appearanceTab.click());

const editorDisplay = Array.from(document.querySelectorAll<HTMLButtonElement>('button'))
.find((button) => button.textContent?.trim() === 'Editor');
if (!displayTab) throw new Error('review display tab did not render');
await act(async () => displayTab.click());
if (!editorDisplay) throw new Error('editor display subsection did not render');
await act(async () => editorDisplay.click());
}

function styleControlButtons(): HTMLButtonElement[] {
Expand All @@ -49,17 +54,17 @@ afterEach(async () => {
if (hasDom) document.body.replaceChildren();
});

describe.if(hasDom)('review Display tab diff style', () => {
describe.if(hasDom)('review Appearance tab diff style', () => {
test('desktop keeps the Split/Unified control', async () => {
await openDisplayTab(false);
await openAppearanceTab(false);

const options = styleControlButtons();
expect(options.map((button) => button.textContent?.trim()).sort()).toEqual(['Split', 'Unified']);
expect(document.body.textContent).not.toContain('unified diffs for the session');
});

test('compact hides the control and explains the session behavior', async () => {
await openDisplayTab(true);
await openAppearanceTab(true);

expect(styleControlButtons()).toHaveLength(0);
expect(document.body.textContent).toContain('unified diffs for the session');
Expand Down
Loading