fixed pagination of log tables and broken cypress tests w/ burnettk (#382)

* fixed pagination of log tables and broken cypress tests w/ burnettk

* wait before clicking the profile button instead of after w/ burnettk

---------

Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
jasquat 2023-07-10 14:06:55 -04:00 committed by GitHub
parent 9285358e69
commit 800b61cf36
8 changed files with 83 additions and 37 deletions

View File

@ -159,20 +159,22 @@ describe('process-instances', () => {
cy.runPrimaryBpmnFile(); cy.runPrimaryBpmnFile();
cy.getBySel('process-instance-list-link').click(); cy.getBySel('process-instance-list-link').click();
cy.getBySel('process-instance-show-link-id').first().click(); cy.getBySel('process-instance-show-link-id').first().click();
cy.getBySel('process-instance-log-list-link').click(); cy.contains('Events').click();
cy.getBySel('process-instance-log-events').click();
cy.contains('process_model_one'); cy.contains('process_model_one');
cy.contains('task_completed'); cy.contains('task_completed');
cy.basicPaginationTest(); cy.basicPaginationTest(undefined, 'pagination-options-events');
}); });
it('can filter', () => { it('can filter', () => {
cy.getBySel('process-instance-list-link').click(); cy.getBySel('process-instance-list-link').click();
cy.getBySel('process-instance-list-all').click(); cy.contains('My Process Instances');
cy.contains('All Process Instances'); cy.get('.process-instance-list-row-variant-for-me');
cy.assertAtLeastOneItemInPaginatedResults(); cy.assertAtLeastOneItemInPaginatedResults();
cy.getBySel('filter-section-expand-toggle').click(); cy.getBySel('process-instance-list-all').click();
cy.contains('All Process Instances');
cy.get('.process-instance-list-row-variant-all');
cy.assertAtLeastOneItemInPaginatedResults();
const statusSelect = '#process-instance-status-select'; const statusSelect = '#process-instance-status-select';
PROCESS_STATUSES.forEach((processStatus) => { PROCESS_STATUSES.forEach((processStatus) => {
@ -188,8 +190,9 @@ describe('process-instances', () => {
cy.assertAtLeastOneItemInPaginatedResults(); cy.assertAtLeastOneItemInPaginatedResults();
cy.getBySel(`process-instance-status-${processStatus}`); cy.getBySel(`process-instance-status-${processStatus}`);
// maybe waiting a bit before trying to click makes this work consistently? // we tried 500 as well to try to make this work consistently
cy.wait(1000); cy.wait(1000);
// there should really only be one, but in CI there are sometimes more // there should really only be one, but in CI there are sometimes more
cy.get('div[aria-label="Clear all selected items"]:first').click(); cy.get('div[aria-label="Clear all selected items"]:first').click();
cy.get('div[aria-label="Clear all selected items"]').should( cy.get('div[aria-label="Clear all selected items"]').should(

View File

@ -96,18 +96,19 @@ describe('tasks', () => {
// This should get the first one which should be the one we just completed // This should get the first one which should be the one we just completed
cy.getBySel('process-instance-show-link-id').first().click(); cy.getBySel('process-instance-show-link-id').first().click();
cy.contains('Process Instance Id: '); cy.contains('Process Instance Id: ');
cy.contains('Status: complete'); cy.get('.process-instance-status').contains('complete');
}); });
it('can paginate items', () => { // we no longer have a tasks table so these are actually covered in the process_instances test
// make sure we have some tasks // it('can paginate items', () => {
kickOffModelWithForm(); // // make sure we have some tasks
kickOffModelWithForm(); // kickOffModelWithForm();
kickOffModelWithForm(); // kickOffModelWithForm();
kickOffModelWithForm(); // kickOffModelWithForm();
kickOffModelWithForm(); // kickOffModelWithForm();
// kickOffModelWithForm();
cy.navigateToHome(); //
cy.basicPaginationTest('process-instance-show-link-id'); // cy.navigateToHome();
}); // cy.basicPaginationTest('process-instance-show-link-id');
// });
}); });

View File

@ -61,8 +61,10 @@ Cypress.Commands.add('login', (username, password) => {
}); });
Cypress.Commands.add('logout', (_selector, ..._args) => { Cypress.Commands.add('logout', (_selector, ..._args) => {
cy.get('#user-profile-toggletip').click();
cy.wait(2000); cy.wait(2000);
// click the profile thingy in the top right
cy.get('.user-profile-toggletip-button').click();
cy.getBySel('logout-button').click(); cy.getBySel('logout-button').click();
if (Cypress.env('SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK') === true) { if (Cypress.env('SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK') === true) {
// otherwise we can click logout, quickly load the next page, and the javascript // otherwise we can click logout, quickly load the next page, and the javascript
@ -142,9 +144,15 @@ Cypress.Commands.add(
Cypress.Commands.add( Cypress.Commands.add(
'basicPaginationTest', 'basicPaginationTest',
(dataQaTagToUseToEnsureTableHasLoaded = 'paginated-entity-id') => { (
cy.getBySel('pagination-options').scrollIntoView(); dataQaTagToUseToEnsureTableHasLoaded = 'paginated-entity-id',
cy.get('.cds--select__item-count').find('.cds--select-input').select('2'); paginationOptionsDataQa = 'pagination-options'
) => {
cy.getBySel(paginationOptionsDataQa).scrollIntoView();
cy.getBySel(paginationOptionsDataQa)
.find('.cds--select__item-count')
.find('.cds--select-input')
.select('2');
// NOTE: this is a em dash instead of en dash // NOTE: this is a em dash instead of en dash
cy.contains(/\b12 of \d+/); cy.contains(/\b12 of \d+/);
@ -159,14 +167,17 @@ Cypress.Commands.add(
.first() .first()
.then(($element) => { .then(($element) => {
const oldId = $element.text().trim(); const oldId = $element.text().trim();
cy.get('.cds--pagination__button--forward').click(); cy.getBySel(paginationOptionsDataQa)
cy.contains( .find('.cds--pagination__button--forward')
`[data-qa=${dataQaTagToUseToEnsureTableHasLoaded}]`, .click();
oldId cy.getBySel(paginationOptionsDataQa)
).should('not.exist'); .contains(`[data-qa=${dataQaTagToUseToEnsureTableHasLoaded}]`, oldId)
cy.contains(/\b34 of \d+/); .should('not.exist');
cy.get('.cds--pagination__button--backward').click(); cy.getBySel(paginationOptionsDataQa).contains(/\b34 of \d+/);
cy.contains(/\b12 of \d+/); cy.getBySel(paginationOptionsDataQa)
.find('.cds--pagination__button--backward')
.click();
cy.getBySel(paginationOptionsDataQa).contains(/\b12 of \d+/);
cy.contains(`[data-qa=${dataQaTagToUseToEnsureTableHasLoaded}]`, oldId); cy.contains(`[data-qa=${dataQaTagToUseToEnsureTableHasLoaded}]`, oldId);
}); });
} }

View File

@ -185,6 +185,7 @@ export default function MessageInstanceList({ processInstanceId }: OwnProps) {
perPage={perPage} perPage={perPage}
pagination={pagination} pagination={pagination}
tableToDisplay={buildTable()} tableToDisplay={buildTable()}
paginationQueryParamPrefix="message-list"
/> />
</> </>
); );

View File

@ -15,6 +15,7 @@ type OwnProps = {
tableToDisplay: any; tableToDisplay: any;
paginationQueryParamPrefix?: string; paginationQueryParamPrefix?: string;
paginationClassName?: string; paginationClassName?: string;
paginationDataQATag?: string;
}; };
export default function PaginationForTable({ export default function PaginationForTable({
@ -25,6 +26,7 @@ export default function PaginationForTable({
tableToDisplay, tableToDisplay,
paginationQueryParamPrefix, paginationQueryParamPrefix,
paginationClassName, paginationClassName,
paginationDataQATag = 'pagination-options',
}: OwnProps) { }: OwnProps) {
const PER_PAGE_OPTIONS = [2, 10, 50, 100]; const PER_PAGE_OPTIONS = [2, 10, 50, 100];
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
@ -47,7 +49,7 @@ export default function PaginationForTable({
{tableToDisplay} {tableToDisplay}
<Pagination <Pagination
className={paginationClassName} className={paginationClassName}
data-qa="pagination-options" data-qa={paginationDataQATag}
backwardText="Previous page" backwardText="Previous page"
forwardText="Next page" forwardText="Next page"
itemsPerPageText="Items per page:" itemsPerPageText="Items per page:"

View File

@ -1648,6 +1648,18 @@ export default function ProcessInstanceListTable({
`${processInstanceShowPathPrefix}/${modifiedModelId}/${processInstance.id}` `${processInstanceShowPathPrefix}/${modifiedModelId}/${processInstance.id}`
); );
}; };
let variantFromMetadata = 'all';
if (reportMetadata) {
reportMetadata.filter_by.forEach((filter: any) => {
if (
filter.field_name === 'with_relation_to_me' &&
filter.field_value
) {
variantFromMetadata = 'for-me';
}
});
}
return ( return (
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
<tr <tr
@ -1655,6 +1667,7 @@ export default function ProcessInstanceListTable({
key={processInstance.id} key={processInstance.id}
onClick={navigateToProcessInstance} onClick={navigateToProcessInstance}
onKeyDown={navigateToProcessInstance} onKeyDown={navigateToProcessInstance}
className={`process-instance-list-row-variant-${variantFromMetadata}`}
> >
{currentRow} {currentRow}
</tr> </tr>

View File

@ -82,6 +82,8 @@ export default function ProcessInstanceLogList({
processInstanceShowPageBaseUrl = `/admin/process-instances/${processModelId}`; processInstanceShowPageBaseUrl = `/admin/process-instances/${processModelId}`;
} }
const taskNameHeader = isEventsView ? 'Task Name' : 'Milestone'; const taskNameHeader = isEventsView ? 'Task Name' : 'Milestone';
const tableType = isEventsView ? 'events' : 'milestones';
const paginationQueryParamPrefix = `log-list-${tableType}`;
const updateSearchParams = (value: string, key: string) => { const updateSearchParams = (value: string, key: string) => {
if (value) { if (value) {
@ -96,7 +98,7 @@ export default function ProcessInstanceLogList({
// Clear out any previous results to avoid a "flicker" effect where columns // Clear out any previous results to avoid a "flicker" effect where columns
// are updated above the incorrect data. // are updated above the incorrect data.
setProcessInstanceLogs([]); setProcessInstanceLogs([]);
setPagination(null); // setPagination(null);
const setProcessInstanceLogListFromResult = (result: any) => { const setProcessInstanceLogListFromResult = (result: any) => {
setProcessInstanceLogs(result.results); setProcessInstanceLogs(result.results);
@ -105,8 +107,6 @@ export default function ProcessInstanceLogList({
const searchParamsToInclude = [ const searchParamsToInclude = [
'events', 'events',
'page',
'per_page',
'bpmn_name', 'bpmn_name',
'bpmn_identifier', 'bpmn_identifier',
'task_type', 'task_type',
@ -117,10 +117,17 @@ export default function ProcessInstanceLogList({
searchParamsToInclude searchParamsToInclude
); );
const { page, perPage } = getPageInfoFromSearchParams(
searchParams,
undefined,
undefined,
paginationQueryParamPrefix
);
HttpService.makeCallToBackend({ HttpService.makeCallToBackend({
path: `${targetUris.processInstanceLogListPath}?${createSearchParams( path: `${targetUris.processInstanceLogListPath}?${createSearchParams(
pickedSearchParams pickedSearchParams
)}`, )}&page=${page}&per_page=${perPage}`,
successCallback: setProcessInstanceLogListFromResult, successCallback: setProcessInstanceLogListFromResult,
}); });
@ -143,6 +150,7 @@ export default function ProcessInstanceLogList({
processModelId, processModelId,
targetUris.processInstanceLogListPath, targetUris.processInstanceLogListPath,
isEventsView, isEventsView,
paginationQueryParamPrefix,
]); ]);
const handleErrorEventModalClose = () => { const handleErrorEventModalClose = () => {
@ -492,6 +500,7 @@ export default function ProcessInstanceLogList({
if (clearAll) { if (clearAll) {
return <p>Page cleared 👍</p>; return <p>Page cleared 👍</p>;
} }
return ( return (
<> <>
{errorEventModal()} {errorEventModal()}
@ -507,6 +516,8 @@ export default function ProcessInstanceLogList({
perPage={perPage} perPage={perPage}
pagination={pagination} pagination={pagination}
tableToDisplay={buildTable()} tableToDisplay={buildTable()}
paginationQueryParamPrefix={paginationQueryParamPrefix}
paginationDataQATag={`pagination-options-${tableType}`}
/> />
</> </>
); );

View File

@ -340,7 +340,11 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
<dl> <dl>
<dt>Status:</dt> <dt>Status:</dt>
<dd> <dd>
<Tag type={statusColor} size="sm" className="span-tag"> <Tag
type={statusColor}
size="sm"
className="span-tag process-instance-status"
>
{processInstance.status} {statusIcon} {processInstance.status} {statusIcon}
</Tag> </Tag>
</dd> </dd>