open-design/apps/web/tests/components/WorkingDirPill.test.tsx
Eli-tangerine ce95266586
Some checks failed
visual-baseline / Capture visual baselines (push) Waiting to run
ci / Detect CI change scopes (push) Successful in 1s
nix-check / build (push) Failing after 3s
ci / Preflight (push) Failing after 2s
ci / Core package tests (push) Failing after 1s
ci / Tools workspace tests (push) Failing after 1s
ci / Daemon workspace tests (1/2) (push) Failing after 1s
ci / Daemon workspace tests (2/2) (push) Failing after 1s
ci / Web workspace tests (push) Failing after 1s
ci / E2E vitest (push) Failing after 1s
ci / Playwright critical (starters) (push) Failing after 1s
ci / Playwright critical (core) (push) Failing after 1s
ci / Build workspaces (push) Failing after 1s
ci / App workspace tests (push) Failing after 0s
ci / Validate workspace (push) Failing after 0s
ci / Runtime trace (push) Has been skipped
[codex] Polish home composer working-directory controls (#2468)
* Polish design system home flows

* Polish home prompt presets

* Polish home working directory controls

* test: align home hero chrome smoke

* fix: stabilize home composer ci checks

---------

Co-authored-by: qiongyu1999 <2694684348@qq.com>
2026-05-21 00:22:46 +08:00

63 lines
1.8 KiB
TypeScript

// @vitest-environment jsdom
import { installMockOpenDesignHost } from '@open-design/host/testing';
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { WorkingDirPill } from '../../src/components/WorkingDirPill';
let restoreHost: (() => void) | null = null;
afterEach(() => {
cleanup();
restoreHost?.();
restoreHost = null;
vi.restoreAllMocks();
});
describe('WorkingDirPill', () => {
it('shows a visible fallback instead of silently doing nothing in web builds', async () => {
render(
<WorkingDirPill
projectId="project-1"
resolvedDir="/Users/example/open-design/project-1"
/>,
);
fireEvent.click(screen.getByTestId('working-dir-pill-trigger'));
fireEvent.click(screen.getByRole('menuitem', { name: 'Show in file manager' }));
expect(
await screen.findByText('Open this project in the desktop app to show the folder.'),
).toBeTruthy();
expect(screen.getByTestId('working-dir-pill-menu')).toBeTruthy();
});
it('opens the project directory through the desktop host bridge', async () => {
const openPath = vi.fn(async () => ({ ok: true as const }));
restoreHost = installMockOpenDesignHost({
host: {
shell: {
openPath,
},
},
});
render(
<WorkingDirPill
projectId="project-1"
resolvedDir="/Users/example/open-design/project-1"
/>,
);
fireEvent.click(screen.getByTestId('working-dir-pill-trigger'));
fireEvent.click(screen.getByRole('menuitem', { name: 'Show in file manager' }));
await waitFor(() => {
expect(openPath).toHaveBeenCalledWith('project-1');
});
await waitFor(() => {
expect(screen.queryByTestId('working-dir-pill-menu')).toBeNull();
});
});
});