CSC510-Group-25 / feature-hunt

A feature collection platform where users can share/vote/discuss feature requests and product owners can organize them
MIT License
0 stars 6 forks source link

Test 'renders feedback' not behaving as expected; need to handle router memory (RESOLVED) #80

Closed snapcat closed 2 years ago

snapcat commented 2 years ago

EDIT: I figured it out in branch group25-patch-tests. Issue will close once branch is merged.

In App.test.js:

test('renders feedback', () => {
      render(<Feedback />, {wrapper: MemoryRouter})
      // TODO: FIX. Should be /Search Features.../i instead. Need to handle router memory.
      const searchfeatures = screen.getByPlaceholderText(/Discover Projects.../i); // check search box text
      const commstr = screen.getByText(/Leave a comment in the box below/i);
      const patient = screen.getByText(/May take some time to load, please be patient!/i);
      expect(commstr).toBeInTheDocument();
      expect(patient).toBeInTheDocument();
})

As it stands, this test does currently pass. However, after the user navigates from any page to the Feedback page, the default text in the search bar should be "Search Features..." and not "Discover Projects...", which should only appear on the Home page.

I've tried using MemoryRouter with an Enzyme mount and initial entries, but I kept getting type errors.

createMemoryHistory also didn't work.

I suspect this has something to do with BrowserRouter being imported in App.js, but I could be wrong.

I don't know javascript so if someone could figure this out, that would be fantastic.

snapcat commented 2 years ago

Resolved in branch group25-patch-tests.

snapcat commented 2 years ago

Closed with approved PR

Group discussion: Discussion: https://github.com/CSC510-Group-25/feature-hunt/pull/92#issuecomment-968377488