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

feat(Cellar): Show purchase notification #421

Merged
merged 2 commits into from
Jun 23, 2023

Conversation

jeremyckahn
Copy link
Owner

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

Cellar purchase notification

@vercel
Copy link

vercel bot commented Jun 17, 2023

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

Name Status Preview Updated (UTC)
farmhand ✅ Ready (Inspect) Visit Preview Jun 17, 2023 10:09pm

Comment on lines -32 to -66
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()
})
Copy link
Owner Author

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:

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.'
)
})

@jeremyckahn jeremyckahn merged commit 723c79a into develop Jun 23, 2023
6 checks passed
@jeremyckahn jeremyckahn deleted the feature/cellar-purchase-notification branch June 23, 2023 16:36
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.

None yet

2 participants