Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Query hasCedarResults instead of failedTestCount for determining if a…
Browse files Browse the repository at this point in the history
… task has test results
  • Loading branch information
khelif96 committed Jan 24, 2024
1 parent 014d0cb commit aa7a343
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2515,6 +2515,7 @@ export type Task = {
generateTask?: Maybe<Scalars["Boolean"]["output"]>;
generatedBy?: Maybe<Scalars["String"]["output"]>;
generatedByName?: Maybe<Scalars["String"]["output"]>;
hasCedarResults: Scalars["Boolean"]["output"];
hostId?: Maybe<Scalars["String"]["output"]>;
id: Scalars["String"]["output"];
ingestTime?: Maybe<Scalars["Time"]["output"]>;
Expand Down Expand Up @@ -6336,7 +6337,7 @@ export type MainlineCommitsQuery = {
__typename?: "Task";
displayName: string;
execution: number;
failedTestCount: number;
hasCedarResults: boolean;
id: string;
status: string;
timeTaken?: number | null;
Expand Down
2 changes: 1 addition & 1 deletion src/gql/queries/mainline-commits.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ query MainlineCommits(
tasks {
displayName
execution
failedTestCount
hasCedarResults
id
status
timeTaken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,18 @@ const tasks = [
id: "1",
status: "failed",
displayName: "One",
hasCedarResults: true,
},
{
id: "2",
status: "success",
displayName: "Two",
hasCedarResults: true,
},
{
id: "3",
status: "success",
displayName: "Three",
hasCedarResults: true,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Default: CustomStoryObj<typeof WaterfallTaskStatusIcon> = {
taskId: "task-id",
identifier: "ubuntu1604",
status: "failed",
failedTestCount: 5,
hasCedarResults: true,
},
argTypes: {
status: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ const props = {
jest.mock("../../utils");

const Content = ({
failedTestCount = 0,
hasCedarResults = false,
status,
}: {
status: string;
failedTestCount?: number;
hasCedarResults: boolean;
}) => (
<MockedProvider mocks={[getTooltipQueryMock]}>
<WaterfallTaskStatusIcon
{...props}
status={status}
failedTestCount={failedTestCount}
hasCedarResults={hasCedarResults}
/>
</MockedProvider>
);
describe("waterfallTaskStatusIcon", () => {
it("tooltip should contain task name, duration, list of failing test names and additonal test count", async () => {
const user = userEvent.setup();
render(<Content status="failed" failedTestCount={1} />);
render(<Content status="failed" hasCedarResults />);
await user.hover(screen.queryByDataCy("waterfall-task-status-icon"));
await waitFor(() => {
expect(
Expand All @@ -67,7 +67,7 @@ describe("waterfallTaskStatusIcon", () => {
});

it("icon should link to task page", async () => {
render(<Content status="failed" />);
render(<Content status="failed" hasCedarResults />);
await waitFor(() => {
expect(
screen.getByDataCy("waterfall-task-status-icon"),
Expand All @@ -89,7 +89,7 @@ describe("waterfallTaskStatusIcon", () => {
);
(removeGlobalHighlightStyle as jest.Mock).mockImplementationOnce(() => {});

render(<Content status="failed" failedTestCount={1} />);
render(<Content status="failed" hasCedarResults />);
await user.hover(screen.queryByDataCy("waterfall-task-status-icon"));
await waitFor(() => {
expect(injectGlobalHighlightStyle).toHaveBeenCalledTimes(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ interface WaterfallTaskStatusIconProps {
displayName: string;
timeTaken?: number;
identifier: string;
failedTestCount?: number;
hasCedarResults: boolean;
}

let timeout;
export const WaterfallTaskStatusIcon: React.FC<
WaterfallTaskStatusIconProps
> = ({
displayName,
failedTestCount,
hasCedarResults,
identifier,
status,
taskId,
Expand All @@ -60,7 +60,7 @@ export const WaterfallTaskStatusIcon: React.FC<
injectGlobalHighlightStyle(identifier);
timeout = setTimeout(() => {
// Only query failing test names if the task has failed.
if (isFailedTaskStatus(status) && failedTestCount > 0) {
if (isFailedTaskStatus(status) && hasCedarResults) {
loadData();
}
}, 600);
Expand Down
6 changes: 3 additions & 3 deletions src/pages/commits/ActiveCommits/BuildVariantCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type taskList = {
status: string;
displayName: string;
timeTaken?: number;
failedTestCount?: number;
hasCedarResults: boolean;
}[];
interface Props {
variant: string;
Expand Down Expand Up @@ -96,15 +96,15 @@ const RenderTaskIcons: React.FC<RenderTaskIconsProps> = ({ tasks, variant }) =>
onMouseEnter={() => injectGlobalDimStyle()}
onMouseLeave={() => removeGlobalDimStyle()}
>
{tasks.map(({ displayName, failedTestCount, id, status, timeTaken }) => (
{tasks.map(({ displayName, hasCedarResults, id, status, timeTaken }) => (
<WaterfallTaskStatusIcon
key={id}
taskId={id}
status={status}
displayName={displayName}
timeTaken={timeTaken}
identifier={`${variant}-${displayName}`}
failedTestCount={failedTestCount}
hasCedarResults={hasCedarResults}
/>
))}
</IconContainer>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/commits/ProjectHealth.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const generateTasks = (count: number) =>
id: `task_${index}`,
status: randomStatus(index),
execution: 0,
failedTestCount: 1,
hasCedarResults: true,
}));

/**
Expand Down
6 changes: 3 additions & 3 deletions src/pages/commits/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const buildVariant1 = {
id: "auth",
execution: 0,
displayName: "auth",
failedTestCount: 0,
hasCedarResults: false,
},
],
};
Expand All @@ -26,7 +26,7 @@ const buildVariant2 = {
id: "benchmarks",
execution: 0,
displayName: "benchmarks",
failedTestCount: 0,
hasCedarResults: false,
},
],
};
Expand All @@ -40,7 +40,7 @@ const buildVariant3 = {
id: "fuzzer",
execution: 0,
displayName: "fuzzer",
failedTestCount: 1,
hasCedarResults: true,
},
],
};
Expand Down

0 comments on commit aa7a343

Please sign in to comment.