feat(mobile): combine PR sidebar and checks parity (#5641)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Orca <help@stably.ai> Co-authored-by: gsxdsm <gsxdsm@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
Orca
gsxdsm
parent
a61c549d37
commit
c9bd61376f
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parseGitHubPrReference } from './github-pr-link-parse'
|
||||
|
||||
describe('parseGitHubPrReference', () => {
|
||||
it('parses bare and #-prefixed numbers', () => {
|
||||
expect(parseGitHubPrReference('123')).toBe(123)
|
||||
expect(parseGitHubPrReference('#123')).toBe(123)
|
||||
expect(parseGitHubPrReference(' #45 ')).toBe(45)
|
||||
})
|
||||
|
||||
it('parses GitHub pull and issue URLs', () => {
|
||||
expect(parseGitHubPrReference('https://github.com/owner/repo/pull/678')).toBe(678)
|
||||
expect(parseGitHubPrReference('https://github.com/o/r/issues/9')).toBe(9)
|
||||
expect(parseGitHubPrReference('https://github.com/o/r/pull/678/files')).toBe(678)
|
||||
})
|
||||
|
||||
it('rejects empty, non-numeric, non-GitHub, and non-positive input', () => {
|
||||
expect(parseGitHubPrReference('')).toBeNull()
|
||||
expect(parseGitHubPrReference('abc')).toBeNull()
|
||||
expect(parseGitHubPrReference('0')).toBeNull()
|
||||
expect(parseGitHubPrReference('-5')).toBeNull()
|
||||
expect(parseGitHubPrReference('https://example.com/foo/bar')).toBeNull()
|
||||
expect(parseGitHubPrReference('ftp://github.com/o/r/pull/1')).toBeNull()
|
||||
})
|
||||
|
||||
it('rejects a non-GitHub host even when the path looks like a PR', () => {
|
||||
// Why: this parser is GitHub-specific; a look-alike host must not parse.
|
||||
expect(parseGitHubPrReference('https://example.com/owner/repo/pull/7')).toBeNull()
|
||||
expect(parseGitHubPrReference('https://gitlab.com/owner/repo/pull/7')).toBeNull()
|
||||
expect(parseGitHubPrReference('https://notgithub.com/o/r/pull/1')).toBeNull()
|
||||
expect(parseGitHubPrReference('https://github.com.evil.test/o/r/pull/7')).toBeNull()
|
||||
})
|
||||
|
||||
it('accepts github.com and enterprise *.github.com subdomains', () => {
|
||||
expect(parseGitHubPrReference('https://github.com/o/r/pull/12')).toBe(12)
|
||||
expect(parseGitHubPrReference('https://GitHub.com/o/r/pull/12')).toBe(12)
|
||||
expect(parseGitHubPrReference('https://www.github.com/o/r/pull/12')).toBe(12)
|
||||
expect(parseGitHubPrReference('https://corp.github.com/o/r/pull/34')).toBe(34)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user