Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 857425e

Browse files
committed
Fix loading of resources that have encoded chars in id
Signed-off-by: Dinika Saxena <dinikasaxenas@gmail.com>
1 parent 5e83b58 commit 857425e

File tree

7 files changed

+75
-48
lines changed

7 files changed

+75
-48
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ a. To run the tests in headed mode:
6565
yarn cy:open
6666
```
6767

68+
If you encounter issues with `project:setup` or `resources:create` tasks because of SSL or certificate errors when running the tests locally, try the following:
69+
70+
```sh
71+
NODE_TLS_REJECT_UNAUTHORIZED=0 yarn cy:open
72+
```
73+
6874
b. To run the tests in headless mode:
6975

7076
```sh

cypress.config.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default defineConfig({
2424
DEBUG: 'cypress:launcher:browsers',
2525
ELECTRON_DISABLE_GPU: 'true',
2626
ELECTRON_EXTRA_LAUNCH_ARGS: '--disable-gpu',
27+
NODE_TLS_REJECT_UNAUTHORIZED: 0,
2728
},
2829
setupNodeEvents(on, config) {
2930
on('before:browser:launch', (browser, launchOptions) => {
@@ -141,12 +142,16 @@ export default defineConfig({
141142
token: authToken,
142143
});
143144

144-
return await createResource({
145+
const createdResource = await createResource({
145146
nexus,
146147
orgLabel,
147148
projectLabel,
148149
resource: resourcePayload,
149150
});
151+
if (!createResource) {
152+
throw new Error('Test Resource was not created');
153+
}
154+
return createdResource;
150155
} catch (e) {
151156
console.log(
152157
'Error encountered in analysisResource:create task.',

cypress/e2e/AnalysisPlugin.cy.ts cypress/e2e/AnalysisPlugni.cy.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ describe('Report (formerly Analysis) Plugin', () => {
5454
);
5555
});
5656

57-
// after(function() {
58-
// cy.task('project:teardown', {
59-
// nexusApiUrl: Cypress.env('NEXUS_API_URL'),
60-
// authToken: this.nexusToken,
61-
// orgLabel: Cypress.env('ORG_LABEL'),
62-
// projectLabel: this.projectLabel,
63-
// });
64-
// });
57+
after(function() {
58+
cy.task('project:teardown', {
59+
nexusApiUrl: Cypress.env('NEXUS_API_URL'),
60+
authToken: this.nexusToken,
61+
orgLabel: Cypress.env('ORG_LABEL'),
62+
projectLabel: this.projectLabel,
63+
});
64+
});
6565

6666
it('user can add a report with name, description and files, categories, types', function() {
6767
cy.visit(

cypress/e2e/ResourceContainer.cy.ts

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Resource } from '@bbp/nexus-sdk';
2-
31
describe('Resource with id that contains URL encoded characters', () => {
42
const resourceIdWithEncodedCharacters =
53
'https://hello.lol/https%3A%2F%2Fencoded.url%2Fwow';
@@ -41,8 +39,6 @@ describe('Resource with id that contains URL encoded characters', () => {
4139
orgLabel,
4240
projectLabel,
4341
resourcePayload,
44-
}).then((resource: Resource) => {
45-
cy.wrap(resource['@id']).as('fullResourceId');
4642
});
4743
}
4844
);
@@ -53,7 +49,7 @@ describe('Resource with id that contains URL encoded characters', () => {
5349

5450
beforeEach(() => {
5551
cy.login(
56-
`${Cypress.env('users').morty.username}-report-plugin`,
52+
`${Cypress.env('users').morty.username}-studio`,
5753
Cypress.env('users').morty.realm,
5854
Cypress.env('users').morty.username,
5955
Cypress.env('users').morty.password
@@ -78,27 +74,28 @@ describe('Resource with id that contains URL encoded characters', () => {
7874
cy.contains('[]');
7975
}
8076

81-
it('resource opens when user clicks on resource row in MyData table', function() {
82-
cy.visit(`/`);
77+
it('resource with any id opens when user clicks on resource row in Search table', function() {
78+
cy.visit('/');
79+
cy.visit(`/search?layout=Neuron%20Morphology`);
8380

84-
cy.findAllByText(new RegExp(displayName))
81+
cy.findAllByTestId('search-table-row')
8582
.first()
8683
.click();
8784

88-
cy.findByTestId('resource-details').within(() => {
89-
testResourceDataInJsonViewer();
90-
});
85+
cy.findByText('Advanced View').click();
86+
cy.contains(`"@id"`);
9187
});
9288

93-
it('resource with any id opens when user clicks on resource row in Search table', function() {
94-
cy.visit(`/search?layout=Neuron%20Morphology`);
89+
it('resource opens when user clicks on resource row in MyData table', function() {
90+
cy.visit(`/`);
9591

96-
cy.findAllByTestId('search-table-row')
92+
cy.findAllByText(new RegExp(displayName))
9793
.first()
9894
.click();
9995

100-
cy.findByText('Advanced View').click();
101-
cy.contains(`"@id"`);
96+
cy.findByTestId('resource-details').within(() => {
97+
testResourceDataInJsonViewer();
98+
});
10299
});
103100

104101
it('resource opens when user directly navigates to resource page', function() {
@@ -114,6 +111,7 @@ describe('Resource with id that contains URL encoded characters', () => {
114111
});
115112

116113
it('resource opens with id resolution page', function() {
114+
cy.visit('/');
117115
const resolvePage = `/resolve/${encodeURIComponent(
118116
resourceIdWithEncodedCharacters
119117
)}`;
@@ -130,9 +128,13 @@ describe('Resource with id that contains URL encoded characters', () => {
130128
// If many e2e tests ran together there may be many resources with same id.
131129
// In this case the id resolution page will look different. Test accordingly.
132130
cy.wait('@idResolution').then(interception => {
131+
// expect(interception.response.body).to.equal(200);
132+
// expect(interception.response.statusMessage).to.equal(200);
133+
expect(interception.response.statusCode).to.equal(200);
133134
const resolvedResources = interception.response.body._results;
134-
135-
if (resolvedResources.length === 1) {
135+
cy.log(`Resolved resources delta response`, interception.response.body);
136+
console.log('Resolved resources delta', interception.response.body);
137+
if (resolvedResources?.length === 1) {
136138
testResourceDataInJsonViewer();
137139
} else {
138140
// Multiple resources with same id found.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"deep-object-diff": "^1.1.0",
6767
"express": "^4.18.2",
6868
"handlebars": "^4.7.7",
69-
"history": "^4.7.2",
69+
"history": "4.5.1",
7070
"https-browserify": "^1.0.0",
7171
"json2csv": "^5.0.5",
7272
"jwt-decode": "^2.2.0",
@@ -228,7 +228,8 @@
228228
},
229229
"resolutions": {
230230
"d3-interpolate": "2.0.1",
231-
"headers-polyfill": "3.0.10"
231+
"headers-polyfill": "3.0.10",
232+
"history": "4.5.1"
232233
},
233234
"overrides": {
234235
"d3-interpolate": "2.0.1"

src/subapps/studioLegacy/containers/__tests__/WorkSpaceMenuContainer.spec.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import '@testing-library/jest-dom';
22
import { vi, describe } from 'vitest';
33
import { NexusProvider } from '@bbp/react-nexus';
4-
import { createBrowserHistory } from 'history';
4+
import { createMemoryHistory } from 'history';
55
import { createNexusClient } from '@bbp/nexus-sdk';
66
import { Provider } from 'react-redux';
77
import { QueryClient, QueryClientProvider } from 'react-query';
@@ -26,7 +26,7 @@ import { setupServer } from 'msw/node';
2626
describe(
2727
'workSpaceMenu',
2828
() => {
29-
const history = createBrowserHistory({ basename: '/' });
29+
const history = createMemoryHistory({});
3030
const contextValue: StudioContextType = {
3131
orgLabel: 'org',
3232
projectLabel: 'project',

yarn.lock

+30-17
Original file line numberDiff line numberDiff line change
@@ -6789,17 +6789,16 @@ hey-listen@^1.0.8:
67896789
resolved "https://registry.yarnpkg.com/hey-listen/-/hey-listen-1.0.8.tgz#8e59561ff724908de1aa924ed6ecc84a56a9aa68"
67906790
integrity sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q==
67916791

6792-
history@^4.7.2, history@^4.9.0:
6793-
version "4.10.1"
6794-
resolved "https://registry.yarnpkg.com/history/-/history-4.10.1.tgz#33371a65e3a83b267434e2b3f3b1b4c58aad4cf3"
6795-
integrity sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==
6792+
history@4.5.1, history@^4.9.0:
6793+
version "4.5.1"
6794+
resolved "https://registry.yarnpkg.com/history/-/history-4.5.1.tgz#44935a51021e3b8e67ebac267a35675732aba569"
6795+
integrity sha512-gfHeJeYeMzFtos61gdA1AloO0hGXPF2Yum+2FRdJvlylYQOz51OnT1zuwg9UYst1BRrONhcAh3Nmsg9iblgl6g==
67966796
dependencies:
6797-
"@babel/runtime" "^7.1.2"
6797+
invariant "^2.2.1"
67986798
loose-envify "^1.2.0"
6799-
resolve-pathname "^3.0.0"
6800-
tiny-invariant "^1.0.2"
6801-
tiny-warning "^1.0.0"
6802-
value-equal "^1.0.1"
6799+
resolve-pathname "^2.0.0"
6800+
value-equal "^0.2.0"
6801+
warning "^3.0.0"
68036802

68046803
hmac-drbg@^1.0.1:
68056804
version "1.0.1"
@@ -7082,6 +7081,13 @@ internal-slot@^1.0.4, internal-slot@^1.0.5:
70827081
hasown "^2.0.0"
70837082
side-channel "^1.0.4"
70847083

7084+
invariant@^2.2.1:
7085+
version "2.2.4"
7086+
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
7087+
integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==
7088+
dependencies:
7089+
loose-envify "^1.0.0"
7090+
70857091
inversify-inject-decorators@^3.1.0:
70867092
version "3.1.0"
70877093
resolved "https://registry.yarnpkg.com/inversify-inject-decorators/-/inversify-inject-decorators-3.1.0.tgz#d9941080bad77cec8a65ee29d905e4d5d73e1e95"
@@ -10815,10 +10821,10 @@ resolve-global@1.0.0, resolve-global@^1.0.0:
1081510821
dependencies:
1081610822
global-dirs "^0.1.1"
1081710823

10818-
resolve-pathname@^3.0.0:
10819-
version "3.0.0"
10820-
resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-3.0.0.tgz#99d02224d3cf263689becbb393bc560313025dcd"
10821-
integrity sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng==
10824+
resolve-pathname@^2.0.0:
10825+
version "2.2.0"
10826+
resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-2.2.0.tgz#7e9ae21ed815fd63ab189adeee64dc831eefa879"
10827+
integrity sha512-bAFz9ld18RzJfddgrO2e/0S2O81710++chRMUxHjXOYKF6jTAMrUNZrEZ1PvV0zlhfjidm08iRPdTLPno1FuRg==
1082210828

1082310829
resolve-pkg-maps@^1.0.0:
1082410830
version "1.0.0"
@@ -12585,10 +12591,10 @@ validate-npm-package-name@^4.0.0:
1258512591
dependencies:
1258612592
builtins "^5.0.0"
1258712593

12588-
value-equal@^1.0.1:
12589-
version "1.0.1"
12590-
resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-1.0.1.tgz#1e0b794c734c5c0cade179c437d356d931a34d6c"
12591-
integrity sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw==
12594+
value-equal@^0.2.0:
12595+
version "0.2.1"
12596+
resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-0.2.1.tgz#c220a304361fce6994dbbedaa3c7e1a1b895871d"
12597+
integrity sha512-yRL36Xb2K/HmFT5Fe3M86S7mu4+a12/3l7uytUh6eNPPjP77ldPBvsAvmnWff39sXn55naRMZN8LZWRO8PWaeQ==
1259212598

1259312599
vary@~1.1.2:
1259412600
version "1.1.2"
@@ -12787,6 +12793,13 @@ w3c-xmlserializer@^4.0.0:
1278712793
dependencies:
1278812794
xml-name-validator "^4.0.0"
1278912795

12796+
warning@^3.0.0:
12797+
version "3.0.0"
12798+
resolved "https://registry.yarnpkg.com/warning/-/warning-3.0.0.tgz#32e5377cb572de4ab04753bdf8821c01ed605b7c"
12799+
integrity sha512-jMBt6pUrKn5I+OGgtQ4YZLdhIeJmObddh6CsibPxyQ5yPZm1XExSyzC1LCNX7BzhxWgiHmizBWJTHJIjMjTQYQ==
12800+
dependencies:
12801+
loose-envify "^1.0.0"
12802+
1279012803
wcwidth@^1.0.1:
1279112804
version "1.0.1"
1279212805
resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"

0 commit comments

Comments
 (0)