mirror of
https://github.com/stablyai/orca.git
synced 2026-09-26 08:02:38 +00:00
Celebrate onboarding and agent wins with GitHub star prompts (#5642)
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -97,6 +97,7 @@ vi.mock('./rate-limit', () => ({
|
||||
}))
|
||||
|
||||
import {
|
||||
checkOrcaStarred,
|
||||
getPRComments,
|
||||
getPRForBranch,
|
||||
getRepoUpstream,
|
||||
@@ -112,6 +113,45 @@ import {
|
||||
_resetMergeQueueCacheForTests
|
||||
} from './client'
|
||||
|
||||
describe('checkOrcaStarred', () => {
|
||||
beforeEach(() => {
|
||||
execFileAsyncMock.mockReset()
|
||||
acquireMock.mockReset()
|
||||
releaseMock.mockReset()
|
||||
acquireMock.mockResolvedValue(undefined)
|
||||
})
|
||||
|
||||
it('returns true only for an included successful GitHub response', async () => {
|
||||
execFileAsyncMock.mockResolvedValueOnce({ stdout: 'HTTP/2.0 204 No Content\r\n', stderr: '' })
|
||||
|
||||
await expect(checkOrcaStarred()).resolves.toBe(true)
|
||||
|
||||
expect(execFileAsyncMock).toHaveBeenCalledWith(
|
||||
'gh',
|
||||
['api', '--include', 'user/starred/stablyai/orca'],
|
||||
{ encoding: 'utf-8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('returns true for an HTTP 200 starred response', async () => {
|
||||
execFileAsyncMock.mockResolvedValueOnce({ stdout: 'HTTP/2.0 200 OK\r\n', stderr: '' })
|
||||
|
||||
await expect(checkOrcaStarred()).resolves.toBe(true)
|
||||
})
|
||||
|
||||
it('returns false for GitHub 404 not starred responses', async () => {
|
||||
execFileAsyncMock.mockRejectedValueOnce(new Error('HTTP 404: Not Found'))
|
||||
|
||||
await expect(checkOrcaStarred()).resolves.toBe(false)
|
||||
})
|
||||
|
||||
it('returns null when gh exits successfully without response headers', async () => {
|
||||
execFileAsyncMock.mockResolvedValueOnce({ stdout: '', stderr: '' })
|
||||
|
||||
await expect(checkOrcaStarred()).resolves.toBe(null)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getPRForBranch', () => {
|
||||
beforeEach(() => {
|
||||
execFileAsyncMock.mockReset()
|
||||
|
||||
@@ -236,8 +236,16 @@ function isNoPullRequestError(err: unknown): boolean {
|
||||
export async function checkOrcaStarred(): Promise<boolean | null> {
|
||||
await acquire()
|
||||
try {
|
||||
await execFileAsync('gh', ['api', `user/starred/${ORCA_REPO}`], { encoding: 'utf-8' })
|
||||
return true
|
||||
const { stdout, stderr } = await execFileAsync(
|
||||
'gh',
|
||||
['api', '--include', `user/starred/${ORCA_REPO}`],
|
||||
{ encoding: 'utf-8' }
|
||||
)
|
||||
const response = `${stdout ?? ''}\n${stderr ?? ''}`
|
||||
if (/HTTP\/\S+\s+(?:200|204)\b/.test(response)) {
|
||||
return true
|
||||
}
|
||||
return null
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err)
|
||||
// 404 means the user hasn't starred — the only expected "no" answer
|
||||
|
||||
Reference in New Issue
Block a user