-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat(Cellar): Show purchase notification #421
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
test('notification is shown when cow pen is purchased', async () => { | ||
const loadedState = saveDataStubFactory({ | ||
money: 1500, | ||
}) | ||
|
||
await farmhandStub({ | ||
localforage: { | ||
getItem: () => Promise.resolve(loadedState), | ||
setItem: (_key, data) => Promise.resolve(data), | ||
}, | ||
}) | ||
|
||
await nextView() | ||
const upgradesTab = screen.getByText('Upgrades') | ||
userEvent.click(upgradesTab) | ||
|
||
const cowPenContainer = screen | ||
.getByText('Buy cow pen') | ||
.closest('.TierPurchase') | ||
|
||
// Open the list of cow pen options | ||
userEvent.click(within(cowPenContainer).getAllByRole('button')[1]) | ||
|
||
userEvent.click(screen.getByRole('option', { name: '$1,500: 10 cow pen' })) | ||
|
||
// Make the purchase | ||
userEvent.click(within(cowPenContainer).getAllByRole('button')[0]) | ||
|
||
const notification = await screen.findByRole('alert') | ||
expect( | ||
within(notification).getByText( | ||
'Purchased a cow pen with capacity for 10 cows! You can visit your cow pen by going to the "Cows" page.' | ||
) | ||
).toBeInTheDocument() | ||
}) |
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 effectively covered by this new test, which is much simpler and more lightweight:
farmhand/src/game-logic/reducers/purchaseCowPen.test.js
Lines 27 to 35 in 73056d8
test('shows notification of purchase', () => { | |
const { todaysNotifications } = purchaseCowPen( | |
{ todaysNotifications: [] }, | |
1 | |
) | |
expect(todaysNotifications[0].message).toEqual( | |
'Purchased a cow pen with capacity for 10 cows! You can visit your cow pen by going to the "Cows" page.' | |
) | |
}) |
What this PR does
This PR shows a notification to the player when a cellar is purchased.
This PR also refactors how cow pen notifications are shown and improves some type definitions.
How this change can be validated
Purchase a cellar and verify that a notification is shown.
Additional information