Skip to content

Commit

Permalink
Merge pull request #752 from hms-dbmi-cellenics/1902-remove-project-f…
Browse files Browse the repository at this point in the history
…rom-code

1902 remove project from redux
  • Loading branch information
cosa65 authored Jul 4, 2022
2 parents a689608 + e06969f commit 5c6233c
Show file tree
Hide file tree
Showing 130 changed files with 1,472 additions and 3,085 deletions.
8 changes: 5 additions & 3 deletions src/__test__/components/ContentWrapper.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import AppRouteProvider from 'utils/AppRouteProvider';

import { makeStore } from 'redux/store';
import { getBackendStatus } from 'redux/selectors';
import { loadProjects, setActiveProject } from 'redux/actions/projects';

import { loadExperiments, setActiveExperiment } from 'redux/actions/experiments';

import { updateExperimentInfo } from 'redux/actions/experimentSettings';
import generateGem2sParamsHash from 'utils/data-management/generateGem2sParamsHash';

Expand Down Expand Up @@ -117,8 +119,8 @@ describe('ContentWrapper', () => {
status: null,
}));

await store.dispatch(loadProjects());
await store.dispatch(setActiveProject(experimentId));
await store.dispatch(loadExperiments());
await store.dispatch(setActiveExperiment(experimentId));
await store.dispatch(updateExperimentInfo({ experimentId, experimentName, sampleIds }));
});

Expand Down
17 changes: 4 additions & 13 deletions src/__test__/components/NotifyByEmail.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ import { act } from 'react-dom/test-utils';
import { Provider } from 'react-redux';
import userEvent from '@testing-library/user-event';
import * as updateExperiment from 'redux/actions/experiments/updateExperiment';
import * as loadProjects from 'redux/actions/projects/loadProjects';
import * as loadExperiments from 'redux/actions/experiments/loadExperiments';
import fetchMock, { enableFetchMocks } from 'jest-fetch-mock';
import mockAPI, {
generateDefaultMockAPIResponses,
} from '__test__/test-utils/mockAPI';

import { makeStore } from 'redux/store';
import fake from '__test__/test-utils/constants';

Expand All @@ -23,19 +20,18 @@ const experimentId = fake.EXPERIMENT_ID;

describe('Notify by email component', () => {
let updateExperimentSpy;
let loadProjectsSpy;
let loadExperimentsSpy;

beforeEach(() => {
jest.clearAllMocks();
updateExperimentSpy = jest.spyOn(updateExperiment, 'default');
loadProjectsSpy = jest.spyOn(loadProjects, 'default');
loadExperimentsSpy = jest.spyOn(loadExperiments, 'default');
enableFetchMocks();
fetchMock.resetMocks();
fetchMock.doMock();
storeState = makeStore();
});

const renderNotifyByEmail = async () => {
await act(async () => (render(
<Provider store={storeState}>
Expand All @@ -45,11 +41,6 @@ describe('Notify by email component', () => {
</Provider>,
)));
};
it('loads experiments if there is an activeProjectUuid', async () => {
fetchMock.mockIf(/.*/, mockAPI(generateDefaultMockAPIResponses(experimentId, fake.PROJECT_ID)));
await renderNotifyByEmail();
expect(loadExperimentsSpy).toHaveBeenCalledTimes(1);
});

it('Renders Correctly', async () => {
await renderNotifyByEmail();
Expand All @@ -67,8 +58,8 @@ describe('Notify by email component', () => {
expect(updateExperimentSpy).toHaveBeenCalledTimes(2);
});

it('loads projects if non-existent', async () => {
it('loads experiments if non-existent', async () => {
await renderNotifyByEmail();
expect(loadProjectsSpy).toHaveBeenCalledTimes(1);
expect(loadExperimentsSpy).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const loadAndRenderDefault = async () => {
fetchMock.resetMocks();
fetchMock.doMock();

fetchMock.mockIf(/.*/, mockAPI(generateDefaultMockAPIResponses(fake.EXPERIMENT_ID, fake.PROJECT_ID)));
fetchMock.mockIf(/.*/, mockAPI(generateDefaultMockAPIResponses(fake.EXPERIMENT_ID)));

storeState = makeStore();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const loadAndRenderDefaultHeatmap = async (storeState) => {
});
};

const mockAPIResponses = generateDefaultMockAPIResponses(experimentId, fake.PROJECT_ID);
const mockAPIResponses = generateDefaultMockAPIResponses(experimentId);

const errorResponse = () => Promise.reject(new Error('Some error idk'));

Expand Down
41 changes: 15 additions & 26 deletions src/__test__/components/data-management/DownloadDataButton.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import DownloadDataButton from 'components/data-management/DownloadDataButton';
import pushNotificationMessage from 'utils/pushNotificationMessage';
import downloadFromUrl from 'utils/data-management/downloadFromUrl';

import initialProjectState, { projectTemplate } from 'redux/reducers/projects/initialState';
import initialSamplesState from 'redux/reducers/samples/initialState';
import initialExperimentsState from 'redux/reducers/experiments/initialState';
import initialExperimentSettingsState from 'redux/reducers/experimentSettings/initialState';
Expand All @@ -28,32 +27,23 @@ jest.mock('utils/http/fetchAPI');
jest.mock('utils/data-management/downloadFromUrl');

const mockStore = configureMockStore([thunk]);
const projectName = 'Project 1';
const projectUuid = 'project-1-uuid';
const projectDescription = 'Some description';
const experimentName = 'Experiment 1';
const experimentDescription = 'Some description';
const experimentId = 'my-experiment-🧬';
const sample1Uuid = 'sample-1';
const sample2Uuid = 'sample-2';

const noDataState = {
projects: {
...initialProjectState,
meta: {
...initialProjectState.meta,
activeProjectUuid: projectUuid,
loading: false,
},
ids: [projectUuid],
[projectUuid]: {
...projectTemplate,
uuid: projectUuid,
name: projectName,
description: projectDescription,
},
},
experiments: {
...initialExperimentsState,
name: experimentName,
description: experimentDescription,
ids: ['experiment-1'],
meta: {
...initialExperimentsState.meta,
activeExperimentId: experimentId,
loading: false,
},
},
experimentSettings: {
...initialExperimentSettingsState,
Expand All @@ -65,13 +55,12 @@ const noDataState = {

const withDataState = {
...noDataState,
projects: {
...noDataState.projects,
[projectUuid]: {
...noDataState.projects[projectUuid],
samples: [sample1Uuid, sample2Uuid],
experiments: {
...noDataState.experiments,
[experimentId]: {
...noDataState.experiments[experimentId],
sampleIds: [sample1Uuid, sample2Uuid],
metadataKeys: ['metadata-1'],
experiments: [experimentId],
},
},
experimentSettings: {
Expand All @@ -97,7 +86,7 @@ describe('DownloadDataButton', () => {
await act(async () => {
render(
<Provider store={store}>
<DownloadDataButton activeProjectUuid={projectUuid} />
<DownloadDataButton />
</Provider>,
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import { runGem2s } from 'redux/actions/pipeline';

import PipelineStatus from 'utils/pipelineStatusValues';
import LaunchAnalysisButton from 'components/data-management/LaunchAnalysisButton';
import initialProjectState, { projectTemplate } from 'redux/reducers/projects/initialState';
import initialSamplesState, { sampleTemplate } from 'redux/reducers/samples/initialState';
import initialExperimentsState, { experimentTemplate } from 'redux/reducers/experiments/initialState';
import initialSamplesState, { sampleTemplate } from 'redux/reducers/samples/initialState';
import { initialExperimentBackendStatus } from 'redux/reducers/backendStatus/initialState';

import UploadStatus from 'utils/upload/UploadStatus';
Expand All @@ -37,37 +36,28 @@ jest.mock('utils/AppRouteProvider', () => ({

const mockStore = configureMockStore([thunk]);

const projectName = 'Project 1';
const projectUuid = 'project-1-uuid';
const projectDescription = 'Some description';
const sample1Name = 'Sample 1';
const experiment1id = 'experiment-1';
const experimentName = 'Experiment 1';
const experimentDescription = 'Some description';
const sample1Uuid = 'sample-1';
const sample2Name = 'Sample 2';
const sample1Name = 'Sample 1';
const sample2Uuid = 'sample-2';
const experiment1id = 'experiment-1';
const sample2Name = 'Sample 2';

const noDataState = {
projects: {
...initialProjectState,
experiments: {
...initialExperimentsState,
meta: {
...initialProjectState.meta,
activeProjectUuid: projectUuid,
...initialExperimentsState,
activeExperimentId: experiment1id,
loading: false,
},
ids: [projectUuid],
[projectUuid]: {
...projectTemplate,
experiments: [experiment1id],
uuid: projectUuid,
name: projectName,
description: projectDescription,
},
},
experiments: {
...initialExperimentsState,
ids: [experiment1id],
[experiment1id]: {
...experimentTemplate,
id: experiment1id,
name: experimentName,
description: experimentDescription,
},
},
samples: {
Expand All @@ -90,28 +80,21 @@ const noDataState = {

const withDataState = {
...noDataState,
projects: {
...noDataState.projects,
[projectUuid]: {
...noDataState.projects[projectUuid],
samples: [sample1Uuid, sample2Uuid],
metadataKeys: ['metadata-1'],
},
},
experiments: {
...noDataState.experiments,
[experiment1id]: {
...experimentTemplate,
...noDataState.experiments[experiment1id],
sampleIds: [sample1Uuid, sample2Uuid],
metadataKeys: ['metadata-1'],
},
},
samples: {
...noDataState.samples,
[sample1Uuid]: {
...sampleTemplate,
name: sample1Name,
projectUuid,
experimentId: experiment1id,
uuid: sample1Uuid,
type: '10X Chromium',
metadata: ['value-1'],
Expand All @@ -125,7 +108,7 @@ const withDataState = {
[sample2Uuid]: {
...sampleTemplate,
name: sample2Name,
projectUuid,
experimentId: experiment1id,
uuid: sample2Uuid,
type: '10X Chromium',
metadata: ['value-2'],
Expand Down Expand Up @@ -239,7 +222,7 @@ describe('LaunchAnalysisButton', () => {
expect(button).not.toBeDisabled();
});

it('Shows Go to Data Processing if there are no changes to the project (same hash)', async () => {
it('Shows Go to Data Processing if there are no changes to the experiment (same hash)', async () => {
generateGem2sParamsHash.mockReturnValueOnce('old-params-hash');

await act(async () => {
Expand All @@ -255,7 +238,7 @@ describe('LaunchAnalysisButton', () => {
});
});

it('Shows Process project if there are changes to the project (different hash)', async () => {
it('Shows Process project if there are changes to the experiment (different hash)', async () => {
generateGem2sParamsHash.mockReturnValueOnce('new-params-hash');

await act(async () => {
Expand All @@ -271,7 +254,7 @@ describe('LaunchAnalysisButton', () => {
});
});

it('Dispatches request for GEM2S if there are changes to the project', async () => {
it('Dispatches request for GEM2S if there are changes to the experiment', async () => {
generateGem2sParamsHash.mockReturnValueOnce('new-params-hash');

await act(async () => {
Expand All @@ -295,7 +278,7 @@ describe('LaunchAnalysisButton', () => {
expect(runGem2s).toHaveBeenCalled();
});

it('Does not dispatch request for GEM2S if there are no changes to the project', async () => {
it('Does not dispatch request for GEM2S if there are no changes to the experiment', async () => {
generateGem2sParamsHash.mockReturnValueOnce('old-params-hash');

await act(async () => {
Expand Down
Loading

0 comments on commit 5c6233c

Please sign in to comment.