mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
396ceb34bb
Linear's new Diffs feature exposes pull request reviews at
linear.review/{owner}/{repo}/pull/{number}, mirroring GitHub pull request
urls. Pasting such a url into a document can now be converted to a mention
that renders with pull request state, matching the GitHub plugin.
Linear's public API does not expose pull requests directly yet, so the
unfurl reads the pull request data Linear syncs onto the attachments of
linked issues via the attachmentsForURL query.
https://claude.ai/code/session_01F9cLTRp6WsFHDxGtd5euGW
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
import { UnfurlResourceType } from "@shared/types";
|
|
import { Linear } from "./linear";
|
|
|
|
describe("Linear.parseUrl", () => {
|
|
it("should parse an issue url", () => {
|
|
expect(
|
|
Linear.parseUrl("https://linear.app/acme/issue/ACM-123/fix-the-thing")
|
|
).toEqual({
|
|
workspaceKey: "acme",
|
|
type: UnfurlResourceType.Issue,
|
|
id: "ACM-123",
|
|
name: "fix-the-thing",
|
|
});
|
|
});
|
|
|
|
it("should parse a project url", () => {
|
|
expect(
|
|
Linear.parseUrl("https://linear.app/acme/project/my-project-abc123")
|
|
).toEqual({
|
|
workspaceKey: "acme",
|
|
type: UnfurlResourceType.Project,
|
|
id: "my-project-abc123",
|
|
name: undefined,
|
|
});
|
|
});
|
|
|
|
it("should parse a review url", () => {
|
|
expect(
|
|
Linear.parseUrl("https://linear.review/outline/outline/pull/1234")
|
|
).toEqual({
|
|
type: UnfurlResourceType.PR,
|
|
owner: "outline",
|
|
repo: "outline",
|
|
number: 1234,
|
|
});
|
|
});
|
|
|
|
it("should not parse a review url with an invalid pull request number", () => {
|
|
expect(
|
|
Linear.parseUrl("https://linear.review/outline/outline/pull/abc")
|
|
).toBeUndefined();
|
|
});
|
|
|
|
it("should not parse a review url missing path segments", () => {
|
|
expect(Linear.parseUrl("https://linear.review/outline")).toBeUndefined();
|
|
expect(
|
|
Linear.parseUrl("https://linear.review/outline/outline/issues/123")
|
|
).toBeUndefined();
|
|
});
|
|
|
|
it("should not parse an in-app review url", () => {
|
|
expect(
|
|
Linear.parseUrl("https://linear.app/acme/review/fix-the-thing-abc123")
|
|
).toBeUndefined();
|
|
});
|
|
|
|
it("should not parse urls from other hosts", () => {
|
|
expect(
|
|
Linear.parseUrl("https://github.com/outline/outline/pull/1234")
|
|
).toBeUndefined();
|
|
});
|
|
|
|
it("should not parse invalid urls", () => {
|
|
expect(Linear.parseUrl("not a url")).toBeUndefined();
|
|
});
|
|
});
|