Files
landing-app/landing/src/app/core/taskstream.spec.ts
pigui 63d4410296 Show proposals and votes from TaskStream on a project's page
The most voted bug reports and ideas, the link to send one while the
board takes them, and how many want each epic on the roadmap. The mock
API serves a showcase for the catalogue so every section can be seen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 20:21:40 +02:00

61 lines
1.8 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from 'vitest';
import { boardLink, fetchShowcase, hasContent } from './taskstream';
const showcase = {
project: { id: 'p', key: 'WEB', name: 'Web', description: null },
activeSprint: null,
roadmap: [],
releases: [],
goodFirst: [
{ key: 'WEB-9', title: 'Typo', type: 'TASK', path: '/p/WEB/issues/WEB-9' },
],
};
describe('TaskStream showcase', () => {
afterEach(() => vi.unstubAllGlobals());
it('reads a showcase, and goes without it when TaskStream fails', async () => {
vi.stubGlobal(
'fetch',
vi.fn(async () => new Response(JSON.stringify(showcase))),
);
expect(await fetchShowcase('https://api.ts/showcase')).toEqual(showcase);
vi.stubGlobal(
'fetch',
vi.fn(async () => new Response('nope', { status: 404 })),
);
expect(await fetchShowcase('https://api.ts/showcase')).toBeNull();
vi.stubGlobal(
'fetch',
vi.fn(async () => {
throw new Error('down');
}),
);
expect(await fetchShowcase('https://api.ts/showcase')).toBeNull();
});
it('builds links into the board and knows an empty one', () => {
expect(
boardLink('https://taskstream.pireon.dev/', '/p/WEB/issues/WEB-9'),
).toBe('https://taskstream.pireon.dev/p/WEB/issues/WEB-9');
expect(hasContent(showcase)).toBe(true);
expect(hasContent({ ...showcase, goodFirst: [] })).toBe(false);
});
it('counts a board that takes proposals as something to show', () => {
const empty = { ...showcase, goodFirst: [] };
expect(
hasContent({
...empty,
proposals: { open: true, path: '/p/WEB/proponer', top: [] },
}),
).toBe(true);
expect(
hasContent({ ...empty, proposals: { open: false, path: null, top: [] } }),
).toBe(false);
});
});