Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

[TES-6303] Update Test Run List table column and decorators #37

Merged
merged 9 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions superset-frontend/src/assets/images/katalon/profile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions superset-frontend/src/assets/images/katalon/status-error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 2 additions & 9 deletions superset-frontend/src/assets/images/katalon/status-failed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 2 additions & 9 deletions superset-frontend/src/assets/images/katalon/status-passed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions superset-frontend/src/assets/images/katalon/test-run.svg

This file was deleted.

209 changes: 209 additions & 0 deletions superset-frontend/src/katalon/DataTable/TableChart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
/* eslint-disable theme-colors/no-literal-colors */

import React from 'react';
import { DataRecord } from '@superset-ui/core';
import { makeStyles } from '@mui/styles';

Check failure on line 5 in superset-frontend/src/katalon/DataTable/TableChart.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Unable to resolve path to module '@mui/styles'

Check failure on line 5 in superset-frontend/src/katalon/DataTable/TableChart.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Unable to resolve path to module '@mui/styles'
import { DataGrid, GridColDef } from '@katalon-studio/katalon-ui/v2';

Check failure on line 6 in superset-frontend/src/katalon/DataTable/TableChart.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Unable to resolve path to module '@katalon-studio/katalon-ui/v2'

Check failure on line 6 in superset-frontend/src/katalon/DataTable/TableChart.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Unable to resolve path to module '@katalon-studio/katalon-ui/v2'
import { TableChartTransformedProps } from './types';
import {
statusDecorator,
IDDecorator,
nameDecorator,
profileDecorator,
durationDecorator,
environmentDecorator,
timeStartedDecorator,
testResultStatusDecorator,
configurationDecorator,
executorDecorator,
} from './TestRunDecorators';

const useStyles = makeStyles(() => ({
tableHeader: {
backgroundColor: '#f7f9fb',
'& .MuiDataGrid-columnHeaderTitle': {
color: '#46474d',
fontSize: '11px',
fontWeight: 700,
},
},
lastColumnHeader: {
backgroundColor: '#f7f9fb',
width: '100%',
'& .MuiDataGrid-columnHeaderTitle': {
color: '#46474d',
fontSize: '11px',
fontWeight: 700,
paddingRight: '16px',
},
},
}));

const PAGE_SIZE = 10;

const parseJSON = (value: any) => {
try {
return JSON.parse(value);
} catch (error) {
console.error(error);
return value;
}
};

const formatData = (data: any) =>
data.map((row: any) => {
const {
configuration,
profile,
environment,
executor,
test_result_status,
run_configuration_name,
test_suite_collection_name,
test_suite_name,
...rest
} = row;

const parsedConfiguration = parseJSON(configuration);
const parsedProfile = parseJSON(profile);
const parsedEnvironment = parseJSON(environment);
const parsedExecutor = parseJSON(executor);
const parsedTestResultStatus = parseJSON(test_result_status);

let name: string[] = [];
if (run_configuration_name) {
name = parseJSON(run_configuration_name);
} else if (test_suite_collection_name) {
name = parseJSON(test_suite_collection_name);
} else if (test_suite_name) {
name = parseJSON(test_suite_name);
}

return {
configuration: parsedConfiguration,
profile: parsedProfile,
environment: parsedEnvironment,
name,
executor: parsedExecutor,
test_result_status: parsedTestResultStatus,
...rest,
};
});

export default function TableChart<D extends DataRecord = DataRecord>(
props: TableChartTransformedProps<D>,
) {
// TODO: Only use the decorators for Test Run v2 dataset

const classes = useStyles();

const { data } = props;

const rows = formatData(data);

const columns: GridColDef[] = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revamp to support decorators based on specific dataset.

{
field: 'status',
headerName: 'STATUS',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i18n

minWidth: 60,
flex: 0.8,
headerAlign: 'center',
headerClassName: classes.tableHeader,
renderCell: cell => statusDecorator(cell.value),
},
{
field: 'id',
headerName: 'ID',
minWidth: 80,
flex: 0.7,
headerClassName: classes.tableHeader,
renderCell: cell => IDDecorator(cell.value),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idDecorator

},
{
field: 'name',
headerName: 'NAME',
minWidth: 320,
flex: 1,
headerClassName: classes.tableHeader,
renderCell: cell => nameDecorator(cell.value),
},
{
field: 'profile',
headerName: 'PROFILE',
minWidth: 150,
flex: 1,
headerClassName: classes.tableHeader,
renderCell: cell => profileDecorator(cell.value),
},
{
field: 'duration',
headerName: 'DURATION',
minWidth: 100,
flex: 1,
headerClassName: classes.tableHeader,
renderCell: cell => durationDecorator(cell.value),
},
{
field: 'environment',
headerName: 'ENVIRONMENT',
minWidth: 150,
flex: 1,
headerClassName: classes.tableHeader,
renderCell: cell => environmentDecorator(cell.value),
},
{
field: 'time_started',
headerName: 'TIME STARTED',
minWidth: 150,
flex: 1,
headerClassName: classes.tableHeader,
renderCell: cell => timeStartedDecorator(cell.value),
},
{
field: 'test_result_status',
headerName: 'TEST RESULT STATUS',
minWidth: 280,
flex: 1,
headerClassName: classes.tableHeader,
renderCell: cell => testResultStatusDecorator(cell.value),
},
{
field: 'configuration',
headerName: 'CONFIGURATION',
minWidth: 150,
flex: 1,
headerClassName: classes.tableHeader,
renderCell: cell => configurationDecorator(cell.value),
},
{
field: 'executor',
headerName: 'EXECUTOR',
minWidth: 200,
flex: 1,
headerClassName: classes.lastColumnHeader,
renderCell: cell => executorDecorator(cell.value),
},
];

return (
<DataGrid
sx={{
fontFamily: 'Inter',
'.MuiDataGrid-columnHeaderTitleContainer': {
backgroundColor: '#f7f9fb',
},
}}
initialState={{
pagination: { paginationModel: { pageSize: PAGE_SIZE } },
}}
rowHeight={42}
columnHeaderHeight={42}
rows={rows}
columns={columns}
pageSizeOptions={[PAGE_SIZE]}
hideFooter={rows.length <= PAGE_SIZE}
checkboxSelection
disableRowSelectionOnClick
/>
);
}
Loading
Loading