-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgithub-api.test.ts
60 lines (55 loc) · 2.48 KB
/
github-api.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { describe, it, expect } from 'vitest';
import { isSuccessComment, isPRModificationFailureComment, isBotComment, isStartWorkComment } from './github-api';
import type { GitHubComment } from './types';
describe('Comment detection', () => {
it('should detect issue success comment', () => {
const comment: GitHubComment = {
id: 1,
html_url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-1',
created_at: '2023-11-28T00:01:00Z',
user: { login: 'github-actions[bot]', type: 'Bot' },
body: 'A potential fix has been generated and a draft PR #5364 has been created. Please review the changes.',
};
expect(isSuccessComment(comment)).toBe(true);
});
it('should detect PR failure comment', () => {
const comment: GitHubComment = {
id: 1,
html_url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-1',
created_at: '2023-11-28T00:01:00Z',
user: { login: 'github-actions[bot]', type: 'Bot' },
body: 'The workflow to fix this issue encountered an error. Please check the workflow logs for more information.',
};
expect(isPRModificationFailureComment(comment)).toBe(true);
});
it('should detect openhands-ai[bot] as a bot', () => {
const comment: GitHubComment = {
id: 1,
html_url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-1',
created_at: '2023-11-28T00:01:00Z',
user: { login: 'openhands-ai[bot]', type: 'Bot' },
body: 'Openhands is working, @neubig can click here to continue refining the PR',
};
expect(isBotComment(comment)).toBe(true);
});
it('should detect new start work format', () => {
const comment: GitHubComment = {
id: 1,
html_url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-1',
created_at: '2023-11-28T00:01:00Z',
user: { login: 'openhands-ai[bot]', type: 'Bot' },
body: 'Openhands is working, @neubig can click here to continue refining the PR',
};
expect(isStartWorkComment(comment)).toBe(true);
});
it('should detect new success format', () => {
const comment: GitHubComment = {
id: 1,
html_url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-1',
created_at: '2023-11-28T00:01:00Z',
user: { login: 'openhands-ai[bot]', type: 'Bot' },
body: '@neubig can click here to [continue refining the PR](https://app.all-hands.dev/conversations/e06b225de3a24fea97504511c80afc44)',
};
expect(isSuccessComment(comment)).toBe(true);
});
});