Files
orca/src/shared/workspace-linked-item-source-context.test.ts
T
Jinjing 74563b6498 feat(jira): link Jira issues from the workspace create dialog (#11296)
* Link Jira issues from workspace create dialog

Add Jira issue linking to workspace creation, matching existing GitHub and Linear workflows. Users can paste Jira issue URLs in the smart name field to auto-populate workspace names and link the issue to the created workspace/worktree.

Linked Jira issues appear on workspace cards via the new 'jira-issue' card property. Implements cancellable searches and summary reads to prevent stalled requests from blocking the shared Jira pool. Persists paired issue + source context metadata with validation of provider/site identity.

Fixes git-username rate-limit handling to reject malformed JSON responses so garbage never becomes branch prefixes.

* feat(jira): link issues during workspace creation

- Display linked Jira issues on worktree cards
- Fetch issue summaries and timestamps via Jira API
- Gate Jira linking behind runtime capability check
- Preserve user-typed names during async lookups

* Enforce git check-ref-format rules in login validation

Extend isBranchSafeHostedLogin to reject usernames that git rejects as
invalid branch components: trailing dots, consecutive dots, and .lock
suffix. Prevents invalid branch names from login usernames.

* Enforce filesystem filename cap for branch-safe logins

Loose refs store logins as single filenames, so the real constraint is the
255-byte filesystem cap, not git check-ref-format rules. This allows longer
provider-agnostic logins while staying platform-safe.
2026-07-29 19:50:18 -07:00

114 lines
3.0 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import type { TaskSourceContext } from './task-source-context'
import type { WorkspaceLinkedItem } from './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('keeps provider matching sufficient for non-Jira items', () => {
expect(
isWorkspaceLinkedItemSourceContextMatch(
{
provider: 'linear',
type: 'issue',
number: 0,
title: 'Linear item',
url: 'https://linear.app/acme/issue/ENG-1/item'
},
{
kind: 'task-source',
provider: 'linear',
projectId: 'project-1',
hostId: 'local'
}
)
).toBe(true)
})
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)
})
})