Skip to content

Commit

Permalink
test: Update tests to use cached PR status
Browse files Browse the repository at this point in the history
The tests were expecting the frontend to fetch PR status directly from
GitHub API, but now that we've moved that logic to the backend, we need
to update the tests to use the PR status from the cache instead.
  • Loading branch information
openhands-agent committed Dec 10, 2024
1 parent 17a2e90 commit 4bcd143
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions src/services/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,14 @@ describe('GitHub Service', () => {
activities: [{
id: 'issue-1-2',
type: 'issue',
status: 'success',
status: 'pr_open',
timestamp: '2023-11-28T00:01:00Z',
url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-2',
prUrl: 'https://api.github.com/repos/All-Hands-AI/OpenHands/pulls/2',
description: 'A potential fix has been generated and a draft PR #2 has been created. Please review the changes.'
}],
lastUpdated: '2023-11-28T00:01:00Z'
});
} else if (url === 'https://api.github.com/repos/All-Hands-AI/OpenHands/pulls/2') {
return createMockResponse({
state: 'open',
merged: false
});
}
throw new Error(`Unexpected URL: ${url}`);
});
Expand All @@ -78,7 +73,7 @@ describe('GitHub Service', () => {
activities: [{
id: 'issue-1-2',
type: 'issue',
status: 'failure',
status: 'no_pr',
timestamp: '2023-11-28T00:01:00Z',
url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-2',
description: 'The workflow to fix this issue encountered an error. Openhands failed to create any code changes.'
Expand Down Expand Up @@ -143,7 +138,7 @@ describe('GitHub Service', () => {
activities: [{
id: 'issue-1-2',
type: 'issue',
status: 'success',
status: 'no_pr',
timestamp: '2023-11-28T00:01:00Z',
url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-2',
description: 'Working on the issue...'
Expand Down Expand Up @@ -173,19 +168,14 @@ describe('GitHub Service', () => {
activities: [{
id: 'issue-1-2',
type: 'issue',
status: 'success',
status: 'pr_open',
timestamp: '2023-11-28T00:01:00Z',
url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-2',
prUrl: 'https://api.github.com/repos/All-Hands-AI/OpenHands/pulls/2',
description: 'Created PR #2'
}],
lastUpdated: '2023-11-28T00:01:00Z'
});
} else if (url === 'https://api.github.com/repos/All-Hands-AI/OpenHands/pulls/2') {
return createMockResponse({
state: 'open',
merged: false
});
}
throw new Error(`Unexpected URL: ${url}`);
});
Expand All @@ -209,19 +199,14 @@ describe('GitHub Service', () => {
activities: [{
id: 'issue-1-2',
type: 'issue',
status: 'success',
status: 'pr_merged',
timestamp: '2023-11-28T00:01:00Z',
url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-2',
prUrl: 'https://api.github.com/repos/All-Hands-AI/OpenHands/pulls/2',
description: 'Created PR #2'
}],
lastUpdated: '2023-11-28T00:01:00Z'
});
} else if (url === 'https://api.github.com/repos/All-Hands-AI/OpenHands/pulls/2') {
return createMockResponse({
state: 'closed',
merged: true
});
}
throw new Error(`Unexpected URL: ${url}`);
});
Expand All @@ -245,19 +230,14 @@ describe('GitHub Service', () => {
activities: [{
id: 'issue-1-2',
type: 'issue',
status: 'success',
status: 'pr_closed',
timestamp: '2023-11-28T00:01:00Z',
url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-2',
prUrl: 'https://api.github.com/repos/All-Hands-AI/OpenHands/pulls/2',
description: 'Created PR #2'
}],
lastUpdated: '2023-11-28T00:01:00Z'
});
} else if (url === 'https://api.github.com/repos/All-Hands-AI/OpenHands/pulls/2') {
return createMockResponse({
state: 'closed',
merged: false
});
}
throw new Error(`Unexpected URL: ${url}`);
});
Expand Down

0 comments on commit 4bcd143

Please sign in to comment.