Skip to content

Commit 8b33e20

Browse files
committed
feat(GAT-3104): Show federation level error when present
Shows 'Disabled on error' to make it clear it has been disabled due to error + shows the error message
1 parent a7bf2c5 commit 8b33e20

6 files changed

Lines changed: 82 additions & 2 deletions

File tree

mocks/data/integration/v1/integration.data.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const generateIntegrationV1 = (data = {}): Integration => {
3232
run_time_hour: faker.datatype.number(),
3333
enabled: faker.datatype.boolean(),
3434
tested: faker.datatype.boolean(),
35+
error: false,
36+
error_text: null,
3537
notifications: [],
3638
id: faker.datatype.number(),
3739
...data,

src/app/[locale]/account/team/[teamId]/(withLeftNav)/integrations/integration/list/[intId]/components/EditIntegrationForm/EditIntegrationForm.test.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,39 @@ describe("EditIntegrationForm", () => {
3737
expect(allSelects[0]).toHaveClass("Mui-disabled");
3838
});
3939

40+
it("should show an error alert with the failure reason when the integration has failed", async () => {
41+
const mockIntegration = {
42+
...integrationV1,
43+
id: 2,
44+
error: true,
45+
error_text: "Connection timed out",
46+
};
47+
server.use(getIntegrationV1({ data: mockIntegration }));
48+
49+
await act(() => render(<EditIntegrationForm />));
50+
51+
expect(
52+
await screen.findByText("Connection timed out")
53+
).toBeInTheDocument();
54+
});
55+
56+
it("should not show an error alert when the integration has not failed", async () => {
57+
const mockIntegration = {
58+
...integrationV1,
59+
id: 2,
60+
error: false,
61+
error_text: null,
62+
};
63+
server.use(getIntegrationV1({ data: mockIntegration }));
64+
65+
await act(() => render(<EditIntegrationForm />));
66+
67+
expect(
68+
await screen.findByDisplayValue(mockIntegration.endpoint_baseurl)
69+
).toBeInTheDocument();
70+
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
71+
});
72+
4073
it("should run the 'Run now' button through Run now -> Running -> Complete -> Run now", async () => {
4174
const mockIntegration = {
4275
...integrationV1,

src/app/[locale]/account/team/[teamId]/(withLeftNav)/integrations/integration/list/[intId]/components/EditIntegrationForm/EditIntegrationForm.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useEffect, useMemo, useRef, useState } from "react";
44
import { useForm } from "react-hook-form";
55
import { yupResolver } from "@hookform/resolvers/yup";
6-
import { Stack, Typography } from "@mui/material";
6+
import { Alert, Stack, Typography } from "@mui/material";
77
import { pick } from "lodash";
88
import { useTranslations } from "next-intl";
99
import { useParams, useRouter } from "next/navigation";
@@ -277,6 +277,9 @@ const EditIntegrationForm = () => {
277277
display: "flex",
278278
flexDirection: "column",
279279
}}>
280+
{integration?.error && (
281+
<Alert severity="error">{integration.error_text}</Alert>
282+
)}
280283
<Paper sx={{ p: 1 }}>
281284
<Box sx={{ display: "flex", justifyContent: "center" }}>
282285
<Stack

src/app/[locale]/account/team/[teamId]/(withLeftNav)/integrations/integration/list/components/IntegrationListItem/IntegrationListItem.test.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,35 @@ describe("IntegrationListItem", () => {
6464
expect(screen.getByText("Disabled")).toBeInTheDocument();
6565
});
6666

67+
it("should show a 'Disabled on error' status and the failure reason when the integration has failed", async () => {
68+
render(
69+
<IntegrationListItem
70+
index={1}
71+
integration={{
72+
...integration,
73+
enabled: false,
74+
error: true,
75+
error_text: "Connection timed out",
76+
}}
77+
/>
78+
);
79+
80+
expect(screen.getByText("Disabled on error")).toBeInTheDocument();
81+
expect(screen.getByText("Error:")).toBeInTheDocument();
82+
expect(screen.getByText("Connection timed out")).toBeInTheDocument();
83+
});
84+
85+
it("should not show an Error row when the integration has not failed", async () => {
86+
render(
87+
<IntegrationListItem
88+
index={1}
89+
integration={{ ...integration, error: false, error_text: null }}
90+
/>
91+
);
92+
93+
expect(screen.queryByText("Error:")).not.toBeInTheDocument();
94+
});
95+
6796
it("should link the Edit action to the integration's detail page", async () => {
6897
render(<IntegrationListItem index={1} integration={integration} />);
6998

src/app/[locale]/account/team/[teamId]/(withLeftNav)/integrations/integration/list/components/IntegrationListItem/IntegrationListItem.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ const IntegrationListItem = ({
122122
<Typography sx={{ fontWeight: "bold", fontSize: 14 }}>
123123
Integration {index}
124124
</Typography>
125-
{integration.enabled ? (
125+
{integration.error ? (
126+
<Chip label="Disabled on error" color="error" />
127+
) : integration.enabled ? (
126128
<Chip label="Enabled" color="success" />
127129
) : (
128130
<Chip label="Disabled" color="error" />
@@ -150,6 +152,15 @@ const IntegrationListItem = ({
150152
)
151153
: "Never",
152154
},
155+
...(integration.error
156+
? [
157+
{
158+
key: "Error",
159+
value: integration.error_text,
160+
color: colors.red700,
161+
},
162+
]
163+
: []),
153164
]}
154165
/>
155166
</Box>

src/interfaces/Integration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ interface Integration {
1717
enabled: boolean;
1818
tested: boolean;
1919
last_run_at: string | null;
20+
error: boolean;
21+
error_text: string | null;
2022
notifications: Notification[] | undefined;
2123
}
2224

0 commit comments

Comments
 (0)