fixed cypress process instance tests w/ burnettk
This commit is contained in:
parent
3754d72f4f
commit
80ec1194db
|
@ -1,5 +1,6 @@
|
|||
import { format } from 'date-fns';
|
||||
import { DATE_FORMAT, PROCESS_STATUSES } from '../../src/config';
|
||||
import { titleizeString } from '../../src/helpers';
|
||||
|
||||
const filterByDate = (fromDate) => {
|
||||
cy.get('#date-picker-start-from').clear().type(format(fromDate, DATE_FORMAT));
|
||||
|
@ -172,14 +173,19 @@ describe('process-instances', () => {
|
|||
cy.contains('All Process Instances');
|
||||
cy.assertAtLeastOneItemInPaginatedResults();
|
||||
|
||||
cy.getBySel('filter-section-expand-toggle').click();
|
||||
|
||||
const statusSelect = '#process-instance-status-select';
|
||||
PROCESS_STATUSES.forEach((processStatus) => {
|
||||
if (!['all', 'waiting'].includes(processStatus)) {
|
||||
cy.get(statusSelect).click();
|
||||
cy.get(statusSelect).contains(processStatus).click();
|
||||
cy.get(statusSelect).contains(titleizeString(processStatus)).click();
|
||||
cy.get(statusSelect).click();
|
||||
cy.getBySel('filter-button').click();
|
||||
cy.url().should('include', `status=${processStatus}`);
|
||||
|
||||
// make sure that there is 1 status item selected in the multiselect
|
||||
cy.get(`${statusSelect} .cds--tag`).contains('1');
|
||||
|
||||
cy.assertAtLeastOneItemInPaginatedResults();
|
||||
cy.getBySel(`process-instance-status-${processStatus}`);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ type OwnProps = {
|
|||
buttonText?: string;
|
||||
buttonClassName?: string;
|
||||
processInstanceReportSelection?: ProcessInstanceReport | null;
|
||||
reportMetadata: ReportMetadata;
|
||||
getReportMetadataCallback: Function;
|
||||
};
|
||||
|
||||
export default function ProcessInstanceListSaveAsReport({
|
||||
|
@ -22,7 +22,7 @@ export default function ProcessInstanceListSaveAsReport({
|
|||
processInstanceReportSelection,
|
||||
buttonClassName,
|
||||
buttonText = 'Save as Perspective',
|
||||
reportMetadata,
|
||||
getReportMetadataCallback,
|
||||
}: OwnProps) {
|
||||
const [identifier, setIdentifier] = useState<string>(
|
||||
processInstanceReportSelection?.identifier || ''
|
||||
|
@ -50,6 +50,11 @@ export default function ProcessInstanceListSaveAsReport({
|
|||
const addProcessInstanceReport = (event: any) => {
|
||||
event.preventDefault();
|
||||
|
||||
const reportMetadata = getReportMetadataCallback();
|
||||
if (!reportMetadata) {
|
||||
return;
|
||||
}
|
||||
|
||||
let path = `/process-instances/reports`;
|
||||
let httpMethod = 'POST';
|
||||
if (isEditMode() && processInstanceReportSelection) {
|
||||
|
|
|
@ -31,7 +31,6 @@ import {
|
|||
DATE_FORMAT_FOR_DISPLAY,
|
||||
} from '../config';
|
||||
import {
|
||||
capitalizeFirstLetter,
|
||||
convertDateAndTimeStringsToSeconds,
|
||||
convertDateObjectToFormattedHoursMinutes,
|
||||
convertSecondsToFormattedDateString,
|
||||
|
@ -42,6 +41,7 @@ import {
|
|||
refreshAtInterval,
|
||||
REFRESH_INTERVAL_SECONDS,
|
||||
REFRESH_TIMEOUT_SECONDS,
|
||||
titleizeString,
|
||||
} from '../helpers';
|
||||
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
||||
|
||||
|
@ -337,10 +337,8 @@ export default function ProcessInstanceListTable({
|
|||
setProcessStatusSelection(
|
||||
(reportFilter.field_value || '').split(',')
|
||||
);
|
||||
setShowFilterOptions(true);
|
||||
} else if (reportFilter.field_name === 'process_initiator_username') {
|
||||
setProcessInitiatorSelection(reportFilter.field_value || '');
|
||||
setShowFilterOptions(true);
|
||||
} else if (reportFilter.field_name === 'process_model_identifier') {
|
||||
selectedProcessModelIdentifier =
|
||||
reportFilter.field_value || undefined;
|
||||
|
@ -358,7 +356,6 @@ export default function ProcessInstanceListTable({
|
|||
reportFilter.field_value as any
|
||||
);
|
||||
timeFunctionToCall(timeString);
|
||||
setShowFilterOptions(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -368,11 +365,14 @@ export default function ProcessInstanceListTable({
|
|||
(processModel: ProcessModel) => {
|
||||
if (processModel.id === selectedProcessModelIdentifier) {
|
||||
setProcessModelSelection(processModel);
|
||||
setShowFilterOptions(true);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (reportMetadataBodyToUse.filter_by.length > 1) {
|
||||
setShowFilterOptions(true);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line prefer-const
|
||||
let { page, perPage } = getPageInfoFromSearchParams(
|
||||
searchParams,
|
||||
|
@ -774,7 +774,7 @@ export default function ProcessInstanceListTable({
|
|||
};
|
||||
|
||||
const formatProcessInstanceStatus = (_row: any, value: any) => {
|
||||
return capitalizeFirstLetter((value || '').replaceAll('_', ' '));
|
||||
return titleizeString((value || '').replaceAll('_', ' '));
|
||||
};
|
||||
const processStatusSearch = () => {
|
||||
return (
|
||||
|
@ -845,18 +845,13 @@ export default function ProcessInstanceListTable({
|
|||
};
|
||||
|
||||
const saveAsReportComponent = () => {
|
||||
const newReportMetadata = getNewReportMetadataBasedOnPageWidgets();
|
||||
|
||||
if (!newReportMetadata) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<ProcessInstanceListSaveAsReport
|
||||
onSuccess={onSaveReportSuccess}
|
||||
buttonClassName="button-white-background narrow-button"
|
||||
buttonText="Save"
|
||||
processInstanceReportSelection={processInstanceReportSelection}
|
||||
reportMetadata={newReportMetadata}
|
||||
getReportMetadataCallback={getNewReportMetadataBasedOnPageWidgets}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -41,6 +41,10 @@ export const capitalizeFirstLetter = (string: any) => {
|
|||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
};
|
||||
|
||||
export const titleizeString = (string: any) => {
|
||||
return capitalizeFirstLetter((string || '').replaceAll('_', ' '));
|
||||
};
|
||||
|
||||
export const convertDateToSeconds = (
|
||||
date: any,
|
||||
onChangeFunction: any = null
|
||||
|
|
Loading…
Reference in New Issue