feat(viewer): bundle md + slug + conditional owner pill [v0.2.0]
Closes 3 of 6 UX-round1 fixes in one TDD cycle (49→56 tests). drawer-bundle-md: TaskRecord.md_content fetched in build-time; drawer reads recordsBySlug instead of fetch — 0 runtime hits to git.kzntsv.site/raw (private repos 401'd browser fetches without token). Fallback dl-block when md=null. ux-show-slug: <code class="card-slug"> rendered under card-title in both render.ts and board.js renderCard (re-render path). ux-owner-conditional: distinctOwner(records) pre-scan. Single owner → pill omitted on cards, header gets <span class="owner-summary"> Owner: X</span>. Multi-owner → pill restored, no header summary. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ function rec(overrides: Partial<TaskRecord>): TaskRecord {
|
||||
branch: 'master',
|
||||
last_commit_iso: null,
|
||||
raw_url: 'https://example/raw',
|
||||
md_content: null,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -154,22 +155,83 @@ describe('renderBoard', () => {
|
||||
expect(html).toContain('"embed-test"');
|
||||
});
|
||||
|
||||
test('renders owner as a pill when project_owner is non-empty', () => {
|
||||
test('bundles per-task md_content inside records JSON (drawer reads it without fetch)', () => {
|
||||
const records = [rec({ slug: 'with-md', md_content: '# heading\n\nbody text' })];
|
||||
|
||||
const html = renderBoard(records, { generatedAt: now });
|
||||
|
||||
// md is inside the records script tag, JSON-escaped (newlines as \n)
|
||||
expect(html).toContain('"md_content":"# heading\\n\\nbody text"');
|
||||
});
|
||||
|
||||
test('renders owner as a pill when records span 2+ distinct owners', () => {
|
||||
const html = renderBoard(
|
||||
[rec({ slug: 'x', project_owner: 'OpeItcLoc03' })],
|
||||
[
|
||||
rec({ slug: 'x', project_owner: 'alice', project: 'a' }),
|
||||
rec({ slug: 'y', project_owner: 'bob', project: 'b' }),
|
||||
],
|
||||
{ generatedAt: now },
|
||||
);
|
||||
|
||||
expect(html).toMatch(/<span class="badge owner">OpeItcLoc03<\/span>/);
|
||||
expect(html).toMatch(/<span class="badge owner">alice<\/span>/);
|
||||
expect(html).toMatch(/<span class="badge owner">bob<\/span>/);
|
||||
});
|
||||
|
||||
test('omits owner pill on every card when all records share a single owner', () => {
|
||||
const html = renderBoard(
|
||||
[
|
||||
rec({ slug: 'x', project_owner: 'alice', project: 'a' }),
|
||||
rec({ slug: 'y', project_owner: 'alice', project: 'b' }),
|
||||
],
|
||||
{ generatedAt: now },
|
||||
);
|
||||
|
||||
expect(html).not.toMatch(/<span class="badge owner">/);
|
||||
});
|
||||
|
||||
test('emits a single-owner header summary when whitelist is mono-owner', () => {
|
||||
const html = renderBoard(
|
||||
[
|
||||
rec({ slug: 'x', project_owner: 'alice', project: 'a' }),
|
||||
rec({ slug: 'y', project_owner: 'alice', project: 'b' }),
|
||||
],
|
||||
{ generatedAt: now },
|
||||
);
|
||||
|
||||
expect(html).toMatch(/<span class="owner-summary"[^>]*>Owner: alice<\/span>/);
|
||||
});
|
||||
|
||||
test('omits the owner-summary header when whitelist is multi-owner', () => {
|
||||
const html = renderBoard(
|
||||
[
|
||||
rec({ slug: 'x', project_owner: 'alice', project: 'a' }),
|
||||
rec({ slug: 'y', project_owner: 'bob', project: 'b' }),
|
||||
],
|
||||
{ generatedAt: now },
|
||||
);
|
||||
|
||||
expect(html).not.toContain('owner-summary');
|
||||
});
|
||||
|
||||
test('omits owner pill when project_owner is empty string', () => {
|
||||
const html = renderBoard(
|
||||
[rec({ slug: 'x', project_owner: '' })],
|
||||
[
|
||||
rec({ slug: 'x', project_owner: '' }),
|
||||
rec({ slug: 'y', project_owner: 'bob' }),
|
||||
],
|
||||
{ generatedAt: now },
|
||||
);
|
||||
|
||||
expect(html).not.toContain('badge owner');
|
||||
expect(html).not.toMatch(/<span class="badge owner"><\/span>/);
|
||||
});
|
||||
|
||||
test('renders slug as a visible <code class="card-slug"> on every card', () => {
|
||||
const html = renderBoard(
|
||||
[rec({ slug: 'board-viewer-pointers', title: 'pointers' })],
|
||||
{ generatedAt: now },
|
||||
);
|
||||
|
||||
expect(html).toMatch(/<code class="card-slug">board-viewer-pointers<\/code>/);
|
||||
});
|
||||
|
||||
test('renders last_commit_iso as a short YYYY-MM-DD date span', () => {
|
||||
|
||||
Reference in New Issue
Block a user