-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(frontend): keep query param when changing routes (#674)
* add tests for changing routes and maintaining query params * fix(frontend): rollback to Router to maintain queryParams sync with store
- Loading branch information
Showing
3 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
describe('QueryParams', () => { | ||
// on smaller screens component will be collapsed by default | ||
beforeEach(() => { | ||
cy.viewport(1440, 900); | ||
}); | ||
|
||
// type a tag so that it's synced to the URL | ||
// IMPORTANT! don't access the url directly since it will render this test useless | ||
// since we are testing populating the queryParams and maintaining between routes | ||
it('maintains queryParams when changing route', () => { | ||
const myTag = 'myrandomtag{}'; | ||
const validate = () => { | ||
cy.location().then((loc) => { | ||
const urlParams = new URLSearchParams(loc.search); | ||
expect(urlParams.get('query')).to.eq(myTag); | ||
}); | ||
}; | ||
|
||
cy.visit('/'); | ||
cy.get('.tags-input').clear().type(myTag); | ||
cy.get('.tags-query button').click(); | ||
validate(); | ||
|
||
cy.findByTestId('sidebar-continuous-comparison').click(); | ||
validate(); | ||
|
||
cy.findByTestId('sidebar-continuous-diff').click(); | ||
validate(); | ||
|
||
cy.findByTestId('sidebar-continuous-single').click(); | ||
validate(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
// src/myHistory.js | ||
import { createBrowserHistory } from 'history'; | ||
const history = createBrowserHistory(); | ||
import basename from './baseurl'; | ||
|
||
const history = createBrowserHistory({ | ||
basename: basename(), | ||
}); | ||
export default history; |