refactor: test run case status messages duplication
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user