Files
Tom Moor 6d7cd455e9 chore: Decouple core plugins (#14340)
* chore: Move plugin-specific integration code into plugins

Core no longer imports from or names the settings of individual plugins.
Plugins now register mention providers, issue status icons, instance URLs,
settings keys, settings and import schemas, and OAuth clients through hooks.

* fix: Recompute embed instance URLs after plugins load and match legacy issue icons by URL

* fix: Skip logo upload jobs queued without a settings path

* chore: Choose issue status icons from the unfurl state
2026-11-02 19:42:48 -05:00

54 lines
1.8 KiB
TypeScript

import { IntegrationService, MentionType } from "@shared/types";
import type Integration from "~/models/Integration";
import { determineMentionType, isURLMentionable } from "./mention";
import { Hook, PluginManager } from "./PluginManager";
const buildIntegration = (service: IntegrationService) =>
({ service, settings: {} }) as unknown as Integration;
describe("mention", () => {
beforeAll(() => {
PluginManager.add({
id: "test-mention-provider",
name: "Test mention provider",
type: Hook.MentionProvider,
value: {
service: IntegrationService.GitHub,
isMentionable: (url) => url.hostname === "example.com",
mentionType: (url) =>
url.pathname.startsWith("/issues/") ? MentionType.Issue : undefined,
},
});
});
it("uses the provider registered for the integration service", () => {
const integration = buildIntegration(IntegrationService.GitHub);
const url = new URL("https://example.com/issues/1");
expect(isURLMentionable({ url, integration })).toBe(true);
expect(determineMentionType({ url, integration })).toBe(MentionType.Issue);
});
it("returns the provider result for URLs it does not recognize", () => {
const integration = buildIntegration(IntegrationService.GitHub);
expect(
isURLMentionable({ url: new URL("https://other.com/"), integration })
).toBe(false);
expect(
determineMentionType({
url: new URL("https://example.com/about"),
integration,
})
).toBeUndefined();
});
it("does not mention URLs for services without a provider", () => {
const integration = buildIntegration(IntegrationService.Slack);
const url = new URL("https://example.com/issues/1");
expect(isURLMentionable({ url, integration })).toBe(false);
expect(determineMentionType({ url, integration })).toBeUndefined();
});
});