mirror of
https://github.com/stablyai/orca.git
synced 2026-11-02 18:17:36 +00:00
* test: remove low-value inventories, passthroughs and redundant cases * style: format test suites after pruning redundant cases * test: remove obsolete workflow and flaky-test references * test: prune deleted builder test from Windows shim allowlist --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
94 lines
2.5 KiB
TypeScript
94 lines
2.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import type { TaskSourceContext } from './task-source-context'
|
|
import type { WorkspaceLinkedItem } from './worktree/types'
|
|
import { isWorkspaceLinkedItemSourceContextMatch } from './workspace-linked-item-source-context'
|
|
|
|
const JIRA_ITEM: WorkspaceLinkedItem = {
|
|
provider: 'jira',
|
|
type: 'issue',
|
|
number: 0,
|
|
title: 'ORCA-123 Link Jira',
|
|
url: 'https://company.atlassian.net/jira/browse/ORCA-123',
|
|
jiraIdentifier: 'ORCA-123'
|
|
}
|
|
|
|
const JIRA_CONTEXT: TaskSourceContext = {
|
|
kind: 'task-source',
|
|
provider: 'jira',
|
|
projectId: 'project-1',
|
|
hostId: 'local',
|
|
providerIdentity: {
|
|
provider: 'jira',
|
|
siteId: 'site-1',
|
|
siteUrl: 'https://company.atlassian.net/jira',
|
|
projectKey: 'ORCA'
|
|
}
|
|
}
|
|
|
|
describe('workspace linked-item source context', () => {
|
|
it('requires Jira key, site URL, site account, and project identity to agree', () => {
|
|
expect(isWorkspaceLinkedItemSourceContextMatch(JIRA_ITEM, JIRA_CONTEXT)).toBe(true)
|
|
expect(
|
|
isWorkspaceLinkedItemSourceContextMatch(JIRA_ITEM, {
|
|
...JIRA_CONTEXT,
|
|
providerIdentity: {
|
|
...JIRA_CONTEXT.providerIdentity!,
|
|
provider: 'jira',
|
|
siteUrl: 'https://other.atlassian.net'
|
|
}
|
|
})
|
|
).toBe(false)
|
|
expect(
|
|
isWorkspaceLinkedItemSourceContextMatch(JIRA_ITEM, {
|
|
...JIRA_CONTEXT,
|
|
providerIdentity: {
|
|
...JIRA_CONTEXT.providerIdentity!,
|
|
provider: 'jira',
|
|
projectKey: 'OTHER'
|
|
}
|
|
})
|
|
).toBe(false)
|
|
expect(
|
|
isWorkspaceLinkedItemSourceContextMatch(
|
|
{ ...JIRA_ITEM, jiraIdentifier: 'ORCA-999' },
|
|
JIRA_CONTEXT
|
|
)
|
|
).toBe(false)
|
|
})
|
|
|
|
it('infers GitHub/GitLab provider when TaskPage seeds omit provider', () => {
|
|
expect(
|
|
isWorkspaceLinkedItemSourceContextMatch(
|
|
{
|
|
type: 'issue',
|
|
number: 42,
|
|
title: 'GitHub issue',
|
|
url: 'https://github.com/acme/repo/issues/42'
|
|
},
|
|
{
|
|
kind: 'task-source',
|
|
provider: 'github',
|
|
projectId: 'project-1',
|
|
hostId: 'local'
|
|
}
|
|
)
|
|
).toBe(true)
|
|
expect(
|
|
isWorkspaceLinkedItemSourceContextMatch(
|
|
{
|
|
type: 'mr',
|
|
number: 7,
|
|
title: 'GitLab MR',
|
|
url: 'https://gitlab.com/acme/repo/-/merge_requests/7'
|
|
},
|
|
{
|
|
kind: 'task-source',
|
|
provider: 'gitlab',
|
|
projectId: 'project-1',
|
|
hostId: 'local'
|
|
}
|
|
)
|
|
).toBe(true)
|
|
})
|
|
})
|