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

Minor refactorings #942

Merged
merged 13 commits into from
Nov 22, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import fetchAPI from 'utils/http/fetchAPI';
import GEM2SLoadingScreen from 'components/GEM2SLoadingScreen';
import '__test__/test-utils/setupTests';

const { Title, Text } = Typography;
const { Title } = Typography;

const mockStore = configureMockStore([thunk]);

Expand Down
33 changes: 0 additions & 33 deletions src/__test__/utils/upload/processSeuratUpload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import UploadStatus from 'utils/upload/UploadStatus';

import processUpload from 'utils/upload/processUpload';

import validate from 'utils/upload/validateSeurat';
import pushNotificationMessage from 'utils/pushNotificationMessage';
import mockFile from '__test__/test-utils/mockFile';

const FILE_SIZE = 1024 * 1024 * 15;
Expand Down Expand Up @@ -76,7 +74,6 @@ jest.mock('axios', () => ({
}));

jest.mock('utils/pushNotificationMessage');
jest.mock('utils/upload/validateSeurat');

let store = null;

Expand Down Expand Up @@ -233,34 +230,4 @@ describe('processUpload', () => {
expect(axios.request).not.toHaveBeenCalled();
});
});

it('Should not validate .rds files', async () => {
cosa65 marked this conversation as resolved.
Show resolved Hide resolved
const mockAxiosCalls = [];
const uploadSuccess = (params) => {
mockAxiosCalls.push(params);
return Promise.resolve({ headers: { etag: 'etag-blah' } });
};

axios.request.mockImplementation(uploadSuccess);

validate.mockImplementationOnce(
() => (['Some file error']),
);

await processUpload(
getValidFiles(),
sampleType,
store.getState().samples,
mockExperimentId,
store.dispatch,
);

// We expect uploads to happen
await waitFor(() => {
expect();
expect(pushNotificationMessage).toHaveBeenCalledTimes(0);
expect(axios.request).toHaveBeenCalledTimes(2);
expect(validate).toHaveBeenCalledTimes(1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const CellSetsTool = (props) => {
setTreeData(composeTree(hierarchy, properties));
}, [hierarchy, properties]);

const [numSelectedCellSetKeys, setNumSelectedCellSetKeys] = useState(0);
const [numSelectedCellSetKeys, setNumSelectedCellSetKeys] = useState(null);

useEffect(() => {
const louvainClusters = hierarchy.find(({ key }) => key === 'louvain')?.children;
Expand All @@ -89,6 +89,11 @@ const CellSetsTool = (props) => {
}, [hierarchy]);

useEffect(() => {
if (selectedCellSetKeys.length === 0) {
setNumSelectedCellSetKeys(null);
return;
}

const selectedCells = union(selectedCellSetKeys, properties);

const numSelectedFiltered = new Set([...selectedCells]
Expand Down Expand Up @@ -124,7 +129,7 @@ const CellSetsTool = (props) => {
const renderContent = () => {
let operations = null;

if (numSelectedCellSetKeys > 0) {
if (numSelectedCellSetKeys !== null) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before, if you selected a cell class that was empty it wouldn't say "0 cells selected" because numSelectedCellSetKeys === 0 meant that nothing was shown.

I added null so that:

  1. nothing is selected ---> numSelectedCellSetKeys = null
  2. the are selected things but they have 0 cells ---> numSelectedCellSetKeys = 0

In this way, we can show "0 cells selected" in case 2.

operations = (
<Space style={{ marginBottom: '10px' }}>
<SubsetCellSetsOperation
Expand Down
4 changes: 3 additions & 1 deletion src/utils/upload/validateSeurat.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const validateSeurat = async () => {};
const validateSeurat = async () => {
// Currently there is no content checking for H5 files
};

export default validateSeurat;
Loading