Skip to content

[Chakra v3 upgrade] @W-18672580 migrate offline components#2684

Merged
sf-jie-dai merged 7 commits intofeature/chakra-ui-upgrade-v3from
jdai.W-18672580.migrateOfflineComponents
Jul 1, 2025
Merged

[Chakra v3 upgrade] @W-18672580 migrate offline components#2684
sf-jie-dai merged 7 commits intofeature/chakra-ui-upgrade-v3from
jdai.W-18672580.migrateOfflineComponents

Conversation

@sf-jie-dai
Copy link
Contributor

@sf-jie-dai sf-jie-dai commented Jun 27, 2025

Description

Migrate offline-banner & offline-boundary components to Chakra v3
Staging v2:
Screenshot 2025-06-26 at 5 10 59 PM

Local v3:
Screenshot 2025-06-30 at 11 51 51 AM

Unit test coverage:
Screenshot 2025-06-30 at 11 45 39 AM

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

How to Test-Drive This PR

  • checkout to feature/chakra-ui-upgrade-v3 branch
  • go to /pwa-kit/packages/template-typescript-minimal directory
  • run npm start
  • make sure localhost:3000 renders without error
  • compare localhost:3000 with staging v2 UI look

In staging env, https://pwa-kit.mobify-storefront.com/, everything works in Chakra v2.
For offline components, we could show them on purpose in staging env following:

  • Inspect the page to open dev console
  • go to Network tab
  • set Network throttling from No throttling to Offline

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@sf-jie-dai sf-jie-dai requested a review from unandyala June 27, 2025 21:10
@cc-prodsec
Copy link
Collaborator

cc-prodsec commented Jun 27, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@sf-jie-dai sf-jie-dai changed the title [Chakra v3 upgrade][WIP] @W-18672580 update: migrate offline components from v2 to v3 [Chakra v3 upgrade] @W-18672580 update: migrate offline components from v2 to v3 Jun 30, 2025
'non-pwa/**/*.{js,jsx}',
'worker/**/*.{js,jsx}',
'scripts/generator/*.{js,jsx}',
'src/**/*.{js,jsx}',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add unit test coverage report for extension-chakra-storefront folder

import {useIntl} from 'react-intl'

// Components
import {Alert, AlertDescription, Flex} from '@chakra-ui/react'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In chakra v3, everything imported from Alert alone, AlertDescription is not needed anymore

@@ -68,23 +68,13 @@ class OfflineBoundary extends React.Component {
return (
<React.Fragment>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Every component in offline-boundary is v3 compatible already.
Removed legacy classnames

@sf-jie-dai sf-jie-dai marked this pull request as ready for review June 30, 2025 18:22
@sf-jie-dai sf-jie-dai requested a review from a team as a code owner June 30, 2025 18:22
@sf-jie-dai sf-jie-dai requested a review from alexvuong June 30, 2025 18:22

test('should render its children', () => {
renderWithRouter(
renderWithRouterAndChakra(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why cant we use renderWithProviders?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In offline-boundary's index.jsx I saw

export default withRouter(OfflineBoundary)

From my understanding, with withRouter, the error boundary becomes "route-aware", in which normal renderWithProviders wouldn't be able to cover this use case. So use renderWithRouter for this special component

@sf-jie-dai sf-jie-dai requested a review from alexvuong June 30, 2025 19:29
@sf-jie-dai sf-jie-dai merged commit 1fac117 into feature/chakra-ui-upgrade-v3 Jul 1, 2025
33 checks passed
@sf-jie-dai sf-jie-dai self-assigned this Jul 1, 2025
@sf-jie-dai sf-jie-dai deleted the jdai.W-18672580.migrateOfflineComponents branch July 1, 2025 16:45
@sf-jie-dai sf-jie-dai changed the title [Chakra v3 upgrade] @W-18672580 update: migrate offline components from v2 to v3 [Chakra v3 upgrade] @W-18672580 migrate offline components Jul 2, 2025
alexvuong pushed a commit that referenced this pull request Jul 16, 2025
…om v2 to v3 (#2684)

* update: migrate offline components from v2 to v3

* add unit test coverage report & cleanup

* class name clean up

* use renderWithRouter to test offline-boundary

* use newer chakra UI component instead of basic html tags

* wrap user.click with act

* clean up comments
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.

4 participants