fix: address mobile dashboard review findings

This commit is contained in:
ajnart committed 2026-08-14 11:32:09 +02:00
1 parent c1efaabd36
commit b4404113c4
11 files changed
+101 -5

No files matched your search

@@ -44,6 +44,7 @@ export const beszelRouter = createTRPCRouter({
};
},
{
throwOnAllFailure: true,
fallback: (integration, error) => ({
integrationId: integration.id,
integrationName: integration.name,
@@ -116,6 +117,7 @@ export const beszelRouter = createTRPCRouter({
};
},
{
throwOnAllFailure: true,
fallback: (integration, error) => ({
integrationId: integration.id,
integrationName: integration.name,
@@ -23,6 +23,22 @@ describe("settleIntegrationQueries", () => {
expect(results).toEqual(["Second"]);
});
it("retains fallback and successful results for a partial failure", async () => {
const results = await settleIntegrationQueries(
integrations,
vi.fn(async (integration) => {
if (integration.id === "first") throw new Error("offline");
return integration.name;
}),
{
throwOnAllFailure: true,
fallback: (integration) => `${integration.name} unavailable`,
},
);
expect(results).toEqual(["First unavailable", "Second"]);
});
it("throws when every integration fails and throwOnAllFailure is enabled", async () => {
await expect(
settleIntegrationQueries(
@@ -35,6 +51,21 @@ describe("settleIntegrationQueries", () => {
).rejects.toThrow("offline");
});
it("throws on total failure even when fallbacks are configured", async () => {
await expect(
settleIntegrationQueries(
integrations,
vi.fn(async () => {
throw new Error("offline");
}),
{
throwOnAllFailure: true,
fallback: (integration) => `${integration.name} unavailable`,
},
),
).rejects.toThrow("offline");
});
it("does not treat an empty integration list as a failure", async () => {
await expect(
settleIntegrationQueries(