diff --git a/package.json b/package.json index 44833bb226..afb89f1196 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "config:test": "ts-node --project ./tsconfig.ts-node.json scripts/set-mock-env.ts", "config:test:watch": "nodemon --config mock-nodemon.json", "config:dev:watch": "nodemon", + "config:check:rest": "yarn run config:prod && ts-node --project ./tsconfig.ts-node.json scripts/test-rest.ts", "prestart:dev": "yarn run config:dev", "prebuild": "yarn run config:dev", "pretest": "yarn run config:test", @@ -29,7 +30,6 @@ "test:watch": "npm-run-all --parallel config:test:watch test", "test": "ng test --sourceMap=true --watch=true", "test:headless": "ng test --watch=false --sourceMap=true --browsers=ChromeHeadless --code-coverage", - "test:rest-api": "yarn run config:prod && ts-node --project ./tsconfig.ts-node.json scripts/test-rest.ts", "lint": "ng lint", "lint-fix": "ng lint --fix=true", "e2e": "ng e2e", diff --git a/scripts/test-rest.ts b/scripts/test-rest.ts index d5cf24eb4e..b12a9929c2 100644 --- a/scripts/test-rest.ts +++ b/scripts/test-rest.ts @@ -56,7 +56,9 @@ function checkJSONResponse(responseData: any): any { console.log(`\t"dspaceUI" = ${parsedData.dspaceUI}`); console.log(`\t"dspaceServer" = ${parsedData.dspaceServer}`); console.log(`\t"dspaceServer" property matches UI's "rest" config? ${(parsedData.dspaceServer === environment.rest.baseUrl)}`); - console.log(`\tDoes "_links" section have values? ${!parsedData._links.length}`); + // Check for "authn" and "sites" in "_links" section as they should always exist (even if no data)! + const linksFound: string[] = Object.keys(parsedData._links); + console.log(`\tDoes "/api" endpoint have HAL links ("_links" section)? ${linksFound.includes('authn') && linksFound.includes('sites')}`); } catch (err) { console.error('ERROR: INVALID DSPACE REST API! Response is not valid JSON!'); console.error(`Response returned:\n${responseData}`);