fix cypress tests and support more generic hotCrumbs style in breadcrumb
This commit is contained in:
parent
484e7e3d4b
commit
bd3be87ac9
|
@ -17,12 +17,12 @@ describe('process-groups', () => {
|
||||||
cy.contains('Process Groups').click();
|
cy.contains('Process Groups').click();
|
||||||
cy.contains(groupDisplayName).click();
|
cy.contains(groupDisplayName).click();
|
||||||
cy.url().should('include', `process-groups/${groupId}`);
|
cy.url().should('include', `process-groups/${groupId}`);
|
||||||
cy.contains(`Process Group: ${groupId}`);
|
cy.contains(`Process Group: ${groupDisplayName}`);
|
||||||
|
|
||||||
cy.contains('Edit process group').click();
|
cy.contains('Edit process group').click();
|
||||||
cy.get('input[name=display_name]').clear().type(newGroupDisplayName);
|
cy.get('input[name=display_name]').clear().type(newGroupDisplayName);
|
||||||
cy.contains('Submit').click();
|
cy.contains('Submit').click();
|
||||||
cy.contains(`Process Group: ${groupId}`);
|
cy.contains(`Process Group: ${newGroupDisplayName}`);
|
||||||
|
|
||||||
cy.contains('Edit process group').click();
|
cy.contains('Edit process group').click();
|
||||||
cy.get('input[name=display_name]').should(
|
cy.get('input[name=display_name]').should(
|
||||||
|
|
|
@ -22,12 +22,12 @@ describe('tasks', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can complete and navigate a form', () => {
|
it('can complete and navigate a form', () => {
|
||||||
const groupId = 'acceptance-tests-group-one';
|
const groupDisplayName = 'Acceptance Tests Group One';
|
||||||
const modelId = `acceptance-tests-model-2`;
|
const modelId = `acceptance-tests-model-2`;
|
||||||
const completedTaskClassName = 'completed-task-highlight';
|
const completedTaskClassName = 'completed-task-highlight';
|
||||||
const activeTaskClassName = 'active-task-highlight';
|
const activeTaskClassName = 'active-task-highlight';
|
||||||
|
|
||||||
cy.navigateToProcessModel(groupId, modelId);
|
cy.navigateToProcessModel(groupDisplayName, modelId);
|
||||||
|
|
||||||
// avoid reloading so we can click on the task link that appears on running the process instance
|
// avoid reloading so we can click on the task link that appears on running the process instance
|
||||||
cy.runPrimaryBpmnFile(false);
|
cy.runPrimaryBpmnFile(false);
|
||||||
|
@ -66,7 +66,7 @@ describe('tasks', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.contains('Task: get_user_generated_number_four');
|
cy.contains('Task: get_user_generated_number_four');
|
||||||
cy.navigateToProcessModel(groupId, modelId);
|
cy.navigateToProcessModel(groupDisplayName, modelId);
|
||||||
cy.getBySel('process-instance-list-link').click();
|
cy.getBySel('process-instance-list-link').click();
|
||||||
cy.assertAtLeastOneItemInPaginatedResults();
|
cy.assertAtLeastOneItemInPaginatedResults();
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ describe('tasks', () => {
|
||||||
);
|
);
|
||||||
cy.url().should('include', '/tasks');
|
cy.url().should('include', '/tasks');
|
||||||
|
|
||||||
cy.navigateToProcessModel(groupId, modelId);
|
cy.navigateToProcessModel(groupDisplayName, modelId);
|
||||||
cy.getBySel('process-instance-list-link').click();
|
cy.getBySel('process-instance-list-link').click();
|
||||||
cy.assertAtLeastOneItemInPaginatedResults();
|
cy.assertAtLeastOneItemInPaginatedResults();
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ describe('tasks', () => {
|
||||||
|
|
||||||
it('can paginate items', () => {
|
it('can paginate items', () => {
|
||||||
cy.navigateToProcessModel(
|
cy.navigateToProcessModel(
|
||||||
'acceptance-tests-group-one',
|
'Acceptance Tests Group One',
|
||||||
'acceptance-tests-model-2'
|
'acceptance-tests-model-2'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ Cypress.Commands.add('createGroup', (groupId, groupDisplayName) => {
|
||||||
cy.contains('Submit').click();
|
cy.contains('Submit').click();
|
||||||
|
|
||||||
cy.url().should('include', `process-groups/${groupId}`);
|
cy.url().should('include', `process-groups/${groupId}`);
|
||||||
cy.contains(`Process Group: ${groupId}`);
|
cy.contains(`Process Group: ${groupDisplayName}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add('createModel', (groupId, modelId, modelDisplayName) => {
|
Cypress.Commands.add('createModel', (groupId, modelId, modelDisplayName) => {
|
||||||
|
|
|
@ -1,20 +1,44 @@
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import Breadcrumb from 'react-bootstrap/Breadcrumb';
|
import Breadcrumb from 'react-bootstrap/Breadcrumb';
|
||||||
|
import { BreadcrumbItem } from '../interfaces';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
processModelId?: string;
|
processModelId?: string;
|
||||||
processGroupId?: string;
|
processGroupId?: string;
|
||||||
linkProcessModel?: boolean;
|
linkProcessModel?: boolean;
|
||||||
|
hotCrumbs?: BreadcrumbItem[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ProcessBreadcrumb({
|
export default function ProcessBreadcrumb({
|
||||||
processModelId,
|
processModelId,
|
||||||
processGroupId,
|
processGroupId,
|
||||||
|
hotCrumbs,
|
||||||
linkProcessModel = false,
|
linkProcessModel = false,
|
||||||
}: OwnProps) {
|
}: OwnProps) {
|
||||||
let processGroupBreadcrumb = null;
|
let processGroupBreadcrumb = null;
|
||||||
let processModelBreadcrumb = null;
|
let processModelBreadcrumb = null;
|
||||||
|
if (hotCrumbs) {
|
||||||
|
const lastItem = hotCrumbs.pop();
|
||||||
|
if (lastItem === undefined) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const lastCrumb = <Breadcrumb.Item active>{lastItem[0]}</Breadcrumb.Item>;
|
||||||
|
const leadingCrumbLinks = hotCrumbs.map((crumb) => {
|
||||||
|
const valueLabel = crumb[0];
|
||||||
|
const url = crumb[1];
|
||||||
|
return (
|
||||||
|
<Breadcrumb.Item linkAs={Link} linkProps={{ to: url }}>
|
||||||
|
{valueLabel}
|
||||||
|
</Breadcrumb.Item>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<Breadcrumb>
|
||||||
|
{leadingCrumbLinks}
|
||||||
|
{lastCrumb}
|
||||||
|
</Breadcrumb>
|
||||||
|
);
|
||||||
|
}
|
||||||
if (processModelId) {
|
if (processModelId) {
|
||||||
if (linkProcessModel) {
|
if (linkProcessModel) {
|
||||||
processModelBreadcrumb = (
|
processModelBreadcrumb = (
|
||||||
|
|
|
@ -10,9 +10,17 @@ export interface RecentProcessModel {
|
||||||
processModelDisplayName: string;
|
processModelDisplayName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ProcessGroup {
|
||||||
|
id: string;
|
||||||
|
display_name: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ProcessModel {
|
export interface ProcessModel {
|
||||||
id: string;
|
id: string;
|
||||||
process_group_id: string;
|
process_group_id: string;
|
||||||
display_name: string;
|
display_name: string;
|
||||||
primary_file_name: string;
|
primary_file_name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tuple of display value and URL
|
||||||
|
export type BreadcrumbItem = [displayValue: string, url?: string];
|
||||||
|
|
|
@ -132,7 +132,7 @@ export default function ProcessGroupList() {
|
||||||
if (pagination) {
|
if (pagination) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ProcessBreadcrumb />
|
<ProcessBreadcrumb hotCrumbs={[['Process Groups']]} />
|
||||||
<Button href="/admin/process-groups/new">Add a process group</Button>
|
<Button href="/admin/process-groups/new">Add a process group</Button>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -5,12 +5,13 @@ import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
||||||
import PaginationForTable from '../components/PaginationForTable';
|
import PaginationForTable from '../components/PaginationForTable';
|
||||||
import HttpService from '../services/HttpService';
|
import HttpService from '../services/HttpService';
|
||||||
import { getPageInfoFromSearchParams } from '../helpers';
|
import { getPageInfoFromSearchParams } from '../helpers';
|
||||||
|
import { ProcessGroup } from '../interfaces';
|
||||||
|
|
||||||
export default function ProcessGroupShow() {
|
export default function ProcessGroupShow() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
|
|
||||||
const [processGroup, setProcessGroup] = useState(null);
|
const [processGroup, setProcessGroup] = useState<ProcessGroup | null>(null);
|
||||||
const [processModels, setProcessModels] = useState([]);
|
const [processModels, setProcessModels] = useState([]);
|
||||||
const [pagination, setPagination] = useState(null);
|
const [pagination, setPagination] = useState(null);
|
||||||
|
|
||||||
|
@ -35,14 +36,15 @@ export default function ProcessGroupShow() {
|
||||||
}, [params, searchParams]);
|
}, [params, searchParams]);
|
||||||
|
|
||||||
const buildTable = () => {
|
const buildTable = () => {
|
||||||
|
if (processGroup === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const rows = processModels.map((row) => {
|
const rows = processModels.map((row) => {
|
||||||
return (
|
return (
|
||||||
<tr key={(row as any).id}>
|
<tr key={(row as any).id}>
|
||||||
<td>
|
<td>
|
||||||
<Link
|
<Link
|
||||||
to={`/admin/process-models/${(processGroup as any).id}/${
|
to={`/admin/process-models/${processGroup.id}/${(row as any).id}`}
|
||||||
(row as any).id
|
|
||||||
}`}
|
|
||||||
data-qa="process-model-show-link"
|
data-qa="process-model-show-link"
|
||||||
>
|
>
|
||||||
{(row as any).id}
|
{(row as any).id}
|
||||||
|
@ -72,7 +74,12 @@ export default function ProcessGroupShow() {
|
||||||
const { page, perPage } = getPageInfoFromSearchParams(searchParams);
|
const { page, perPage } = getPageInfoFromSearchParams(searchParams);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ProcessBreadcrumb processGroupId={(processGroup as any).id} />
|
<ProcessBreadcrumb
|
||||||
|
hotCrumbs={[
|
||||||
|
['Process Groups', '/admin'],
|
||||||
|
[`Process Group: ${processGroup.display_name}`],
|
||||||
|
]}
|
||||||
|
/>
|
||||||
<ul>
|
<ul>
|
||||||
<Stack direction="horizontal" gap={3}>
|
<Stack direction="horizontal" gap={3}>
|
||||||
<Button
|
<Button
|
||||||
|
|
Loading…
Reference in New Issue