diff --git a/src/workflows-app/SubmissionHistory.js b/src/workflows-app/SubmissionHistory.js index 30130431c1..f65872f3d1 100644 --- a/src/workflows-app/SubmissionHistory.js +++ b/src/workflows-app/SubmissionHistory.js @@ -13,7 +13,6 @@ import * as Nav from 'src/libs/nav'; import { notify } from 'src/libs/notifications'; import { useCancellation, useOnMount, usePollingEffect } from 'src/libs/react-utils'; import { AppProxyUrlStatus, workflowsAppStore } from 'src/libs/state'; -import { differenceFromDatesInSeconds } from 'src/libs/utils'; import * as Utils from 'src/libs/utils'; import { doesAppProxyUrlExist, loadAppUrls } from 'src/workflows-app/utils/app-utils'; import { @@ -37,7 +36,6 @@ export const BaseSubmissionHistory = ({ namespace, workspace }, _ref) => { const signal = useCancellation(); const scheduledRefresh = useRef(); const workspaceId = workspace.workspace.workspaceId; - const workspaceCreated = workspace.workspace.createdDate; const loadRunSets = useCallback( async (cbasUrlRoot) => { @@ -47,20 +45,12 @@ export const BaseSubmissionHistory = ({ namespace, workspace }, _ref) => { (r) => _.merge(r, { duration: getDuration(r.state, r.submission_timestamp, r.last_modified_timestamp, isRunSetInTerminalState) }), runSets.run_sets ); - // TODO: Remove filtering once WM-2232 is complete - // We are doing this filtering to ensure submissions from cloned workspaces are not displayed in the workspace clone. - const onlyWorkspaceRunSets = durationEnhancedRunSets.filter( - (runSet) => differenceFromDatesInSeconds(workspaceCreated, runSet.submission_timestamp) > 0 - ); - return { - ...runSets, - run_sets: onlyWorkspaceRunSets, - }; + return _.merge(runSets, { run_sets: durationEnhancedRunSets }); } catch (error) { notify('error', 'Error getting run set data', { detail: error instanceof Response ? await error.text() : error }); } }, - [signal, workspaceCreated] + [signal] ); const loadAllRunSets = useCallback( diff --git a/src/workflows-app/SubmissionHistory.test.js b/src/workflows-app/SubmissionHistory.test.js index f6a00ee46f..48a6bb42bd 100644 --- a/src/workflows-app/SubmissionHistory.test.js +++ b/src/workflows-app/SubmissionHistory.test.js @@ -1,6 +1,5 @@ import { act, screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import _ from 'lodash/fp'; import { div, h } from 'react-hyperscript-helpers'; import { MenuTrigger } from 'src/components/PopupTrigger'; import { Ajax } from 'src/libs/ajax'; @@ -49,27 +48,18 @@ const originalOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototyp const runSetData = { run_sets: [ { - error_count: 2, + error_count: 0, submission_timestamp: '2022-01-01T12:00:00.000+00:00', last_modified_timestamp: '2022-01-02T13:01:01.000+00:00', record_type: 'FOO', - run_count: 4, - run_set_id: '1f496c9a-e2ab-4f33-9298-e444c53c7d9d', - state: 'COMPLETE', - }, - { - error_count: 0, - submission_timestamp: '2023-08-01T12:00:00.000+00:00', - last_modified_timestamp: '2023-08-02T13:01:01.000+00:00', - record_type: 'FOO', run_count: 1, run_set_id: 'ea001565-1cd6-4e43-b446-932ac1918081', state: 'COMPLETE', }, { error_count: 1, - submission_timestamp: '2023-07-10T12:00:00.000+00:00', - last_modified_timestamp: '2023-08-11T13:01:01.000+00:00', + submission_timestamp: '2021-07-10T12:00:00.000+00:00', + last_modified_timestamp: '2021-08-11T13:01:01.000+00:00', record_type: 'FOO', run_count: 2, run_set_id: 'b7234aae-6f43-405e-bb3a-71f924e09825', @@ -160,11 +150,11 @@ describe('SubmissionHistory tab', () => { // Click on "Date Submitted" column and check that the top column is correct for: // * ascending order await user.click(await within(headers[headerPosition['Date Submitted']]).getByRole('button')); - within(topRowCells(headerPosition['Date Submitted'])).getByText(/Jul 10, 2023/); + within(topRowCells(headerPosition['Date Submitted'])).getByText(/Jul 10, 2021/); // * descending order await user.click(await within(headers[headerPosition['Date Submitted']]).getByRole('button')); - within(topRowCells(headerPosition['Date Submitted'])).getByText(/Aug 1, 2023/); + within(topRowCells(headerPosition['Date Submitted'])).getByText(/Jan 1, 2022/); // Click on "Status" column and check that the top column is correct for: // * ascending order @@ -267,7 +257,7 @@ describe('SubmissionHistory tab', () => { expect(table).toHaveAttribute('aria-rowcount', '3'); const rows = within(table).getAllByRole('row'); - expect(rows.length).toBe(3); // header + 2 submissions after workspace creation + expect(rows.length).toBe(3); const headers = within(rows[0]).getAllByRole('columnheader'); expect(headers.length).toBe(6); @@ -285,7 +275,7 @@ describe('SubmissionHistory tab', () => { within(cellsFromDataRow1[headerPosition.Submission]).getByText('Data used: FOO'); within(cellsFromDataRow1[headerPosition.Submission]).getByText('1 workflows'); within(cellsFromDataRow1[headerPosition.Status]).getByText('Success'); - within(cellsFromDataRow1[headerPosition['Date Submitted']]).getByText(/Aug 1, 2023/); + within(cellsFromDataRow1[headerPosition['Date Submitted']]).getByText(/Jan 1, 2022/); within(cellsFromDataRow1[headerPosition.Duration]).getByText('1 day 1 hour 1 minute 1 second'); const cellsFromDataRow2 = within(rows[2]).getAllByRole('cell'); @@ -293,24 +283,35 @@ describe('SubmissionHistory tab', () => { within(headers[headerPosition.Actions]).getByText('Actions'); within(cellsFromDataRow2[headerPosition.Submission]).getByText('Data used: FOO'); within(cellsFromDataRow2[headerPosition.Status]).getByText('Failed with 1 errors'); - within(cellsFromDataRow2[headerPosition['Date Submitted']]).getByText(/Jul 10, 2023/); + within(cellsFromDataRow2[headerPosition['Date Submitted']]).getByText(/Jul 10, 2021/); within(cellsFromDataRow2[headerPosition.Duration]).getByText('1 month 1 day 1 hour 1 minute 1 second'); }); it('should support canceled and canceling submissions', async () => { - const newRunSetData = { - run_sets: _.merge(runSetData.run_sets, [ - {}, + const runSetData = { + run_sets: [ { + error_count: 0, + submission_timestamp: '2022-01-01T12:00:00.000+00:00', + last_modified_timestamp: '2022-01-02T13:01:01.000+00:00', + record_type: 'FOO', + run_count: 1, + run_set_id: 'ea001565-1cd6-4e43-b446-932ac1918081', state: 'CANCELED', }, { + error_count: 0, + submission_timestamp: '2021-07-10T12:00:00.000+00:00', + last_modified_timestamp: '2021-08-11T13:01:01.000+00:00', + record_type: 'FOO', + run_count: 2, + run_set_id: 'b7234aae-6f43-405e-bb3a-71f924e09825', state: 'CANCELING', }, - ]), + ], }; - const getRunSetsMethod = jest.fn(() => Promise.resolve(newRunSetData)); + const getRunSetsMethod = jest.fn(() => Promise.resolve(runSetData)); const mockLeoResponse = jest.fn(() => Promise.resolve(mockAzureApps)); const mockUserResponse = jest.fn(() => Promise.resolve({ userSubjectId: 'user-id-blah-blah' })); @@ -364,8 +365,8 @@ describe('SubmissionHistory tab', () => { run_sets: [ { error_count: 0, - submission_timestamp: '2023-08-01T12:00:00.000+00:00', - last_modified_timestamp: '2023-08-02T13:01:01.000+00:00', + submission_timestamp: '2022-01-01T12:00:00.000+00:00', + last_modified_timestamp: '2022-01-02T13:01:01.000+00:00', record_type: 'FOO', run_count: 1, run_set_id: '20000000-0000-0000-0000-200000000002',