Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1902 remove project from redux #752

Merged
merged 57 commits into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
3048590
Add metadataKeys and handle some of the project actions in the experi…
cosa65 Jun 28, 2022
1e45d34
Make LaunchAnalysisButton stop using project
cosa65 Jun 28, 2022
22241a9
Update comment
cosa65 Jun 29, 2022
fb4953b
Cleanup
cosa65 Jun 29, 2022
379617f
Change from using active project to using active experiemnt in conten…
cosa65 Jun 29, 2022
e1de202
Update NotifyByEmail
cosa65 Jun 29, 2022
9fef7a6
Some fixes
cosa65 Jun 29, 2022
27a209a
Update DownloadDataButton
cosa65 Jun 29, 2022
f9a7b1e
Update SamplesTable
cosa65 Jun 29, 2022
f759747
Update MetadataColumn and SamplesTable
cosa65 Jun 29, 2022
fe5a5bf
Update ProjectCard and ProjectsList
cosa65 Jun 29, 2022
8db9944
Update ProjectDeleteModal
cosa65 Jun 29, 2022
a4be135
Update ProjectDetails
cosa65 Jun 29, 2022
b49ef26
Switch many places to using experiemnts
cosa65 Jun 29, 2022
10f9ea2
More switch to experiment
cosa65 Jun 29, 2022
b9d40d9
Remove last selectors that take project
cosa65 Jun 29, 2022
1ad647c
Add the activeExperimentId selection in again
cosa65 Jun 29, 2022
8b6d07d
Change loadProjects -> loadExperiments and loadExperiments -> loadExp…
cosa65 Jun 29, 2022
1bde753
Some fixes and comment out all project reducers
cosa65 Jun 29, 2022
4e62092
fix deleteSamples
cosa65 Jun 29, 2022
e36f663
Delete updateProject and fix createMetadataTrack
cosa65 Jun 29, 2022
c1a46d0
Move action creators setActiveProject -> setActiveExpeirment and dele…
cosa65 Jun 29, 2022
fee183e
Rename some project action creators, some fixes and remove PROJECTS_C…
cosa65 Jun 29, 2022
35c334b
Delete no longer used project actionTypes and move the still used one…
cosa65 Jun 29, 2022
dc60677
Rename project suffix actionTypes to experiment suffix
cosa65 Jun 29, 2022
46df2b3
Fix merge conflicts
cosa65 Jun 30, 2022
5a45f27
Avoid fail before experiments are loaded
cosa65 Jun 30, 2022
4e27b53
Some cleanup and remove loadExperiment
cosa65 Jun 30, 2022
62742ea
Omit samplesOrder
cosa65 Jun 30, 2022
7ec32d0
Remove WIPs
cosa65 Jun 30, 2022
5c4b8af
Remove projects reducers and adapt some tests
cosa65 Jun 30, 2022
f4ac4cf
Use createdAt instead of createdDate
cosa65 Jun 30, 2022
991264b
Clean up and adapt some tests
cosa65 Jun 30, 2022
2801230
Fix AppRouteProvider
cosa65 Jun 30, 2022
a5fbcbb
Fix ShareExperimentModal tests and remove some old snapshots
cosa65 Jun 30, 2022
ffa3365
Fix NotifyByEmail
cosa65 Jun 30, 2022
a6854af
Fix ProjectsList.test
cosa65 Jun 30, 2022
8b65423
Update snapshots
cosa65 Jun 30, 2022
2a0cbcf
Fix NewProjectModal.test.jsx
cosa65 Jun 30, 2022
9aee881
Delete redundant tests and move some old project tests into experimen…
cosa65 Jun 30, 2022
efbc502
Fix createExperiment.test.js
cosa65 Jun 30, 2022
a2b7b47
Update and minor fix
cosa65 Jun 30, 2022
13fe74d
Update snapshots
cosa65 Jun 30, 2022
cc0f0d7
Some refactoring and updating snapshots/fixing tests related to exper…
cosa65 Jun 30, 2022
3361717
Fix experiment reducer tests
cosa65 Jun 30, 2022
dbc3f0f
Fix loadExperiments.test.js
cosa65 Jun 30, 2022
50364c4
Fix metadata trak tests
cosa65 Jun 30, 2022
5d3de1c
Add metadata reducer tests
cosa65 Jul 1, 2022
0af071f
Merge branch 'master' into 1902-remove-project-from-code
cosa65 Jul 1, 2022
6800b93
Add activeExperimentId to initialState
cosa65 Jul 1, 2022
821b1c7
Some code review refactoring
cosa65 Jul 1, 2022
116dfdf
Remove some more console logs
cosa65 Jul 1, 2022
cd2d218
Remove projectUuid from samples
cosa65 Jul 1, 2022
8cb0ffc
Remove commented out code
cosa65 Jul 4, 2022
bac9546
Replace fake project_id with fake experiment_id, same with name
cosa65 Jul 4, 2022
d5bfb8e
Replace mockProjectUuid with mockExpeirmentId
cosa65 Jul 4, 2022
e06969f
More coverage
cosa65 Jul 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});
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,
projectUuid: experiment1id,
uuid: sample1Uuid,
type: '10X Chromium',
metadata: ['value-1'],
Expand All @@ -125,7 +108,7 @@ const withDataState = {
[sample2Uuid]: {
...sampleTemplate,
name: sample2Name,
projectUuid,
projectUuid: 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
30 changes: 15 additions & 15 deletions src/__test__/components/data-management/NewProjectModal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const { Text } = Typography;
const mockStore = configureMockStore([thunk]);

const initialState = {
projects: {
experiments: {
cosa65 marked this conversation as resolved.
Show resolved Hide resolved
ids: [],
meta: {
loading: true,
Expand All @@ -26,16 +26,16 @@ const initialState = {
},
};

const storeWithProjects = {
projects: {
const storeWithExperiments = {
experiments: {
ids: ['123'],
meta: {
loading: true,
saving: false,
error: false,
},
cosa65 marked this conversation as resolved.
Show resolved Hide resolved
123: {
name: 'my awesome project',
name: 'my awesome experiment',
},
},
};
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('NewProjectModal', () => {
// It has an input
expect(component.find(Input).length).toEqual(1);

// It has a project description input
// It has a experiment description input
expect(component.find(TextArea).length).toEqual(1);

// It has a button
Expand All @@ -75,7 +75,7 @@ describe('NewProjectModal', () => {

it('contains required components for later flows', () => {
const component = mount(
<Provider store={mockStore(storeWithProjects)}>
<Provider store={mockStore(storeWithExperiments)}>
<NewProjectModal onCancel={onCancel} onCreate={onCreate} />
</Provider>,
);
Expand All @@ -86,24 +86,24 @@ describe('NewProjectModal', () => {
// It has an input
expect(component.find(Input).length).toEqual(1);

// It has a project description input
// It has a experiment description input
expect(component.find(TextArea).length).toEqual(1);

// It has a button
expect(component.find(Button).length).toEqual(1);
});

it('disables input and shows loading when project is being saved', () => {
it('disables input and shows loading when experiment is being saved', () => {
const savingState = {
...initialState,
projects: {
experiments: {
meta: {
...initialState.projects.meta,
...initialState.experiments.meta,
saving: true,
},
ids: ['123'],
123: {
name: 'my awesome project',
name: 'my awesome experiment',
},
},
};
Expand All @@ -124,19 +124,19 @@ describe('NewProjectModal', () => {
expect(component.find(ClipLoader).length).toEqual(1);
});

it('disables input and shows error if project has errors', () => {
it('disables input and shows error if experiment has errors', () => {
const errMsg = 'Error message';

const errorState = {
...initialState,
projects: {
experiments: {
meta: {
...initialState.projects.meta,
...initialState.experiments.meta,
error: errMsg,
},
ids: ['123'],
123: {
name: 'my awesome project',
name: 'my awesome experiment',
},
},
};
Expand Down
Loading