test(onboarding): cover integration checks
This commit is contained in:
1 parent
dd707bed7e
commit
ece6757979
2 files changed
+54
-20
No files matched your search
@@ -152,6 +152,38 @@ const seedBoardAsync = async (
|
||||
return { layoutId, sectionId };
|
||||
};
|
||||
|
||||
describe("onboard.testIntegration", () => {
|
||||
it("tests an onboarding draft without persisting it", async () => {
|
||||
const db = createDb();
|
||||
const claimToken = await seedOnboardingAsync(db);
|
||||
const testConnection = vi.spyOn(integrationConnection, "testConnectionAsync").mockResolvedValue({ success: true });
|
||||
|
||||
try {
|
||||
await expect(
|
||||
createCaller(db, claimToken).testIntegration({
|
||||
sourceId: "manual:sonarr",
|
||||
name: "Sonarr",
|
||||
url: "http://sonarr:8989",
|
||||
kind: "sonarr",
|
||||
secrets: [{ kind: "apiKey", value: "secret" }],
|
||||
}),
|
||||
).resolves.toEqual({ success: true });
|
||||
expect(testConnection).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
id: stableIntegrationIdForSource("manual:sonarr"),
|
||||
name: "Sonarr",
|
||||
url: "http://sonarr:8989",
|
||||
kind: "sonarr",
|
||||
}),
|
||||
);
|
||||
expect(await db.query.integrations.findMany()).toHaveLength(0);
|
||||
expect(await db.query.integrationSecrets.findMany()).toHaveLength(0);
|
||||
} finally {
|
||||
testConnection.mockRestore();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("onboard.completeSetup", () => {
|
||||
beforeEach(() => {
|
||||
listDiscoveredContainersAsync.mockReset();
|
||||
|
||||
@@ -1312,16 +1312,35 @@ const IntegrationEditor = ({
|
||||
{t("noCredentialsDescription")}
|
||||
</Text>
|
||||
) : null}
|
||||
<Group justify="flex-end">
|
||||
{apiKeyUrl ? (
|
||||
<Anchor href={apiKeyUrl} target="_blank" rel="noopener noreferrer" size="sm">
|
||||
<Group gap={4}>
|
||||
<IconKey size={14} />
|
||||
{t("getApiKey")}
|
||||
<IconExternalLink size={14} />
|
||||
</Group>
|
||||
</Anchor>
|
||||
) : null}
|
||||
<Group justify="space-between" align="center" wrap="wrap">
|
||||
{documentationUrl ? (
|
||||
<Anchor href={documentationUrl} target="_blank" rel="noopener noreferrer" size="sm">
|
||||
<Group gap={4}>
|
||||
<IconExternalLink size={14} />
|
||||
{t("openGuide")}
|
||||
</Group>
|
||||
</Anchor>
|
||||
) : (
|
||||
<span />
|
||||
)}
|
||||
<Button
|
||||
variant="default"
|
||||
size="compact-sm"
|
||||
size="xs"
|
||||
disabled={needsConfiguration}
|
||||
loading={testConnection.isPending}
|
||||
color={
|
||||
testConnection.data?.success ? "green" : testConnection.data?.success === false ? "red" : undefined
|
||||
}
|
||||
leftSection={testConnection.data?.success ? <IconCheck size={15} /> : <IconPlugConnected size={15} />}
|
||||
leftSection={testConnection.data?.success ? <IconCheck size={14} /> : <IconPlugConnected size={14} />}
|
||||
onClick={() =>
|
||||
testConnection.mutate({
|
||||
sourceId: draft.sourceId ?? draft.id,
|
||||
@@ -1335,23 +1354,6 @@ const IntegrationEditor = ({
|
||||
{t("testConnection")}
|
||||
</Button>
|
||||
</Group>
|
||||
{apiKeyUrl ? (
|
||||
<Anchor href={apiKeyUrl} target="_blank" rel="noopener noreferrer" size="sm">
|
||||
<Group gap={4}>
|
||||
<IconKey size={14} />
|
||||
{t("getApiKey")}
|
||||
<IconExternalLink size={14} />
|
||||
</Group>
|
||||
</Anchor>
|
||||
) : null}
|
||||
{documentationUrl ? (
|
||||
<Anchor href={documentationUrl} target="_blank" rel="noopener noreferrer" size="sm">
|
||||
<Group gap={4}>
|
||||
<IconExternalLink size={14} />
|
||||
{t("openGuide")}
|
||||
</Group>
|
||||
</Anchor>
|
||||
) : null}
|
||||
</Stack>
|
||||
</Accordion.Panel>
|
||||
</Accordion.Item>
|
||||
|
||||
Reference in new issue
Block a user