-
Notifications
You must be signed in to change notification settings - Fork 1
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
Incremental UI Tests #4 #83
Conversation
|
||
it('renders Infinity per Week', () => { | ||
render(<FrequencyChart reviews={reviews} />); | ||
expect(screen.getAllByText('Infinity')).toBeDefined(); |
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 expect this will change once glue gets merged in -- happy to update once that's ready, but this test will be a good canary in that coalmine.
expect(screen.getByText(displayName)).toBeDefined(); | ||
}); | ||
|
||
// TODO EM: I think this should be a <Link /> so that it's easier to test. |
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'm getting weird errors about how href
based navigation isn't supported in JSDOM
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 have no complaints about moving all href -> Link
Should I commit that on this branch before merging?
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.
Nah, I made an issue for it
#84
@@ -20,7 +20,7 @@ export default function MinimalStatBoxView({ userDisplayName, reviews }: Minimal | |||
); | |||
|
|||
// destructure if not null, or set all to undefined | |||
const { numReviews, ppwString, ppwColor } = getReviewStats(reviews) || {}; | |||
const { numReviews, ppwString, ppwColor } = getReviewStats(reviews); |
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 couldn't find any way that the || {}
would ever trigger. Can you?
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.
Hmm no, I think what you have is safe.
The reviews
arg is typed to be Review[]
so TS compiler would've complained if there were a valid route to passing undefined
or null
instead, right?
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.
That was my thinking as well, yeah
@@ -135,7 +135,7 @@ export default function PaperSearchBarView({ | |||
<div> | |||
<br /> | |||
{searchArea} | |||
{loading ? <Spin className="searchResult loading-spinner" /> : searchRender} | |||
{loading ? <Spin data-testid="paper-searchbar-spinner" className="searchResult loading-spinner" /> : searchRender} |
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.
using data-testid
should really be a last resort since it's an accessibility code smell. But in this case, it's antd
s component, so I'm just tagging it so I can check for it in tests.
a7d2e5f
to
baa811c
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.
it('renders about 1 per week', () => { | ||
render(<FrequencyChart reviews={reviews} />); | ||
expect(screen.getAllByText('1')).toBeDefined(); | ||
}); |
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.
Question: it seems like the test criteria in this test and the preceding test are pretty vague, i.e.,
screen.getAllByText('1'))
doesn't really test that ppw = 1- If ppw = 4.01, for example, both tests pass (but shouldn't)
Thoughts?
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.
Yeah, good point. It's partially because react testing library can't search for text across HTML elements, which makes searching for the full string hard. Let's open an issue to clean these up later.
|
||
describe('with a logged-in user', () => { | ||
it('redirects to the dashboard', () => { | ||
const initialState = { ...getBlankInitialState(), user: { ...blankUser, display: 'Piranesi' } }; |
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.
Hmm. This passes because technically a User is present and it does redirect. But display
isn't a valid attribute of User
and it wouldn't show their name correctly (should be displayName
).
I guess this test doesn't actually test that the displayName works as expected, so maybe okay?
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.
ah that was just a typo, let me push a fix before we merge
it('shows the information icon with information on hover', async () => { | ||
renderWithRouterRedux(<MenuBarRedux />); | ||
|
||
userEvent.hover(screen.getByLabelText('info-circle')); |
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.
Very cool!
expect(screen.getByText(displayName)).toBeDefined(); | ||
}); | ||
|
||
// TODO EM: I think this should be a <Link /> so that it's easier to test. |
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 have no complaints about moving all href -> Link
Should I commit that on this branch before merging?
@@ -20,7 +20,7 @@ export default function MinimalStatBoxView({ userDisplayName, reviews }: Minimal | |||
); | |||
|
|||
// destructure if not null, or set all to undefined | |||
const { numReviews, ppwString, ppwColor } = getReviewStats(reviews) || {}; | |||
const { numReviews, ppwString, ppwColor } = getReviewStats(reviews); |
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.
Hmm no, I think what you have is safe.
The reviews
arg is typed to be Review[]
so TS compiler would've complained if there were a valid route to passing undefined
or null
instead, right?
import NotFound from './NotFound'; | ||
|
||
describe('<NotFound />', () => { | ||
it('shows a stupid compass lol?', () => { |
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 is cyber-bullying
Let's hire Re'em to make a 404 page
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.
Jokes aside, I think that'd be a really nice gesture
|
||
it('the second one redirects to the form page', () => { | ||
renderWithRouterRedux(<PaperSearchBar />, { redirectTo: '/form' }); | ||
userEvent.click(screen.getAllByText(/Create Manual Entry/)[1]); |
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.
Okay nice, I was wondering how this would get resolved 👀
* shhhh is okay * self review feedback * Basic FrequencyChart tests * Login tests * MenuBar tests * test todos * Remove impossible conclusion * safe assertion, I hope * NotFound test * bare bones paper search * more paper search tests * whoo, that should be it! * display --> displayName
Review #82 first! Then rebase this and merge.
