feat: enhance onboarding
This commit is contained in:
1 parent
ece6757979
commit
775ae0147c
23 files changed
+415
-170
No files matched your search
@@ -411,9 +411,10 @@ export const onboardRouter = createTRPCRouter({
|
||||
throw new TRPCError({ code: "BAD_REQUEST", message: error.message });
|
||||
});
|
||||
if (!result.success) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
message: `Unable to connect to ${integration.name}: ${result.error.message}`,
|
||||
logger.warn("Creating onboarding integration after its connection test failed", {
|
||||
name: integration.name,
|
||||
kind: integration.kind,
|
||||
error: result.error.message,
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -528,6 +528,37 @@ describe("onboard.completeSetup", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("creates a selected integration when its connection test fails", async () => {
|
||||
const db = createDb();
|
||||
const claimToken = await seedOnboardingAsync(db);
|
||||
await seedBoardAsync(db, { boardId: "target" });
|
||||
const input = completionInput("target");
|
||||
input.integrations = [
|
||||
{
|
||||
sourceId: "manual:sonarr",
|
||||
name: "Sonarr",
|
||||
url: "http://sonarr:8989",
|
||||
kind: "sonarr",
|
||||
secrets: [{ kind: "apiKey", value: "invalid" }],
|
||||
},
|
||||
];
|
||||
const testConnection = vi
|
||||
.spyOn(integrationConnection, "testConnectionAsync")
|
||||
.mockResolvedValue({ success: false, error: new Error("Connection refused") as never });
|
||||
|
||||
try {
|
||||
await expect(createCaller(db, claimToken).completeSetup(input)).resolves.toMatchObject({ boardId: "target" });
|
||||
expect(
|
||||
await db.query.integrations.findFirst({
|
||||
where: eq(integrations.id, stableIntegrationIdForSource("manual:sonarr")),
|
||||
}),
|
||||
).toMatchObject({ name: "Sonarr", kind: "sonarr" });
|
||||
expect(await db.query.onboarding.findFirst()).toMatchObject({ step: "finish" });
|
||||
} finally {
|
||||
testConnection.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it("rolls draft records back with board writes and reuses stable IDs on retry", async () => {
|
||||
const db = createDb();
|
||||
const claimToken = await seedOnboardingAsync(db);
|
||||
|
||||
Reference in new issue
Block a user