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

DEVPROD-1135 Add timeout test status #2272

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/constants/test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
import { Variant } from "@leafygreen-ui/badge";
import { TestStatus } from "types/test";

export const statusToBadgeColor = {
[TestStatus.Pass]: Variant.Green,
[TestStatus.Fail]: Variant.Red,
[TestStatus.SilentFail]: Variant.Blue,
[TestStatus.Skip]: Variant.Yellow,
};

export const statusCopy = {
[TestStatus.Pass]: "Pass",
[TestStatus.Fail]: "Fail",
[TestStatus.Skip]: "Skip",
[TestStatus.SilentFail]: "Silent Fail",
};

export const testStatusesFilterTreeData = [
{
title: "All",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Styled from "@emotion/styled";
import { size } from "constants/tokens";
import { CustomMeta, CustomStoryObj } from "test_utils/types";
import { TestStatus } from "types/test";
import TestStatusBadge from ".";

export default {
component: TestStatusBadge,
} satisfies CustomMeta<typeof TestStatusBadge>;

export const Default: CustomStoryObj<typeof TestStatusBadge> = {
render: (args) => (
<Container>
{Object.values(TestStatus).map((status) => (
<TestStatusBadge {...args} status={status} key={status} />
))}
</Container>
),
argTypes: {},
args: {},
};

const Container = Styled.div`
display: flex;
gap: ${size.s};
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Snapshot Tests TestStatusBadge.stories Default 1`] = `
<div>
<div
class="css-8cvf0s-Container et5ujl80"
>
<div
class="leafygreen-ui-ud6teo"
>
Fail
</div>
<div
class="leafygreen-ui-ixbeze"
>
Skip
</div>
<div
class="leafygreen-ui-1qtf7xy"
>
Silent Fail
</div>
<div
class="leafygreen-ui-n4itms"
>
Pass
</div>
<div
class="leafygreen-ui-ohl2hc"
>
all
</div>
<div
class="leafygreen-ui-ud6teo"
>
Timeout
</div>
</div>
</div>
`;
18 changes: 18 additions & 0 deletions src/pages/task/taskTabs/testsTable/TestStatusBadge/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Variant } from "@leafygreen-ui/badge";
import { TestStatus } from "types/test";

export const statusToBadgeColor = {
[TestStatus.Pass]: Variant.Green,
[TestStatus.Fail]: Variant.Red,
[TestStatus.SilentFail]: Variant.Blue,
[TestStatus.Skip]: Variant.Yellow,
[TestStatus.Timeout]: Variant.Red,
};

export const statusCopy = {
[TestStatus.Pass]: "Pass",
[TestStatus.Fail]: "Fail",
[TestStatus.Skip]: "Skip",
[TestStatus.SilentFail]: "Silent Fail",
[TestStatus.Timeout]: "Timeout",
};
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import Badge, { Variant } from "@leafygreen-ui/badge";
import { statusToBadgeColor, statusCopy } from "constants/test";
import { TestStatus } from "types/test";
import { statusToBadgeColor, statusCopy } from "./constants";

interface TestStatusBadgeProps {
status: string;
status: TestStatus;
}

export const TestStatusBadge: React.FC<TestStatusBadgeProps> = ({ status }) => (
const TestStatusBadge: React.FC<TestStatusBadgeProps> = ({ status }) => (
<Badge
variant={statusToBadgeColor[status?.toLowerCase()] || Variant.LightGray}
key={status}
>
{statusCopy[status?.toLowerCase()] || status}
</Badge>
);

export default TestStatusBadge;
2 changes: 1 addition & 1 deletion src/pages/task/taskTabs/testsTable/getColumnsTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { testStatusesFilterTreeData } from "constants/test";
import { TestSortCategory, TaskQuery } from "gql/generated/types";
import { string } from "utils";
import { LogsColumn } from "./LogsColumn";
import { TestStatusBadge } from "./TestStatusBadge";
import TestStatusBadge from "./TestStatusBadge";

const { msToDuration } = string;

Expand Down
1 change: 1 addition & 0 deletions src/types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export enum TestStatus {
SilentFail = "silentfail",
Pass = "pass",
All = "all",
Timeout = "timeout",
}
Loading