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

Develop #1480

Merged
merged 89 commits into from
Jan 30, 2024
Merged

Develop #1480

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
c06ef8f
Don't ignore the VS Code folder
danburonline Dec 4, 2023
6974062
Add basic Chrome debugger `launch.json`
danburonline Dec 4, 2023
2d6f853
Have full-stack debugging for SRR
danburonline Dec 4, 2023
40d85db
Add VS Code recommendations and settings
danburonline Dec 4, 2023
f5f38d5
Merge branch 'develop' of https://github.com/BlueBrain/nexus-web into…
danburonline Dec 6, 2023
f0826e0
Add explicit end of line inside VS Code settings
danburonline Dec 11, 2023
4da189b
Merge branch 'develop' into chore/add-vs-debugger
bilalesi Dec 14, 2023
daee9f7
Merge branch 'develop' into chore/add-vs-debugger
danburonline Dec 18, 2023
07e3250
Clean, sort, remove unused imports/declarations
danburonline Dec 18, 2023
65c9076
Merge branch 'develop' into fix/es-indexing-view-improv
danburonline Dec 19, 2023
58bd9b0
Only fetch indexing errors on expand
danburonline Dec 19, 2023
b38fa28
Try to fix tests
danburonline Dec 19, 2023
e23138f
Merge branch 'develop' into chore/add-vs-debugger
danburonline Dec 20, 2023
9229f3b
Fix one failing test
danburonline Dec 20, 2023
f0c4aac
Anoter try to fix tests
danburonline Dec 20, 2023
6bdaf88
Add data test id
danburonline Dec 20, 2023
d04b578
Remove badge overview incl. tests
danburonline Dec 20, 2023
636071e
Fix unit tests
danburonline Dec 20, 2023
f0d6d21
Fix build issue with thrown Exception
danburonline Dec 20, 2023
71315c9
Change error as it was before
danburonline Dec 20, 2023
bbc92bc
Merge branch 'develop' into fix/es-indexing-view-improv
danburonline Dec 20, 2023
3e95c10
Clean and add additional bug TODOs
danburonline Dec 20, 2023
0984813
Merge branch 'develop' into fix/es-indexing-view-improv
danburonline Jan 3, 2024
bcbcdfb
Fix issue of undefined indexing errors
danburonline Jan 3, 2024
e7e9c51
Fix type errors
danburonline Jan 3, 2024
4b6a4df
Pinpoint failing unit test (add TODO)
danburonline Jan 3, 2024
384e8f8
Fix unit test by making it async
danburonline Jan 3, 2024
6b5efe8
Change conditional based on PR feedback
danburonline Jan 4, 2024
a526c1f
Revert type changes to previous ones
danburonline Jan 4, 2024
c87782e
Fix linter issue
danburonline Jan 4, 2024
2fb8441
Remove unused import
danburonline Jan 4, 2024
de5dd4b
Don't return an empty object on error
danburonline Jan 4, 2024
36a8659
Change types accordingly
danburonline Jan 4, 2024
ffa7535
Also send exception to Sentry
danburonline Jan 4, 2024
d1179fc
Change display of error view
danburonline Jan 7, 2024
dd690b0
Change assertion in unit test
danburonline Jan 7, 2024
da84ecc
Remove console.log
danburonline Jan 7, 2024
bc7b0ce
Remove type casting and be more explicit
danburonline Jan 7, 2024
22775a4
Remove another unnecessary console.error
danburonline Jan 7, 2024
d0944ee
Add TODO for weird unfocus fetch issue
danburonline Jan 7, 2024
be3d6a7
Merge branch 'develop' into chore/add-vs-debugger
danburonline Jan 8, 2024
604947d
Remove unused `error` argument
danburonline Jan 8, 2024
4790d52
Pinpoint lines of errors/confusion
danburonline Jan 8, 2024
b9917d7
Update snapshot
danburonline Jan 8, 2024
f0a37c4
Fix over-fetching issue
danburonline Jan 8, 2024
fdfc692
Change TODOs
danburonline Jan 8, 2024
c134857
Remove unnecessary else statements
danburonline Jan 8, 2024
06968be
Merge branch 'develop' into fix/es-indexing-view-improv
danburonline Jan 8, 2024
4b81976
fix: remove duplicated tag resource button
bilalesi Jan 9, 2024
d1fd943
Merge branch 'develop' into fix/es-indexing-view-improv
danburonline Jan 10, 2024
0350fc1
Fetch errors every time the row is expanded
danburonline Jan 10, 2024
4802179
Show undo deprecation button for other types
danburonline Jan 10, 2024
123340e
Add TODO
danburonline Jan 10, 2024
aead340
Merge branch 'develop' into chore/add-vs-debugger
danburonline Jan 10, 2024
548c568
Merge pull request #1448 from BlueBrain/fix/es-indexing-view-improv
danburonline Jan 10, 2024
890d251
Merge branch 'develop' into chore/add-vs-debugger
danburonline Jan 10, 2024
166966a
Merge branch 'develop' into feat/undeprecate-others
danburonline Jan 10, 2024
5fab940
Merge pull request #1440 from BlueBrain/chore/add-vs-debugger
danburonline Jan 10, 2024
fb80f31
Make undeprecate work
danburonline Jan 10, 2024
5f3c8ea
Merge branch 'develop' into feat/undeprecate-others
danburonline Jan 10, 2024
d350aa6
Hide button for other types and remove TODO
danburonline Jan 12, 2024
18a343b
Make undeprecation work for all other types
danburonline Jan 12, 2024
c3e973b
Add TODOs
danburonline Jan 12, 2024
a20ceff
Make construct URL function more generic
danburonline Jan 12, 2024
1486881
Make undeprecation work for all types
danburonline Jan 12, 2024
456e762
Make construct URL function DRY
danburonline Jan 12, 2024
d3f6c5e
Fix linter type issue
danburonline Jan 12, 2024
b6a8fed
Remove incorrect leftover comment
danburonline Jan 12, 2024
a15e5f1
Improve lookup from `O(n)` to `O(1)`
danburonline Jan 15, 2024
35517fd
Adjust custom linter logic for code editor
danburonline Jan 17, 2024
857d66c
Bring TSDoc comments back
danburonline Jan 17, 2024
bf5ce29
Bring back other TSDoc comment as well
danburonline Jan 17, 2024
19da337
Remove unnecessary comment
danburonline Jan 17, 2024
48bdba7
Merge pull request #1468 from BlueBrain/feat/undeprecate-others
danburonline Jan 17, 2024
2680b64
Merge branch 'develop' into fix/meta-validation-fix
danburonline Jan 17, 2024
f4c8ad5
4262 // All revisions inside the list should be accessible (atleast t…
Dinika Jan 17, 2024
f4b8f3d
Merge branch 'develop' into fix/meta-validation-fix
danburonline Jan 17, 2024
dba5dc1
Fix linting errors
danburonline Jan 17, 2024
d33dc3a
Fix unit tests
danburonline Jan 17, 2024
bbca3a1
Fix remaining unit test
danburonline Jan 17, 2024
260f964
Fix type issue
danburonline Jan 17, 2024
e1849b7
Add additional test for sub-field validations
danburonline Jan 17, 2024
16d3d84
4639/update: rename the copy button labels
bilalesi Jan 17, 2024
55387da
Merge branch 'develop' into fix/meta-validation-fix
danburonline Jan 17, 2024
87ca9a6
4641 // Pin history version so that encoded chars in id are not
Dinika Jan 19, 2024
dbf130d
4641 // Add test to check resource with encoded char id opens correct…
Dinika Jan 19, 2024
4744c4d
Merge branch 'develop' into fix/meta-validation-fix
danburonline Jan 24, 2024
6572a57
Merge pull request #1474 from BlueBrain/fix/meta-validation-fix
danburonline Jan 24, 2024
b8ffaba
4646 // Resource view should sort correctly after text search cleared
Dinika Jan 24, 2024
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
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dist/
node_modules/
storybook-static/
coverage/
.vscode
yarn-error.log
cypress/screenshots/
cypress/videos/
Expand Down
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"editorconfig.editorconfig",
"christian-kohler.npm-intellisense"
]
}
25 changes: 25 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Attach SPA debugging (frontend-only)",
"url": "http://localhost:8000",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "launch",
"name": "SRR debugging (full-stack)",
"runtimeExecutable": "node",
"runtimeArgs": ["--inspect-brk", "${workspaceFolder}/dist/server.js"],
"env": {
"NODE_ENV": "development",
"DEBUG": "*"
},
"console": "integratedTerminal",
"internalConsoleOptions": "openOnSessionStart"
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.formatOnSave": true,
"files.eol": "\n"
}
Binary file added bun.lockb
Binary file not shown.
135 changes: 135 additions & 0 deletions cypress/e2e/ResourceContainer.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import { Resource } from '@bbp/nexus-sdk';

describe('Resource with id that contains URL encoded characters', () => {
const resourceIdWithEncodedCharacters =
'https://hello.lol/https%3A%2F%2Fencoded.url%2Fwow';
const displayName = 'https%3A%2F%2Fencoded.url%2Fwow';

before(() => {
if (
!Cypress.env('use_existing_delta_instance') ||
Cypress.env('use_existing_delta_instance') === false
) {
cy.task('auth:createRealmsAndUsers', Cypress.env('users'));
}

cy.login(
`${Cypress.env('users').morty.username}-studio`,
Cypress.env('users').morty.realm,
Cypress.env('users').morty.username,
Cypress.env('users').morty.password
).then(() => {
cy.window().then(win => {
const authToken = win.localStorage.getItem('nexus__token');
cy.wrap(authToken).as('nexusToken');

const orgLabel = Cypress.env('ORG_LABEL');
const projectLabelBase = Cypress.env('PROJECT_LABEL_BASE');

cy.task('project:setup', {
nexusApiUrl: Cypress.env('NEXUS_API_URL'),
authToken,
orgLabel,
projectLabelBase,
}).then(({ projectLabel }: { projectLabel: string }) => {
cy.wrap(projectLabel).as('projectLabel');
cy.fixture('ResourceWithEncodedCharactersId.json').then(
resourcePayload => {
cy.task('resource:create', {
nexusApiUrl: Cypress.env('NEXUS_API_URL'),
authToken,
orgLabel,
projectLabel,
resourcePayload,
}).then((resource: Resource) => {
cy.wrap(resource['@id']).as('fullResourceId');
});
}
);
});
});
});
});

beforeEach(() => {
cy.login(
`${Cypress.env('users').morty.username}-report-plugin`,
Cypress.env('users').morty.realm,
Cypress.env('users').morty.username,
Cypress.env('users').morty.password
);
});

after(function() {
cy.task('project:teardown', {
nexusApiUrl: Cypress.env('NEXUS_API_URL'),
authToken: this.nexusToken,
orgLabel: Cypress.env('ORG_LABEL'),
projectLabel: this.projectLabel,
});
});

function testResourceDataInJsonViewer() {
cy.findByText('Advanced View').click();

cy.contains(`"@id"`);
cy.contains(resourceIdWithEncodedCharacters);
cy.contains('type');
cy.contains('[]');
}

it('resource opens when user clicks on resource row in MyData table', function() {
cy.visit(`/`);

cy.findAllByText(new RegExp(displayName))
.first()
.click();

cy.findByTestId('resource-details').within(() => {
testResourceDataInJsonViewer();
});
});

it('resource opens when user directly navigates to resource page', function() {
const resourcePage = `/${Cypress.env('ORG_LABEL')}/${
this.projectLabel
}/resources/${encodeURIComponent(resourceIdWithEncodedCharacters)}`;

cy.visit(`${resourcePage}`);

cy.findByTestId('resource-details').within(() => {
testResourceDataInJsonViewer();
});
});

it('resource opens with id resolution page', function() {
const resolvePage = `/resolve/${encodeURIComponent(
resourceIdWithEncodedCharacters
)}`;
const resourcePage = `/${Cypress.env('ORG_LABEL')}/${
this.projectLabel
}/resources/${encodeURIComponent(resourceIdWithEncodedCharacters)}`;

cy.visit(resolvePage);

cy.intercept(`${Cypress.env('NEXUS_API_URL')}/${resolvePage}`).as(
'idResolution'
);

// If many e2e tests ran together there may be many resources with same id.
// In this case the id resolution page will look different. Test accordingly.
cy.wait('@idResolution').then(interception => {
const resolvedResources = interception.response.body._results;

if (resolvedResources.length === 1) {
testResourceDataInJsonViewer();
} else {
// Multiple resources with same id found.
cy.findByText('Open Resource', {
selector: `a[href="${resourcePage}"]`,
}).click();
testResourceDataInJsonViewer();
}
});
});
});
4 changes: 4 additions & 0 deletions cypress/fixtures/ResourceWithEncodedCharactersId.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"@id": "https://hello.lol/https%3A%2F%2Fencoded.url%2Fwow",
"@type": []
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"express-prom-bundle": "^5.0.2",
"git-revision-webpack-plugin": "^3.0.6",
"handlebars": "^4.7.7",
"history": "^4.7.2",
"history": "4.5.1",
"http-proxy-middleware": "^2.0.1",
"json2csv": "^5.0.5",
"jwt-decode": "^2.2.0",
Expand Down Expand Up @@ -240,5 +240,8 @@
"webpack-hot-middleware": "^2.24.3",
"webpack-node-externals": "^1.7.2"
},
"resolutions": {
"history": "4.5.1"
},
"url": "https://github.com/BlueBrain/nexus/issues/new?labels=fusion"
}
102 changes: 102 additions & 0 deletions src/__mocks__/handlers/ResourceListContainerHandlers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { rest } from 'msw';
import { deltaPath } from '__mocks__/handlers/handlers';
import { Resource } from '@bbp/nexus-sdk';

export const resourcesHandler = rest.get(
deltaPath(`resources/bbp/agents`),
(_, res, ctx) => {
const mockResponse = {
'@context': ['https://bluebrain.github.io/nexus/contexts/metadata.json'],
_total: 3,
_results: [
getMockResource('1'),
getMockResource('2'),
getMockResource('3'),
],
};

return res(ctx.status(200), ctx.json(mockResponse));
}
);

export const searchHitsHandler = rest.post(
deltaPath(
'/views/bbp/agents/https%3A%2F%2Fbluebrain.github.io%2Fnexus%2Fvocabulary%2FdefaultElasticSearchIndex/_search'
),
(_, res, ctx) => {
const filteredByDeprecation = {
buckets: [getMockBucket('1'), getMockBucket('2'), getMockBucket('3')],
doc_count_error_upper_bound: 0,
sum_other_doc_count: 0,
};
const mockResponse = {
aggregations: {
schemas: {
doc_count: 3,
filteredByDeprecation: { ...filteredByDeprecation },
},
types: {
doc_count: 8,
filteredByDeprecation: { ...filteredByDeprecation },
},
},
hits: {
hits: [
getMockSearchHit('1'),
getMockSearchHit('2'),
getMockSearchHit('3'),
],
max_score: 123,
total: { relation: 'eq', value: 11 },
},
timed_out: false,
took: 0,
_shards: { failed: 0, skipped: 0, successful: 1, total: 1 },
};

return res(
// Respond with a 200 status code
ctx.status(200),
ctx.json(mockResponse)
);
}
);

const getMockResource = (id: string, extra?: Partial<Resource>) => ({
'@id': id,
'@type': ['View'],
description: 'Test description',
name: 'Test name',
_constrainedBy: 'https://bluebrain.github.io/nexus/schemas/views.json',
_createdAt: '2024-01-19T11:40:24.804553Z',
_createdBy: 'https://bbp.epfl.ch/nexus/v1/realms/bbp/users/mockuser',
_deprecated: false,
_incoming: 'test',
_outgoing: 'test',
_project: 'https://dev.nise.bbp.epfl.ch/nexus/v1/projects/bbp/agents',
_rev: 1,
_self: id,
_updatedAt: '2024-01-19T11:40:24.804553Z',
_updatedBy: 'https://bbp.epfl.ch/nexus/v1/realms/bbp/users/mockuser',
_uuid: id,
...extra,
});

const getMockSearchHit = (id: string, extra?: Partial<Resource>) => {
const resource = getMockResource(id, extra);
return {
_id: id,
_index: `delta_${id}`,
_score: 123,
_source: {
...resource,
_original_source: JSON.stringify(resource),
},
_type: '_doc',
};
};

const getMockBucket = (key: string, docCount: number = 1) => ({
key,
doc_count: docCount,
});
2 changes: 1 addition & 1 deletion src/shared/components/ResourceActions/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import { Tooltip, Button, Popconfirm } from 'antd';
import { Resource } from '@bbp/nexus-sdk';
import useNotification from '../../hooks/useNotification';

import './ResourceActions.less';
import useNotification from '../../hooks/useNotification';

export type ActionType = {
name: string; // A unique name for your action type
Expand Down
Loading
Loading