refactor: test run case status messages duplication
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { TestTypeType } from '@/types/testType';
|
||||
import { PriorityType } from '@/types/priority';
|
||||
import { TestStatusType } from '@/types/testStatus';
|
||||
import { TestRunCaseStatusType } from '@/types/testRunCaseStatus';
|
||||
|
||||
const roles = [{ uid: 'administrator' }, { uid: 'user' }];
|
||||
|
||||
@@ -13,7 +13,18 @@ const locales = [
|
||||
{ code: 'ja', name: '日本語' },
|
||||
];
|
||||
|
||||
const testRunCaseStatus: TestStatusType[] = [
|
||||
// The status of each test run
|
||||
const testRunStatus = [
|
||||
{ uid: 'new' },
|
||||
{ uid: 'inProgress' },
|
||||
{ uid: 'underReview' },
|
||||
{ uid: 'rejected' },
|
||||
{ uid: 'done' },
|
||||
{ uid: 'closed' },
|
||||
];
|
||||
|
||||
// The status of each test case in test run
|
||||
const testRunCaseStatus: TestRunCaseStatusType[] = [
|
||||
{
|
||||
uid: 'untested',
|
||||
color: 'primary',
|
||||
@@ -57,15 +68,6 @@ const automationStatus = [
|
||||
|
||||
const templates = [{ uid: 'text' }, { uid: 'step' }];
|
||||
|
||||
const testRunStatus = [
|
||||
{ uid: 'new' },
|
||||
{ uid: 'inProgress' },
|
||||
{ uid: 'underReview' },
|
||||
{ uid: 'rejected' },
|
||||
{ uid: 'done' },
|
||||
{ uid: 'closed' },
|
||||
];
|
||||
|
||||
export {
|
||||
roles,
|
||||
memberRoles,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"Status": {
|
||||
"RunCaseStatus": {
|
||||
"untested": "Untested",
|
||||
"passed": "Passed",
|
||||
"failed": "Failed",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"Status": {
|
||||
"RunCaseStatus": {
|
||||
"untested": "未実行",
|
||||
"passed": "成功",
|
||||
"failed": "失敗",
|
||||
|
||||
@@ -13,7 +13,7 @@ import { useTheme } from 'next-themes';
|
||||
import TestTypesChart from './TestTypesDonutChart';
|
||||
import TestPriorityChart from './TestPriorityDonutChart';
|
||||
import TestProgressBarChart from './TestProgressColumnChart';
|
||||
import { TestStatusMessages } from '@/types/testStatus';
|
||||
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus';
|
||||
import { TestTypeMessages } from '@/types/testType';
|
||||
import { PriorityMessages } from '@/types/priority';
|
||||
|
||||
@@ -45,12 +45,18 @@ async function fetchProject(jwt: string, projectId: number) {
|
||||
type Props = {
|
||||
projectId: string;
|
||||
messages: HomeMessages;
|
||||
statusMessages: TestStatusMessages;
|
||||
testRunCaseStatusMessages: TestRunCaseStatusMessages;
|
||||
testTypeMessages: TestTypeMessages;
|
||||
priorityMessages: PriorityMessages;
|
||||
};
|
||||
|
||||
export function ProjectHome({ projectId, messages, statusMessages, testTypeMessages, priorityMessages }: Props) {
|
||||
export function ProjectHome({
|
||||
projectId,
|
||||
messages,
|
||||
testRunCaseStatusMessages,
|
||||
testTypeMessages,
|
||||
priorityMessages,
|
||||
}: Props) {
|
||||
const context = useContext(TokenContext);
|
||||
const { theme, setTheme } = useTheme();
|
||||
const [project, setProject] = useState({
|
||||
@@ -97,7 +103,7 @@ export function ProjectHome({ projectId, messages, statusMessages, testTypeMessa
|
||||
const priorityRet = aggregateTestPriority(project);
|
||||
setPriorityCounts([...priorityRet]);
|
||||
|
||||
const { series, categories } = aggregateProgress(project, statusMessages);
|
||||
const { series, categories } = aggregateProgress(project, testRunCaseStatusMessages);
|
||||
setProgressSeries([...series]);
|
||||
setProgressCategories([...categories]);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ProjectType } from '@/types/project';
|
||||
import { testTypes, priorities, testRunCaseStatus } from '@/config/selection';
|
||||
import { TestStatusMessages } from '@/types/testStatus';
|
||||
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus';
|
||||
|
||||
// aggregate folder, case, run mum
|
||||
function aggregateBasicInfo(project: ProjectType) {
|
||||
@@ -50,9 +50,9 @@ function aggregateTestPriority(project: ProjectType) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function aggregateProgress(project: ProjectType, statusMessages: TestStatusMessages) {
|
||||
function aggregateProgress(project: ProjectType, testRunCaseStatusMessages: TestRunCaseStatusMessages) {
|
||||
let series = testRunCaseStatus.map((status) => {
|
||||
return { name: statusMessages[status.uid], data: [] };
|
||||
return { name: testRunCaseStatusMessages[status.uid], data: [] };
|
||||
});
|
||||
let categories = [];
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ProjectHome } from './ProjectHome';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { PriorityMessages } from '@/types/priority';
|
||||
import { TestTypeMessages } from '@/types/testType';
|
||||
import { TestStatusMessages } from '@/types/testStatus';
|
||||
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus';
|
||||
|
||||
export type HomeMessages = {
|
||||
folders: string;
|
||||
@@ -26,13 +26,13 @@ export default function Page({ params }: { params: { projectId: string } }) {
|
||||
byPriority: t('by_priority'),
|
||||
};
|
||||
|
||||
const st = useTranslations('Status');
|
||||
const statusMessages: TestStatusMessages = {
|
||||
untested: st('untested'),
|
||||
passed: st('passed'),
|
||||
failed: st('failed'),
|
||||
retest: st('retest'),
|
||||
skipped: st('skipped'),
|
||||
const rcst = useTranslations('RunCaseStatus');
|
||||
const testRunCaseStatusMessages: TestRunCaseStatusMessages = {
|
||||
untested: rcst('untested'),
|
||||
passed: rcst('passed'),
|
||||
failed: rcst('failed'),
|
||||
retest: rcst('retest'),
|
||||
skipped: rcst('skipped'),
|
||||
};
|
||||
|
||||
const tt = useTranslations('Type');
|
||||
@@ -65,7 +65,7 @@ export default function Page({ params }: { params: { projectId: string } }) {
|
||||
<ProjectHome
|
||||
projectId={params.projectId}
|
||||
messages={messages}
|
||||
statusMessages={statusMessages}
|
||||
testRunCaseStatusMessages={testRunCaseStatusMessages}
|
||||
testTypeMessages={testTypeMessages}
|
||||
priorityMessages={priorityMessages}
|
||||
/>
|
||||
|
||||
@@ -38,7 +38,7 @@ import { TokenContext } from '@/utils/TokenProvider';
|
||||
import { useTheme } from 'next-themes';
|
||||
import { useFormGuard } from '@/utils/formGuard';
|
||||
import { PriorityMessages } from '@/types/priority';
|
||||
import { TestStatusMessages } from '@/types/testStatus';
|
||||
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus';
|
||||
|
||||
const defaultTestRun = {
|
||||
id: 0,
|
||||
@@ -55,12 +55,19 @@ type Props = {
|
||||
projectId: string;
|
||||
runId: string;
|
||||
messages: RunMessages;
|
||||
statusMessages: TestStatusMessages;
|
||||
testRunCaseStatusMessages: TestRunCaseStatusMessages;
|
||||
priorityMessages: PriorityMessages;
|
||||
locale: string;
|
||||
};
|
||||
|
||||
export default function RunEditor({ projectId, runId, messages, statusMessages, priorityMessages, locale }: Props) {
|
||||
export default function RunEditor({
|
||||
projectId,
|
||||
runId,
|
||||
messages,
|
||||
testRunCaseStatusMessages,
|
||||
priorityMessages,
|
||||
locale,
|
||||
}: Props) {
|
||||
const context = useContext(TokenContext);
|
||||
const { theme, setTheme } = useTheme();
|
||||
const [testRun, setTestRun] = useState<RunType>(defaultTestRun);
|
||||
@@ -206,7 +213,11 @@ export default function RunEditor({ projectId, runId, messages, statusMessages,
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
<RunProgressChart statusCounts={runStatusCounts} statusMessages={statusMessages} theme={theme} />
|
||||
<RunProgressChart
|
||||
statusCounts={runStatusCounts}
|
||||
testRunCaseStatusMessages={testRunCaseStatusMessages}
|
||||
theme={theme}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-grow">
|
||||
@@ -318,7 +329,7 @@ export default function RunEditor({ projectId, runId, messages, statusMessages,
|
||||
onIncludeCase={(includeTestId) => handleIncludeExcludeCase(true, includeTestId)}
|
||||
onExcludeCase={(excludeCaseId) => handleIncludeExcludeCase(false, excludeCaseId)}
|
||||
messages={messages}
|
||||
statusMessages={statusMessages}
|
||||
testRunCaseStatusMessages={testRunCaseStatusMessages}
|
||||
priorityMessages={priorityMessages}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -3,16 +3,16 @@ import { useState, useEffect } from 'react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { testRunCaseStatus } from '@/config/selection';
|
||||
import { RunStatusCountType } from '@/types/run';
|
||||
import { TestStatusMessages } from '@/types/testStatus';
|
||||
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus';
|
||||
const Chart = dynamic(() => import('react-apexcharts'), { ssr: false });
|
||||
|
||||
type Props = {
|
||||
statusCounts: RunStatusCountType[];
|
||||
statusMessages: TestStatusMessages;
|
||||
testRunCaseStatusMessages: TestRunCaseStatusMessages;
|
||||
theme: string | undefined;
|
||||
};
|
||||
|
||||
export default function RunProgressDounut({ statusCounts, statusMessages, theme }: Props) {
|
||||
export default function RunProgressDounut({ statusCounts, testRunCaseStatusMessages, theme }: Props) {
|
||||
const [chartData, setChartData] = useState({
|
||||
series: [],
|
||||
options: {
|
||||
@@ -29,7 +29,7 @@ export default function RunProgressDounut({ statusCounts, statusMessages, theme
|
||||
return found ? found.count : 0;
|
||||
});
|
||||
|
||||
const labels = testRunCaseStatus.map((entry) => statusMessages[entry.uid]);
|
||||
const labels = testRunCaseStatus.map((entry) => testRunCaseStatusMessages[entry.uid]);
|
||||
const colors = testRunCaseStatus.map((entry) => entry.chartColor);
|
||||
const legend = {
|
||||
labels: {
|
||||
|
||||
@@ -32,7 +32,7 @@ import { RunMessages } from '@/types/run';
|
||||
import TestCaseDetailDialog from './TestCaseDetailDialog';
|
||||
import { PriorityMessages } from '@/types/priority';
|
||||
import TestCasePriority from '@/components/TestCasePriority';
|
||||
import { TestStatusMessages } from '@/types/testStatus';
|
||||
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus';
|
||||
|
||||
type Props = {
|
||||
cases: CaseType[];
|
||||
@@ -43,7 +43,7 @@ type Props = {
|
||||
onIncludeCase: (includeCaseId: number) => {};
|
||||
onExcludeCase: (excludeCaseId: number) => {};
|
||||
messages: RunMessages;
|
||||
statusMessages: TestStatusMessages;
|
||||
testRunCaseStatusMessages: TestRunCaseStatusMessages;
|
||||
priorityMessages: PriorityMessages;
|
||||
};
|
||||
|
||||
@@ -56,7 +56,7 @@ export default function TestCaseSelector({
|
||||
onIncludeCase,
|
||||
onExcludeCase,
|
||||
messages,
|
||||
statusMessages,
|
||||
testRunCaseStatusMessages,
|
||||
priorityMessages,
|
||||
}: Props) {
|
||||
const headerColumns = [
|
||||
@@ -160,7 +160,9 @@ export default function TestCaseSelector({
|
||||
startContent={isIncluded && renderStatusIcon(testRunCaseStatus[runStatus].uid)}
|
||||
endContent={isIncluded && <ChevronDown size={16} />}
|
||||
>
|
||||
<span className="w-12">{isIncluded && statusMessages[testRunCaseStatus[runStatus].uid]}</span>
|
||||
<span className="w-12">
|
||||
{isIncluded && testRunCaseStatusMessages[testRunCaseStatus[runStatus].uid]}
|
||||
</span>
|
||||
</Button>
|
||||
</DropdownTrigger>
|
||||
<DropdownMenu disabledKeys={disabledStatusKeys} aria-label="test case actions">
|
||||
@@ -170,7 +172,7 @@ export default function TestCaseSelector({
|
||||
startContent={renderStatusIcon(runCaseStatus.uid)}
|
||||
onPress={() => onChangeStatus(testCase.id, index)}
|
||||
>
|
||||
{statusMessages[runCaseStatus.uid]}
|
||||
{testRunCaseStatusMessages[runCaseStatus.uid]}
|
||||
</DropdownItem>
|
||||
))}
|
||||
</DropdownMenu>
|
||||
|
||||
@@ -2,7 +2,7 @@ import RunEditor from './RunEditor';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { RunMessages } from '@/types/run';
|
||||
import { PriorityMessages } from '@/types/priority';
|
||||
import { TestStatusMessages } from '@/types/testStatus';
|
||||
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus';
|
||||
|
||||
export default function Page({ params }: { params: { projectId: string; runId: string; locale: string } }) {
|
||||
const t = useTranslations('Run');
|
||||
@@ -38,13 +38,13 @@ export default function Page({ params }: { params: { projectId: string; runId: s
|
||||
close: t('close'),
|
||||
};
|
||||
|
||||
const st = useTranslations('Status');
|
||||
const statusMessages: TestStatusMessages = {
|
||||
untested: st('untested'),
|
||||
passed: st('passed'),
|
||||
failed: st('failed'),
|
||||
retest: st('retest'),
|
||||
skipped: st('skipped'),
|
||||
const rcst = useTranslations('RunCaseStatus');
|
||||
const testRunCaseStatusMessages: TestRunCaseStatusMessages = {
|
||||
untested: rcst('untested'),
|
||||
passed: rcst('passed'),
|
||||
failed: rcst('failed'),
|
||||
retest: rcst('retest'),
|
||||
skipped: rcst('skipped'),
|
||||
};
|
||||
|
||||
const pt = useTranslations('Priority');
|
||||
@@ -60,7 +60,7 @@ export default function Page({ params }: { params: { projectId: string; runId: s
|
||||
projectId={params.projectId}
|
||||
runId={params.runId}
|
||||
messages={messages}
|
||||
statusMessages={statusMessages}
|
||||
testRunCaseStatusMessages={testRunCaseStatusMessages}
|
||||
priorityMessages={priorityMessages}
|
||||
locale={params.locale}
|
||||
/>
|
||||
|
||||
18
frontend/types/testRunCaseStatus.ts
Normal file
18
frontend/types/testRunCaseStatus.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
// The status of each test case in test run
|
||||
type TestRunCaseStatusUidType = 'untested' | 'passed' | 'failed' | 'retest' | 'skipped';
|
||||
|
||||
type TestRunCaseStatusType = {
|
||||
uid: TestRunCaseStatusUidType;
|
||||
color: string;
|
||||
chartColor: string;
|
||||
};
|
||||
|
||||
type TestRunCaseStatusMessages = {
|
||||
untested: string;
|
||||
passed: string;
|
||||
failed: string;
|
||||
retest: string;
|
||||
skipped: string;
|
||||
};
|
||||
|
||||
export type { TestRunCaseStatusUidType, TestRunCaseStatusType, TestRunCaseStatusMessages };
|
||||
@@ -1,17 +0,0 @@
|
||||
type TestStatusUidType = 'untested' | 'passed' | 'failed' | 'retest' | 'skipped';
|
||||
|
||||
type TestStatusType = {
|
||||
uid: TestStatusUidType;
|
||||
color: string;
|
||||
chartColor: string;
|
||||
};
|
||||
|
||||
type TestStatusMessages = {
|
||||
untested: string;
|
||||
passed: string;
|
||||
failed: string;
|
||||
retest: string;
|
||||
skipped: string;
|
||||
};
|
||||
|
||||
export type { TestStatusUidType, TestStatusType, TestStatusMessages };
|
||||
Reference in New Issue
Block a user