Skip to content

Commit

Permalink
Revert "[WM-2355] Hide workflow submissions from cloned workspace (#4424
Browse files Browse the repository at this point in the history
)"

This reverts commit bfddd4e.
  • Loading branch information
mspector committed Mar 27, 2024
1 parent 6cf0233 commit 584f4b2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 37 deletions.
14 changes: 2 additions & 12 deletions src/workflows-app/SubmissionHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) => {
Expand All @@ -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(
Expand Down
51 changes: 26 additions & 25 deletions src/workflows-app/SubmissionHistory.test.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -285,32 +275,43 @@ 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');
expect(cellsFromDataRow2.length).toBe(6);
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' }));

Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 584f4b2

Please sign in to comment.