From 85430f869f27f9f163041114205de188536d85c3 Mon Sep 17 00:00:00 2001 From: Jhonny Gonzalez <55560129+jhonnyoddball@users.noreply.github.com> Date: Fri, 17 Sep 2021 10:58:56 -0400 Subject: [PATCH] upgrade react-router-dom dependency (#18762) * upgrade react-router-dom dependency * Fix unit tests that rely on push to same path Co-authored-by: Jeff Balboni --- package.json | 2 +- .../components/ConfirmationPage.unit.spec.jsx | 8 +++---- .../ConfirmationPageV2.unit.spec.jsx | 6 ++--- ...irmationDirectScheduleInfoV2.unit.spec.jsx | 7 +++--- yarn.lock | 22 +++++++++---------- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index c56aa99d23f8..9fa9ea24f00c 100644 --- a/package.json +++ b/package.json @@ -288,7 +288,7 @@ "react-meta-tags": "^0.7.4", "react-redux": "^7.2.5", "react-router": "3", - "react-router-dom": "^5.2.0", + "react-router-dom": "^5.3.0", "react-router-last-location": "^2.0.1", "react-scroll": "^1.8.4", "react-tabs": "^3.2.2", diff --git a/src/applications/vaos/tests/covid-19-vaccine/components/ConfirmationPage.unit.spec.jsx b/src/applications/vaos/tests/covid-19-vaccine/components/ConfirmationPage.unit.spec.jsx index 94926b355f17..d2d5c604aa70 100644 --- a/src/applications/vaos/tests/covid-19-vaccine/components/ConfirmationPage.unit.spec.jsx +++ b/src/applications/vaos/tests/covid-19-vaccine/components/ConfirmationPage.unit.spec.jsx @@ -1,4 +1,3 @@ -import userEvent from '@testing-library/user-event'; import { waitFor } from '@testing-library/dom'; import { expect } from 'chai'; import moment from 'moment'; @@ -85,9 +84,10 @@ describe('VAOS vaccine flow ', () => { expect(screen.baseElement).to.contain.text('Main phone: 307-778-7580'); expect(screen.getByText(/add to calendar/i)).to.have.tagName('a'); - userEvent.click(screen.getByText(/View your appointments/i)); - expect(screen.history.push.called).to.be.true; - expect(screen.history.push.getCall(0).args[0]).to.equal('/'); + expect(screen.getByText(/View your appointments/i)).to.have.attribute( + 'href', + '/', + ); }); it('should redirect to home page if no form data', async () => { diff --git a/src/applications/vaos/tests/covid-19-vaccine/components/ConfirmationPageV2.unit.spec.jsx b/src/applications/vaos/tests/covid-19-vaccine/components/ConfirmationPageV2.unit.spec.jsx index 9716a16e8b78..9f440cbab1d7 100644 --- a/src/applications/vaos/tests/covid-19-vaccine/components/ConfirmationPageV2.unit.spec.jsx +++ b/src/applications/vaos/tests/covid-19-vaccine/components/ConfirmationPageV2.unit.spec.jsx @@ -102,10 +102,10 @@ describe('VAOS vaccine flow ', () => { ), ).to.be.ok; userEvent.click(screen.getByText(/View your appointments/i)); - expect(screen.history.push.called).to.be.true; - expect(screen.history.push.getCall(0).args[0]).to.equal('/'); + expect(screen.history.replace.called).to.be.true; + expect(screen.history.replace.firstCall.args[0]).to.equal('/'); userEvent.click(screen.getByText(/New appointment/i)); - expect(screen.history.push.getCall(1).args[0]).to.equal('/new-appointment'); + expect(screen.history.push.firstCall.args[0]).to.equal('/new-appointment'); }); it('should redirect to home page if no form data', async () => { diff --git a/src/applications/vaos/tests/new-appointment/components/ConfirmationPage/ConfirmationDirectScheduleInfoV2.unit.spec.jsx b/src/applications/vaos/tests/new-appointment/components/ConfirmationPage/ConfirmationDirectScheduleInfoV2.unit.spec.jsx index 48edc79ef17a..b08b779bcad7 100644 --- a/src/applications/vaos/tests/new-appointment/components/ConfirmationPage/ConfirmationDirectScheduleInfoV2.unit.spec.jsx +++ b/src/applications/vaos/tests/new-appointment/components/ConfirmationPage/ConfirmationDirectScheduleInfoV2.unit.spec.jsx @@ -121,9 +121,10 @@ describe('VAOS ', () => { it('should render appointment list page when "View your appointments" link is clicked', () => { const screen = renderWithStoreAndRouter(, { store }); - userEvent.click(screen.getByText(/View your appointments/i)); - expect(screen.history.push.called).to.be.true; - expect(screen.history.push.getCall(0).args[0]).to.equal('/'); + expect(screen.getByText(/View your appointments/i)).to.have.attribute( + 'href', + '/', + ); }); it('should render new appointment page when "New appointment" link is clicked', () => { diff --git a/yarn.lock b/yarn.lock index 19ab9c8c6fc3..afb48a9dfb82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15419,16 +15419,16 @@ react-remove-scroll@^2.4.1: use-callback-ref "^1.2.3" use-sidecar "^1.0.1" -react-router-dom@^5.2.0: - version "5.2.0" - resolved "https://registry.npmjs.org/react-router-dom/-/react-router-dom-5.2.0.tgz" - integrity sha512-gxAmfylo2QUjcwxI63RhQ5G85Qqt4voZpUXSEqCwykV0baaOTQDR1f0PmY8AELqIyVc0NEZUj0Gov5lNGcXgsA== +react-router-dom@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-5.3.0.tgz#da1bfb535a0e89a712a93b97dd76f47ad1f32363" + integrity sha512-ObVBLjUZsphUUMVycibxgMdh5jJ1e3o+KpAZBVeHcNQZ4W+uUGGWsokurzlF4YOldQYRQL4y6yFRWM4m3svmuQ== dependencies: - "@babel/runtime" "^7.1.2" + "@babel/runtime" "^7.12.13" history "^4.9.0" loose-envify "^1.3.1" prop-types "^15.6.2" - react-router "5.2.0" + react-router "5.2.1" tiny-invariant "^1.0.2" tiny-warning "^1.0.0" @@ -15451,12 +15451,12 @@ react-router@3: react-is "^16.13.0" warning "^3.0.0" -react-router@5.2.0: - version "5.2.0" - resolved "https://registry.npmjs.org/react-router/-/react-router-5.2.0.tgz" - integrity sha512-smz1DUuFHRKdcJC0jobGo8cVbhO3x50tCL4icacOlcwDOEQPq4TMqwx3sY1TP+DvtTgz4nm3thuo7A+BK2U0Dw== +react-router@5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/react-router/-/react-router-5.2.1.tgz#4d2e4e9d5ae9425091845b8dbc6d9d276239774d" + integrity sha512-lIboRiOtDLFdg1VTemMwud9vRVuOCZmUIT/7lUoZiSpPODiiH1UQlfXy+vPLC/7IWdFYnhRwAyNqA/+I7wnvKQ== dependencies: - "@babel/runtime" "^7.1.2" + "@babel/runtime" "^7.12.13" history "^4.9.0" hoist-non-react-statics "^3.1.0" loose-envify "^1.3.1"