refactor: test run status messages duplication
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { RunStatusType, TestRunCaseStatusType } from '@/types/status';
|
||||
import { TestTypeType } from '@/types/testType';
|
||||
import { PriorityType } from '@/types/priority';
|
||||
import { TestRunCaseStatusType } from '@/types/testRunCaseStatus';
|
||||
|
||||
const roles = [{ uid: 'administrator' }, { uid: 'user' }];
|
||||
|
||||
@@ -14,7 +14,7 @@ const locales = [
|
||||
];
|
||||
|
||||
// The status of each test run
|
||||
const testRunStatus = [
|
||||
const testRunStatus: RunStatusType[] = [
|
||||
{ uid: 'new' },
|
||||
{ uid: 'inProgress' },
|
||||
{ uid: 'underReview' },
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
{
|
||||
"RunStatus": {
|
||||
"new": "New",
|
||||
"inProgress": "In progress",
|
||||
"underReview": "Under review",
|
||||
"rejected": "Rejected",
|
||||
"done": "Done",
|
||||
"closed": "Closed"
|
||||
},
|
||||
"RunCaseStatus": {
|
||||
"untested": "Untested",
|
||||
"passed": "Passed",
|
||||
@@ -234,12 +242,6 @@
|
||||
"title": "Title",
|
||||
"please_enter": "Please enter run name",
|
||||
"description": "Description",
|
||||
"new": "New",
|
||||
"inProgress": "In progress",
|
||||
"underReview": "Under review",
|
||||
"rejected": "Rejected",
|
||||
"done": "Done",
|
||||
"closed": "Closed",
|
||||
"priority": "Priority",
|
||||
"status": "Status",
|
||||
"actions": "Actions",
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
{
|
||||
"RunStatus": {
|
||||
"new": "新規",
|
||||
"inProgress": "進行中",
|
||||
"underReview": "レビュー中",
|
||||
"rejected": "却下",
|
||||
"done": "完了",
|
||||
"closed": "クローズ"
|
||||
},
|
||||
"RunCaseStatus": {
|
||||
"untested": "未実行",
|
||||
"passed": "成功",
|
||||
@@ -234,12 +242,6 @@
|
||||
"id": "ID",
|
||||
"title": "タイトル",
|
||||
"description": "詳細",
|
||||
"new": "新規",
|
||||
"inProgress": "進行中",
|
||||
"underReview": "レビュー中",
|
||||
"rejected": "却下",
|
||||
"done": "完了",
|
||||
"closed": "クローズ",
|
||||
"please_enter": "タイトルを入力してください",
|
||||
"priority": "優先度",
|
||||
"status": "ステータス",
|
||||
|
||||
@@ -13,7 +13,7 @@ import { useTheme } from 'next-themes';
|
||||
import TestTypesChart from './TestTypesDonutChart';
|
||||
import TestPriorityChart from './TestPriorityDonutChart';
|
||||
import TestProgressBarChart from './TestProgressColumnChart';
|
||||
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus';
|
||||
import { TestRunCaseStatusMessages } from '@/types/status';
|
||||
import { TestTypeMessages } from '@/types/testType';
|
||||
import { PriorityMessages } from '@/types/priority';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ProjectType } from '@/types/project';
|
||||
import { testTypes, priorities, testRunCaseStatus } from '@/config/selection';
|
||||
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus';
|
||||
import { TestRunCaseStatusMessages } from '@/types/status';
|
||||
|
||||
// aggregate folder, case, run mum
|
||||
function aggregateBasicInfo(project: ProjectType) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ProjectHome } from './ProjectHome';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { PriorityMessages } from '@/types/priority';
|
||||
import { TestTypeMessages } from '@/types/testType';
|
||||
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus';
|
||||
import { TestRunCaseStatusMessages } from '@/types/status';
|
||||
|
||||
export type HomeMessages = {
|
||||
folders: string;
|
||||
|
||||
@@ -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 { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus';
|
||||
import { RunStatusMessages, TestRunCaseStatusMessages } from '@/types/status';
|
||||
|
||||
const defaultTestRun = {
|
||||
id: 0,
|
||||
@@ -55,6 +55,7 @@ type Props = {
|
||||
projectId: string;
|
||||
runId: string;
|
||||
messages: RunMessages;
|
||||
runStatusMessages: RunStatusMessages;
|
||||
testRunCaseStatusMessages: TestRunCaseStatusMessages;
|
||||
priorityMessages: PriorityMessages;
|
||||
locale: string;
|
||||
@@ -64,6 +65,7 @@ export default function RunEditor({
|
||||
projectId,
|
||||
runId,
|
||||
messages,
|
||||
runStatusMessages,
|
||||
testRunCaseStatusMessages,
|
||||
priorityMessages,
|
||||
locale,
|
||||
@@ -261,7 +263,7 @@ export default function RunEditor({
|
||||
>
|
||||
{testRunStatus.map((status, index) => (
|
||||
<SelectItem key={status.uid} value={index}>
|
||||
{messages[status.uid]}
|
||||
{runStatusMessages[status.uid]}
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useState, useEffect } from 'react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { testRunCaseStatus } from '@/config/selection';
|
||||
import { RunStatusCountType } from '@/types/run';
|
||||
import { TestRunCaseStatusMessages } from '@/types/testRunCaseStatus';
|
||||
import { TestRunCaseStatusMessages } from '@/types/status';
|
||||
const Chart = dynamic(() => import('react-apexcharts'), { ssr: false });
|
||||
|
||||
type Props = {
|
||||
|
||||
@@ -2,7 +2,7 @@ import RunEditor from './RunEditor';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { RunMessages } from '@/types/run';
|
||||
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 } }) {
|
||||
const t = useTranslations('Run');
|
||||
@@ -16,12 +16,6 @@ export default function Page({ params }: { params: { projectId: string; runId: s
|
||||
title: t('title'),
|
||||
pleaseEnter: t('please_enter'),
|
||||
description: t('description'),
|
||||
new: t('new'),
|
||||
inProgress: t('inProgress'),
|
||||
underReview: t('underReview'),
|
||||
rejected: t('rejected'),
|
||||
done: t('done'),
|
||||
closed: t('closed'),
|
||||
priority: t('priority'),
|
||||
actions: t('actions'),
|
||||
status: t('status'),
|
||||
@@ -38,6 +32,16 @@ export default function Page({ params }: { params: { projectId: string; runId: s
|
||||
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 testRunCaseStatusMessages: TestRunCaseStatusMessages = {
|
||||
untested: rcst('untested'),
|
||||
@@ -60,6 +64,7 @@ export default function Page({ params }: { params: { projectId: string; runId: s
|
||||
projectId={params.projectId}
|
||||
runId={params.runId}
|
||||
messages={messages}
|
||||
runStatusMessages={runStatusMessages}
|
||||
testRunCaseStatusMessages={testRunCaseStatusMessages}
|
||||
priorityMessages={priorityMessages}
|
||||
locale={params.locale}
|
||||
|
||||
41
frontend/types/status.ts
Normal file
41
frontend/types/status.ts
Normal 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,
|
||||
};
|
||||
@@ -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 };
|
||||
Reference in New Issue
Block a user