refactor: test run status messages duplication

This commit is contained in:
Takeshi Kimata
2024-07-21 15:46:06 +09:00
parent 1da19ed43c
commit 32ee0231b0
11 changed files with 79 additions and 45 deletions

View File

@@ -1,6 +1,6 @@
import { RunStatusType, TestRunCaseStatusType } from '@/types/status';
import { TestTypeType } from '@/types/testType'; import { TestTypeType } from '@/types/testType';
import { PriorityType } from '@/types/priority'; import { PriorityType } from '@/types/priority';
import { TestRunCaseStatusType } from '@/types/testRunCaseStatus';
const roles = [{ uid: 'administrator' }, { uid: 'user' }]; const roles = [{ uid: 'administrator' }, { uid: 'user' }];
@@ -14,7 +14,7 @@ const locales = [
]; ];
// The status of each test run // The status of each test run
const testRunStatus = [ const testRunStatus: RunStatusType[] = [
{ uid: 'new' }, { uid: 'new' },
{ uid: 'inProgress' }, { uid: 'inProgress' },
{ uid: 'underReview' }, { uid: 'underReview' },

View File

@@ -1,4 +1,12 @@
{ {
"RunStatus": {
"new": "New",
"inProgress": "In progress",
"underReview": "Under review",
"rejected": "Rejected",
"done": "Done",
"closed": "Closed"
},
"RunCaseStatus": { "RunCaseStatus": {
"untested": "Untested", "untested": "Untested",
"passed": "Passed", "passed": "Passed",
@@ -234,12 +242,6 @@
"title": "Title", "title": "Title",
"please_enter": "Please enter run name", "please_enter": "Please enter run name",
"description": "Description", "description": "Description",
"new": "New",
"inProgress": "In progress",
"underReview": "Under review",
"rejected": "Rejected",
"done": "Done",
"closed": "Closed",
"priority": "Priority", "priority": "Priority",
"status": "Status", "status": "Status",
"actions": "Actions", "actions": "Actions",

View File

@@ -1,4 +1,12 @@
{ {
"RunStatus": {
"new": "新規",
"inProgress": "進行中",
"underReview": "レビュー中",
"rejected": "却下",
"done": "完了",
"closed": "クローズ"
},
"RunCaseStatus": { "RunCaseStatus": {
"untested": "未実行", "untested": "未実行",
"passed": "成功", "passed": "成功",
@@ -234,12 +242,6 @@
"id": "ID", "id": "ID",
"title": "タイトル", "title": "タイトル",
"description": "詳細", "description": "詳細",
"new": "新規",
"inProgress": "進行中",
"underReview": "レビュー中",
"rejected": "却下",
"done": "完了",
"closed": "クローズ",
"please_enter": "タイトルを入力してください", "please_enter": "タイトルを入力してください",
"priority": "優先度", "priority": "優先度",
"status": "ステータス", "status": "ステータス",

View File

@@ -13,7 +13,7 @@ import { useTheme } from 'next-themes';
import TestTypesChart from './TestTypesDonutChart'; import TestTypesChart from './TestTypesDonutChart';
import TestPriorityChart from './TestPriorityDonutChart'; import TestPriorityChart from './TestPriorityDonutChart';
import TestProgressBarChart from './TestProgressColumnChart'; import TestProgressBarChart from './TestProgressColumnChart';
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus'; import { TestRunCaseStatusMessages } from '@/types/status';
import { TestTypeMessages } from '@/types/testType'; import { TestTypeMessages } from '@/types/testType';
import { PriorityMessages } from '@/types/priority'; import { PriorityMessages } from '@/types/priority';

View File

@@ -1,6 +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 { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus'; import { TestRunCaseStatusMessages } from '@/types/status';
// aggregate folder, case, run mum // aggregate folder, case, run mum
function aggregateBasicInfo(project: ProjectType) { function aggregateBasicInfo(project: ProjectType) {

View File

@@ -2,7 +2,7 @@ import { ProjectHome } from './ProjectHome';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import { PriorityMessages } from '@/types/priority'; import { PriorityMessages } from '@/types/priority';
import { TestTypeMessages } from '@/types/testType'; import { TestTypeMessages } from '@/types/testType';
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus'; import { TestRunCaseStatusMessages } from '@/types/status';
export type HomeMessages = { export type HomeMessages = {
folders: string; folders: string;

View File

@@ -38,7 +38,7 @@ import { TokenContext } from '@/utils/TokenProvider';
import { useTheme } from 'next-themes'; import { useTheme } from 'next-themes';
import { useFormGuard } from '@/utils/formGuard'; import { useFormGuard } from '@/utils/formGuard';
import { PriorityMessages } from '@/types/priority'; import { PriorityMessages } from '@/types/priority';
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus'; import { RunStatusMessages, TestRunCaseStatusMessages } from '@/types/status';
const defaultTestRun = { const defaultTestRun = {
id: 0, id: 0,
@@ -55,6 +55,7 @@ type Props = {
projectId: string; projectId: string;
runId: string; runId: string;
messages: RunMessages; messages: RunMessages;
runStatusMessages: RunStatusMessages;
testRunCaseStatusMessages: TestRunCaseStatusMessages; testRunCaseStatusMessages: TestRunCaseStatusMessages;
priorityMessages: PriorityMessages; priorityMessages: PriorityMessages;
locale: string; locale: string;
@@ -64,6 +65,7 @@ export default function RunEditor({
projectId, projectId,
runId, runId,
messages, messages,
runStatusMessages,
testRunCaseStatusMessages, testRunCaseStatusMessages,
priorityMessages, priorityMessages,
locale, locale,
@@ -261,7 +263,7 @@ export default function RunEditor({
> >
{testRunStatus.map((status, index) => ( {testRunStatus.map((status, index) => (
<SelectItem key={status.uid} value={index}> <SelectItem key={status.uid} value={index}>
{messages[status.uid]} {runStatusMessages[status.uid]}
</SelectItem> </SelectItem>
))} ))}
</Select> </Select>

View File

@@ -3,7 +3,7 @@ import { useState, useEffect } from 'react';
import dynamic from 'next/dynamic'; import dynamic from 'next/dynamic';
import { testRunCaseStatus } from '@/config/selection'; import { testRunCaseStatus } from '@/config/selection';
import { RunStatusCountType } from '@/types/run'; import { RunStatusCountType } from '@/types/run';
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus'; import { TestRunCaseStatusMessages } from '@/types/status';
const Chart = dynamic(() => import('react-apexcharts'), { ssr: false }); const Chart = dynamic(() => import('react-apexcharts'), { ssr: false });
type Props = { type Props = {

View File

@@ -2,7 +2,7 @@ import RunEditor from './RunEditor';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import { RunMessages } from '@/types/run'; import { RunMessages } from '@/types/run';
import { PriorityMessages } from '@/types/priority'; import { PriorityMessages } from '@/types/priority';
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus'; import { RunStatusMessages, TestRunCaseStatusMessages } from '@/types/status';
export default function Page({ params }: { params: { projectId: string; runId: string; locale: string } }) { export default function Page({ params }: { params: { projectId: string; runId: string; locale: string } }) {
const t = useTranslations('Run'); const t = useTranslations('Run');
@@ -16,12 +16,6 @@ export default function Page({ params }: { params: { projectId: string; runId: s
title: t('title'), title: t('title'),
pleaseEnter: t('please_enter'), pleaseEnter: t('please_enter'),
description: t('description'), description: t('description'),
new: t('new'),
inProgress: t('inProgress'),
underReview: t('underReview'),
rejected: t('rejected'),
done: t('done'),
closed: t('closed'),
priority: t('priority'), priority: t('priority'),
actions: t('actions'), actions: t('actions'),
status: t('status'), status: t('status'),
@@ -38,6 +32,16 @@ export default function Page({ params }: { params: { projectId: string; runId: s
close: t('close'), close: t('close'),
}; };
const rst = useTranslations('RunStatus');
const runStatusMessages: RunStatusMessages = {
new: rst('new'),
inProgress: rst('inProgress'),
underReview: rst('underReview'),
rejected: rst('rejected'),
done: rst('done'),
closed: rst('closed'),
};
const rcst = useTranslations('RunCaseStatus'); const rcst = useTranslations('RunCaseStatus');
const testRunCaseStatusMessages: TestRunCaseStatusMessages = { const testRunCaseStatusMessages: TestRunCaseStatusMessages = {
untested: rcst('untested'), untested: rcst('untested'),
@@ -60,6 +64,7 @@ export default function Page({ params }: { params: { projectId: string; runId: s
projectId={params.projectId} projectId={params.projectId}
runId={params.runId} runId={params.runId}
messages={messages} messages={messages}
runStatusMessages={runStatusMessages}
testRunCaseStatusMessages={testRunCaseStatusMessages} testRunCaseStatusMessages={testRunCaseStatusMessages}
priorityMessages={priorityMessages} priorityMessages={priorityMessages}
locale={params.locale} locale={params.locale}

41
frontend/types/status.ts Normal file
View File

@@ -0,0 +1,41 @@
// The status of each test run
type RunStatusUidType = 'new' | 'inProgress' | 'underReview' | 'rejected' | 'done' | 'closed';
type RunStatusType = {
uid: RunStatusUidType;
};
type RunStatusMessages = {
new: string;
inProgress: string;
underReview: string;
rejected: string;
done: string;
closed: string;
};
// 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 {
RunStatusUidType,
RunStatusType,
RunStatusMessages,
TestRunCaseStatusUidType,
TestRunCaseStatusType,
TestRunCaseStatusMessages,
};

View File

@@ -1,18 +0,0 @@
// 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 };