Open History to see the last commit
1/** Test fixture builders. NOW is the frozen reference time for all tests. */
2
3import type {
4 DiscussionItem,
5 IssueItem,
6 PRItem,
7 TimelineEvent,
8 ToolsetConfig,
9} from './types'
10
11export const NOW = new Date('2026-07-16T00:00:00Z')
12
13export function hoursAgo(h: number): string {
14 return new Date(NOW.getTime() - h * 60 * 60 * 1000).toISOString()
15}
16
17export function daysAgo(d: number): string {
18 return hoursAgo(d * 24)
19}
20
21export const config: ToolsetConfig = {
22 repo: 'TanStack/ai',
23 maintainers: [
24 {
25 github: 'tom',
26 discord: '111',
27 areas: ['packages/ai-sandbox*/**', 'packages/ai-claude-code/**'],
28 maxOpenAssignments: 5,
29 },
30 {
31 github: 'alem',
32 discord: null,
33 areas: ['packages/ai/**', 'packages/ai-client/**'],
34 maxOpenAssignments: 5,
35 },
36 {
37 github: 'jack',
38 discord: null,
39 areas: ['docs/**', 'examples/**'],
40 maxOpenAssignments: 5,
41 },
42 ],
43 sla: {
44 firstResponseHours: 24,
45 followUpResponseHours: 48,
46 staleAuthorDays: 14,
47 },
48 spam: { maxAccountAgeDays: 30, maxChangedLines: 30 },
49 botAllowlist: ['renovate'],
50 maxCommentsPerRun: 25,
51}
52
53export function comment(
54 actor: string,
55 at: string,
56 body = '',
57 isBot = false,
58): TimelineEvent {
59 return { kind: 'comment', actor, isBot, at, body }
60}
61
62export function review(
63 actor: string,
64 at: string,
65 reviewState: string,
66): TimelineEvent {
67 return { kind: 'review', actor, isBot: false, at, reviewState }
68}
69
70export function commit(actor: string, at: string): TimelineEvent {
71 return { kind: 'commit', actor, isBot: false, at }
72}
73
74export function makePR(overrides: Partial<PRItem> = {}): PRItem {
75 const number = overrides.number ?? 100
76 return {
77 type: 'pr',
78 number,
79 title: 'feat: add thing',
80 url: `https://github.com/TanStack/ai/pull/${number}`,
81 author: 'contributor',
82 authorIsBot: false,
83 authorAccountCreatedAt: daysAgo(400),
84 authorAssociation: 'CONTRIBUTOR',
85 createdAt: daysAgo(2),
86 updatedAt: daysAgo(1),
87 isDraft: false,
88 mergeable: 'MERGEABLE',
89 reviewDecision: '',
90 additions: 120,
91 deletions: 30,
92 changedFiles: 4,
93 files: ['packages/ai/src/core/chat.ts', '.changeset/nice-fix.md'],
94 labels: [],
95 assignees: [],
96 requestedReviewers: [],
97 ciState: 'success',
98 linkedIssues: [50],
99 timeline: [],
100 ...overrides,
101 }
102}
103
104export function makeIssue(overrides: Partial<IssueItem> = {}): IssueItem {
105 return {
106 type: 'issue',
107 number: 200,
108 title: 'bug: chat streaming breaks',
109 url: 'https://github.com/TanStack/ai/issues/200',
110 author: 'reporter',
111 authorIsBot: false,
112 authorAssociation: 'NONE',
113 createdAt: daysAgo(2),
114 updatedAt: daysAgo(1),
115 body: 'It breaks. Repro: https://stackblitz.com/x',
116 labels: [],
117 assignees: [],
118 timeline: [],
119 ...overrides,
120 }
121}
122
123export function makeDiscussion(
124 overrides: Partial<DiscussionItem> = {},
125): DiscussionItem {
126 return {
127 type: 'discussion',
128 number: 300,
129 title: 'How do I use tools?',
130 url: 'https://github.com/TanStack/ai/discussions/300',
131 author: 'asker',
132 createdAt: daysAgo(3),
133 updatedAt: daysAgo(3),
134 isAnswered: false,
135 category: 'Q&A',
136 upvotes: 2,
137 commentCount: 0,
138 comments: [],
139 ...overrides,
140 }
141}