Files
kandev/apps/web/components/linear/linear-import-bar.tsx
T
João Salavisa 5936bb6808 test: add e2e coverage and mock backends for jira and linear integrations (#771)
* test: add e2e coverage and mock backends for jira and linear integrations

Adds in-memory MockClient + MockController for both integrations gated by
KANDEV_MOCK_{JIRA,LINEAR}=true, plus apiClient mock helpers and Playwright
specs covering settings and import flows.

Also fixes ValidatedPopover's TriggerButton silently dropping radix Slot's
onClick handler — the popover wouldn't open under any synthetic-click path
(including Playwright). Spreads `...rest` onto the inner Button.

Reworks the integration cleanup hook in test-base as an auto fixture so it
runs for every test using the imported `test` object, not just tests in the
fixture file itself.

* fix: address PR review feedback on jira/linear mocks and e2e specs

- Fix SetAuthResult docstrings: nil simulates an unconfigured state, not the default success.
- Drop unused JSON tags from doneTransitionCall and setStateCall (Go-only test fixtures).
- Track Linear issue insertion order so SearchIssues returns deterministic results instead of map-iteration shuffle.
- Document filterByJQL precedence at the SearchTickets call site so the all-hits-on-no-match fallback is visible.
- Wait for the post-save auth-health probe before forcing a failure in the seeded-failure tests, eliminating a goroutine race.
- Reorder authMethod precedence in setJiraConfig/setLinearConfig to put the spread first so 'caller wins' reads naturally.

---------

Co-authored-by: Kandev Agent <agent@kandev.dev>
2026-05-02 14:41:36 +01:00

40 lines
1.4 KiB
TypeScript

"use client";
import { IconHexagon } from "@tabler/icons-react";
import { getLinearIssue } from "@/lib/api/domains/linear-api";
import type { LinearIssue } from "@/lib/types/linear";
import { LINEAR_KEY_RE } from "./linear-issue-common";
import { useLinearAvailable } from "@/hooks/domains/linear/use-linear-availability";
import { ValidatedPopover } from "@/components/integrations/validated-popover";
type LinearImportBarProps = {
workspaceId: string | null;
disabled?: boolean;
onImport: (issue: LinearIssue) => void;
};
export function LinearImportBar({ workspaceId, disabled, onImport }: LinearImportBarProps) {
const available = useLinearAvailable(workspaceId);
if (!available || !workspaceId) return null;
return (
<ValidatedPopover
triggerStyle="ghost-icon"
triggerIcon={<IconHexagon className="h-4 w-4" />}
triggerAriaLabel="Import from Linear"
triggerDisabled={disabled}
testIdPrefix="linear-import"
tooltip="Import from Linear issue URL or identifier"
align="start"
headline="Import Linear issue"
placeholder="ENG-123 or paste issue URL"
extractKey={(raw) => raw.toUpperCase().match(LINEAR_KEY_RE)?.[0] ?? null}
validationHint="Paste a Linear issue URL or identifier (ENG-123)"
fetch={(key) => getLinearIssue(workspaceId, key)}
onSuccess={(_key, issue) => onImport(issue)}
submitLabel="Import"
submittingLabel="Loading..."
/>
);
}