-
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
#548 P0: Chris/fix previous picks #549
Changes from all commits
fdaae4f
42edf0f
b732f61
dff9b78
cea643e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,12 +184,9 @@ describe('League Week Picks', () => { | |
); | ||
|
||
// Wait for the main content to be displayed | ||
await waitFor( | ||
() => { | ||
expect(screen.getByTestId('weekly-picks')).toBeInTheDocument(); | ||
}, | ||
{ timeout: 5000 }, | ||
); | ||
await waitFor(() => { | ||
expect(screen.getByTestId('weekly-picks')).toBeInTheDocument(); | ||
}); | ||
|
||
expect(screen.queryByTestId('global-spinner')).not.toBeInTheDocument(); | ||
}); | ||
|
@@ -241,12 +238,9 @@ describe('League Week Picks', () => { | |
/>, | ||
); | ||
|
||
await waitFor( | ||
() => { | ||
expect(screen.getByTestId('weekly-picks')).toBeInTheDocument(); | ||
}, | ||
{ timeout: 5000 }, | ||
); | ||
await waitFor(() => { | ||
expect(screen.getByTestId('weekly-picks')).toBeInTheDocument(); | ||
}); | ||
|
||
expect(screen.getByTestId('user-pick-history')).toBeInTheDocument(); | ||
|
||
|
@@ -261,6 +255,46 @@ describe('League Week Picks', () => { | |
'/_next/image?url=https%3A%2F%2Fexample.com%2Fbrowns.png&w=128&q=75', | ||
); | ||
}); | ||
it('should show previous week pick as no pick if there is no history of selected teams', async () => { | ||
mockUseAuthContext.isSignedIn = true; | ||
const mockWeek = '2'; | ||
(getCurrentUserEntries as jest.Mock).mockResolvedValue([ | ||
{ | ||
$id: '123', | ||
name: 'Entry 1', | ||
user: '123', | ||
league: '123', | ||
selectedTeams: ['', 'Browns'], | ||
eliminated: false, | ||
}, | ||
]); | ||
|
||
render( | ||
<Week | ||
entry={entry} | ||
league={league} | ||
NFLTeams={NFLTeams} | ||
week={mockWeek} | ||
/>, | ||
); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByTestId('weekly-picks')).toBeInTheDocument(); | ||
}); | ||
|
||
expect(screen.getByTestId('user-pick-history')).toBeInTheDocument(); | ||
expect(screen.getByTestId('user-pick-history')).toHaveTextContent( | ||
'No Pick', | ||
); | ||
|
||
expect(screen.getByTestId('no-pick')).toBeInTheDocument(); | ||
const userPickHistoryLogos = screen.queryAllByTestId('league-history-logo'); | ||
expect(userPickHistoryLogos).toHaveLength(1); | ||
expect(userPickHistoryLogos[0]).toHaveAttribute( | ||
'src', | ||
'/_next/image?url=https%3A%2F%2Fexample.com%2Fbrowns.png&w=128&q=75', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: Why is the URL string encoded like this instead of url=https://example.com/browns.png? (same questions with the other URLs) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jennifertieu great question! the component is using Next Image. This is how Next Image formats the url for images so it can apply its customizations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chris-nowicki replying late lol but that is good to know!! I'll keep that in mind when testing with Next in the future, thanks Chris! |
||
); | ||
}); | ||
|
||
xit('should show success notification after changing your team pick', async () => { | ||
(createWeeklyPicks as jest.Mock).mockResolvedValue({}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,7 +285,7 @@ const Week = ({ entry, league, NFLTeams, week }: IWeekProps): JSX.Element => { | |
|
||
return ( | ||
<div | ||
key={`${logoURL}-${index + 1}`} | ||
key={`${logoURL ? logoURL : 'no-pick'}-${index + 1}`} | ||
className={cn( | ||
'flex flex-col items-center justify-center border p-2 rounded-lg gap-1', | ||
isCurrentWeek && hasCurrentWeekPick | ||
|
@@ -298,14 +298,23 @@ const Week = ({ entry, league, NFLTeams, week }: IWeekProps): JSX.Element => { | |
? 'CURRENT' | ||
: `WEEK ${index + 1}`} | ||
</span> | ||
<Image | ||
className="league-entry-logo" | ||
width={64} | ||
height={64} | ||
data-testid="league-history-logo" | ||
src={logoURL} | ||
alt="teamLogo" | ||
/> | ||
{logoURL ? ( | ||
<Image | ||
className="league-entry-logo" | ||
width={64} | ||
height={64} | ||
data-testid="league-history-logo" | ||
src={logoURL} | ||
alt="teamLogo" | ||
/> | ||
) : ( | ||
<span | ||
className="text-xs h-16 w-16 text-primary pt-6 text-center" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm worried about the a11y of the color and the small text size, did you check this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ryandotfurrer I did not check this. hmmmmm @shashilo what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine for now. A11Y audit can come after. |
||
data-testid="no-pick" | ||
> | ||
No Pick | ||
</span> | ||
)} | ||
</div> | ||
); | ||
})} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,18 +59,27 @@ const LeagueEntries = ({ | |
> | ||
{userPickHistory?.map((logoURL, index) => ( | ||
<div | ||
key={logoURL} | ||
key={`${logoURL ? logoURL : 'no-pick'}-${index + 1}`} | ||
className="flex flex-col h-[66px] opacity-80 items-center justify-center border border-border px-4 py-1 rounded-lg gap-1" | ||
> | ||
<span className="text-xs">WEEK {index + 1}</span> | ||
<Image | ||
className="league-entry-logo" | ||
width={40} | ||
height={40} | ||
data-testid="league-history-logo" | ||
src={logoURL} | ||
alt="teamLogo" | ||
/> | ||
{logoURL ? ( | ||
<Image | ||
className="league-entry-logo" | ||
width={40} | ||
height={40} | ||
data-testid="league-history-logo" | ||
src={logoURL} | ||
alt="teamLogo" | ||
/> | ||
) : ( | ||
<span | ||
className="text-xs h-10 w-full text-primary pt-2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm worried about the a11y of the color and the small text size, did you check this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ryandotfurrer I did not check this. hmmmmm @shashilo what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine for now. A11Y audit can come after. |
||
data-testid="no-pick" | ||
> | ||
No Pick | ||
</span> | ||
)} | ||
</div> | ||
))} | ||
</section> | ||
|
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.
nit: I know there was a conversation on your other PR about declaring variable vs inline but I think this scenario where you have to write
screen.getByTestId('user-pick-history')
twice is a good use case to save it in a variable instead to reuse.Both approaches work though! The code still runs but might save you or someone else in the future sometime. Of course, we'll see what Shashi thinks because I'm curious which is better or how much it matters😅.
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.
When there's more than 2, that's always a good case to make a variable.
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.
@shashilo @jennifertieu thanks! yes, moving forward I will be doing this when there are more than 2.