Display information of project on home tab

This commit is contained in:
Takeshi Kimata
2024-05-06 23:02:07 +09:00
parent 47457e45f4
commit de2f915c30
7 changed files with 86 additions and 41 deletions

View File

@@ -1,24 +1,35 @@
const categoricalPalette = [
"#fba91e",
"#6ea56c",
"#3ac6e1",
"#feda2f",
"#f15f47",
"#244470",
"#9c80bb",
"#f595a6",
];
const priorities = [ const priorities = [
{ uid: "critical", color: "#d00002", chartColor: "#d00002" }, { uid: "critical", color: "#bb3e03", chartColor: "#bb3e03" },
{ uid: "high", color: "#ee6b4e", chartColor: "#ee6b4e" }, { uid: "high", color: "#ca6702", chartColor: "#ca6702" },
{ uid: "medium", color: "#fccb69", chartColor: "#fccb69" }, { uid: "medium", color: "#ee9b00", chartColor: "#ee9b00" },
{ uid: "low", color: "#0b62e8", chartColor: "#0b62e8" }, { uid: "low", color: "#94d2bd", chartColor: "#94d2bd" },
]; ];
const testTypes = [ const testTypes = [
{ uid: "other", chartColor: "#688ae8" }, { uid: "other", chartColor: categoricalPalette[0] },
{ uid: "security", chartColor: "#c33d69" }, { uid: "security", chartColor: categoricalPalette[1] },
{ uid: "performance", chartColor: "#2ea597" }, { uid: "performance", chartColor: categoricalPalette[2] },
{ uid: "accessibility", chartColor: "#8456ce" }, { uid: "accessibility", chartColor: categoricalPalette[3] },
{ uid: "functional", chartColor: "#e07941" }, { uid: "functional", chartColor: categoricalPalette[4] },
{ uid: "acceptance", chartColor: "#3759ce" }, { uid: "acceptance", chartColor: categoricalPalette[5] },
{ uid: "usability", chartColor: "#962249" }, { uid: "usability", chartColor: categoricalPalette[6] },
{ uid: "smokeSanity", chartColor: "#096f64" }, { uid: "smokeSanity", chartColor: categoricalPalette[7] },
{ uid: "compatibility", chartColor: "#6237a7" }, { uid: "compatibility", chartColor: categoricalPalette[0] },
{ uid: "destructive", chartColor: "#a84401" }, { uid: "destructive", chartColor: categoricalPalette[1] },
{ uid: "regression", chartColor: "#273ea5" }, { uid: "regression", chartColor: categoricalPalette[2] },
{ uid: "automated", chartColor: "#780d35" }, { uid: "automated", chartColor: categoricalPalette[3] },
{ uid: "manual", chartColor: "#03524a" }, { uid: "manual", chartColor: categoricalPalette[4] },
]; ];
const automationStatus = [ const automationStatus = [
@@ -43,12 +54,12 @@ const testRunCaseStatus = [
{ {
uid: "untested", uid: "untested",
color: "primary", color: "primary",
chartColor: "#e5e7eb", chartColor: "#3ac6e1",
}, },
{ uid: "passed", color: "success", chartColor: "#059669" }, { uid: "passed", color: "success", chartColor: "#6ea56c" },
{ uid: "failed", color: "danger", chartColor: "#f87171" }, { uid: "failed", color: "danger", chartColor: "#f15f47" },
{ uid: "retest", color: "warning", chartColor: "#fbbf24" }, { uid: "retest", color: "warning", chartColor: "#fba91e" },
{ uid: "skipped", color: "primary", chartColor: "#4b5563" }, { uid: "skipped", color: "primary", chartColor: "#805aab" },
]; ];
export { export {

View File

@@ -37,7 +37,14 @@
"test_cases": "Test Cases", "test_cases": "Test Cases",
"test_runs": "Test Runs", "test_runs": "Test Runs",
"progress": "Progress", "progress": "Progress",
"test_types": "Test types", "untested": "Untested",
"passed": "Passed",
"failed": "Failed",
"retest": "Retest",
"skipped": "Skipped",
"test_classification": "Test Classification",
"by_type": "By test type",
"by_priority": "By test priority",
"other": "Other", "other": "Other",
"security": "Security", "security": "Security",
"performance": "Performance", "performance": "Performance",
@@ -51,7 +58,6 @@
"regression": "Regression", "regression": "Regression",
"automated": "Automated", "automated": "Automated",
"manual": "Manual", "manual": "Manual",
"priority": "Priority",
"critical": "Critical", "critical": "Critical",
"high": "High", "high": "High",
"medium": "Medium", "medium": "Medium",

View File

@@ -37,7 +37,14 @@
"test_cases": "テストケース", "test_cases": "テストケース",
"test_runs": "テスト実行", "test_runs": "テスト実行",
"progress": "進捗", "progress": "進捗",
"test_types": "テスト種別", "untested": "未実行",
"passed": "成功",
"failed": "失敗",
"retest": "再テスト",
"skipped": "スキップ",
"test_classification": "テスト分類",
"by_type": "タイプ別",
"by_priority": "優先度別",
"other": "その他", "other": "その他",
"security": "セキュリティ", "security": "セキュリティ",
"performance": "パフォーマンス", "performance": "パフォーマンス",
@@ -51,7 +58,6 @@
"regression": "回帰", "regression": "回帰",
"automated": "自動", "automated": "自動",
"manual": "手動", "manual": "手動",
"priority": "優先度",
"critical": "致", "critical": "致",
"high": "高", "high": "高",
"medium": "中", "medium": "中",

View File

@@ -2,6 +2,7 @@ import React from "react";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import dynamic from "next/dynamic"; import dynamic from "next/dynamic";
import { ProgressSeriesType } from "@/types/run"; import { ProgressSeriesType } from "@/types/run";
import { testRunCaseStatus } from "@/config/selection";
const Chart = dynamic(() => import("react-apexcharts"), { ssr: false }); const Chart = dynamic(() => import("react-apexcharts"), { ssr: false });
type Props = { type Props = {
@@ -36,6 +37,9 @@ export default function TestProgressBarChart({
legend: { legend: {
position: "right", position: "right",
}, },
colors: testRunCaseStatus.map((itr) => {
return itr.chartColor;
}),
xaxis: { xaxis: {
type: "datetime", type: "datetime",
categories: progressCategories, categories: progressCategories,

View File

@@ -1,5 +1,6 @@
import { ProjectType } from "@/types/project"; import { ProjectType } from "@/types/project";
import { testTypes, priorities, testRunCaseStatus } from "@/config/selection"; import { testTypes, priorities, testRunCaseStatus } from "@/config/selection";
import { HomeMessages } from "./page";
// aggregate folder, case, run mum // aggregate folder, case, run mum
function aggregateBasicInfo(project: ProjectType) { function aggregateBasicInfo(project: ProjectType) {
@@ -49,9 +50,9 @@ function aggregateTestPriority(project: ProjectType) {
return result; return result;
} }
function aggregateProgress(project: ProjectType) { function aggregateProgress(project: ProjectType, messages: HomeMessages) {
let series = testRunCaseStatus.map((status) => { let series = testRunCaseStatus.map((status) => {
return { name: status.uid, data: [] }; return { name: messages[status.uid], data: [] };
}); });
let categories = []; let categories = [];

View File

@@ -1,7 +1,7 @@
"use client"; "use client";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { Divider } from "@nextui-org/react"; import { Divider } from "@nextui-org/react";
import { title } from "@/components/primitives"; import { title, subtitle } from "@/components/primitives";
import { Card, CardBody, Chip } from "@nextui-org/react"; import { Card, CardBody, Chip } from "@nextui-org/react";
import { Folder, Clipboard, FlaskConical } from "lucide-react"; import { Folder, Clipboard, FlaskConical } from "lucide-react";
import { CaseTypeCountType, CasePriorityCountType } from "@/types/case"; import { CaseTypeCountType, CasePriorityCountType } from "@/types/case";
@@ -66,7 +66,6 @@ export function Home({ projectId, messages }: Props) {
try { try {
const data = await fetchProject(url); const data = await fetchProject(url);
setProject(data); setProject(data);
console.log(data);
} catch (error: any) { } catch (error: any) {
console.error("Error in effect:", error.message); console.error("Error in effect:", error.message);
} }
@@ -88,7 +87,7 @@ export function Home({ projectId, messages }: Props) {
const priorityRet = aggregateTestPriority(project); const priorityRet = aggregateTestPriority(project);
setPriorityCounts([...priorityRet]); setPriorityCounts([...priorityRet]);
const { series, categories } = aggregateProgress(project); const { series, categories } = aggregateProgress(project, messages);
setProgressSeries([...series]); setProgressSeries([...series]);
setProgressCategories([...categories]); setProgressCategories([...categories]);
} }
@@ -123,27 +122,30 @@ export function Home({ projectId, messages }: Props) {
</Chip> </Chip>
</div> </div>
{project.detail && (
<Card className="mt-3 bg-neutral-100" shadow="none"> <Card className="mt-3 bg-neutral-100" shadow="none">
<CardBody>{project.detail}</CardBody> <CardBody>{project.detail}</CardBody>
</Card> </Card>
)}
<Divider className="my-6" /> <Divider className="my-8" />
<div style={{ height: "20rem" }}> <h2 className={subtitle()}>{messages.progress}</h2>
<h3>{messages.progress}</h3> <div style={{ height: "18rem" }}>
<TestProgressBarChart <TestProgressBarChart
progressSeries={progressSeries} progressSeries={progressSeries}
progressCategories={progressCategories} progressCategories={progressCategories}
/> />
</div> </div>
<Divider className="my-6" /> <Divider className="my-12" />
<h2 className={subtitle()}>{messages.testClassification}</h2>
<div className="flex pb-20"> <div className="flex pb-20">
<div style={{ width: "32rem", height: "18rem" }}> <div style={{ width: "32rem", height: "18rem" }}>
<h3>{messages.testTypes}</h3> <h3>{messages.byType}</h3>
<TestTypesChart typesCounts={typesCounts} messages={messages} /> <TestTypesChart typesCounts={typesCounts} messages={messages} />
</div> </div>
<div style={{ width: "30rem", height: "18rem" }}> <div style={{ width: "30rem", height: "18rem" }}>
<h3>{messages.priority}</h3> <h3>{messages.byPriority}</h3>
<TestPriorityChart <TestPriorityChart
priorityCounts={priorityCounts} priorityCounts={priorityCounts}
messages={messages} messages={messages}

View File

@@ -6,6 +6,14 @@ export type HomeMessages = {
testCases: string; testCases: string;
testRuns: string; testRuns: string;
progress: string; progress: string;
untested: string;
passed: string;
failed: string;
retest: string;
skipped: string;
testClassification: string;
byType: string;
byPriority: string;
testTypes: string; testTypes: string;
other: string; other: string;
security: string; security: string;
@@ -20,7 +28,6 @@ export type HomeMessages = {
regression: string; regression: string;
automated: string; automated: string;
manual: string; manual: string;
priority: string;
critical: string; critical: string;
high: string; high: string;
medium: string; medium: string;
@@ -34,6 +41,14 @@ export default function Page({ params }: { params: { projectId: string } }) {
testCases: t("test_cases"), testCases: t("test_cases"),
testRuns: t("test_runs"), testRuns: t("test_runs"),
progress: t("progress"), progress: t("progress"),
untested: t("untested"),
passed: t("passed"),
failed: t("failed"),
retest: t("retest"),
skipped: t("skipped"),
testClassification: t("test_classification"),
byType: t("by_type"),
byPriority: t("by_priority"),
testTypes: t("test_types"), testTypes: t("test_types"),
other: t("other"), other: t("other"),
security: t("security"), security: t("security"),