mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
test: remove 244 low-value tests (#39507)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -1,36 +1,7 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { classifyGitHubUnavailable, isGitHubUnavailableError } from './api-availability'
|
||||
import { classifyGitHubUnavailable } from './api-availability'
|
||||
|
||||
describe('classifyGitHubUnavailable', () => {
|
||||
it('classifies HTTP 5xx outages as server_error', () => {
|
||||
expect(classifyGitHubUnavailable('HTTP 503: Service Unavailable')).toBe('server_error')
|
||||
expect(classifyGitHubUnavailable('gh: Command failed: HTTP 502 Bad Gateway')).toBe(
|
||||
'server_error'
|
||||
)
|
||||
expect(classifyGitHubUnavailable('GitHub API error: 500 Internal Server Error')).toBe(
|
||||
'server_error'
|
||||
)
|
||||
expect(classifyGitHubUnavailable('The service is temporarily unavailable')).toBe('server_error')
|
||||
})
|
||||
|
||||
it('classifies transport failures as network', () => {
|
||||
for (const message of [
|
||||
'request to https://api.github.com failed, reason: getaddrinfo ENOTFOUND api.github.com',
|
||||
'error connecting to api.github.com\ncheck your internet connection or GitHub status',
|
||||
'dial tcp: lookup api.github.com: no such host',
|
||||
'connect ETIMEDOUT 140.82.112.5:443',
|
||||
'TimeoutError: request aborted',
|
||||
'NetworkError when attempting to fetch resource',
|
||||
'network unavailable',
|
||||
'fetch failed',
|
||||
'socket hang up',
|
||||
'could not resolve host: api.github.com',
|
||||
'connection refused'
|
||||
]) {
|
||||
expect(classifyGitHubUnavailable(message)).toBe('network')
|
||||
}
|
||||
})
|
||||
|
||||
it('classifies rate limiting as rate_limited (even when it carries HTTP 403)', () => {
|
||||
expect(classifyGitHubUnavailable('HTTP 403: API rate limit exceeded')).toBe('rate_limited')
|
||||
expect(classifyGitHubUnavailable('You have exceeded a secondary rate limit')).toBe(
|
||||
@@ -56,12 +27,3 @@ describe('classifyGitHubUnavailable', () => {
|
||||
expect(classifyGitHubUnavailable('found 512 pull requests')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('isGitHubUnavailableError', () => {
|
||||
it('detects reachability failures from Error objects and strings', () => {
|
||||
expect(isGitHubUnavailableError(new Error('HTTP 503: Service Unavailable'))).toBe(true)
|
||||
expect(isGitHubUnavailableError('fetch failed')).toBe(true)
|
||||
expect(isGitHubUnavailableError(new Error('HTTP 404: Not Found'))).toBe(false)
|
||||
expect(isGitHubUnavailableError(null)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
GITHUB_OWNER_NUMBER_SHORTHAND_RE,
|
||||
GITHUB_OWNER_SLUG_RE,
|
||||
isGitHubOwnerSlug
|
||||
} from './owner-slug'
|
||||
import { GITHUB_OWNER_SLUG_RE, isGitHubOwnerSlug } from './owner-slug'
|
||||
|
||||
describe('GitHub owner slug alphabet', () => {
|
||||
it('accepts plain logins and Enterprise Managed User logins', () => {
|
||||
@@ -33,13 +29,4 @@ describe('GitHub owner slug alphabet', () => {
|
||||
}
|
||||
expect(isGitHubOwnerSlug(123)).toBe(false)
|
||||
})
|
||||
|
||||
it('shorthand captures the same owner alphabet plus a number', () => {
|
||||
expect(GITHUB_OWNER_NUMBER_SHORTHAND_RE.exec('octocat_acme/12')?.slice(1)).toEqual([
|
||||
'octocat_acme',
|
||||
'12'
|
||||
])
|
||||
expect(GITHUB_OWNER_NUMBER_SHORTHAND_RE.test('_acme/12')).toBe(false)
|
||||
expect(GITHUB_OWNER_NUMBER_SHORTHAND_RE.test('acme/x')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { tailDiffHunk, threadDiffLines } from './pr-comment-diff-hunk'
|
||||
|
||||
const HUNK = [
|
||||
'@@ -20,4 +20,6 @@ export function Banner(props) {',
|
||||
' return (',
|
||||
'- <View style={styles.box}>',
|
||||
'+ <View style={styles.banner}>',
|
||||
'+ <Icon size={16} radius={20} />',
|
||||
' <Text>{props.title}</Text>'
|
||||
].join('\n')
|
||||
|
||||
describe('pr comment diff hunk', () => {
|
||||
it('numbers the anchored lines back from the end line, skipping removed lines', () => {
|
||||
const tail = tailDiffHunk(HUNK) ?? ''
|
||||
const strip = (lines: ReturnType<typeof threadDiffLines>) =>
|
||||
lines.map(({ number, sign, text }) => ({ number, sign, text }))
|
||||
expect(strip(threadDiffLines(tail, 23))).toEqual([
|
||||
{ number: 23, sign: ' ', text: ' <Text>{props.title}</Text>' }
|
||||
])
|
||||
// A hunk ending on line 21 with a removal inside 20..21: it shows unnumbered and line 20 still shows.
|
||||
const toLine21 = tail.split('\n').slice(0, 3).join('\n')
|
||||
expect(strip(threadDiffLines(toLine21, 21, 20))).toEqual([
|
||||
{ number: 20, sign: ' ', text: ' return (' },
|
||||
{ number: null, sign: '-', text: ' <View style={styles.box}>' },
|
||||
{ number: 21, sign: '+', text: ' <View style={styles.banner}>' }
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -1,60 +1,15 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import type { GitHubWorkItem } from './work-item-types'
|
||||
import {
|
||||
GITHUB_PR_REVIEWER_INPUT_MAX_BYTES,
|
||||
getGitHubPRReviewerRows,
|
||||
parseGitHubReviewerInputLogins
|
||||
} from './pr-reviewer-display'
|
||||
|
||||
function item(patch: Partial<GitHubWorkItem>): GitHubWorkItem {
|
||||
return patch as GitHubWorkItem
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
describe('GitHub PR reviewer display', () => {
|
||||
it('builds reviewer rows for requested and reviewed users', () => {
|
||||
expect(
|
||||
getGitHubPRReviewerRows(
|
||||
item({
|
||||
reviewRequests: [{ login: 'ExampleReviewer', name: null, avatarUrl: 'avatar-1' }],
|
||||
latestReviews: [
|
||||
{ login: 'reviewer', state: 'APPROVED', avatarUrl: 'avatar-2' },
|
||||
{ login: 'ExampleReviewer', state: 'COMMENTED', avatarUrl: 'avatar-1b' }
|
||||
]
|
||||
})
|
||||
)
|
||||
).toEqual([
|
||||
{
|
||||
login: 'ExampleReviewer',
|
||||
name: null,
|
||||
avatarUrl: 'avatar-1',
|
||||
stateLabel: 'Requested'
|
||||
},
|
||||
{
|
||||
login: 'reviewer',
|
||||
name: null,
|
||||
avatarUrl: 'avatar-2',
|
||||
stateLabel: 'Approved'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('parses pasted reviewer input without regex splitting', () => {
|
||||
const split = vi.spyOn(String.prototype, 'split')
|
||||
const input = ['@ExampleReviewer,', String.fromCharCode(160), '@new-reviewer\nthird'].join('')
|
||||
|
||||
expect(parseGitHubReviewerInputLogins(input)).toEqual([
|
||||
'@ExampleReviewer',
|
||||
'@new-reviewer',
|
||||
'third'
|
||||
])
|
||||
expect(split).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('rejects oversized reviewer input before tokenizing pasted text', () => {
|
||||
const split = vi.spyOn(String.prototype, 'split')
|
||||
const oversized = 'secret-reviewer,'.repeat(GITHUB_PR_REVIEWER_INPUT_MAX_BYTES)
|
||||
|
||||
@@ -86,12 +86,6 @@ describe('resolveBoardColumnField', () => {
|
||||
expect(resolveBoardColumnField(v)).toBe(SPRINT_FIELD)
|
||||
})
|
||||
|
||||
it('falls back to the Status field, then any single-select', () => {
|
||||
const priority: GitHubProjectField = { ...STATUS_FIELD, id: 'f_prio', name: 'Priority' }
|
||||
expect(resolveBoardColumnField(view({ fields: [priority, STATUS_FIELD] }))).toBe(STATUS_FIELD)
|
||||
expect(resolveBoardColumnField(view({ fields: [priority] }))).toBe(priority)
|
||||
})
|
||||
|
||||
it('ignores a non-select vertical field instead of building clear-only columns', () => {
|
||||
const textField: GitHubProjectField = {
|
||||
kind: 'field',
|
||||
@@ -102,28 +96,9 @@ describe('resolveBoardColumnField', () => {
|
||||
const v = view({ fields: [STATUS_FIELD], verticalGroupByFields: [textField] })
|
||||
expect(resolveBoardColumnField(v)).toBe(STATUS_FIELD)
|
||||
})
|
||||
|
||||
it('returns null when nothing can shape columns', () => {
|
||||
expect(
|
||||
resolveBoardColumnField(
|
||||
view({ fields: [{ kind: 'field', id: 'f_t', name: 'Title', dataType: 'TITLE' }] })
|
||||
)
|
||||
).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildBoardColumns', () => {
|
||||
it('emits every option as a column in option order, empty ones included', () => {
|
||||
const columns = buildBoardColumns(STATUS_FIELD, [
|
||||
row('a', [statusValue('opt_done', 'Done')]),
|
||||
row('b', [statusValue('opt_todo', 'Todo')])
|
||||
])
|
||||
expect(columns.map((c) => c.label)).toEqual(['Todo', 'In Progress', 'Done', 'No Status'])
|
||||
expect(columns.map((c) => c.rows.length)).toEqual([1, 0, 1, 0])
|
||||
expect(columns[0]?.dropValue).toEqual({ kind: 'single-select', optionId: 'opt_todo' })
|
||||
expect(columns[0]?.color).toBe('GREEN')
|
||||
})
|
||||
|
||||
it('routes no-value rows to the trailing column whose drop clears the field', () => {
|
||||
const columns = buildBoardColumns(STATUS_FIELD, [row('a', [])])
|
||||
const trailing = columns.at(-1)!
|
||||
@@ -143,24 +118,6 @@ describe('buildBoardColumns', () => {
|
||||
expect(columns.at(-1)?.label).toBe('No Status')
|
||||
})
|
||||
|
||||
it('builds iteration columns with iteration drops', () => {
|
||||
const columns = buildBoardColumns(SPRINT_FIELD, [
|
||||
row('a', [
|
||||
{
|
||||
kind: 'iteration',
|
||||
fieldId: 'f_sprint',
|
||||
iterationId: 'it_2',
|
||||
title: 'Sprint 2',
|
||||
startDate: '2026-09-07',
|
||||
duration: 14
|
||||
}
|
||||
])
|
||||
])
|
||||
expect(columns.map((c) => c.label)).toEqual(['Sprint 1', 'Sprint 2', 'No Sprint'])
|
||||
expect(columns[1]?.dropValue).toEqual({ kind: 'iteration', iterationId: 'it_2' })
|
||||
expect(columns[1]?.rows.map((r) => r.id)).toEqual(['a'])
|
||||
})
|
||||
|
||||
it('buckets non-select fields read-only', () => {
|
||||
const assignees: GitHubProjectField = {
|
||||
kind: 'field',
|
||||
|
||||
@@ -1,230 +1,9 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
buildRoadmapTicks,
|
||||
getRoadmapSpan,
|
||||
parseRoadmapDate,
|
||||
resolveRoadmapDateSource,
|
||||
roadmapOffsetPx,
|
||||
ROADMAP_DAY_MS,
|
||||
type RoadmapSpan
|
||||
} from './project-roadmap-timeline'
|
||||
import type {
|
||||
GitHubProjectField,
|
||||
GitHubProjectFieldValue,
|
||||
GitHubProjectRow,
|
||||
GitHubProjectView
|
||||
} from './project-types'
|
||||
|
||||
function dateField(id: string, name: string): GitHubProjectField {
|
||||
return { kind: 'field', id, name, dataType: 'DATE' }
|
||||
}
|
||||
|
||||
function iterationField(id: string, name: string): GitHubProjectField {
|
||||
return { kind: 'iteration', id, name, dataType: 'ITERATION', iterations: [] }
|
||||
}
|
||||
|
||||
function view(fields: GitHubProjectField[]): GitHubProjectView {
|
||||
return {
|
||||
id: 'PVTV_1',
|
||||
number: 1,
|
||||
name: 'Roadmap',
|
||||
layout: 'ROADMAP_LAYOUT',
|
||||
filter: '',
|
||||
fields,
|
||||
groupByFields: [],
|
||||
sortByFields: []
|
||||
}
|
||||
}
|
||||
|
||||
function row(values: GitHubProjectFieldValue[]): GitHubProjectRow {
|
||||
const fieldValuesByFieldId: Record<string, GitHubProjectFieldValue> = {}
|
||||
for (const value of values) {
|
||||
fieldValuesByFieldId[value.fieldId] = value
|
||||
}
|
||||
return {
|
||||
id: 'PVTI_1',
|
||||
itemType: 'ISSUE',
|
||||
content: {
|
||||
number: 1,
|
||||
title: 'Item',
|
||||
body: null,
|
||||
url: 'https://github.com/o/r/issues/1',
|
||||
state: 'OPEN',
|
||||
stateReason: null,
|
||||
isDraft: null,
|
||||
repository: 'o/r',
|
||||
assignees: [],
|
||||
labels: [],
|
||||
parentIssue: null,
|
||||
issueType: null
|
||||
},
|
||||
fieldValuesByFieldId,
|
||||
updatedAt: '2026-08-31T00:00:00Z',
|
||||
position: 0
|
||||
}
|
||||
}
|
||||
import { buildRoadmapTicks, parseRoadmapDate, type RoadmapSpan } from './project-roadmap-timeline'
|
||||
|
||||
const utc = (iso: string): number => Date.parse(`${iso}T00:00:00Z`)
|
||||
|
||||
describe('resolveRoadmapDateSource', () => {
|
||||
it('pairs date fields by name regardless of view order', () => {
|
||||
const target = dateField('f_end', 'Target date')
|
||||
const start = dateField('f_start', 'Start date')
|
||||
expect(resolveRoadmapDateSource(view([target, start]))).toEqual({
|
||||
kind: 'date-range',
|
||||
startField: start,
|
||||
targetField: target
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps a name-matched field in its role when the other name matches nothing', () => {
|
||||
const review = dateField('f_review', 'Review date')
|
||||
const start = dateField('f_start', 'Start date')
|
||||
expect(resolveRoadmapDateSource(view([review, start]))).toEqual({
|
||||
kind: 'date-range',
|
||||
startField: start,
|
||||
targetField: review
|
||||
})
|
||||
})
|
||||
|
||||
it('finds placement fields via sortByFields when the visible list hides them', () => {
|
||||
const start = dateField('f_start', 'Start date')
|
||||
const target = dateField('f_end', 'Target date')
|
||||
const hidden = view([{ kind: 'field', id: 'f_t', name: 'Title', dataType: 'TITLE' }])
|
||||
hidden.sortByFields = [
|
||||
{ direction: 'ASC', field: start },
|
||||
{ direction: 'ASC', field: target }
|
||||
]
|
||||
expect(resolveRoadmapDateSource(hidden)).toEqual({
|
||||
kind: 'date-range',
|
||||
startField: start,
|
||||
targetField: target
|
||||
})
|
||||
})
|
||||
|
||||
it('derives placement fields from row values when no configured field has them', () => {
|
||||
const bare = view([{ kind: 'field', id: 'f_t', name: 'Title', dataType: 'TITLE' }])
|
||||
const rows = [
|
||||
row([
|
||||
{ kind: 'date', fieldId: 'f_start', date: '2026-03-02', fieldName: 'Start date' },
|
||||
{ kind: 'date', fieldId: 'f_end', date: '2026-03-04', fieldName: 'Target date' }
|
||||
])
|
||||
]
|
||||
expect(resolveRoadmapDateSource(bare, rows)).toEqual({
|
||||
kind: 'date-range',
|
||||
startField: { kind: 'field', id: 'f_start', name: 'Start date', dataType: 'DATE' },
|
||||
targetField: { kind: 'field', id: 'f_end', name: 'Target date', dataType: 'DATE' }
|
||||
})
|
||||
})
|
||||
|
||||
it('falls back to view order when names do not match the patterns', () => {
|
||||
const first = dateField('f_1', '開始')
|
||||
const second = dateField('f_2', '完了')
|
||||
expect(resolveRoadmapDateSource(view([first, second]))).toEqual({
|
||||
kind: 'date-range',
|
||||
startField: first,
|
||||
targetField: second
|
||||
})
|
||||
})
|
||||
|
||||
it('prefers an iteration field over a lone date field', () => {
|
||||
const iteration = iterationField('f_it', 'Sprint')
|
||||
expect(resolveRoadmapDateSource(view([dateField('f_1', 'Start date'), iteration]))).toEqual({
|
||||
kind: 'iteration',
|
||||
field: iteration
|
||||
})
|
||||
})
|
||||
|
||||
it('uses a lone date field as a point source', () => {
|
||||
const only = dateField('f_1', 'Ship date')
|
||||
expect(resolveRoadmapDateSource(view([only]))).toEqual({ kind: 'date-point', field: only })
|
||||
})
|
||||
|
||||
it('returns null when the view has nothing to place items on', () => {
|
||||
expect(
|
||||
resolveRoadmapDateSource(
|
||||
view([{ kind: 'field', id: 'f_t', name: 'Title', dataType: 'TITLE' }])
|
||||
)
|
||||
).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('getRoadmapSpan', () => {
|
||||
const start = dateField('f_start', 'Start date')
|
||||
const target = dateField('f_end', 'Target date')
|
||||
const source = { kind: 'date-range', startField: start, targetField: target } as const
|
||||
|
||||
it('spans an inclusive end date', () => {
|
||||
const span = getRoadmapSpan(
|
||||
row([
|
||||
{ kind: 'date', fieldId: 'f_start', date: '2026-03-02' },
|
||||
{ kind: 'date', fieldId: 'f_end', date: '2026-03-04' }
|
||||
]),
|
||||
source
|
||||
)
|
||||
expect(span).toEqual({ startMs: utc('2026-03-02'), endMs: utc('2026-03-05'), point: false })
|
||||
})
|
||||
|
||||
it('renders a single known date as a point', () => {
|
||||
const span = getRoadmapSpan(
|
||||
row([{ kind: 'date', fieldId: 'f_end', date: '2026-03-04' }]),
|
||||
source
|
||||
)
|
||||
expect(span).toEqual({ startMs: utc('2026-03-04'), endMs: utc('2026-03-05'), point: true })
|
||||
})
|
||||
|
||||
it('orders an inverted pair instead of dropping the row', () => {
|
||||
const span = getRoadmapSpan(
|
||||
row([
|
||||
{ kind: 'date', fieldId: 'f_start', date: '2026-03-10' },
|
||||
{ kind: 'date', fieldId: 'f_end', date: '2026-03-01' }
|
||||
]),
|
||||
source
|
||||
)
|
||||
expect(span).toEqual({ startMs: utc('2026-03-01'), endMs: utc('2026-03-11'), point: false })
|
||||
})
|
||||
|
||||
it('returns null when neither date is set', () => {
|
||||
expect(getRoadmapSpan(row([]), source)).toBeNull()
|
||||
})
|
||||
|
||||
it('derives the span from an iteration value', () => {
|
||||
const span = getRoadmapSpan(
|
||||
row([
|
||||
{
|
||||
kind: 'iteration',
|
||||
fieldId: 'f_it',
|
||||
iterationId: 'it_1',
|
||||
title: 'Sprint 1',
|
||||
startDate: '2026-03-02',
|
||||
duration: 14
|
||||
}
|
||||
]),
|
||||
{ kind: 'iteration', field: iterationField('f_it', 'Sprint') }
|
||||
)
|
||||
expect(span).toEqual({
|
||||
startMs: utc('2026-03-02'),
|
||||
endMs: utc('2026-03-02') + 14 * ROADMAP_DAY_MS,
|
||||
point: false
|
||||
})
|
||||
})
|
||||
|
||||
it('ignores a value whose kind does not match the source', () => {
|
||||
expect(
|
||||
getRoadmapSpan(row([{ kind: 'text', fieldId: 'f_start', text: '2026-03-02' }]), source)
|
||||
).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseRoadmapDate', () => {
|
||||
it('reads the date part of an ISO timestamp', () => {
|
||||
expect(parseRoadmapDate('2026-03-02T11:22:33Z')).toBe(utc('2026-03-02'))
|
||||
})
|
||||
|
||||
it('rejects malformed input', () => {
|
||||
expect(parseRoadmapDate('March 2')).toBeNull()
|
||||
})
|
||||
|
||||
it('rejects invalid calendar dates instead of letting Date.UTC normalize them', () => {
|
||||
expect(parseRoadmapDate('2026-02-30')).toBeNull()
|
||||
expect(parseRoadmapDate('2026-13-01')).toBeNull()
|
||||
@@ -240,35 +19,6 @@ describe('buildRoadmapTicks', () => {
|
||||
point: false
|
||||
})
|
||||
|
||||
it('pads one month on each side of the covered range', () => {
|
||||
const ticks = buildRoadmapTicks([span('2026-03-02', '2026-10-10')], 'month', utc('2026-03-15'))
|
||||
expect(ticks[0]?.startMs).toBe(utc('2026-02-01'))
|
||||
expect(ticks.at(-1)?.endMs).toBe(utc('2026-12-01'))
|
||||
})
|
||||
|
||||
it('always covers today even when every item sits elsewhere', () => {
|
||||
const ticks = buildRoadmapTicks([span('2026-03-02', '2026-03-10')], 'month', utc('2026-09-15'))
|
||||
expect(ticks[0]?.startMs).toBe(utc('2026-02-01'))
|
||||
expect(ticks.at(-1)?.endMs).toBe(utc('2026-11-01'))
|
||||
})
|
||||
|
||||
it('widens an empty roadmap to the minimum readable width', () => {
|
||||
expect(buildRoadmapTicks([], 'month', utc('2026-03-15'))).toHaveLength(6)
|
||||
expect(buildRoadmapTicks([], 'quarter', utc('2026-03-15'))).toHaveLength(4)
|
||||
expect(buildRoadmapTicks([], 'year', utc('2026-03-15'))).toHaveLength(3)
|
||||
})
|
||||
|
||||
it('snaps quarter and year grids to their unit boundaries', () => {
|
||||
const quarters = buildRoadmapTicks(
|
||||
[span('2026-05-02', '2026-05-10')],
|
||||
'quarter',
|
||||
utc('2026-05-15')
|
||||
)
|
||||
expect(quarters[0]?.startMs).toBe(utc('2026-01-01'))
|
||||
const years = buildRoadmapTicks([span('2026-05-02', '2026-05-10')], 'year', utc('2026-05-15'))
|
||||
expect(years[0]?.startMs).toBe(utc('2025-01-01'))
|
||||
})
|
||||
|
||||
it('caps the grid instead of expanding for a far-future date, keeping today visible', () => {
|
||||
const today = utc('2026-03-15')
|
||||
const ticks = buildRoadmapTicks([span('2026-03-02', '9999-01-01')], 'month', today)
|
||||
@@ -287,24 +37,3 @@ describe('buildRoadmapTicks', () => {
|
||||
expect(ticks.at(-1)!.endMs).toBe(utc('2026-05-01'))
|
||||
})
|
||||
})
|
||||
|
||||
describe('roadmapOffsetPx', () => {
|
||||
const ticks = buildRoadmapTicks([], 'month', utc('2026-03-15'))
|
||||
|
||||
it('interpolates inside the containing tick so column rules stay aligned', () => {
|
||||
const second = ticks[1]
|
||||
expect(second).toBeDefined()
|
||||
expect(roadmapOffsetPx(second!.startMs, ticks, 100)).toBe(100)
|
||||
const midpoint = second!.startMs + (second!.endMs - second!.startMs) / 2
|
||||
expect(roadmapOffsetPx(midpoint, ticks, 100)).toBeCloseTo(150, 5)
|
||||
})
|
||||
|
||||
it('clamps out-of-range timestamps to the grid edges', () => {
|
||||
expect(roadmapOffsetPx(utc('1990-01-01'), ticks, 100)).toBe(0)
|
||||
expect(roadmapOffsetPx(utc('2090-01-01'), ticks, 100)).toBe(ticks.length * 100)
|
||||
})
|
||||
|
||||
it('returns zero for an empty grid', () => {
|
||||
expect(roadmapOffsetPx(utc('2026-03-15'), [], 100)).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { PRRefreshOutcome } from './pull-request-refresh-types'
|
||||
|
||||
import type { PRInfo } from './pull-request-types'
|
||||
import { normalizeGitHubPRForBranchOutcome } from './pull-request-for-branch-outcome'
|
||||
|
||||
@@ -14,11 +14,6 @@ const PR: PRInfo = {
|
||||
}
|
||||
|
||||
describe('normalizeGitHubPRForBranchOutcome', () => {
|
||||
it('preserves current classified outcomes', () => {
|
||||
const outcome: PRRefreshOutcome = { kind: 'found', pr: PR, fetchedAt: 10 }
|
||||
expect(normalizeGitHubPRForBranchOutcome(outcome, 20)).toBe(outcome)
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ kind: 'no-pr' as const, fetchedAt: 10 },
|
||||
{ kind: 'no-pr' as const, fetchedAt: 10, rejectedPRUrls: [PR.url] }
|
||||
@@ -37,14 +32,4 @@ describe('normalizeGitHubPRForBranchOutcome', () => {
|
||||
fetchedAt: 20
|
||||
})
|
||||
})
|
||||
|
||||
it('preserves classified upstream errors', () => {
|
||||
const outcome: PRRefreshOutcome = {
|
||||
kind: 'upstream-error',
|
||||
errorType: 'network',
|
||||
message: 'network unavailable',
|
||||
fetchedAt: 10
|
||||
}
|
||||
expect(normalizeGitHubPRForBranchOutcome(outcome, 20)).toBe(outcome)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user