From 320521cba67442aa33ff0f0b6020dc8ec30a3497 Mon Sep 17 00:00:00 2001 From: Dinika Saxena Date: Tue, 6 Feb 2024 15:16:05 +0100 Subject: [PATCH] Hotfix // Remove double encoding of id to load resource correctly in search Signed-off-by: Dinika Saxena --- cypress/e2e/ResourceContainer.cy.ts | 11 +++++++++++ src/subapps/search/containers/SearchContainer.tsx | 8 +++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/ResourceContainer.cy.ts b/cypress/e2e/ResourceContainer.cy.ts index ffd29bdea..6d336f39a 100644 --- a/cypress/e2e/ResourceContainer.cy.ts +++ b/cypress/e2e/ResourceContainer.cy.ts @@ -90,6 +90,17 @@ describe('Resource with id that contains URL encoded characters', () => { }); }); + it('resource with any id opens when user clicks on resource row in Search table', function() { + cy.visit(`/search?layout=Neuron%20Morphology`); + + cy.findAllByTestId('search-table-row') + .first() + .click(); + + cy.findByText('Advanced View').click(); + cy.contains(`"@id"`); + }); + it('resource opens when user directly navigates to resource page', function() { const resourcePage = `/${Cypress.env('ORG_LABEL')}/${ this.projectLabel diff --git a/src/subapps/search/containers/SearchContainer.tsx b/src/subapps/search/containers/SearchContainer.tsx index 0e2ed5e54..053b2f7d1 100644 --- a/src/subapps/search/containers/SearchContainer.tsx +++ b/src/subapps/search/containers/SearchContainer.tsx @@ -84,13 +84,15 @@ const SearchContainer: React.FC = () => { background: location, }); }; - const onRowClick = (record: any): { onClick: () => void } => { + const onRowClick = ( + record: any + ): { onClick: () => void; 'data-testid': string } => { return { onClick: () => { const [orgLabel, projectLabel] = record.project.label.split('/'); - const resourceId = encodeURIComponent(record['@id']); - goToResource(orgLabel, projectLabel, resourceId); + goToResource(orgLabel, projectLabel, record['@id']); }, + 'data-testid': 'search-table-row', }; }; const {