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

Fix useSearchParams to replace the url instead of appending to the existing #1219

Merged
merged 10 commits into from
Jun 29, 2023

Conversation

mutuajames
Copy link
Contributor

Checks if weve appended a url before appending another.
closes #1216

@codecov-commenter
Copy link

codecov-commenter commented Jun 22, 2023

Codecov Report

Merging #1219 (f08e9b3) into master (145a4d9) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1219   +/-   ##
=======================================
  Coverage   95.03%   95.03%           
=======================================
  Files         320      320           
  Lines        9348     9353    +5     
  Branches     2029     2030    +1     
=======================================
+ Hits         8884     8889    +5     
  Misses        456      456           
  Partials        8        8           
Impacted Files Coverage Δ
app/src/App/App.tsx 98.24% <ø> (-0.02%) ⬇️
.../components/OrganizationList/ViewDetails/index.tsx 97.43% <ø> (ø)
...s/fhir-care-team/src/components/ListView/index.tsx 100.00% <100.00%> (ø)
...hir-care-team/src/components/ViewDetails/index.tsx 88.33% <100.00%> (ø)
packages/react-utils/src/hooks/useSearchParams.ts 95.65% <100.00%> (+0.91%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@peterMuriuki peterMuriuki left a comment

Choose a reason for hiding this comment

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

Lets add tests

`);
fireEvent.click(viewDetailsLink);
expect(history.location.pathname).toEqual('/admin/CareTeams/308');
Copy link
Collaborator

Choose a reason for hiding this comment

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

expect(history.location.pathname).toEqual('/admin/CareTeams/308');
Why was this removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of the path, we're testing for the querystring that has been added to the path, hence replaced pathname with search.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I get that, but is the previous assertion no longer necessary, why was it there initially

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially, view-details was just creating a path using the care team url plus the id of the care team hence getting the pathname to match was the assertion.

Copy link
Collaborator

@peterMuriuki peterMuriuki left a comment

Choose a reason for hiding this comment

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

@mutuajames nice work so far, I however do not think the test changes done show that the reported issue is resolved.

You want the test to show that:
If you call userSearchParams().addParam with a key that already exists on the url, the param value is changed instead of appending to whatever was there initially.

@mutuajames mutuajames changed the title Fix useSearchParams to delete current appended url before appending another Fix useSearchParams to replace the url instead of appending to the existing Jun 27, 2023
mutuajames and others added 4 commits June 27, 2023 15:06
addParam only adds one keyValue pair to url at a time and commits this to the url

addParams can add several keyValue pairs in a single call before commiting to url
@peterMuriuki peterMuriuki merged commit ab58a5a into master Jun 29, 2023
2 checks passed
@peterMuriuki peterMuriuki deleted the 1216-view-details-url-bug branch June 29, 2023 10:35
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.

View details url bug
3 participants