Skip to content

Commit

Permalink
Merge pull request #1385 from BlueBrain/develop
Browse files Browse the repository at this point in the history
Merge Develop to Main
  • Loading branch information
bilalesi authored Sep 4, 2023
2 parents 117c13e + a4dca23 commit 1778dfc
Show file tree
Hide file tree
Showing 17 changed files with 730 additions and 164 deletions.
7 changes: 2 additions & 5 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 --maxWorkers=4",
"test:watch": "jest --watch",
"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 @@ -211,10 +211,7 @@
],
"globals": {
"FUSION_VERSION": "1.0.0",
"COMMIT_HASH": "9013fa343",
"ts-jest": {
"isolatedModules": true
}
"COMMIT_HASH": "9013fa343"
},
"watchPathIgnorePatterns": [
"node_modules"
Expand Down
10 changes: 8 additions & 2 deletions src/__mocks__/handlers/DataTableContainer/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ export const ORIGINAL_6_SORTED_5 = 'sterling';
export const MOCK_VAR = 'Given Name';

export const sparqlViewSingleResult = rest.post(
deltaPath('/views/bbp/agents/graph/sparql'),
deltaPath(
`/views/bbp/agents/${encodeURIComponent(
'https://bluebrain.github.io/nexus/vocabulary/defaultSparqlIndex'
)}/sparql`
),
(req, res, ctx) => {
const mockResponse = {
head: {
Expand Down Expand Up @@ -287,7 +291,9 @@ export const sparqlViewResultHandler = (
studioRows: ReturnType<typeof getMockStudioResource>[]
) => {
return rest.post(
deltaPath('/views/bbp/agents/graph/sparql'),
deltaPath(
'/views/bbp/agents/https%3A%2F%2Fbluebrain.github.io%2Fnexus%2Fvocabulary%2FdefaultSparqlIndex/sparql'
),
(req, res, ctx) => {
const mockResponse = {
head: {
Expand Down
208 changes: 208 additions & 0 deletions src/__mocks__/handlers/Settings/ViewsSubViewHandlers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
import { rest } from 'msw';
import { deltaPath } from '__mocks__/handlers/handlers';

export const identitiesHandler = () => {
return rest.get(deltaPath(`/identities`), (req, res, ctx) => {
const mockResponse = {
'@context': [
'https://bluebrain.github.io/nexus/contexts/metadata.json',
'https://bluebrain.github.io/nexus/contexts/identities.json',
],
identities: [
{
'@id':
'https://dev.nise.bbp.epfl.ch/nexus/v1/realms/local/authenticated',
'@type': 'Authenticated',
realm: 'test',
},
],
};
return res(ctx.status(200), ctx.json(mockResponse));
});
};

export const aclsHandler = (orgLabel: string, projectLabel: string) => {
return rest.get(
deltaPath(`/acls/${orgLabel}/${projectLabel}`),
(req, res, ctx) => {
const mockResponse = {
'@context': ['https://bluebrain.github.io/nexus/contexts/acls.json'],
_total: 1,
_results: [
{
'@id': 'https://dev.nise.bbp.epfl.ch/nexus/v1/acls',
'@type': 'AccessControlList',
acl: [
{
identity: {
'@id':
'https://dev.nise.bbp.epfl.ch/nexus/v1/realms/local/authenticated',
'@type': 'Authenticated',
realm: 'test',
},
permissions: [
'realms/write',
'files/write',
'events/read',
'organizations/write',
'projects/delete',
'projects/write',
'views/write',
],
},
{
identity: {
'@id': 'https://dev.nise.bbp.epfl.ch/nexus/v1/anonymous',
'@type': 'Anonymous',
},
permissions: [
'realms/read',
'permissions/read',
'version/read',
],
},
],
_self: 'https://dev.nise.bbp.epfl.ch/nexus/v1/acls',
},
],
};
return res(ctx.status(200), ctx.json(mockResponse));
}
);
};

export const viewWithIndexingErrors =
'https://bluebrain.github.io/nexus/vocabulary/defaultSparqlIndex';

export const viewWithNoIndexingErrors =
'https://bluebrain.github.io/nexus/vocabulary/defaultElasticSearchIndex';

export const viewsHandler = (orgLabel: string, projectLabel: string) => {
const baseViewObject = baseView(orgLabel, projectLabel);

return rest.get(
deltaPath(`/views/${orgLabel}/${projectLabel}`),
(req, res, ctx) => {
const mockResponse = {
'@context': [
'https://bluebrain.github.io/nexus/contexts/search.json',
'https://bluebrain.github.io/nexus/contexts/search-metadata.json',
],
_total: 3,
_results: [
{
'@id': viewWithNoIndexingErrors,
'@type': ['ElasticSearchView', 'View'],
name: 'Default Elasticsearch view',
...baseViewObject,
},
{
'@id': 'https://bluebrain.github.io/nexus/vocabulary/searchView',
'@type': ['View', 'CompositeView'],
...baseViewObject,
},
{
'@id': viewWithIndexingErrors,
'@type': ['View', 'SparqlView'],
name: 'Default Sparql view',
...baseViewObject,
},
],
};
return res(ctx.status(200), ctx.json(mockResponse));
}
);
};

export const viewErrorsHandler = (orgLabel: string, projectLabel: string) => {
return rest.get(
deltaPath(`/views/${orgLabel}/${projectLabel}/:viewId/failures`),
(req, res, ctx) => {
const { viewId } = req.params;
const decodedId = decodeURIComponent(viewId as string);

const mockResponse = {
'@context': ['https://bluebrain.github.io/nexus/contexts/error.json'],
_total: decodedId === viewWithIndexingErrors ? 2 : 0,
_results:
decodedId === viewWithIndexingErrors
? [
{
...baseIndexingError(
orgLabel,
projectLabel,
`${decodedId}-1`
),
message: 'Mock Error 1',
},
{
...baseIndexingError(
orgLabel,
projectLabel,
`${decodedId}-2`
),
message: 'Mock Error 2',
},
]
: [],
};
return res(ctx.status(200), ctx.json(mockResponse));
}
);
};

export const viewStatsHandler = (orgLabel: string, projectLabel: string) => {
return rest.get(
deltaPath(`/views/${orgLabel}/${projectLabel}/:viewId/statistics`),
(req, res, ctx) => {
const mockResponse = {
'@context':
'https://bluebrain.github.io/nexus/contexts/statistics.json',
'@type': 'ViewStatistics',
delayInSeconds: 0,
discardedEvents: 0,
evaluatedEvents: 10489,
failedEvents: 0,
lastEventDateTime: '2023-08-24T13:53:01.884Z',
lastProcessedEventDateTime: '2023-08-24T13:53:01.884Z',
processedEvents: 10489,
remainingEvents: 0,
totalEvents: 10489,
};
return res(ctx.status(200), ctx.json(mockResponse));
}
);
};

const baseIndexingError = (
orgLabel: string,
projectLabel: string,
id: string
) => ({
id,
errorType: 'epfl.indexing.ElasticSearchSink.BulkUpdateException',
message: 'Super dramatic error',
offset: {
'@type': 'At',
value: 264934,
},
project: `${orgLabel}/${projectLabel}`,
_rev: 1,
});

const baseView = (orgLabel: string, projectLabel: string) => ({
_constrainedBy: 'https://bluebrain.github.io/nexus/schemas/views.json',
_createdAt: '2022-04-01T08:27:55.583Z',
_createdBy:
'https://test.nise.bbp.epfl.ch/nexus/v1/realms/serviceaccounts/users/service-account-nexus-sa',
_deprecated: false,
_incoming: `https://test.nise.bbp.epfl.ch/nexus/v1/views/${orgLabel}/${projectLabel}/graph/incoming`,
_indexingRev: 1,
_outgoing: `https://test.nise.bbp.epfl.ch/nexus/v1/views/${orgLabel}/${projectLabel}/graph/outgoing`,
_project: `https://test.nise.bbp.epfl.ch/nexus/v1/projects/${orgLabel}/${projectLabel}`,
_rev: 1,
_self: `https://test.nise.bbp.epfl.ch/nexus/v1/views/${orgLabel}/${projectLabel}/graph`,
_updatedAt: '2022-04-01T08:27:55.583Z',
_updatedBy: `https://test.nise.bbp.epfl.ch/nexus/v1/realms/serviceaccounts/users/service-account-nexus-sa`,
_uuid: 'b48c6970-2e20-4a39-9180-574b5c656965',
});
Loading

0 comments on commit 1778dfc

Please sign in to comment.