fixed cypress process instance tests w/ burnettk

This commit is contained in:
jasquat 2023-04-28 11:56:52 -04:00
parent 3754d72f4f
commit 80ec1194db
4 changed files with 26 additions and 16 deletions

View File

@ -1,5 +1,6 @@
import { format } from 'date-fns'; import { format } from 'date-fns';
import { DATE_FORMAT, PROCESS_STATUSES } from '../../src/config'; import { DATE_FORMAT, PROCESS_STATUSES } from '../../src/config';
import { titleizeString } from '../../src/helpers';
const filterByDate = (fromDate) => { const filterByDate = (fromDate) => {
cy.get('#date-picker-start-from').clear().type(format(fromDate, DATE_FORMAT)); 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.contains('All Process Instances');
cy.assertAtLeastOneItemInPaginatedResults(); cy.assertAtLeastOneItemInPaginatedResults();
cy.getBySel('filter-section-expand-toggle').click();
const statusSelect = '#process-instance-status-select'; const statusSelect = '#process-instance-status-select';
PROCESS_STATUSES.forEach((processStatus) => { PROCESS_STATUSES.forEach((processStatus) => {
if (!['all', 'waiting'].includes(processStatus)) { if (!['all', 'waiting'].includes(processStatus)) {
cy.get(statusSelect).click(); cy.get(statusSelect).click();
cy.get(statusSelect).contains(processStatus).click(); cy.get(statusSelect).contains(titleizeString(processStatus)).click();
cy.get(statusSelect).click(); cy.get(statusSelect).click();
cy.getBySel('filter-button').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.assertAtLeastOneItemInPaginatedResults();
cy.getBySel(`process-instance-status-${processStatus}`); cy.getBySel(`process-instance-status-${processStatus}`);

View File

@ -14,7 +14,7 @@ type OwnProps = {
buttonText?: string; buttonText?: string;
buttonClassName?: string; buttonClassName?: string;
processInstanceReportSelection?: ProcessInstanceReport | null; processInstanceReportSelection?: ProcessInstanceReport | null;
reportMetadata: ReportMetadata; getReportMetadataCallback: Function;
}; };
export default function ProcessInstanceListSaveAsReport({ export default function ProcessInstanceListSaveAsReport({
@ -22,7 +22,7 @@ export default function ProcessInstanceListSaveAsReport({
processInstanceReportSelection, processInstanceReportSelection,
buttonClassName, buttonClassName,
buttonText = 'Save as Perspective', buttonText = 'Save as Perspective',
reportMetadata, getReportMetadataCallback,
}: OwnProps) { }: OwnProps) {
const [identifier, setIdentifier] = useState<string>( const [identifier, setIdentifier] = useState<string>(
processInstanceReportSelection?.identifier || '' processInstanceReportSelection?.identifier || ''
@ -50,6 +50,11 @@ export default function ProcessInstanceListSaveAsReport({
const addProcessInstanceReport = (event: any) => { const addProcessInstanceReport = (event: any) => {
event.preventDefault(); event.preventDefault();
const reportMetadata = getReportMetadataCallback();
if (!reportMetadata) {
return;
}
let path = `/process-instances/reports`; let path = `/process-instances/reports`;
let httpMethod = 'POST'; let httpMethod = 'POST';
if (isEditMode() && processInstanceReportSelection) { if (isEditMode() && processInstanceReportSelection) {

View File

@ -31,7 +31,6 @@ import {
DATE_FORMAT_FOR_DISPLAY, DATE_FORMAT_FOR_DISPLAY,
} from '../config'; } from '../config';
import { import {
capitalizeFirstLetter,
convertDateAndTimeStringsToSeconds, convertDateAndTimeStringsToSeconds,
convertDateObjectToFormattedHoursMinutes, convertDateObjectToFormattedHoursMinutes,
convertSecondsToFormattedDateString, convertSecondsToFormattedDateString,
@ -42,6 +41,7 @@ import {
refreshAtInterval, refreshAtInterval,
REFRESH_INTERVAL_SECONDS, REFRESH_INTERVAL_SECONDS,
REFRESH_TIMEOUT_SECONDS, REFRESH_TIMEOUT_SECONDS,
titleizeString,
} from '../helpers'; } from '../helpers';
import { useUriListForPermissions } from '../hooks/UriListForPermissions'; import { useUriListForPermissions } from '../hooks/UriListForPermissions';
@ -337,10 +337,8 @@ export default function ProcessInstanceListTable({
setProcessStatusSelection( setProcessStatusSelection(
(reportFilter.field_value || '').split(',') (reportFilter.field_value || '').split(',')
); );
setShowFilterOptions(true);
} else if (reportFilter.field_name === 'process_initiator_username') { } else if (reportFilter.field_name === 'process_initiator_username') {
setProcessInitiatorSelection(reportFilter.field_value || ''); setProcessInitiatorSelection(reportFilter.field_value || '');
setShowFilterOptions(true);
} else if (reportFilter.field_name === 'process_model_identifier') { } else if (reportFilter.field_name === 'process_model_identifier') {
selectedProcessModelIdentifier = selectedProcessModelIdentifier =
reportFilter.field_value || undefined; reportFilter.field_value || undefined;
@ -358,7 +356,6 @@ export default function ProcessInstanceListTable({
reportFilter.field_value as any reportFilter.field_value as any
); );
timeFunctionToCall(timeString); timeFunctionToCall(timeString);
setShowFilterOptions(true);
} }
} }
} }
@ -368,11 +365,14 @@ export default function ProcessInstanceListTable({
(processModel: ProcessModel) => { (processModel: ProcessModel) => {
if (processModel.id === selectedProcessModelIdentifier) { if (processModel.id === selectedProcessModelIdentifier) {
setProcessModelSelection(processModel); setProcessModelSelection(processModel);
setShowFilterOptions(true);
} }
} }
); );
if (reportMetadataBodyToUse.filter_by.length > 1) {
setShowFilterOptions(true);
}
// eslint-disable-next-line prefer-const // eslint-disable-next-line prefer-const
let { page, perPage } = getPageInfoFromSearchParams( let { page, perPage } = getPageInfoFromSearchParams(
searchParams, searchParams,
@ -774,7 +774,7 @@ export default function ProcessInstanceListTable({
}; };
const formatProcessInstanceStatus = (_row: any, value: any) => { const formatProcessInstanceStatus = (_row: any, value: any) => {
return capitalizeFirstLetter((value || '').replaceAll('_', ' ')); return titleizeString((value || '').replaceAll('_', ' '));
}; };
const processStatusSearch = () => { const processStatusSearch = () => {
return ( return (
@ -845,18 +845,13 @@ export default function ProcessInstanceListTable({
}; };
const saveAsReportComponent = () => { const saveAsReportComponent = () => {
const newReportMetadata = getNewReportMetadataBasedOnPageWidgets();
if (!newReportMetadata) {
return null;
}
return ( return (
<ProcessInstanceListSaveAsReport <ProcessInstanceListSaveAsReport
onSuccess={onSaveReportSuccess} onSuccess={onSaveReportSuccess}
buttonClassName="button-white-background narrow-button" buttonClassName="button-white-background narrow-button"
buttonText="Save" buttonText="Save"
processInstanceReportSelection={processInstanceReportSelection} processInstanceReportSelection={processInstanceReportSelection}
reportMetadata={newReportMetadata} getReportMetadataCallback={getNewReportMetadataBasedOnPageWidgets}
/> />
); );
}; };

View File

@ -41,6 +41,10 @@ export const capitalizeFirstLetter = (string: any) => {
return string.charAt(0).toUpperCase() + string.slice(1); return string.charAt(0).toUpperCase() + string.slice(1);
}; };
export const titleizeString = (string: any) => {
return capitalizeFirstLetter((string || '').replaceAll('_', ' '));
};
export const convertDateToSeconds = ( export const convertDateToSeconds = (
date: any, date: any,
onChangeFunction: any = null onChangeFunction: any = null