Skip to content

Commit 3db0f2b

Browse files
Show an error if not all repos completed successfully
1 parent aa9e2fb commit 3db0f2b

File tree

4 files changed

+113
-4
lines changed

4 files changed

+113
-4
lines changed

extensions/ql-vscode/src/stories/variant-analysis/VariantAnalysisStats.stories.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ StartedWithSkippedRepositories.args = {
5353
skippedRepositoryCount: 3,
5454
};
5555

56+
export const StartedWithFailedAnalyses = Template.bind({});
57+
StartedWithFailedAnalyses.args = {
58+
...Starting.args,
59+
completedRepositoryCount: 5,
60+
successfulRepositoryCount: 3,
61+
};
62+
5663
export const Succeeded = Template.bind({});
5764
Succeeded.args = {
5865
...Started.args,
@@ -73,6 +80,22 @@ SucceededWithSkippedRepositories.args = {
7380
skippedRepositoryCount: 6,
7481
};
7582

83+
export const SucceededWithFailedAnalyses = Template.bind({});
84+
SucceededWithFailedAnalyses.args = {
85+
...Succeeded.args,
86+
totalRepositoryCount: 10,
87+
completedRepositoryCount: 10,
88+
successfulRepositoryCount: 7,
89+
};
90+
91+
export const SucceededWithFailedAnalysesAndSkippedRepositories = Template.bind(
92+
{},
93+
);
94+
SucceededWithFailedAnalysesAndSkippedRepositories.args = {
95+
...SucceededWithFailedAnalyses.args,
96+
skippedRepositoryCount: 6,
97+
};
98+
7699
export const Failed = Template.bind({});
77100
Failed.args = {
78101
...Starting.args,

extensions/ql-vscode/src/view/variant-analysis/VariantAnalysisRepositoriesStats.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,27 @@ export const VariantAnalysisRepositoriesStats = ({
3333
);
3434
}
3535

36+
const showError = successfulRepositoryCount < completedRepositoryCount;
3637
const showWarning = skippedRepositoryCount > 0;
3738

3839
return (
3940
<>
4041
{formatDecimal(successfulRepositoryCount)}/
4142
{formatDecimal(totalRepositoryCount)}
42-
{showWarning && (
43+
{showError && (
44+
<>
45+
<HorizontalSpace size={2} />
46+
<ErrorIcon />
47+
</>
48+
)}
49+
{showWarning && !showError && (
4350
<>
4451
<HorizontalSpace size={2} />
4552
<WarningIcon />
4653
</>
4754
)}
48-
{!showWarning &&
55+
{!showError &&
56+
!showWarning &&
4957
variantAnalysisStatus === VariantAnalysisStatus.Succeeded && (
5058
<>
5159
<HorizontalSpace size={2} />

extensions/ql-vscode/src/view/variant-analysis/VariantAnalysisStats.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,19 @@ export const VariantAnalysisStats = ({
5353
return "Stopped";
5454
}
5555

56+
if (
57+
variantAnalysisStatus === VariantAnalysisStatus.Succeeded &&
58+
successfulRepositoryCount < completedRepositoryCount
59+
) {
60+
return "Some analyses failed";
61+
}
62+
5663
return "Succeeded";
57-
}, [variantAnalysisStatus]);
64+
}, [
65+
variantAnalysisStatus,
66+
successfulRepositoryCount,
67+
completedRepositoryCount,
68+
]);
5869

5970
const duration = useMemo(() => {
6071
if (!completedAt) {

extensions/ql-vscode/src/view/variant-analysis/__tests__/VariantAnalysisStats.spec.tsx

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,53 @@ describe(VariantAnalysisStats.name, () => {
8080
).toBeInTheDocument();
8181
});
8282

83+
it("renders an error icon when the overall variant analysis status is in progress but some analyses failed", () => {
84+
render({
85+
variantAnalysisStatus: VariantAnalysisStatus.InProgress,
86+
completedRepositoryCount: 10,
87+
successfulRepositoryCount: 5,
88+
});
89+
90+
expect(
91+
screen.getByRole("img", {
92+
name: "Error",
93+
}),
94+
).toBeInTheDocument();
95+
});
96+
97+
it("renders an error icon when the overall variant analysis status is succeeded but some analyses failed", () => {
98+
render({
99+
variantAnalysisStatus: VariantAnalysisStatus.Succeeded,
100+
completedRepositoryCount: 10,
101+
successfulRepositoryCount: 5,
102+
});
103+
104+
expect(
105+
screen.getByRole("img", {
106+
name: "Error",
107+
}),
108+
).toBeInTheDocument();
109+
});
110+
111+
it("renders an error icon when some analyses failed but also some repositories were skipped", () => {
112+
render({
113+
completedRepositoryCount: 10,
114+
successfulRepositoryCount: 5,
115+
skippedRepositoryCount: 2,
116+
});
117+
118+
expect(
119+
screen.getByRole("img", {
120+
name: "Error",
121+
}),
122+
).toBeInTheDocument();
123+
expect(
124+
screen.queryByRole("img", {
125+
name: "Warning",
126+
}),
127+
).not.toBeInTheDocument();
128+
});
129+
83130
it("renders a view logs link when the variant analysis status is succeeded", () => {
84131
render({
85132
variantAnalysisStatus: VariantAnalysisStatus.Succeeded,
@@ -108,12 +155,32 @@ describe(VariantAnalysisStats.name, () => {
108155
expect(screen.getByText("Stopped")).toBeInTheDocument();
109156
});
110157

111-
it("renders a succeeded text when the variant analysis status is succeeded", () => {
158+
it("renders a some analyses failed text when the overall variant analysis status is succeeded but not all analyses successful", () => {
159+
render({
160+
variantAnalysisStatus: VariantAnalysisStatus.Succeeded,
161+
completedRepositoryCount: 10,
162+
successfulRepositoryCount: 5,
163+
});
164+
165+
expect(screen.getByText("Some analyses failed")).toBeInTheDocument();
166+
});
167+
168+
it("renders a succeeded text when the variant analysis status is succeeded and successful repository count omitted", () => {
112169
render({ variantAnalysisStatus: VariantAnalysisStatus.Succeeded });
113170

114171
expect(screen.getByText("Succeeded")).toBeInTheDocument();
115172
});
116173

174+
it("renders a succeeded text when the variant analysis status is succeeded and successful repository count equals total repository count", () => {
175+
render({
176+
variantAnalysisStatus: VariantAnalysisStatus.Succeeded,
177+
completedRepositoryCount: 10,
178+
successfulRepositoryCount: 10,
179+
});
180+
181+
expect(screen.getByText("Succeeded")).toBeInTheDocument();
182+
});
183+
117184
it("does not render the duration when the completedAt is not set", () => {
118185
render({ createdAt: new Date("2021-05-01T00:00:00Z") });
119186

0 commit comments

Comments
 (0)