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

upgrade react-router-dom dependency #18762

Merged
merged 3 commits into from Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
@@ -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';
Expand Down Expand Up @@ -85,9 +84,10 @@ describe('VAOS vaccine flow <ConfirmationPage>', () => {
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(
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests were breaking due to remix-run/react-router#5362

For the tests that were breaking, we were rendering a page outside of our normal route structure, so the url of the page being tested wasn't the actual url, it was just /. This means that some of our links back to the homepage looked to react-router like we were going from / to /, which now doesn't generate a history push. We were testing the link clicks by looking for a push.

Instead, I've updated them to just look at the href and not click when we don't care about switching to another page, and looking for a history replace when we do care about the next page.

'href',
'/',
);
});

it('should redirect to home page if no form data', async () => {
Expand Down
Expand Up @@ -102,10 +102,10 @@ describe('VAOS vaccine flow <ConfirmationPageV2>', () => {
),
).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 () => {
Expand Down
Expand Up @@ -121,9 +121,10 @@ describe('VAOS <ConfirmationDirectScheduleInfoV2>', () => {

it('should render appointment list page when "View your appointments" link is clicked', () => {
const screen = renderWithStoreAndRouter(<ConfirmationPage />, { 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', () => {
Expand Down
22 changes: 11 additions & 11 deletions yarn.lock
Expand Up @@ -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"

Expand All @@ -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"
Expand Down