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

Mai/fix 350 bug leagues page stuck in loading st #362

Merged
merged 15 commits into from
Jul 9, 2024

Conversation

vmaineng
Copy link
Contributor

@vmaineng vmaineng commented Jul 2, 2024

fix #350

  1. updated Loading.... to You are not enrolled in any leagues
  2. Added unit test to test message is stated if a user is not signed up to a league
  3. updated wrapper module so when writing
jest.mock('../../utils/utils')

can be

jest.mock('@utils/utils')
image

Test passing:
image

@vmaineng vmaineng requested review from shashilo and mhchen as code owners July 2, 2024 17:42
Copy link

vercel bot commented Jul 2, 2024

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

Name Status Preview Comments Updated (UTC)
gridiron-survivor ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 9, 2024 0:09am
gridiron-survivor-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 9, 2024 0:09am

Copy link

appwrite bot commented Jul 2, 2024

Gridiron Survivor Application 6616ea581ef9f5521c7d

Function ID Status Action
Your function deployment has failed. Please check the logs for more details and retry.

Project name: Gridiron Survivor Application
Project ID: 6616ea581ef9f5521c7d

Function ID Status Action
userAuth 6626fef885a9f630442b failed Failed View Logs

Only deployments on the production branch are activated automatically. If you'd like to activate this deployment, navigate to your deployments. Learn more about Appwrite Function deployments.

💡 Did you know?
You can use Avatars API to generate QR code for any text or URLs

@@ -9,6 +12,9 @@ const createJestConfig = nextJest({
// Add any custom config to be passed to Jest
const config: Config = {
coverageProvider: 'v8',
moduleNameMapper: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was this added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was added because when I writing down the path jest.mock('@utils/utils'), it didn't recognize the file path and I had to use jest.mock('../../../utils/utils').

@@ -69,7 +69,9 @@ const Leagues = (): JSX.Element => {
))
) : (
<div className="text-center">
<p className="text-lg font-bold">Loading ...</p>
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: We will need to look into Suspense in another ticket.


describe('Leagues Component', () => {
const mockUser = { id: '123', leagues: [] };
const mockUseDataStore = require('@/store/dataStore').useDataStore;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is mocking the function like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make the test more accessible, but let me take a look to revise them.

const mockGetGameWeek = require('@/api/apiFunctions').getGameWeek;

beforeEach(() => {
mockUseDataStore.mockReturnValue({ user: mockUser });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of returning the data here, the mock on line 5 should return this as the default. Then, if you need to override the return, the individual test can do that.

@vmaineng vmaineng merged commit 0522ae9 into develop Jul 9, 2024
6 of 7 checks passed
@vmaineng vmaineng deleted the mai/fix-350-bug-leagues-page-stuck-in-loading-st branch July 9, 2024 00:14
Clue355 pushed a commit that referenced this pull request Jul 10, 2024
fix #350 
1) updated `Loading....` to `You are not enrolled in any leagues`
2) Added unit test to test message is stated if a user is not signed up
to a league
3) updated wrapper module so when writing 
```js
jest.mock('../../utils/utils')
```
can be
```js
jest.mock('@utils/utils')
```

<img width="821" alt="image"
src="https://github.com/LetsGetTechnical/gridiron-survivor/assets/100221733/e707c2ab-d270-48b4-b185-99f37fea7b3a">


Test passing: 
<img width="1109" alt="image"
src="https://github.com/LetsGetTechnical/gridiron-survivor/assets/100221733/ba688e94-efff-4e78-ae75-ebb8a1385f10">

---------

Co-authored-by: Shashi Lo <[email protected]>
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.

Bug: Leagues page stuck in loading state when the user has no leagues
3 participants