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

fix: Update SW video field #696

Merged
merged 7 commits into from
Aug 22, 2023
Merged

fix: Update SW video field #696

merged 7 commits into from
Aug 22, 2023

Conversation

cyaiox
Copy link
Contributor

@cyaiox cyaiox commented Aug 21, 2023

This PR updates the video field for smart wearables when approving a curation.

@coveralls
Copy link

coveralls commented Aug 21, 2023

Pull Request Test Coverage Report for Build 5942496375

  • 22 of 22 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 69.805%

Totals Coverage Status
Change from base Build 5882423751: 0.1%
Covered Lines: 2898
Relevant Lines: 3987

💛 - Coveralls

@cyaiox cyaiox marked this pull request as ready for review August 22, 2023 13:23
*/
private updateCollectionItemsContent = async (collectionId: string) => {
const itemService = new ItemService()
itemService.updateDCLItemsContent(collectionId)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add the await here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right! added the await

Copy link
Contributor

@LautaroPetaccio LautaroPetaccio left a comment

Choose a reason for hiding this comment

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

The changes look great 👍
I've left some comments on the tests that I think we could improve.

Comment on lines 653 to 661
updateSpy = jest
.spyOn(service, 'updateById')
.mockResolvedValueOnce(expectedCuration)
const updateItemSpy = jest
.spyOn(Item, 'upsert')
.mockResolvedValue({
...mockItem,
video: newVideoHash,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind setting these two in the beforeEach?
The same goes for the other test.

},
video: 'videoHash',
}
;(Item.findOne as jest.Mock).mockRestore()
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you need to use restores because there was an issue with the mocks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not required the restores, removing it

Comment on lines 133 to 138
;(collectionAPI.fetchCollection as jest.Mock).mockImplementation(() =>
Promise.resolve({
...collectionFragmentMock,
creator: oldCreatorAddress,
})
)
Copy link
Contributor

Choose a reason for hiding this comment

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

The mocks that return values can be simplified using the resolve or return mocks. Would you mind changing them?

Suggested change
;(collectionAPI.fetchCollection as jest.Mock).mockImplementation(() =>
Promise.resolve({
...collectionFragmentMock,
creator: oldCreatorAddress,
})
)
;(collectionAPI.fetchCollection as jest.Mock).mockResolvedValueOnce({
...collectionFragmentMock,
creator: oldCreatorAddress,
})

;(Item.findOne as jest.Mock).mockRestore()
;(Item.findOne as jest.Mock).mockResolvedValueOnce(dbItem)
;(Item.hasPublishedItems as jest.Mock).mockResolvedValue(true)
;(Item.upsert as jest.Mock).mockImplementation((value) => value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind using the once version of the mocks? This will prevent the mocks from leaking into other tests.

Copy link
Contributor

@LautaroPetaccio LautaroPetaccio left a comment

Choose a reason for hiding this comment

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

🚀

@cyaiox cyaiox merged commit bda4e94 into master Aug 22, 2023
4 checks passed
@cyaiox cyaiox deleted the fix/update-sw-video-field branch August 22, 2023 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants