-
Notifications
You must be signed in to change notification settings - Fork 29
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
fix: fix tests using the new sdk #1665
base: new-sdk-release
Are you sure you want to change the base?
Conversation
…ontend into new-sdk-tests-fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @martin-trajanovski - I've reviewed your changes - here's some feedback:
Overall Comments:
- There are some TODO comments about fixing types that should be addressed in follow-up PRs, but they don't block the core functionality
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 2 issues found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
src/app/datasets/dataset-detail/dataset-detail.component.spec.ts
Outdated
Show resolved
Hide resolved
Bumps the types group with 1 update: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node). Updates `@types/node` from 22.9.0 to 22.9.3 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: types ... Signed-off-by: dependabot[bot] <support@github.com>
…ypes-c0e67af0c7 chore(deps-dev): bump @types/node from 22.9.0 to 22.9.3 in the types group
Bumps [cypress](https://github.com/cypress-io/cypress) from 13.15.2 to 13.16.0. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/CHANGELOG.md) - [Commits](cypress-io/cypress@v13.15.2...v13.16.0) --- updated-dependencies: - dependency-name: cypress dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
…ypress-13.16.0 chore(deps-dev): bump cypress from 13.15.2 to 13.16.0
Bumps [mathjs](https://github.com/josdejong/mathjs) from 13.2.2 to 14.0.0. - [Changelog](https://github.com/josdejong/mathjs/blob/develop/HISTORY.md) - [Commits](josdejong/mathjs@v13.2.2...v14.0.0) --- updated-dependencies: - dependency-name: mathjs dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
…athjs-14.0.0 chore(deps): bump mathjs from 13.2.2 to 14.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general.
I stopped tracking the use case of createMock
where the mockData has already been defined in the MockStubs.ts file. It would be easier to track them with search in vscode
src/app/datasets/dataset-detail/dataset-detail.component.spec.ts
Outdated
Show resolved
Hide resolved
@@ -131,7 +136,7 @@ describe("DatasetTableComponent", () => { | |||
|
|||
describe("#userErrorCondition()", () => { | |||
it("should return true if dataset has missingFilesError", () => { | |||
const dataset = new Dataset(); | |||
const dataset = createMock<DatasetClass>({}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it better if we use DatasetClass as the default for mockDataset
and use OutputDatasetObsoleteDto
for edge cases? What do you think?
// TODO: Fix this any type casting here | ||
spyOn( | ||
component.userIdentititiesService, | ||
"userIdentitiesControllerIsValidEmail", | ||
).and.returnValue(of(true) as any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is type any needed here?
src/app/proposals/view-proposal-page/view-proposal-page.component.spec.ts
Outdated
Show resolved
Hide resolved
src/app/publisheddata/publisheddata-dashboard/publisheddata-dashboard.component.spec.ts
Outdated
Show resolved
Hide resolved
return data as T; | ||
} | ||
|
||
export const mockDataset = createMock<OutputDatasetObsoleteDto>({}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned above, wouldn't it make more sense to use DatasetClass instead of ObsoleteDto?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned below I am not focusing that much on the details here in the tests right now as we will refactor all this in the near future if we use the next version of the dataset endpoints. They will be typed correctly and we wont have these inconsistencies anymore
// TODO: Try to fix any type casting here | ||
datasetApi.datasetsControllerThumbnail.and.returnValue( | ||
of({ thumbnail } as any), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe something like of({ thumbnail } as unknown as HttpResponse<Attachment>)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a TODO comment here and don't want to investigate the proper fix right now as it is in the tests and the tests are passing. Will try to do it later and fix most of the TODOs left with this PR in the future whenever we can get some extra time doing this. I think I spent a lot of time around the types and most of them at least in the code are fixed. In the tests we can check it later I hope. But thanks for the feedback @Junjiequan I appreciate it.
}); | ||
|
||
it("should fetch thumbnail and cache it if not already cached", async () => { | ||
const pid = "test-pid"; | ||
const thumbnail = "http://thumbnail-url.com/image.jpg"; | ||
|
||
datasetApi.thumbnail.and.returnValue(of({ thumbnail })); | ||
datasetApi.datasetsControllerThumbnail.and.returnValue( | ||
of({ thumbnail } as any), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
Description
Fixing e2e and unit tests with the new sdk
Motivation
E2e and unit tests failing after the new sdk migration.
Tests included
Documentation
official documentation info
If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included
Backend version
Summary by Sourcery
Bug Fixes:
Summary by Sourcery
Fix tests to work with the new SDK by updating service imports and method calls. Refactor Cypress commands for better token handling. Update test files to ensure compatibility with the new SDK structure.
Bug Fixes:
Enhancements:
Tests: