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

feat: Pagination component #690

Merged
merged 33 commits into from
Jul 25, 2022
Merged

feat: Pagination component #690

merged 33 commits into from
Jul 25, 2022

Conversation

suzubara
Copy link
Contributor

@suzubara suzubara commented Jun 28, 2022

SC-523

Do not be fooled by the charming avatar. This PR now belongs to @abbyoung 💀

To Do

  • finish updating unit tests
  • fix linting errors that came outta nowhere (these might resolve once jacob's carousel PR is merged and i rebase)
  • cypress, y u flake?

Proposed changes

  • Adds Pagination component based on USWDS design/rules
  • Adds this component to the ArticleList page
  • Implements pagination on Orbit Blog page (which uses ArticleList page)

Reviewer notes

You can view the pagination component on a page by visiting /about-us/orbit-blog, but what displays will depend on how many published ORBITBlog articles are in the db.

I've added some test articles to the dev environment so you should see more than one page. If you want to see more, you'll need to add and publish more articles in the cms.

You can also view the component on Storybook and use the sandbox to test how it will behave visually with different inputs.

Setup

Locally:
In ussf-portal-client, yarn services:up && yarn dev
In ussf-portal-cms, yarn dev

You'll need to populate db with articles in ORBITBlog category to see paginated results on /about-us/orbit-blog

To view Storybook, run yarn storybook in ussf-portal-client and view the Pagination components.

Code review steps

As the original developer, I have

  • Met the acceptance criteria, or will meet them in subsequent PRs or stories
    • ...
  • Created new stories in Storybook if applicable
    • Checked that all Storybook accessibility checks are passing
  • Created/modified automated unit tests in Jest
    • Including jest-axe checks when UI changes
  • Created/modified automated E2E tests in Cypress
    • Including cypress-axe checks when UI changes
  • Performed a11y testing:
    • Checked responsiveness in mobile, tablet, and desktop
    • Checked keyboard navigability
    • Tested with VoiceOver in Safari
    • Checked VO's rotor menu for landmarks, page heading structure and links
    • Used a browser a11y tool to check for issues (WAVE, axe, ANDI or Accessibility addon tab for Storybook)
  • Requested a design review for user-facing changes
  • For any new migrations/schema changes:
    • Followed guidelines for zero-downtime deploys

As code reviewer(s), I have

  • Pulled this branch locally and tested it
  • Reviewed this code and left comments
  • Checked that all code is adequately covered by tests
  • Made it clear which comments need to be addressed before this work is merged
  • Considered marking this as accepted even if there are small changes needed
  • Performed a11y testing:
    • Checked responsiveness in mobile, tablet, and desktop
    • Checked keyboard navigability
    • Tested with VoiceOver in Safari
    • Checked VO's rotor menu for landmarks, page heading structure and links
    • Used a browser a11y tool to check for issues (WAVE, axe, ANDI or Accessibility addon tab for Storybook)

As a designer reviewer, I have

  • Checked in the design translated visually
  • Checked behavior
  • Checked different states (empty, one, some, error)
  • Checked for landmarks, page heading structure, and links
  • Tried to break the intended flow
  • Performed a11y testing:
    • Checked responsiveness in mobile, tablet, and desktop
    • Checked keyboard navigability
    • Tested with VoiceOver in Safari
    • Checked VO's rotor menu for landmarks, page heading structure and links
    • Used a browser a11y tool to check for issues (WAVE, axe, ANDI or Accessibility addon tab for Storybook)

As a test user, I have

  • Run through the Test Script:
    • On commercial internet in IE11
    • On commercial internet Edge
    • On commercial internet in Firefox
    • On commercial internet in Chrome
    • On commercial internet in Safari
    • On NIPR in IE11
    • On NIPR in Firefox
    • On NIPR in Chrome
    • On NIPR in Safari
    • On a mobile device in Firefox
    • On a mobile device in Chrome
    • On a mobile device in Safari
  • Added any anomalous behavior to this PR

Screenshots

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #523: Add pagination to article list page.

@abbyoung abbyoung self-assigned this Jul 11, 2022
@suzubara suzubara requested a review from noahfirth as a code owner July 12, 2022 20:43
@abbyoung abbyoung changed the title [WIP] Pagination component feat: Pagination component Jul 12, 2022
Dockerfile Outdated
@@ -3,13 +3,13 @@
FROM node:14.19.3-slim AS builder

RUN apt-get update \
&& apt-get -y --no-install-recommends install openssl libc6
&& apt-get -y --no-install-recommends install openssl libc6 git ca-certificates
Copy link
Contributor

Choose a reason for hiding this comment

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

@esacteksab now that we have a released version of react uswds, is it ok to keep the changes you made? or do we need to revert?

Copy link
Contributor

Choose a reason for hiding this comment

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

revert please. I'm happy to do this here or on another branch. Which would you like?

Copy link
Contributor

Choose a reason for hiding this comment

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

here is best since they haven't been merged in yet!

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it's done.

Copy link
Contributor

@gidjin gidjin left a comment

Choose a reason for hiding this comment

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

Changes look good. I left some minor comments, nothing blocking. I haven't done the a11y review yet but wanted the comments shared now in case I don't finish the a11y checks before you look at the PR again.

Dockerfile Outdated

WORKDIR /app

COPY . .

RUN yarn install --frozen-lockfile
RUN rm yarn.lock && yarn install --frozen-lockfile --network-concurrency 1
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: I'll defer to Barry here, but I think we can revert these now that react-uswds is released. Especially since this line removes the yarn.lock file that we have checked in which isn't ideal, though should have little effect since our package.json is locked down.

Copy link
Contributor

Choose a reason for hiding this comment

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

Reverted

Comment on lines +27 to +33
{pagination && (
<Pagination
pathname={window.location.pathname}
totalPages={pagination.totalPages}
currentPage={pagination.currentPage}
/>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit-pick(non-blocking): Can you add a test to ArticleList.test.tsx to verify that if pagination props are passed in that the <Pagination /> component is included and has the expected props?

If it's too much trouble then feel free to skip.

}: {
pathname: string
page: number

Copy link
Contributor

Choose a reason for hiding this comment

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

nit-pick(non-blocking): Can you remove this empty line?

// If no query or an invalid param, return page 1
const currentPage = parseInt(context.query.page) || 1

const articlesPerPage = 10
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: I wonder if this should be a param in the future? So that we can adjust the items per page. Nothing to do in this PR just future thoughts.

gidjin
gidjin previously approved these changes Jul 14, 2022
Copy link
Contributor

@gidjin gidjin left a comment

Choose a reason for hiding this comment

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

LGTM.

question: I don't see an e2e test. Will you be adding one? Though that maybe simpler once we have the data seed stuff figured out. I'll approve since this isn't blocking for me but let me know if you add an e2e test that you want me to review.

Dockerfile Outdated
@@ -27,9 +27,6 @@ RUN yarn install --production --ignore-scripts --prefer-offline
# E2E image for running tests (same as prod but without certs)
FROM node:14.19.3-slim AS e2e

RUN apt-get update \
&& apt-get -y --no-install-recommends install openssl libc6
Copy link
Contributor

Choose a reason for hiding this comment

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

@esacteksab is this expected to have this PR remove all of this? or am i missing something? just don't want to delete anything important..

Copy link
Contributor

Choose a reason for hiding this comment

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

That was definitely a miss for me. I put it back. Thank you for catching this.

@abbyoung
Copy link
Contributor

LGTM.

question: I don't see an e2e test. Will you be adding one? Though that maybe simpler once we have the data seed stuff figured out. I'll approve since this isn't blocking for me but let me know if you add an e2e test that you want me to review.

@gidjin I went ahead and added an e2e test for the ORBIT Blog page that is essentially a placeholder until we get some CMS data. But feels better to have one in place with a TODO note, even if incomplete.

@abbyoung abbyoung requested a review from gidjin July 14, 2022 22:14
Copy link
Contributor

@gidjin gidjin left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +12 to +13
// TODO: Once we have data in CMS test db, we can test
// that articles and pagination are working as expected.
Copy link
Contributor

Choose a reason for hiding this comment

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

Praise: good idea on having a place holder with a TODO, should make coming back later to add the test easier to find.

@abbyoung abbyoung requested review from jbecker01 and jcbcapps July 15, 2022 16:20
Copy link
Contributor

@jbecker01 jbecker01 left a comment

Choose a reason for hiding this comment

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

Looks good!

@gidjin gidjin merged commit bc20cd5 into main Jul 25, 2022
@gidjin gidjin deleted the sc-523/article-pagination branch July 25, 2022 20:59
@gidjin gidjin mentioned this pull request Jul 29, 2022
gidjin added a commit that referenced this pull request Aug 2, 2022
## [4.5.0](4.4.0...4.5.0) (2022-07-29)


### Features

* Add link to ORBIT Blog on portal ([#719](#719)) ([7ce6af9](7ce6af9))
* Create internal news page and update existing external news page ([#711](#711)) ([feadcae](feadcae))
* Edit display name ([#706](#706)) ([372ad2a](372ad2a))
* Pagination component ([#690](#690)) ([bc20cd5](bc20cd5))
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.

6 participants