Set test run status icon

This commit is contained in:
Takeshi Kimata
2024-04-21 19:26:40 +09:00
parent 8f4ca3d882
commit 99923eea9d
4 changed files with 51 additions and 15 deletions

View File

@@ -15,7 +15,16 @@ import {
Selection, Selection,
SortDescriptor, SortDescriptor,
} from "@nextui-org/react"; } from "@nextui-org/react";
import { ChevronDown, MoreVertical, CopyPlus, CopyMinus } from "lucide-react"; import {
ChevronDown,
MoreVertical,
CopyPlus,
CopyMinus,
Circle,
CircleCheck,
CircleX,
CircleSlash2
} from "lucide-react";
import { priorities, testRunCaseStatus } from "@/config/selection"; import { priorities, testRunCaseStatus } from "@/config/selection";
import { CaseType } from "@/types/case"; import { CaseType } from "@/types/case";
@@ -60,6 +69,18 @@ export default function TestCaseSelector({
const notIncludedCaseClass = "text-neutral-200 dark:text-neutral-600"; const notIncludedCaseClass = "text-neutral-200 dark:text-neutral-600";
const chipBaseClass = "border-none gap-1 text-default-600"; const chipBaseClass = "border-none gap-1 text-default-600";
const renderStatusIcon = (uid: string) => {
if (uid === "untested") {
return <Circle size={16} color="#d4d4d8"/>;
} else if (uid === "passed") {
return <CircleCheck size={16} color="#17c964" />;
} else if (uid === "failed") {
return <CircleX size={16} color="#f31260" />;
} else if (uid === "skipped") {
return <CircleSlash2 size={16} color="#d4d4d8" />;
}
};
const renderCell = (testCase: CaseType, columnKey: Key) => { const renderCell = (testCase: CaseType, columnKey: Key) => {
const cellValue = testCase[columnKey as keyof CaseType]; const cellValue = testCase[columnKey as keyof CaseType];
const isIncluded = testCase.isIncluded; const isIncluded = testCase.isIncluded;
@@ -86,15 +107,23 @@ export default function TestCaseSelector({
size="sm" size="sm"
variant="light" variant="light"
isDisabled={!isIncluded} isDisabled={!isIncluded}
endContent={isIncluded ? <ChevronDown size={16} /> : <></>} startContent={
isIncluded &&
renderStatusIcon(testRunCaseStatus[cellValue].uid)
}
endContent={isIncluded && <ChevronDown size={16} />}
> >
{isIncluded ? testRunCaseStatus[cellValue].name : <></>} {isIncluded && testRunCaseStatus[cellValue].name}
</Button> </Button>
</DropdownTrigger> </DropdownTrigger>
<DropdownMenu aria-label="test case actions"> <DropdownMenu aria-label="test case actions">
{testRunCaseStatus.map((runCaseStatus, index) => ( {testRunCaseStatus.map((runCaseStatus, index) => (
<DropdownItem key={index} onClick={() => {}}> <DropdownItem
{testRunCaseStatus[index].name} key={index}
startContent={renderStatusIcon(runCaseStatus.uid)}
onClick={() => {}}
>
{runCaseStatus.name}
</DropdownItem> </DropdownItem>
))} ))}
</DropdownMenu> </DropdownMenu>

View File

@@ -40,13 +40,20 @@ const testRunStatus = [
{ name: "Rejected", uid: "rejected" }, { name: "Rejected", uid: "rejected" },
{ name: "Done", uid: "done" }, { name: "Done", uid: "done" },
{ name: "Closed", uid: "closed" }, { name: "Closed", uid: "closed" },
] ];
const testRunCaseStatus = [ const testRunCaseStatus = [
{ name: "Untested", uid: "untested", color: "primary" }, { name: "Untested", uid: "untested", color: "primary" },
{ name: "Passed", uid: "passed", color: "success" }, { name: "Passed", uid: "passed", color: "success" },
{ name: "Failed", uid: "untested", color: "danger" }, { name: "Failed", uid: "failed", color: "danger" },
{ name: "Skipped", uid: "medium", color: "primary" }, { name: "Skipped", uid: "skipped", color: "primary" },
] ];
export { priorities, testTypes, automationStatus, templates, testRunStatus, testRunCaseStatus }; export {
priorities,
testTypes,
automationStatus,
templates,
testRunStatus,
testRunCaseStatus,
};

View File

@@ -21,7 +21,7 @@
"eslint-config-next": "14.0.2", "eslint-config-next": "14.0.2",
"framer-motion": "^10.16.4", "framer-motion": "^10.16.4",
"intl-messageformat": "^10.5.0", "intl-messageformat": "^10.5.0",
"lucide-react": "^0.335.0", "lucide-react": "^0.372.0",
"next": "14.0.2", "next": "14.0.2",
"next-themes": "^0.2.1", "next-themes": "^0.2.1",
"postcss": "8.4.31", "postcss": "8.4.31",
@@ -5100,9 +5100,9 @@
} }
}, },
"node_modules/lucide-react": { "node_modules/lucide-react": {
"version": "0.335.0", "version": "0.372.0",
"resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.335.0.tgz", "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.372.0.tgz",
"integrity": "sha512-FNmIG4JLdvpK86ZFJjrT0SnFEa95KhsiNokVicA5mWEf1oe+ujP2C/bTr0PVQzr/wzvZpzgxaOySq0O79q2oMA==", "integrity": "sha512-0cKdqmilHXWUwWAWnf6CrrjHD8YaqPMtLrmEHXolZusNTr9epULCsiJwIOHk2q1yFxdEwd96D4zShlAj67UJdA==",
"peerDependencies": { "peerDependencies": {
"react": "^16.5.1 || ^17.0.0 || ^18.0.0" "react": "^16.5.1 || ^17.0.0 || ^18.0.0"
} }

View File

@@ -22,7 +22,7 @@
"eslint-config-next": "14.0.2", "eslint-config-next": "14.0.2",
"framer-motion": "^10.16.4", "framer-motion": "^10.16.4",
"intl-messageformat": "^10.5.0", "intl-messageformat": "^10.5.0",
"lucide-react": "^0.335.0", "lucide-react": "^0.372.0",
"next": "14.0.2", "next": "14.0.2",
"next-themes": "^0.2.1", "next-themes": "^0.2.1",
"postcss": "8.4.31", "postcss": "8.4.31",