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

add content filtering to the website content listing page #1046

Merged
merged 1 commit into from
Feb 23, 2022

Conversation

alicewriteswrongs
Copy link
Contributor

@alicewriteswrongs alicewriteswrongs commented Feb 22, 2022

Pre-Flight checklist

  • Screenshots and design review for any changes that affect layout or styling
    • Desktop screenshots
    • Mobile width screenshots
  • Testing
    • Code is tested
    • Changes have been manually tested

What are the relevant tickets?

for #1020

What's this PR do?

this PR implements a basic sort UI on the content listing pages. I pulled out the logic I wrote for the same type of sort on the /sites page into a hook and then added it to the content page, so it works the same way.

How should this be manually tested?

go to a content page like /sites/$SITENAME/type/page and try it out!

Screenshots (if appropriate)

Screen Shot 2022-02-22 at 11 50 09 AM

@codecov-commenter
Copy link

codecov-commenter commented Feb 22, 2022

Codecov Report

Merging #1046 (12d5225) into master (934657b) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1046      +/-   ##
==========================================
+ Coverage   91.10%   91.12%   +0.02%     
==========================================
  Files         200      201       +1     
  Lines        7652     7670      +18     
  Branches     1333     1333              
==========================================
+ Hits         6971     6989      +18     
  Misses        596      596              
  Partials       85       85              
Impacted Files Coverage Δ
static/js/components/RepeatableContentListing.tsx 97.82% <100.00%> (+0.23%) ⬆️
static/js/hooks/search.ts 100.00% <100.00%> (ø)
static/js/pages/SitesDashboard.tsx 100.00% <100.00%> (ø)
static/js/test_util.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 934657b...12d5225. Read the comment docs.

Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

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

Nice 🪝 ... So cool that it can be reused from the dashboard to the listings.

One minor request/question

Comment on lines 276 to 280
await wait(800)
wrapper.update()
expect(wrapper.find(".site-search-input").prop("value")).toBe(
"my-search-string"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Question / Requested Change: What's the goal of this test? I think it might not be doing what is expected.

Doesn't the input update immediately, but the history / url bar has debounced updating? I tried this test out and the assertion passes without the wait(800).

Is the goal to test the debouncing history thing? If yes, two suggestions:

  • I think jest.spyOn(helper.browserHistory, 'push') should let us spy on the url bar... but maybe theres a better way. Unsure.

  • Instead of using wait, you could use jest.useFakeTimers and jest.advanceFakeTimers ... :timelord:

    Although, I imagine wait isn't a significant contributor to our test runtime 🤷

Anyway, requested change is: remove the wait(800) if the test is the way it is is supposed to be, or make it fail without the wait(800).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had a heck of a time with this test! I'll give spyOn a try, but it was the strangest thing - although I had an almost identical test to the corresponding one for the SitesDashboard, for some reason the calls to history.push in the hook weren't changing any kind of history anywhere that I could pull out and assert, so I got a little frustrated and then just asserted that the new search string was present as the value prop on the input. I'll give it another go today :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok spyOn worked, but still if I console.log(helper.browserHistory.location) the .search prop is ""... 🤷‍♀️

const filterInput = wrapper.find(".site-search-input")
const event = {
// eslint-disable-next-line @typescript-eslint/no-empty-function
preventDefault() {},
Copy link
Contributor

Choose a reason for hiding this comment

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

Random question: I noticed useTextInputState in your hook, so I went to go look at it... do you know why we call preventDefault in useTextInputState? When is preventing default on a text input important?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

haha, no idea - it probably just got put in by default

@Ferdi
Copy link

Ferdi commented Feb 22, 2022

why just "Pages" ?

@alicewriteswrongs
Copy link
Contributor Author

@Ferdi it's not just present on pages, I just neglected to screenshot them :)

Here's what it looks like elsewhere:

Screen Shot 2022-02-23 at 9 14 05 AM

Screen Shot 2022-02-23 at 9 25 48 AM

This adds a basic sort UI on the content listing pages. It's implemented
by pulling out the filtering UI from the `/sites` page into a reusable
hook that we can then use in both places.

part of #1020
pr #1046
@alicewriteswrongs alicewriteswrongs merged commit f1a47db into master Feb 23, 2022
@alicewriteswrongs alicewriteswrongs deleted the ap/content-filtering branch February 23, 2022 16:24
@alicewriteswrongs alicewriteswrongs temporarily deployed to ocw-studio-ci February 23, 2022 16:38 Inactive
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.

4 participants