-
Notifications
You must be signed in to change notification settings - Fork 27
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
662/asterner profile tests #673
Conversation
@@ -145,7 +145,9 @@ const Profile = () => { | |||
width: isSmallScreen ? '100%' : 'auto' | |||
}} | |||
> | |||
<Typography sx={{ fontWeight: 'bold', fontSize: '18px' }}>My Profile</Typography> | |||
<Typography variant="h1" sx={{ fontWeight: 'bold', fontSize: '18px' }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes this text into a proper heading without modifying the visual rendering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking over it, I'm not certain whether we need it to say "My Profile" at the top at all. The breadcrumb basically covers the same role already and we don't really apply this same concept to other pages (such as the Contacts page). But that's a different discussion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I attempted to make minimal changes to the page itself. This seems like something we can take a look at post MVP.
1005f5b
to
3d9658e
Compare
SignedInUserContext needs to be mocked in multiple places. This commit adds a MockSignedInUserContext that can be used for this purpose.
b824b66
to
1f8628a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor edits I'd like but it's looking good to me
@@ -145,7 +145,9 @@ const Profile = () => { | |||
width: isSmallScreen ? '100%' : 'auto' | |||
}} | |||
> | |||
<Typography sx={{ fontWeight: 'bold', fontSize: '18px' }}>My Profile</Typography> | |||
<Typography variant="h1" sx={{ fontWeight: 'bold', fontSize: '18px' }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking over it, I'm not certain whether we need it to say "My Profile" at the top at all. The breadcrumb basically covers the same role already and we don't really apply this same concept to other pages (such as the Contacts page). But that's a different discussion
test/pages/Profile.test.jsx
Outdated
import { render, screen, cleanup, waitForElementToBeRemoved } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { describe, expect, it, beforeEach, afterEach } from 'vitest'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can delete these extra lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
import { vi } from 'vitest'; | ||
import { SignedInUserContext } from '@contexts'; | ||
import * as profileHelper from '../../../src/model-helpers/Profile'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to keep this, we can leave a TODO note here to import it elsewhere. I'm pretty sure there are other tests that can make use of this but not as part of this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would you like to add as a TODO?
I don't see the SignedInUserContext used in other tests (other than the tests for the context itself).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll put a pin in that idea. I want to think it over more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one extra line that can be removed but approving anyway.
Also would like @leekahung to give this a once-over just to be extra safe
import { vi } from 'vitest'; | ||
import { SignedInUserContext } from '@contexts'; | ||
import * as profileHelper from '../../../src/model-helpers/Profile'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll put a pin in that idea. I want to think it over more
Sweet! I'll wait for feedback from @leekahung |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a comment on the mock context, but it's a positive one. I can approve this. 👍
@@ -0,0 +1,32 @@ | |||
import React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see we're making mock contexts for the tests. I'm fine with this since it'll be useful in case multiple tests need the same context.
Awesome! Thanks y'all :) merged! |
This PR:
Resolves (part of) #662
1. Adds basic render tests for the
Profile
page2. Adds tests to check basic functionality for the
Profile
page3. Factors out a
MockSignedInUserContext
to allow multiple tests to access user profilesFuture Steps:
We should figure out why there's a second timeout before loading the full profile page...
PASS/src/pages/Profile.jsx
Lines 114 to 128 in 52c881f