Skip to content

Commit

Permalink
US 3 // Filter resources that have path missing
Browse files Browse the repository at this point in the history
Signed-off-by: Dinika Saxena <[email protected]>
  • Loading branch information
Dinika committed Jun 30, 2023
1 parent 842a3a5 commit dc3dd94
Show file tree
Hide file tree
Showing 11 changed files with 468 additions and 64 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"start": "NODE_ENV=development DEBUG=* webpack --mode development --config-name server && node dist/server.js",
"build": "NODE_ENV=production NODE_OPTIONS=--max_old_space_size=8192 webpack --mode production",
"test": "jest",
"test:watch": "jest --watch",
"test:watch": "jest --watch --maxWorkers=4",
"cy:open": "cypress open",
"cy:run": "cypress run",
"test-ui": "API_ENDPOINT=http://test start-server-and-test start http://localhost:8000 cy:run",
Expand Down Expand Up @@ -210,7 +210,10 @@
],
"globals": {
"FUSION_VERSION": "1.0.0",
"COMMIT_HASH": "9013fa343"
"COMMIT_HASH": "9013fa343",
"ts-jest": {
"isolatedModules": true
}
},
"watchPathIgnorePatterns": [
"node_modules"
Expand Down
2 changes: 1 addition & 1 deletion src/__mocks__/handlers/DataExplorer/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const getMockResource = (
extra: { [key: string]: any },
project: string = 'hippocampus'
): Resource => ({
...extra,
'@id': `https://bbp.epfl.ch/neurosciencegraph/data/${selfSuffix}`,
'@type':
'https://bbp.epfl.ch/ontologies/core/bmo/SimulationCampaignConfiguration',
Expand All @@ -115,7 +116,6 @@ export const getMockResource = (
_self: `https://bbp.epfl.ch/nexus/v1/resources/bbp/${project}/_/${selfSuffix}`,
_updatedAt: '2023-06-21T09:39:47.844Z',
_updatedBy: 'https://bbp.epfl.ch/nexus/v1/realms/bbp/users/antonel',
...extra,
});

export const defaultMockResult: Resource[] = [
Expand Down
1 change: 1 addition & 0 deletions src/shared/App.less
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
}
&.data-explorer-container {
width: fit-content;
min-width: calc(100vw - 1rem);
padding-right: 0;
margin-right: 1rem;
}
Expand Down
1 change: 1 addition & 0 deletions src/shared/layouts/FusionMainLayout.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
height: 100%;
min-height: 100vh !important;
width: fit-content;
min-width: 100vw;
&.wall {
.fusion-main-layout__content {
margin-top: 0;
Expand Down
132 changes: 132 additions & 0 deletions src/subapps/dataExplorer/DataExplorer-utils.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import { getAllPaths, isPathMissing } from './PredicateSelector';

describe('DataExplorerSpec-Utils', () => {
it('shows all paths for resources', () => {
const resources = [
{
'@id': '123',
distribution: [
{ name: 'foo', label: ['label1', 'label2'] },
{ filename: 'foo2', label: 'label3' },
],
},
{
'@id': '123',
distribution: [
{
name: 'foo',
label: ['label1', 'label2'],
contentType: [
{ mimeType: 'application/json' },
{
mimeType: 'application/csv',
extension: ['csv'],
possibleExtensions: ['2', '2'],
},
],
},
{ filename: 'foo2', label: 'label3' },
],
contributors: {
name: { firstname: 'Michael', lastname: 'Angelo' },
},
},
];
const expectedPaths = [
'@id',
'distribution',
'distribution.name',
'distribution.label',
'distribution.filename',
'distribution.contentType',
'distribution.contentType.mimeType',
'distribution.contentType.extension',
'distribution.contentType.possibleExtensions',
'contributors',
'contributors.name',
'contributors.name.firstname',
'contributors.name.lastname',
];
expect(getAllPaths(resources)).toEqual(expectedPaths);
});

it('returns true when top level property does not exist in resource', () => {
const resource = {
foo: 'some value',
nullValue: null,
undefinedValue: undefined,
emptyString: '',
emptyArray: [],
emptyObject: {},
distribution: [
{
name: 'sally',
label: {
official: 'official',
unofficial: 'unofficial',
emptyArray: [],
emptyString: '',
extended: [{ prefix: '1', suffix: 2 }, { prefix: '1' }],
},
},
{
name: 'sally',
sillyname: 'soliloquy',
label: [
{
official: 'official',
emptyArray: [],
emptyString: '',
extended: [{ prefix: '1', suffix: 2 }, { prefix: '1' }],
},
{
official: 'official',
unofficial: 'unofficial',
emptyArray: [1],
extended: [{ prefix: '1', suffix: 2 }, { prefix: '1' }],
},
],
},
],
};
expect(isPathMissing(resource, 'bar')).toEqual(true);
expect(isPathMissing(resource, 'nullValue')).toEqual(false);
expect(isPathMissing(resource, 'undefinedValue')).toEqual(false);
expect(isPathMissing(resource, 'emptyString')).toEqual(false);
expect(isPathMissing(resource, 'emptyArray')).toEqual(false);
expect(isPathMissing(resource, 'emptyObject')).toEqual(false);

expect(isPathMissing(resource, 'foo')).toEqual(false);
expect(isPathMissing(resource, 'foo.xyz')).toEqual(true);
expect(isPathMissing(resource, 'foo.distribution')).toEqual(true);

expect(isPathMissing(resource, 'distribution')).toEqual(false);
expect(isPathMissing(resource, 'distribution.name')).toEqual(false);
expect(isPathMissing(resource, 'distribution.name.sillyname')).toEqual(
true
);
expect(
isPathMissing(resource, 'distribution.name.sillyname.pancake')
).toEqual(true);
expect(isPathMissing(resource, 'distribution.name.label.pancake')).toEqual(
true
);
expect(isPathMissing(resource, 'distribution.label.unofficial')).toEqual(
true
);
expect(
isPathMissing(resource, 'distribution.label.extended.prefix')
).toEqual(false);
expect(
isPathMissing(resource, 'distribution.label.extended.suffix')
).toEqual(true);
expect(isPathMissing(resource, 'distribution.foo')).toEqual(true);
expect(isPathMissing(resource, 'distribution.emptyArray')).toEqual(true);
expect(isPathMissing(resource, 'distribution.label.emptyArray')).toEqual(
false
);
expect(isPathMissing(resource, 'distribution.label.emptyString')).toEqual(
true
);
});
});
Loading

0 comments on commit dc3dd94

Please sign in to comment.