mirror of
https://github.com/nexu-io/open-design.git
synced 2026-05-31 19:04:39 +07:00
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
* 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>
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { cleanup, render, screen, waitFor } from '@testing-library/react';
|
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
|
|
import { RecentProjectsStrip } from '../../src/components/RecentProjectsStrip';
|
|
import type { Project } from '../../src/types';
|
|
|
|
vi.mock('../../src/providers/registry', () => ({
|
|
fetchProjectFiles: vi.fn(async (projectId: string) => {
|
|
if (projectId === 'project-ds') {
|
|
return [{ name: 'logo.svg', path: 'assets/logo.svg', kind: 'image', mtime: 3 }];
|
|
}
|
|
if (projectId === 'project-html') {
|
|
return [{ name: 'index.html', kind: 'html', mtime: 2 }];
|
|
}
|
|
return [];
|
|
}),
|
|
projectFileUrl: (projectId: string, fileName: string) =>
|
|
`/api/projects/${projectId}/files/${fileName}`,
|
|
}));
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
});
|
|
|
|
function project(overrides: Partial<Project>): Project {
|
|
return {
|
|
id: 'project-1',
|
|
name: 'Project',
|
|
skillId: null,
|
|
designSystemId: null,
|
|
createdAt: 1,
|
|
updatedAt: 2,
|
|
status: { value: 'not_started' },
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
describe('RecentProjectsStrip', () => {
|
|
it('matches project cards with previews and design-system tags', async () => {
|
|
const { container } = render(
|
|
<RecentProjectsStrip
|
|
projects={[
|
|
project({
|
|
id: 'project-ds',
|
|
name: 'Acme Design System',
|
|
updatedAt: 4,
|
|
metadata: {
|
|
kind: 'other',
|
|
importedFrom: 'design-system',
|
|
},
|
|
}),
|
|
project({
|
|
id: 'project-html',
|
|
name: 'Web Prototype',
|
|
updatedAt: 3,
|
|
}),
|
|
]}
|
|
onOpen={() => {}}
|
|
onViewAll={() => {}}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.getByText('Design System')).toBeTruthy();
|
|
expect(screen.getAllByText('Prototype').length).toBeGreaterThan(0);
|
|
const designSystemCard = container.querySelector('.recent-projects__card.is-design-system-project');
|
|
expect(designSystemCard).toBeTruthy();
|
|
expect(designSystemCard?.querySelectorAll('.design-card-tag')).toHaveLength(1);
|
|
|
|
await waitFor(() => {
|
|
expect(designSystemCard?.querySelector('.recent-projects__card-thumb-logo img')).toBeTruthy();
|
|
expect(container.querySelector('.recent-projects__card-thumb-html iframe')).toBeTruthy();
|
|
});
|
|
});
|
|
});
|