From 18371cb2f53fdf108c28375f44461286f2af9cf1 Mon Sep 17 00:00:00 2001 From: Jon Herron Date: Wed, 9 Nov 2022 15:44:11 -0500 Subject: [PATCH] Squashed 'spiffworkflow-frontend/' changes from 2149f03f5..45854fa9a 45854fa9a merged in and recsovled conflicts of frontend tree w/ burnettk baa5f37ae Merge branch 'main' of github.com:sartography/spiff-arena 3cb6a9c77 process instance cypress tests pass now w/ burnettk git-subtree-dir: spiffworkflow-frontend git-subtree-split: 45854fa9aea1cc8b48b39afd5680e525a745188d --- cypress/e2e/process_instances.cy.js | 36 ++++++++++++++--------------- cypress/support/commands.js | 7 +++++- src/helpers.test.tsx | 7 +++++- src/helpers.tsx | 4 +++- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/cypress/e2e/process_instances.cy.js b/cypress/e2e/process_instances.cy.js index d25350bc0..a04ebd681 100644 --- a/cypress/e2e/process_instances.cy.js +++ b/cypress/e2e/process_instances.cy.js @@ -169,30 +169,30 @@ describe('process-instances', () => { cy.getBySel('process-instance-list-link').click(); cy.assertAtLeastOneItemInPaginatedResults(); - // PROCESS_STATUSES.forEach((processStatus) => { - // if (!['all', 'waiting'].includes(processStatus)) { - // cy.get('#process-instance-status-select').click(); - // cy.get('#process-instance-status-select') - // .contains(processStatus) - // .click(); - // // close the dropdown again - // cy.get('#process-instance-status-select').click(); - // cy.getBySel('filter-button').click(); - // cy.assertAtLeastOneItemInPaginatedResults(); - // cy.getBySel(`process-instance-status-${processStatus}`).contains( - // processStatus - // ); - // // there should really only be one, but in CI there are sometimes more - // cy.get('div[aria-label="Clear all selected items"]:first').click(); - // } - // }); + PROCESS_STATUSES.forEach((processStatus) => { + if (!['all', 'waiting'].includes(processStatus)) { + cy.get('#process-instance-status-select').click(); + cy.get('#process-instance-status-select') + .contains(processStatus) + .click(); + // close the dropdown again + cy.get('#process-instance-status-select').click(); + cy.getBySel('filter-button').click(); + cy.assertAtLeastOneItemInPaginatedResults(); + cy.getBySel(`process-instance-status-${processStatus}`).contains( + processStatus + ); + // there should really only be one, but in CI there are sometimes more + cy.get('div[aria-label="Clear all selected items"]:first').click(); + } + }); const date = new Date(); date.setHours(date.getHours() - 1); filterByDate(date); cy.assertAtLeastOneItemInPaginatedResults(); - date.setHours(date.getHours() + 2); + date.setHours(date.getHours() + 26); filterByDate(date); cy.assertNoItemInPaginatedResults(); }); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index c6518917a..40074518d 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -118,7 +118,12 @@ Cypress.Commands.add('assertAtLeastOneItemInPaginatedResults', () => { }); Cypress.Commands.add('assertNoItemInPaginatedResults', () => { - cy.getBySel('total-paginated-items').contains('0'); + cy.contains(/\b0–0 of 0 items/); +}); + +Cypress.Commands.add('modifyProcessModelPath', (path) => { + path.replace('/', ':'); + return path; }); Cypress.Commands.add('modifyProcessModelPath', (path) => { diff --git a/src/helpers.test.tsx b/src/helpers.test.tsx index 9a58f5e65..1031fc46b 100644 --- a/src/helpers.test.tsx +++ b/src/helpers.test.tsx @@ -1,7 +1,12 @@ -import { slugifyString } from './helpers'; +import { convertSecondsToFormattedDate, slugifyString } from './helpers'; test('it can slugify a string', () => { expect(slugifyString('hello---world_ and then Some such-')).toEqual( 'hello-world-and-then-some-such' ); }); + +test('it can keep the correct date when converting seconds to date', () => { + const dateString = convertSecondsToFormattedDate(1666325400); + expect(dateString).toEqual('2022-10-21'); +}); diff --git a/src/helpers.tsx b/src/helpers.tsx index adb28e731..eb5902e36 100644 --- a/src/helpers.tsx +++ b/src/helpers.tsx @@ -44,7 +44,9 @@ export const convertDateToSeconds = ( export const convertStringToDate = (dateString: string) => { if (dateString) { - return new Date(dateString); + // add midnight time to the date so it c uses the correct date + // after converting to timezone + return new Date(`${dateString}T00:10:00`); } return null; };