Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Write tests for search-store #286

Merged
merged 1 commit into from
Oct 13, 2021
Merged

Write tests for search-store #286

merged 1 commit into from
Oct 13, 2021

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Oct 4, 2021

Fixes

Fixes #285 by @obulat

Description

This PR adds tests for search-store and raises the coverage to 100%.

This PR also removes the actions for fetching collection images because they are not used anywhere. If needed, they can be re-added in the future.

To make adding media types easier, actions are created using an object now:
instead of actions(audioService, imageService),
they use a services object:
services = { 'audio': audioService, 'image': imageService }.

A couple of small bugs were also fixed:

  • MEDIA_NOT_FOUND is called correctly, using both state and params as parameters.
  • in FETCH_AUDIO, the usageSessionId is set correctly, using the namespaced user.usageSessionId
  • only the search page watches for query changes, and updates the media in Vuex store, instead of both search page and SearchGridManualLoad. I've reverted this change

Testing Instructions

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@obulat obulat added 🟨 priority: medium Not blocking but should be addressed soon 💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users labels Oct 4, 2021
@obulat obulat requested a review from a team as a code owner October 4, 2021 08:03
@obulat obulat requested review from AetherUnbound, sarayourfriend, krysal and zackkrida and removed request for AetherUnbound October 4, 2021 08:03
Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

LGTM aside from the expect().rejects issue I pointed out in a few places. Otherwise once those are addressed this will be a nice addition to the test suite 😁

test/unit/specs/store/search-store.spec.js Outdated Show resolved Hide resolved
test/unit/specs/store/search-store.spec.js Outdated Show resolved Hide resolved
test/unit/specs/store/search-store.spec.js Outdated Show resolved Hide resolved
test/unit/specs/store/search-store.spec.js Outdated Show resolved Hide resolved
Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@obulat obulat added 🛠 goal: fix Bug fix and removed 🧰 goal: internal improvement Improvement that benefits maintainers, not users labels Oct 11, 2021
@obulat obulat force-pushed the fix/search_store_tests branch from 220170a to d47bc40 Compare October 12, 2021 13:55
@obulat
Copy link
Contributor Author

obulat commented Oct 12, 2021

I also added a bug-fix in here: both SearchGridManualLoad and search page were watching the query and updating the media in store on change. It is enough to watch for query changes on the search page. To make sure that all changes in query trigger the watcher, I added the deep: true to the watcher.

@sarayourfriend
Copy link
Contributor

@obulat Now that there are some changes outside of adding tests can you add testing instructions?

@obulat
Copy link
Contributor Author

obulat commented Oct 13, 2021

@obulat Now that there are some changes outside of adding tests can you add testing instructions?

There was previously a bug when on a Search Form submit (clicking Search button) you would get all the query parameters in URL, even if they were blank: openverse/search/images?q=&license=&license_type=&, and I was trying to fix it with some small changes. But I don't see this bug anymore, I have no idea why! So, I just reverted the changes to only contain the Search store tests, and two small bug fixes, that you've already seen and approved, @sarayourfriend . Sorry for so much back-and-forth on this PR

Add initial query values

Handle media reset on query change only in `search` page

Handle media reset on query change only in `search` page

Remove unused lines

Update src/utils/prepare-search-query-params.js

Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com>

Revert some unrelated changes

Add check for newQuery
@obulat obulat force-pushed the fix/search_store_tests branch from 5c3e959 to dadc62c Compare October 13, 2021 06:49
Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

LGTM! No worries about the back and forth 😅

Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

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

🥳

@obulat obulat merged commit 3967fc1 into main Oct 13, 2021
@obulat obulat deleted the fix/search_store_tests branch October 13, 2021 19:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💻 aspect: code Concerns the software code in the repository 🛠 goal: fix Bug fix 🟨 priority: medium Not blocking but should be addressed soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Search store is not covered with tests
3 participants