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

59 - Add new Dataset use cases to support the Dataset page (SPA) #60

Merged
merged 31 commits into from
Jun 13, 2023

Conversation

GPortas
Copy link
Contributor

@GPortas GPortas commented May 15, 2023

What this PR does / why we need it:

NEW USE CASES

This PR includes new use cases and model transformations to support the following UI components of the Dataset page:

  • Page boilerplate and basic Dataset info (title and version)
  • Citation block
  • Dataset summary

The use cases consume new endpoints implemented in:

NEW GITHUB ACTION

Pulled from #61 (now closed in favor of this PR)

Introduces an automated GitHub action to be executed on PR commits.

The action builds and deploys the package to a new GitHub npm registry (https://github.com/IQSS/dataverse-client-javascript/pkgs/npm/dataverse-client-javascript), dedicated to development images from PRs only. This way the SPA can use these versions to test the changes developed in the package during the PRs.

Which issue(s) this PR closes:

Special notes for your reviewer:

N/A

Suggestions on how to test this:

N/A

Is there a release notes update needed for this change?:

N/A

Additional documentation:

N/A

@GPortas GPortas self-assigned this May 15, 2023
@GPortas GPortas added this to Ready for Review ⏩ in IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) via automation May 15, 2023
@GPortas GPortas moved this from Ready for Review ⏩ to IQSS Team - In Progress 💻 in IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) May 15, 2023
@GPortas GPortas removed their assignment May 22, 2023
@GPortas GPortas marked this pull request as ready for review May 22, 2023 16:22
@GPortas GPortas moved this from IQSS Team - In Progress 💻 to Ready for Review ⏩ in IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) May 22, 2023
@MellyGray MellyGray self-assigned this May 23, 2023
@MellyGray MellyGray moved this from Ready for Review ⏩ to In Review 🔎 in IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) May 23, 2023
Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things. I'm getting errors on some tests when running test:coverage. Details below.

Also, should we update the README? A suggestion:

 ## NPM
 
-Module available as `js-dataverse` at https://www.npmjs.com/package/js-dataverse
+A stable 1.x version of this package is available as `js-dataverse` at https://www.npmjs.com/package/js-dataverse
+
+An unstable 2.x version of this package with breaking changes is under development. Until a 2.0 version is officially released, it can be installed from https://github.com/IQSS/dataverse-client-javascript/pkgs/npm/dataverse-client-javascript
 
 ## Getting Started

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a few of the tests (like this one), I'm getting an error when I run test:coverage. I'm not sure why. Here's an example:

HMDC-beamish:dataverse-client-javascript pdurbin$ node --version
v19.7.0
HMDC-beamish:dataverse-client-javascript pdurbin$ npm run test:coverage test/unit/datasets/GetDatasetById.test.ts

> js-dataverse@2.0.0 test:coverage
> jest --coverage -c jest.config.js test/unit/datasets/GetDatasetById.test.ts

 FAIL  test/unit/datasets/GetDatasetById.test.ts
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
     • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    SyntaxError: /Users/pdurbin/github/iqss/dataverse-client-javascript/node_modules/domino/lib/sloppy.js: 'with' in strict mode. (10:4)

       8 |   Window_run: function _run(code, file) {
       9 |     if (file) code += '\n//@ sourceURL=' + file;
    > 10 |     with(this) eval(code);
         |     ^
      11 |   },
      12 |   EventHandlerBuilder_build: function build() {
      13 |     try {

      at instantiate (node_modules/@babel/parser/src/parse-error/credentials.ts:62:21)
      at instantiate (node_modules/@babel/parser/src/parse-error.ts:60:12)
      at Parser.toParseError [as raise] (node_modules/@babel/parser/src/tokenizer/index.ts:1490:19)
      at Parser.raise [as parseWithStatement] (node_modules/@babel/parser/src/parser/statement.ts:1200:12)
      at Parser.parseWithStatement [as parseStatementContent] (node_modules/@babel/parser/src/parser/statement.ts:545:21)
      at Parser.parseStatementContent [as parseStatementLike] (node_modules/@babel/parser/src/parser/statement.ts:417:17)
      at Parser.parseStatementLike [as parseStatementListItem] (node_modules/@babel/parser/src/parser/statement.ts:366:17)
      at Parser.parseStatementListItem [as parseBlockOrModuleBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1360:16)
      at Parser.parseBlockOrModuleBlockBody [as parseBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1333:10)
      at Parser.parseBlockBody [as parseBlock] (node_modules/@babel/parser/src/parser/statement.ts:1301:10)
      at Parser.parseBlock [as parseFunctionBody] (node_modules/@babel/parser/src/parser/expression.ts:2552:24)
      at Parser.parseFunctionBody [as parseFunctionBodyAndFinish] (node_modules/@babel/parser/src/parser/expression.ts:2523:10)
      at parseFunctionBodyAndFinish (node_modules/@babel/parser/src/parser/statement.ts:1600:12)
      at Parser.callback [as withSmartMixTopicForbiddingContext] (node_modules/@babel/parser/src/parser/expression.ts:3051:14)
      at Parser.withSmartMixTopicForbiddingContext [as parseFunction] (node_modules/@babel/parser/src/parser/statement.ts:1598:10)
      at Parser.parseFunction [as parseFunctionOrFunctionSent] (node_modules/@babel/parser/src/parser/expression.ts:1622:17)
      at Parser.parseFunctionOrFunctionSent [as parseExprAtom] (node_modules/@babel/parser/src/parser/expression.ts:1199:21)
      at Parser.parseExprAtom [as parseExprSubscripts] (node_modules/@babel/parser/src/parser/expression.ts:718:23)
      at Parser.parseExprSubscripts [as parseUpdate] (node_modules/@babel/parser/src/parser/expression.ts:695:21)
      at Parser.parseUpdate [as parseMaybeUnary] (node_modules/@babel/parser/src/parser/expression.ts:657:23)
      at Parser.parseMaybeUnary [as parseMaybeUnaryOrPrivate] (node_modules/@babel/parser/src/parser/expression.ts:395:14)
      at Parser.parseMaybeUnaryOrPrivate [as parseExprOps] (node_modules/@babel/parser/src/parser/expression.ts:407:23)
      at Parser.parseExprOps [as parseMaybeConditional] (node_modules/@babel/parser/src/parser/expression.ts:362:23)
      at Parser.parseMaybeConditional [as parseMaybeAssign] (node_modules/@babel/parser/src/parser/expression.ts:302:21)
      at parseMaybeAssign (node_modules/@babel/parser/src/parser/expression.ts:256:12)
      at Parser.callback [as allowInAnd] (node_modules/@babel/parser/src/parser/expression.ts:3077:12)
      at Parser.allowInAnd [as parseMaybeAssignAllowIn] (node_modules/@babel/parser/src/parser/expression.ts:255:17)
      at Parser.parseMaybeAssignAllowIn [as parseObjectProperty] (node_modules/@babel/parser/src/parser/expression.ts:2267:16)
      at Parser.parseObjectProperty [as parseObjPropValue] (node_modules/@babel/parser/src/parser/expression.ts:2326:12)
      at Parser.parseObjPropValue [as parsePropertyDefinition] (node_modules/@babel/parser/src/parser/expression.ts:2170:17)
      at Parser.parsePropertyDefinition [as parseObjectLike] (node_modules/@babel/parser/src/parser/expression.ts:2044:21)
      at Parser.parseObjectLike [as parseExprAtom] (node_modules/@babel/parser/src/parser/expression.ts:1191:21)
      at Parser.parseExprAtom [as parseExprSubscripts] (node_modules/@babel/parser/src/parser/expression.ts:718:23)
      at Parser.parseExprSubscripts [as parseUpdate] (node_modules/@babel/parser/src/parser/expression.ts:695:21)
      at Parser.parseUpdate [as parseMaybeUnary] (node_modules/@babel/parser/src/parser/expression.ts:657:23)
      at Parser.parseMaybeUnary [as parseMaybeUnaryOrPrivate] (node_modules/@babel/parser/src/parser/expression.ts:395:14)
      at Parser.parseMaybeUnaryOrPrivate [as parseExprOps] (node_modules/@babel/parser/src/parser/expression.ts:407:23)
      at Parser.parseExprOps [as parseMaybeConditional] (node_modules/@babel/parser/src/parser/expression.ts:362:23)
      at Parser.parseMaybeConditional [as parseMaybeAssign] (node_modules/@babel/parser/src/parser/expression.ts:302:21)
      at Parser.parseMaybeAssign (node_modules/@babel/parser/src/parser/expression.ts:340:25)
      at Parser.parseMaybeAssign [as parseExpressionBase] (node_modules/@babel/parser/src/parser/expression.ts:225:23)
      at parseExpressionBase (node_modules/@babel/parser/src/parser/expression.ts:216:39)
      at Parser.callback [as allowInAnd] (node_modules/@babel/parser/src/parser/expression.ts:3072:16)
      at Parser.allowInAnd [as parseExpression] (node_modules/@babel/parser/src/parser/expression.ts:216:17)
      at Parser.parseExpression [as parseStatementContent] (node_modules/@babel/parser/src/parser/statement.ts:628:23)
      at Parser.parseStatementContent [as parseStatementLike] (node_modules/@babel/parser/src/parser/statement.ts:417:17)
      at Parser.parseStatementLike [as parseModuleItem] (node_modules/@babel/parser/src/parser/statement.ts:354:17)
      at Parser.parseModuleItem [as parseBlockOrModuleBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1359:16)
      at Parser.parseBlockOrModuleBlockBody [as parseBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1333:10)
      at Parser.parseBlockBody [as parseProgram] (node_modules/@babel/parser/src/parser/statement.ts:226:10)
      at Parser.parseProgram [as parseTopLevel] (node_modules/@babel/parser/src/parser/statement.ts:208:25)
      at Parser.parseTopLevel [as parse] (node_modules/@babel/parser/src/parser/index.ts:45:10)
      at parse (node_modules/@babel/parser/src/index.ts:67:38)
      at parser (node_modules/@babel/core/src/parser/index.ts:28:19)
          at parser.next (<anonymous>)
      at normalizeFile (node_modules/@babel/core/src/transformation/normalize-file.ts:51:24)
          at normalizeFile.next (<anonymous>)
      at run (node_modules/@babel/core/src/transformation/index.ts:38:36)
          at run.next (<anonymous>)
      at transform (node_modules/@babel/core/src/transform.ts:29:20)
          at transform.next (<anonymous>)
      at evaluateSync (node_modules/gensync/index.js:251:28)
      at sync (node_modules/gensync/index.js:89:14)
      at fn (node_modules/@babel/core/src/errors/rewrite-stack-trace.ts:97:14)
      at transformSync (node_modules/@babel/core/src/transform.ts:66:52)
      at ScriptTransformer._instrumentFile (node_modules/@jest/transform/build/ScriptTransformer.js:389:46)
      at ScriptTransformer._buildTransformResult (node_modules/@jest/transform/build/ScriptTransformer.js:491:33)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:551:17)
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:671:40)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:723:19)
      at Object.require (node_modules/domino/lib/defineElement.js:4:14)
      at Object.require (node_modules/domino/lib/htmlelts.js:7:21)
      at Object.require (node_modules/domino/lib/Document.js:21:12)
      at Object.require (node_modules/domino/lib/DOMImplementation.js:4:16)
      at Object.require (node_modules/domino/lib/index.js:2:25)

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------
Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.671 s
Ran all test suites matching /test\/unit\/datasets\/GetDatasetById.test.ts/i.
HMDC-beamish:dataverse-client-javascript pdurbin$ 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by ignoring the node_modules folder in the jest configuration.

Thanks!

Copy link
Contributor

@MellyGray MellyGray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) automation moved this from In Review 🔎 to Ready for QA ⏩ May 31, 2023
@MellyGray MellyGray removed their assignment May 31, 2023
@kcondon kcondon self-assigned this Jun 1, 2023
@kcondon kcondon merged commit cc987f2 into develop Jun 13, 2023
2 checks passed
IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) automation moved this from QA ✅ to Done 🚀 Jun 13, 2023
@kcondon kcondon deleted the 59-dataset-info-use-cases branch June 13, 2023 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[Spike - js-dataverse] Add new Dataset use cases to support the Dataset page (SPA)
5 participants