Apply the AGENTS.md comments guideline to every .ts under tests/: remove what the code already expresses, keep only what it cannot. Removed: spec-header coverage inventories the describe/test tree already names; comments restating the next line's assertion or its message; helper JSDoc whose body already says it; within-file duplicates; five stale claims (trendChart's "six aggregated turns" against agg.length === 8, agentGraph's "six categories" against CATS' seven, fold-timing's "cheapest call LAST" against a loop that feeds it first, fold-surface's unreachable plain-JSON note, contextView's "two turns" for a one-turn fixture). Kept and condensed: the projection-freeze class, strict wire/state-schema hazards, retention and pricing windows, pairing rules, hostile-input rationale, fixture and expectation-array ground truth, jsdom mechanics, and issue-numbered regressions. Comment lines 2604 -> 2014 (-22%); 85 module headers kept, 30 coverage inventories dropped; every surviving comment line is within the 140-column limit, with 36 wrapped lines joined onto fuller ones. No logic, string, identifier, import or directive changed: a comment-strip gate proves each file's comment-free code is byte-identical to HEAD, and a line-level proof pairs all 845 changed lines with an unchanged code part. pnpm run lint && pnpm run test (106 files / 2061 tests, per-file 100% coverage) && pnpm run build all pass.
49 lines
1.9 KiB
TypeScript
49 lines
1.9 KiB
TypeScript
// Plugin self-metadata (src/client/meta.ts): the build-time define fallbacks and the define-armed variants, each
|
|
// setting its globals BEFORE the dynamic import (vi.resetModules clears the cache so the constants re-evaluate).
|
|
|
|
import assert from 'node:assert/strict'
|
|
import { afterEach, describe, test, vi } from 'vitest'
|
|
|
|
const globals = globalThis as Record<string, unknown>
|
|
|
|
afterEach(() => {
|
|
delete globals.__DSH_CTX_VERSION__
|
|
delete globals.__DSH_CTX_REPO__
|
|
vi.resetModules()
|
|
})
|
|
|
|
async function importMeta(): Promise<typeof import('../../src/client/meta')> {
|
|
vi.resetModules()
|
|
return await import('../../src/client/meta')
|
|
}
|
|
|
|
describe('meta', () => {
|
|
test('without build defines the dev/test fallbacks apply', async () => {
|
|
const meta = await importMeta()
|
|
assert.equal(meta.PLUGIN_NAME, 'dsh-context')
|
|
assert.equal(meta.PLUGIN_VERSION, '0.0.0-dev')
|
|
assert.equal(meta.PLUGIN_REPO, 'https://github.com/bowenliang123/dsh-context')
|
|
assert.equal(meta.PLUGIN_REPO_SHORT, 'bowenliang123/dsh-context')
|
|
})
|
|
|
|
test('a version define wins over the dev fallback', async () => {
|
|
globals.__DSH_CTX_VERSION__ = '9.9.9'
|
|
const meta = await importMeta()
|
|
assert.equal(meta.PLUGIN_VERSION, '9.9.9')
|
|
assert.equal(meta.PLUGIN_REPO, 'https://github.com/bowenliang123/dsh-context')
|
|
})
|
|
|
|
test('a repo define wins and the short form strips the github prefix', async () => {
|
|
globals.__DSH_CTX_REPO__ = 'https://github.com/acme/widget'
|
|
const meta = await importMeta()
|
|
assert.equal(meta.PLUGIN_REPO, 'https://github.com/acme/widget')
|
|
assert.equal(meta.PLUGIN_REPO_SHORT, 'acme/widget')
|
|
})
|
|
|
|
test('a non-github repo keeps its full URL as the short form', async () => {
|
|
globals.__DSH_CTX_REPO__ = 'http://git.example.com/acme/widget'
|
|
const meta = await importMeta()
|
|
assert.equal(meta.PLUGIN_REPO_SHORT, 'http://git.example.com/acme/widget')
|
|
})
|
|
})
|