open-design/apps/web/tests/components/design-system-project.test.ts
Chris Seifert 085963a1e2
fix(web): show published design systems as "Published" on project cards (#2849)
A published design-system project still showed its last generation run status on its card. When that run had failed, the published system read as "Failed" on the home Recent projects strip and in the Projects grid. The system is published and live, so showing a stale run failure there is wrong.

Cards now read "Published" when the backing design system's status is published, keyed off the design system summary instead of the project run status. Every other project keeps its run status.

A shared isPublishedDesignSystemProject helper lets the home strip and the Designs grid apply one rule. The label uses a new designs.status.published key in the locale files, with a green style that matches the existing succeeded color.
2026-05-25 03:14:26 +00:00

64 lines
2 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import type { DesignSystemSummary, Project } from '../../src/types';
import {
isDesignSystemProject,
isPublishedDesignSystemProject,
} from '../../src/components/design-system-project';
function project(overrides: Partial<Project> = {}): Project {
return {
id: 'p1',
name: 'StackMe',
updatedAt: 1,
designSystemId: null,
...overrides,
} as Project;
}
function system(overrides: Partial<DesignSystemSummary> = {}): DesignSystemSummary {
return {
id: 'user:stackme',
title: 'StackMe',
category: 'Custom',
summary: '',
swatches: [],
surface: 'web',
source: 'user',
status: 'draft',
isEditable: true,
...overrides,
};
}
describe('isDesignSystemProject', () => {
it('matches projects imported from a design system', () => {
expect(isDesignSystemProject(project({ metadata: { kind: 'other', importedFrom: 'design-system' } }))).toBe(true);
expect(isDesignSystemProject(project({ metadata: { kind: 'prototype' } }))).toBe(false);
expect(isDesignSystemProject(project())).toBe(false);
});
});
describe('isPublishedDesignSystemProject', () => {
const dsProject = project({
metadata: { kind: 'other', importedFrom: 'design-system' },
designSystemId: 'user:stackme',
});
it('is true when the backing design system is published, even if the run failed', () => {
expect(isPublishedDesignSystemProject(dsProject, [system({ status: 'published' })])).toBe(true);
});
it('is false while the design system is still a draft', () => {
expect(isPublishedDesignSystemProject(dsProject, [system({ status: 'draft' })])).toBe(false);
});
it('is false for non-design-system projects and when the system is missing', () => {
expect(
isPublishedDesignSystemProject(project({ metadata: { kind: 'prototype' } }), [
system({ status: 'published' }),
]),
).toBe(false);
expect(isPublishedDesignSystemProject(dsProject, [])).toBe(false);
});
});