← Public packages
@kentcdodds/friction-log
Qualify and file friction papercuts to GitHub (any owner/repo) or wake Patch for Kody packages; daily sweep of kody-hq/kody friction issues.
src/eligibility.test.ts
98 lines · 2.8 KB · TypeScriptimport assert from 'node:assert/strict'
import { describe, it } from 'node:test'
import { eligibleIssues, hasSkippedLabel, isEligibleIssue } from './eligibility.ts'
import { skippedLabel, type FrictionIssue, type IssueComment } from './shared.ts'
function comment(input: Partial<IssueComment> & Pick<IssueComment, 'body' | 'createdAt'>): IssueComment {
return {
id: input.id ?? 1,
userLogin: input.userLogin ?? 'kody-bot',
createdAt: input.createdAt,
body: input.body,
}
}
function issue(input: { labels?: Array<string>; comments?: Array<IssueComment> } = {}): FrictionIssue {
return {
number: 12,
title: 'Friction: pnpm test files',
body: 'test files are ignored',
htmlUrl: 'https://github.com/kody-hq/kody/issues/12',
userLogin: 'agent',
createdAt: '2026-08-20T00:00:00.000Z',
updatedAt: '2026-08-21T00:00:00.000Z',
labels: input.labels ?? ["friction"],
comments: input.comments ?? [],
}
}
describe('isEligibleIssue', () => {
it('keeps an open friction issue without friction-skipped', () => {
assert.deepEqual(isEligibleIssue(issue()), { eligible: true, reason: 'open' })
})
it('skips an issue labeled friction-skipped even if Kent later commented', () => {
const skipped = issue({
labels: ['friction', skippedLabel],
comments: [
comment({
id: 2,
userLogin: 'kody-bot',
createdAt: '2026-08-21T12:00:00.000Z',
body: 'Recommended fix.',
}),
comment({
id: 3,
userLogin: 'kentcdodds',
createdAt: '2026-08-21T13:00:00.000Z',
body: 'Ship the recommended fix.',
}),
],
})
assert.deepEqual(isEligibleIssue(skipped), { eligible: false, reason: 'skipped' })
assert.equal(hasSkippedLabel(skipped), true)
})
it('does not parse HTML skip comments for eligibility', () => {
const commented = issue({
labels: ['friction'],
comments: [
comment({
id: 2,
userLogin: 'kody-bot',
createdAt: '2026-08-21T12:00:00.000Z',
body: 'Recommended fix.\n\n' + '<!-- friction-log:skipped -->',
}),
],
})
assert.deepEqual(isEligibleIssue(commented), { eligible: true, reason: 'open' })
})
it('requeues when friction-skipped is removed, regardless of comments', () => {
const unskipped = issue({
labels: ['friction'],
comments: [
comment({
id: 2,
userLogin: 'kody-bot',
createdAt: '2026-08-21T12:00:00.000Z',
body: 'Recommended fix.',
}),
],
})
assert.deepEqual(isEligibleIssue(unskipped), { eligible: true, reason: 'open' })
})
})
describe('eligibleIssues', () => {
it('drops friction-skipped issues and keeps open friction issues', () => {
const open = issue()
const skipped = issue({ labels: ['friction', skippedLabel] })
const selected = eligibleIssues([open, skipped])
assert.deepEqual(
selected.map((row) => row.number),
[12],
)
assert.equal(selected[0], open)
})
})