skillhub/cli/test/unit/shared/github-source.test.ts
小妍儿 ✨ c6911c6f79
feat(github-sync): 同步版本记录并展示上游仓库 tag 来源 (#1129)
* docs(openspec): propose recording GitHub sync source tags (#1051)

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(github-sync): resolve repository semver tag of the fixed commit (#1051)

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(github-sync): store and expose upstream source tags of synced versions (#1051)

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(web): show upstream tag and declared version in the GitHub source card (#1051)

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(cli): show upstream repository tag for synced versions (#1051)

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* docs(github-sync): document the optional source tag report field (#1051)

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(github-sync): bound source tag command output without data races (#1051)

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* docs(openspec): mark verified source tag tasks (#1051)

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(api): read GitHub source only for synced versions on version detail and CLI resolve (#1051)

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(github-sync): keep optional source tags from rejecting reports or bypassing cooldowns (#1051)

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* docs(openspec): mark full backend gate done for #1051

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

---------

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
2026-11-24 11:28:29 +08:00

24 lines
1.3 KiB
TypeScript

import { describe, expect, test } from 'bun:test'
import { formatUpstreamTag, type GithubSource } from '../../../src/shared/github-source'
function source(upstreamTag?: GithubSource['upstreamTag']): GithubSource {
return { ownerLogin: 'o', repositoryName: 'r', skillPath: 's', commitSha: 'a'.repeat(40), syncRevision: 1,
...(upstreamTag ? { upstreamTag } : {}) }
}
describe('formatUpstreamTag', () => {
test('labels each recorded relation', () => {
expect(formatUpstreamTag(source({ status: 'EXACT', scope: 'REPOSITORY', tag: 'v7.0.1', commitsAfterTag: 0 })))
.toBe('upstream v7.0.1')
expect(formatUpstreamTag(source({ status: 'AFTER_TAG', scope: 'REPOSITORY', tag: 'v1.3.2', commitsAfterTag: 3 })))
.toBe('upstream v1.3.2+3')
expect(formatUpstreamTag(source({ status: 'NO_TAG', scope: 'REPOSITORY' }))).toBe('upstream: no repository tag')
expect(formatUpstreamTag(source({ status: 'UNKNOWN', scope: 'REPOSITORY', reason: 'TIMEOUT' }))).toBe('upstream: unknown')
})
test('keeps output unchanged when nothing was recorded', () => {
expect(formatUpstreamTag(undefined)).toBeUndefined()
expect(formatUpstreamTag(source())).toBeUndefined()
expect(formatUpstreamTag(source({ status: 'UNRECORDED', scope: 'REPOSITORY' }))).toBeUndefined()
})
})