techishiring-website icon indicating copy to clipboard operation
techishiring-website copied to clipboard

[Developer Experience]: Add Cypress Test for Header Component

Open chadstewart opened this issue 1 year ago • 3 comments

Developer Experience Issue

Please describe your Developer Experience Issue. A clear and concise description of what the problem is. Ex. I have an issue when [...]

A Cypress Test should be added to test the header in both Desktop and Mobile.

Describe the solution you'd like A clear and concise description of what you want to happen. Add any considered drawbacks.

A Cypress test suite should be written that:

  • Test that the components in header render properly in both Desktop and Mobile.
  • Test that the navigation in each works. It doesn't have to check exactly where it's being navigated to.
  • Tests that the TechIsHiring logo navigates back to Home on '/'.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

n/a

Teachability, Documentation, Adoption, Migration Strategy If you can, explain how users will be able to use this and possibly write out a version in the docs. Maybe a screenshot or design?

n/a

chadstewart avatar May 10 '23 22:05 chadstewart

Hey!

I'd like to take this issue to get some practice with writing Cypress tests, but I think I will take a couple of days to finish off some other stuff I have going, familiarise myself with the codebase, the relevant PR #140 and get to work on it.

If that's okay please assign me.

Btw, I think it would be nice to mention that PR in all the testing/Cypress related issues because atm it's basically the projects documentation on those things.

jackz070 avatar May 29 '23 20:05 jackz070

Hey!

I'd like to take this issue to get some practice with writing Cypress tests, but I think I will take a couple of days to finish off some other stuff I have going, familiarise myself with the codebase, the relevant PR #140 and get to work on it.

If that's okay please assign me.

Btw, I think it would be nice to mention that PR in all the testing/Cypress related issues because atm it's basically the projects documentation on those things.

Sure, no problem. Feel free to work on this.

Yeah, I'll add #140 to the other Cypress issues just so that there's reference for other contributors coming in.

Thanks so much!

chadstewart avatar May 30 '23 01:05 chadstewart

I guess I will need some help on this one.

Apparently the Header component includes the main-nav component which uses useRouter hook to get the current pathname. With latest NextJS update the RouterProvider component is gone and having searched for answers a lot I don't know how to either:

  • render the component wrapped with true or mocked router context provider OR
  • mock the useRouter hook so that the context provider won't be needed

Without one of those I don't think it's possible to render the component at all. Or am I missing something?

Any input will be appreciated!

jackz070 avatar May 31 '23 19:05 jackz070