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(project): Replace Create React App with Vite #506

Merged
merged 30 commits into from
Aug 30, 2024
Merged

Conversation

jeremyckahn
Copy link
Owner

What this PR does

Drop Create React App in favor of Vite. CRA is unmaintained, so this project would do well to transition to something more modern.

How this change can be validated

  • Run all the scripts
  • Fully test the game for regressions
  • Hope for the best

Questions or concerns about this change

I tried to keep the scope of this change as narrow as possible, but it still touches pretty much everything in the project. We'll probably find something broken after the fact, so we'll just have to fix forward if that's the case.

jeremyckahn and others added 26 commits August 19, 2024 08:40
chore(config): treat .js files as .jsx

chore(project): rename .jsx files to .js
chore(project): [wip] await importActual
chore(project): [wip] fix broken test

chore(project): [wip] fix broken test

chore(project): [wip] fix broken test

chore(project): [wip] fix broken test

chore(project): [wip] fix broken test

chore(project): [wip] fix broken test
Copy link

vercel bot commented Aug 29, 2024

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

Name Status Preview Comments Updated (UTC)
farmhand ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 30, 2024 1:55am

Comment on lines -86 to -117
describe('fertilize-mode class', () => {
test('is not present when fieldMode != FERTILIZE', () => {
expect(component.find('.Field').hasClass('fertilize-mode')).toBeFalsy()
})

test('is present when fieldMode == FERTILIZE', () => {
component.setProps({ fieldMode: fieldMode.FERTILIZE })
expect(component.find('.Field').hasClass('fertilize-mode')).toBeTruthy()
})
})

describe('plant-mode class', () => {
test('is not present when fieldMode != PLANT', () => {
expect(component.find('.Field').hasClass('plant-mode')).toBeFalsy()
})

test('is present when fieldMode == PLANT', () => {
component.setProps({ fieldMode: fieldMode.PLANT })
expect(component.find('.Field').hasClass('plant-mode')).toBeTruthy()
})
})

describe('harvest-mode class', () => {
test('is not present when fieldMode != HARVEST', () => {
expect(component.find('.Field').hasClass('harvest-mode')).toBeFalsy()
})

test('is present when fieldMode == HARVEST', () => {
component.setProps({ fieldMode: fieldMode.HARVEST })
expect(component.find('.Field').hasClass('harvest-mode')).toBeTruthy()
})
})
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These and the removed tests below are obviated by src/shell/field.test.js, introduced by this PR:

describe('field interaction', () => {
beforeEach(async () => {
const loadedState = saveDataStubFactory({
purchasedCowPen: 1,
inventory: [
{ id: carrotSeed.id, quantity: 1 },
{ id: fertilizer.id, quantity: 1 },
],
})
await farmhandStub({
localforage: {
getItem: () => Promise.resolve(loadedState),
setItem: (_key, data) => Promise.resolve(data),
},
})
// NOTE: Navigates to Field
await nextView()
await nextView()
})
test('can enable water mode', async () => {
const field = screen.getByTestId('field')
const wateringCanButton = screen.getByAltText(WATERING_CAN_ALT_TEXT)
expect(field).not.toHaveClass('water-mode')
userEvent.click(wateringCanButton)
expect(field).toHaveClass('water-mode')
})
test('can enable cleanup mode', async () => {
const field = screen.getByTestId('field')
const hoeButton = screen.getByAltText(HOE_ALT_TEXT)
expect(field).not.toHaveClass('cleanup-mode')
userEvent.click(hoeButton)
expect(field).toHaveClass('cleanup-mode')
})
test('can enable harvest mode', async () => {
const field = screen.getByTestId('field')
const scytheButton = screen.getByAltText(SCYTHE_ALT_TEXT)
expect(field).not.toHaveClass('harvest-mode')
userEvent.click(scytheButton)
expect(field).toHaveClass('harvest-mode')
})
test('can enable plant mode', async () => {
const field = screen.getByTestId('field')
const [, carrotSeedButton] = screen.getAllByAltText(carrotSeed.name)
expect(field).not.toHaveClass('plant-mode')
userEvent.click(carrotSeedButton)
expect(field).toHaveClass('plant-mode')
})
test('can enable fertilize mode', async () => {
const field = screen.getByTestId('field')
const [, carrotSeedButton] = screen.getAllByAltText(fertilizer.name)
expect(field).not.toHaveClass('fertilize-mode')
userEvent.click(carrotSeedButton)
expect(field).toHaveClass('fertilize-mode')
})
})

@@ -22,7 +22,7 @@ export const purchaseForest = (state, forestId) => {
const { columns, price, rows } = PURCHASABLE_FOREST_SIZES.get(forestId)

/*
* FIXME: using FOREST_AVAILABLE_NOTIFICATION here is temporary, this code path will
* TODO: using FOREST_AVAILABLE_NOTIFICATION here is temporary, this code path will
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @lstebner I changed this from a FIXME to a TODO. I find it helpful to treat FIXMEs as an indication that something that needs to be addressed before a PR is merged, whereas a TODO indicates an improvement to be optionally made at some point in the future.

Comment on lines -41 to -53
describe('fieldMode === PLANT', () => {
beforeEach(() => {
handlers().handleFieldModeSelect(fieldMode.PLANT)
})

test('updates fieldMode state', () => {
expect(component.state().fieldMode).toEqual(fieldMode.PLANT)
})

test('does not change state.selectedItemId', () => {
expect(component.state().selectedItemId).toEqual('sample-crop-3')
})
})
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These have also been obviated by src/shell/field.test.js.

@jeremyckahn jeremyckahn marked this pull request as ready for review August 30, 2024 01:55
@jeremyckahn jeremyckahn merged commit 4e05344 into develop Aug 30, 2024
5 checks passed
@jeremyckahn jeremyckahn deleted the feature/vite branch August 30, 2024 01:58
jeremyckahn added a commit that referenced this pull request Aug 30, 2024
jeremyckahn added a commit that referenced this pull request Aug 30, 2024
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.

1 participant