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

#6: Integration Test Home Route #96

Closed

Conversation

bajajcodes
Copy link
Collaborator

@bajajcodes bajajcodes commented Jan 1, 2024

Summary

Integration tests for HomePage route/component.
The tests are written from user POV, How user will behave and interact with home page.

NOTE: To run tests local-backend is expected to be running

Description

1. Renders Home Page:

  • Objective: Verify the correct rendering of the home page.
  • Actions: Render HomePage within a BrowserRouter.
  • Assertions: Confirm the presence of key elements like "WanderLust" text, "Create post" button, and loading skeletons.

2. Calls Mocked useNavigate Function:

  • Objective: Ensure the "Create post" button triggers the useNavigate function.
  • Actions: Render HomePage and click the "Create post" button.
  • Assertions: Verify the mockedUseNavigate function is called once.

3. Renders Home Page with BlogFeed:

  • Objective: Confirm correct rendering of the BlogFeed section.
  • Actions: Render HomePage, click a category pill, and check for related posts.
  • Assertions: Validate the BlogFeed rendering and category pill functionality.

4. Navigates on Featured Post Click:

  • Objective: Check if clicking a featured post card navigates to the details page.
  • Actions: Render HomePage and click the first featured post card.
  • Assertions: Ensure the mockedUseNavigate function is called once.

5. Renders Home Page with All Posts:

  • Objective: Verify the correct rendering of all post cards.
  • Actions: Render HomePage.
  • Assertions: Confirm the expected number of post cards are rendered.

6. Navigates on All-Post Click:

  • Objective: Check if clicking on an individual post card navigates to the details page.
  • Actions: Render HomePage and click the first post card.
  • Assertions: Ensure the mockedUseNavigate function is called once.

These tests cover various aspects of the HomePage component, including rendering, user interactions, and navigation behavior. The use of testing libraries facilitates thorough testing of the React application.

  • No Tests for api Failed to display home page with blog-feed/all-posts because firstly shouldn't mock api for integration tests, and second tests are written with user-pov and third user is not ack with failed api responses.

Miscallenous FEYI

Cannot mock backend for testcases because using jest, vite and msw results into following errors, which can result into series of errors:
- Request/Response/TextEncoder is not defined (Jest)
- Cannot find module ‘msw/node’ (JSDOM)
- TS Error: Definitions of the following identifiers conflict with those in another file.

Issue(s) Addressed

#6

Images

Screenshot 2024-01-06 at 12 17 33 AM

Prerequisites

Copy link

vercel bot commented Jan 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wanderlust ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2024 4:07pm
wanderlust-backend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2024 4:07pm

@bajajcodes bajajcodes changed the title chore: test skeleton added feat: test skeleton added Jan 1, 2024
@bajajcodes bajajcodes changed the title feat: test skeleton added #6: Integration Test Home Route Jan 5, 2024
@bajajcodes
Copy link
Collaborator Author

A unit test is not a unit test if it uses these external dependencies - that would rather be an integration test.

@krishnaacharyaa
Copy link
Owner

Hi @shmbajaj, Big thanks from bottom of my heart for this wonderful efforts and timely updates and fast paced PR, This PR contains quite a few updates, can we arrange a call when we both and @chinmaykunkikar is free and review this PR and merge?

p.s: It would be great if you could add snapshots of the test cases, so that i can get a overview...

@bajajcodes
Copy link
Collaborator Author

Hi @shmbajaj, Big thanks from bottom of my heart for this wonderful efforts and timely updates and fast paced PR, This PR contains quite a few updates, can we arrange a call when we both and @chinmaykunkikar is free and review this PR and merge?

p.s: It would be great if you could add snapshots of the test cases, so that i can get a overview...

Firstly Thanks @krishnaacharyaa.

Honestly I didn't understood what do you mean by snapshots.
Also we can connect today at 09:00PM/2100HRS.

@krishnaacharyaa
Copy link
Owner

krishnaacharyaa commented Jan 9, 2024

Honestly I didn't understood what do you mean by snapshots.

I got it in the description :)

Also we can connect today at 09:00PM/2100HRS.

Sure

@bajajcodes
Copy link
Collaborator Author

Closing PR because of wrong rebase conflicts created.

@bajajcodes
Copy link
Collaborator Author

@krishnaacharyaa closing this PR because of hells of commits created.

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.

4 participants