Files
orca/src/shared/workspace-linked-item-source-context.test.ts
T
OrcaWinandOrcaWin de93f326ea test: remove low-value inventories, passthroughs and redundant cases (#33796)
* 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>
2026-10-25 23:41:49 -07:00

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)
})
})