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

build(deps): upgrade to react 18 #700

Merged
merged 26 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6f0f2a2
build(deps): update jest-watch-typeahead from v0.6.5 to v2.2.2
theborakompanioni Nov 26, 2023
47f45df
build(deps): update jest-websocket-mock to v2.5.0
theborakompanioni Nov 26, 2023
f557587
build(deps): update to react 18 (wip)
theborakompanioni Nov 27, 2023
caa3d23
fix(test): Wallet component tests after upgrade to react 18
theborakompanioni Nov 27, 2023
305dded
fix(test): Wallets component tests after upgrade to react 18
theborakompanioni Nov 27, 2023
61d0d9e
fix(test): fix other tests after update to react 18
theborakompanioni Nov 27, 2023
76a2959
build(deps): update i18next dependencies
theborakompanioni Nov 27, 2023
863b494
fix(ts): fix typescript errors after update to react 18
theborakompanioni Nov 27, 2023
3ef9e5d
fix: use createRoot in index.tsx
theborakompanioni Nov 27, 2023
025f721
build(deps): update react-router-dom to v6.20.0
theborakompanioni Nov 27, 2023
f283e8b
refactor: WebsocketContext from jsx to tsx
theborakompanioni Nov 27, 2023
e2e03bc
refactor: ShareButton from jsx to tsx
theborakompanioni Nov 27, 2023
34319af
refactor: i18n files from js to ts
theborakompanioni Nov 27, 2023
8690fe8
chore(build): disallow javascript
theborakompanioni Nov 27, 2023
055adea
chore: adhere to new i18next release rules
theborakompanioni Nov 27, 2023
7172130
ui: add success page to wallet import flow
theborakompanioni Nov 27, 2023
77100d4
chore: enable react-router v7 futures
theborakompanioni Nov 27, 2023
86f34ae
chore(build): prevent build warning by installing babel plugin
theborakompanioni Nov 27, 2023
3b00259
chore(test): prevent test env warning
theborakompanioni Nov 27, 2023
0f01425
build(deps): update build dependencies
theborakompanioni Nov 27, 2023
6cbaf6b
fix(test): prevent log message in Wallets.test.tsx
theborakompanioni Nov 27, 2023
3426583
test(websocket): enable websocket indicator test in App.test.tsx
theborakompanioni Nov 27, 2023
564b239
ui(import): add link to main wallet view to import success page
theborakompanioni Nov 30, 2023
0f02a2e
build(deps): update react-bootstrap to v2.9.1
theborakompanioni Dec 1, 2023
b281208
build(deps): update dependencies
theborakompanioni Dec 1, 2023
d677e8c
chore: remove in-flight session request handling
theborakompanioni Dec 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36,605 changes: 17,623 additions & 18,982 deletions package-lock.json

Large diffs are not rendered by default.

41 changes: 21 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,40 @@
},
"homepage": ".",
"devDependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^29.0.3",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.5.1",
"@types/jest": "^29.5.10",
"@types/node": "^17.0.35",
"@types/qrcode": "^1.5.2",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"conventional-changelog": "^3.1.25",
"@types/qrcode": "^1.5.3",
"@types/react": "^18.2.39",
"@types/react-dom": "^18.2.17",
"conventional-changelog": "^5.1.0",
"http-proxy-middleware": "^2.0.6",
"husky": "^8.0.1",
"husky": "^8.0.3",
"jest-watch-typeahead": "^2.2.2",
"jest-websocket-mock": "^2.5.0",
"lint-staged": "^13.0.3",
"prettier": "^3.0.3",
"lint-staged": "^14.0.1",
"prettier": "^3.1.0",
"react-scripts": "^5.0.1",
"typescript": "^4.8.4"
},
"dependencies": {
"@emotion/react": "^11.11.1",
"@table-library/react-table-library": "^4.0.23",
"@table-library/react-table-library": "^4.1.7",
"bootstrap": "^5.3.2",
"classnames": "^2.3.2",
"formik": "^2.4.5",
"i18next": "^22.0.4",
"i18next-browser-languagedetector": "^7.0.1",
"qrcode": "^1.5.1",
"react": "^17.0.2",
"react-bootstrap": "^2.9.0",
"react-dom": "^17.0.2",
"react-i18next": "^12.0.0",
"i18next": "^23.7.7",
"i18next-browser-languagedetector": "^7.2.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",
"react-bootstrap": "^2.9.1",
"react-dom": "^18.2.0",
"react-i18next": "^13.5.0",
"react-router-bootstrap": "^0.26.2",
"react-router-dom": "^6.6.1"
"react-router-dom": "^6.20.0"
},
"scripts": {
"dev:start": "REACT_APP_JAM_DEV_MODE=true npm start",
Expand Down
50 changes: 27 additions & 23 deletions src/components/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ describe('<App />', () => {
;(apiMock.getSession as jest.Mock).mockResolvedValue(neverResolvingPromise)
})

it('should display Onboarding screen initially', () => {
render(<App />)
it('should display Onboarding screen initially', async () => {
await act(async () => render(<App />))

// Onboarding screen
expect(screen.getByText('onboarding.splashscreen_button_get_started')).toBeInTheDocument()
Expand All @@ -27,58 +27,62 @@ describe('<App />', () => {
// Wallets screen shown after Intro is skipped
expect(screen.queryByText('wallets.title')).not.toBeInTheDocument()

act(() => {
const skipIntro = screen.getByText('onboarding.splashscreen_button_skip_intro')
user.click(skipIntro)
})
const skipIntro = screen.getByText('onboarding.splashscreen_button_skip_intro')
await user.click(skipIntro)

expect(screen.getByText('wallets.title')).toBeInTheDocument()
})

it('should display Wallets screen directly when Onboarding screen has been shown', () => {
it('should display Wallets screen directly when Onboarding screen has been shown', async () => {
global.__DEV__.addToAppSettings({ showOnboarding: false })

act(() => {
render(<App />)
})
await act(async () => render(<App />))

// Wallets screen
expect(screen.getByText('wallets.title')).toBeInTheDocument()
expect(screen.getByText('wallets.button_new_wallet')).toBeInTheDocument()
})

it('should display a modal with beta warning information', () => {
it('should display a modal with beta warning information', async () => {
global.__DEV__.addToAppSettings({ showOnboarding: false })

act(() => {
render(<App />)
})
await act(async () => render(<App />))

expect(screen.getByText('Read this before using.')).toBeInTheDocument()
expect(screen.queryByText(/While JoinMarket is tried and tested, Jam is not./)).not.toBeInTheDocument()

act(() => {
const readThis = screen.getByText('Read this before using.')
user.click(readThis)
})
const readThis = screen.getByText('Read this before using.')
await user.click(readThis)

expect(screen.getByText('footer.warning_alert_text')).toBeInTheDocument()
expect(screen.getByText('footer.warning_alert_button_ok')).toBeInTheDocument()
})

it('should display a websocket connection indicator', async () => {
it('should display websocket connection indicator as CONNECTED', async () => {
global.__DEV__.addToAppSettings({ showOnboarding: false })

act(() => {
await act(async () => {
render(<App />)
})

expect(screen.getByTestId('connection-indicator-icon').classList.contains('text-secondary')).toBe(true)
expect(screen.getByTestId('connection-indicator-icon').classList.contains('text-success')).toBe(false)

await global.__DEV__.JM_WEBSOCKET_SERVER_MOCK.connected

expect(screen.getByTestId('connection-indicator-icon').classList.contains('text-success')).toBe(true)
expect(screen.getByTestId('connection-indicator-icon').classList.contains('text-secondary')).toBe(false)
})

it('should display websocket connection indicator AS DISCONNECTED', async () => {
global.__DEV__.addToAppSettings({ showOnboarding: false })

await act(async () => {
render(<App />)
})

await act(async () => {
global.__DEV__.JM_WEBSOCKET_SERVER_MOCK.close()
})

expect(screen.getByTestId('connection-indicator-icon').classList.contains('text-success')).toBe(false)
expect(screen.getByTestId('connection-indicator-icon').classList.contains('text-secondary')).toBe(true)
})
})
4 changes: 4 additions & 0 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ export default function App() {
),
{
basename: window.JM.PUBLIC_PATH,
future: {
v7_fetcherPersist: true,
v7_normalizeFormMethod: true,
},
},
)

Expand Down
33 changes: 10 additions & 23 deletions src/components/Balance.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react'
import user from '@testing-library/user-event'
import { act } from 'react-dom/test-utils'
import { screen } from '../testUtils'
import { BTC, SATS } from '../utils'
import Balance from './Balance'
Expand Down Expand Up @@ -144,67 +143,55 @@ describe('<Balance />', () => {
expect(screen.queryByTestId('sats-symbol')).not.toBeInTheDocument()
})

it('should toggle visibility of initially hidden balance on click by default', () => {
it('should toggle visibility of initially hidden balance on click by default', async () => {
render(<Balance valueString={`21`} convertToUnit={SATS} showBalance={false} />)
expect(screen.queryByTestId(`sats-amount`)).not.toBeInTheDocument()
expect(screen.getByText(`*****`)).toBeInTheDocument()

act(() => {
user.click(screen.getByText(`*****`))
})
await user.click(screen.getByText(`*****`))

expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
expect(screen.queryByText(`*****`)).not.toBeInTheDocument()

act(() => {
user.click(screen.getByTestId(`sats-amount`))
})
await user.click(screen.getByTestId(`sats-amount`))

expect(screen.queryByTestId(`sats-amount`)).not.toBeInTheDocument()
expect(screen.getByText(`*****`)).toBeInTheDocument()
})

it('should NOT toggle visibility of initially hidden balance on click when disabled via flag', () => {
it('should NOT toggle visibility of initially hidden balance on click when disabled via flag', async () => {
render(<Balance valueString={`21`} convertToUnit={SATS} showBalance={false} enableVisibilityToggle={false} />)
expect(screen.queryByTestId(`sats-amount`)).not.toBeInTheDocument()
expect(screen.getByText(`*****`)).toBeInTheDocument()

act(() => {
user.click(screen.getByText(`*****`))
})
await user.click(screen.getByText(`*****`))

expect(screen.queryByTestId(`sats-amount`)).not.toBeInTheDocument()
expect(screen.getByText(`*****`)).toBeInTheDocument()
})

it('should NOT toggle visibility of initially visible balance on click by default', () => {
it('should NOT toggle visibility of initially visible balance on click by default', async () => {
render(<Balance valueString={`21`} convertToUnit={SATS} showBalance={true} />)
expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
expect(screen.queryByText(`*****`)).not.toBeInTheDocument()

act(() => {
user.click(screen.getByTestId(`sats-amount`))
})
await user.click(screen.getByTestId(`sats-amount`))

expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
expect(screen.queryByText(`*****`)).not.toBeInTheDocument()
})

it('should toggle visibility of initially visible balance on click when enabled via flag', () => {
it('should toggle visibility of initially visible balance on click when enabled via flag', async () => {
render(<Balance valueString={`21`} convertToUnit={SATS} showBalance={true} enableVisibilityToggle={true} />)
expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
expect(screen.queryByText(`*****`)).not.toBeInTheDocument()

act(() => {
user.click(screen.getByTestId(`sats-amount`))
})
await user.click(screen.getByTestId(`sats-amount`))

expect(screen.queryByTestId(`sats-amount`)).not.toBeInTheDocument()
expect(screen.getByText(`*****`)).toBeInTheDocument()

act(() => {
user.click(screen.getByText(`*****`))
})
await user.click(screen.getByText(`*****`))

expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
expect(screen.queryByText(`*****`)).not.toBeInTheDocument()
Expand Down
Loading