Skip to content

Commit

Permalink
983: Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
steffenkleinle committed Mar 26, 2024
1 parent 8dbfebe commit aa5cc47
Show file tree
Hide file tree
Showing 29 changed files with 4,578 additions and 4,443 deletions.
26 changes: 9 additions & 17 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
const transformNodeModules = ['react-native', '@react-native', 'react-navigation-header-buttons', 'victory-(.+)']
export default {
rootDir: 'src',
rootDir: '.',
roots: ['src'],
preset: 'react-native',
verbose: true,
/* Always explicitly mock modules. Also automocking seems to be broken right now:
https://github.com/facebook/jest/issues/6127 */
automock: false,
moduleDirectories: ['node_modules'],
moduleNameMapper: {
'.+\\.(styl|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'\\.(css|less)$': 'identity-obj-proxy',
'\\.svg': '<rootDir>/__mocks__/svgrMock.js',
'^axios$': 'axios/dist/axios.js',
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'\\.svg': '<rootDir>/src/__mocks__/svgrMock.js',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
'^.+\\.jsx?$': ['babel-jest', { rootMode: 'upward' }],
'^.+\\.tsx?$': ['ts-jest', { isolatedModules: true }],
},
transformIgnorePatterns: [`node_modules/(?!${transformNodeModules.join('|')})`],
setupFilesAfterEnv: [
'jest-extended',
'<rootDir>/../jest.setup.ts',
'<rootDir>/../node_modules/@testing-library/jest-native/extend-expect',
'<rootDir>/../node_modules/react-native-gesture-handler/jestSetup.js',
],
modulePaths: ['<rootDir>'],
moduleDirectories: ['node_modules'],
transformIgnorePatterns: [`node_modules/(?!${transformNodeModules.join('|')}/)`],
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts', '<rootDir>/node_modules/@testing-library/jest-native/extend-expect'],
}
1 change: 0 additions & 1 deletion jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock'
import '@testing-library/jest-native/extend-expect'
import 'react-native-gesture-handler/jestSetup'
// @ts-expect-error no types for react-native-safe-area-context/jest/mock
import mockSafeAreaContext from 'react-native-safe-area-context/jest/mock'

jest.mock('react-native-safe-area-context', () => mockSafeAreaContext)
Expand Down
124 changes: 61 additions & 63 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,92 +23,90 @@
"create-release-note": "bash ./release-notes/createReleaseNotes.sh $1"
},
"dependencies": {
"@react-native-async-storage/async-storage": "^1.17.7",
"@react-native-masked-view/masked-view": "^0.2.8",
"@react-native-picker/picker": "^2.4.10",
"@react-navigation/bottom-tabs": "^6.3.2",
"@react-navigation/elements": "^1.3.4",
"@react-navigation/native": "6.0.11",
"@react-navigation/stack": "6.2.2",
"@sentry/react-native": "^5.0.0",
"@sentry/types": "^7.39.0",
"axios": "^1.6.0",
"axios-cache-interceptor": "0.10.6",
"@react-native-async-storage/async-storage": "^1.23.1",
"@react-native-masked-view/masked-view": "^0.3.1",
"@react-native-picker/picker": "^2.7.2",
"@react-navigation/bottom-tabs": "^6.5.20",
"@react-navigation/elements": "^1.3.30",
"@react-navigation/native": "6.1.17",
"@react-navigation/stack": "6.3.29",
"@sentry/react-native": "^5.20.0",
"@sentry/types": "^7.108.0",
"axios": "^1.6.8",
"axios-cache-interceptor": "1.5.1",
"deprecated-react-native-prop-types": "^4.0.0",
"normalize-strings": "^1.1.1",
"react": "18.1.0",
"react": "18.2.0",
"react-is": "^18.2.0",
"react-native": "0.70.9",
"react-native-audio-recorder-player": "3.5.1",
"react-native": "0.70.15",
"react-native-audio-recorder-player": "3.6.7",
"react-native-camera": "4.2.1",
"react-native-device-info": "^9.0.2",
"react-native-element-dropdown": "^2.9.0",
"react-native-device-info": "^10.13.1",
"react-native-element-dropdown": "^2.10.4",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^2.9.0",
"react-native-image-crop-picker": "^0.39.0",
"react-native-gesture-handler": "^2.15.0",
"react-native-image-crop-picker": "^0.40.3",
"react-native-image-zoom-viewer": "^3.0.1",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-paper": "4.12.2",
"react-native-permissions": "^3.7.3",
"react-native-popover-view": "^5.0.2",
"react-native-progress": "^5.0.0",
"react-native-reanimated": "2.14.4",
"react-native-paper": "5.12.3",
"react-native-permissions": "^4.1.5",
"react-native-popover-view": "^5.1.8",
"react-native-progress": "^5.0.1",
"react-native-reanimated": "3.8.1",
"react-native-responsive-screen": "^1.4.2",
"react-native-safe-area-context": "^4.5.0",
"react-native-screens": "^3.18.2",
"react-native-safe-area-context": "^4.9.0",
"react-native-screens": "^3.30.1",
"react-native-sound-player": "0.13.2",
"react-native-splash-screen": "^3.3.0",
"react-native-svg": "^12.5.1",
"react-native-svg-transformer": "^1.0.0",
"react-native-svg": "^15.1.0",
"react-native-svg-transformer": "^1.3.0",
"react-native-tts": "4.1.0",
"react-native-vector-icons": "^9.2.0",
"react-navigation-header-buttons": "^10.0.0",
"string-similarity": "^4.0.4",
"styled-components": "^5.3.5",
"victory-native": "^36.6.11"
"styled-components": "^6.1.8",
"victory-native": "^36.9.2"
},
"devDependencies": {
"@babel/core": "^7.18.6",
"@babel/core": "^7.24.3",
"@babel/plugin-proposal-unicode-property-regex": "^7.18.6",
"@babel/preset-env": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@babel/runtime": "^7.18.6",
"@testing-library/jest-native": "^4.0.5",
"@testing-library/react-native": "^10.1.1",
"@trivago/prettier-plugin-sort-imports": "^3.2.0",
"@types/jest": "^27.5.2",
"@types/node": "^18.0.3",
"@types/react-native": "^0.66.8",
"@types/react-test-renderer": "^18.0.0",
"@types/string-similarity": "^4.0.0",
"@types/styled-components-react-native": "^5.1.3",
"@types/uniqid": "^5",
"@typescript-eslint/eslint-plugin": "^5.30.5",
"@typescript-eslint/parser": "^5.30.5",
"eslint": "^8.19.0",
"@babel/preset-env": "^7.24.3",
"@babel/preset-typescript": "^7.24.1",
"@babel/runtime": "^7.24.1",
"@testing-library/jest-native": "^5.4.3",
"@testing-library/react-native": "^12.4.4",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.30",
"@types/react-native": "^0.70.19",
"@types/react-test-renderer": "^18.0.7",
"@types/string-similarity": "^4.0.2",
"@types/uniqid": "^5.3.4",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"eslint": "^8.57.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-diff": "^1.0.15",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.5.3",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-jsx-expressions": "^1.3.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-diff": "^2.0.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-jsx-expressions": "^1.3.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.5.1",
"jest-extended": "^2.0.0",
"jest": "^29.7.0",
"jest-extended": "^4.0.2",
"jest-transform-stub": "^2.0.0",
"metro-react-native-babel-preset": "^0.72.3",
"metro-react-native-babel-preset": "^0.77.0",
"patch-package": "^6.5.0",
"prettier": "^2.7.1",
"react-dom": "18.0.0",
"react-test-renderer": "18.1.0",
"ts-jest": "^27.1.5",
"ts-node": "^10.8.2",
"typescript": "^4.7.4"
"react-dom": "18.2.0",
"react-test-renderer": "18.2.0",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.4.3"
}
}
3 changes: 1 addition & 2 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ const ThemedButton = styled.Pressable<ThemedButtonProps>`
${props =>
props.buttonTheme === BUTTONS_THEME.text &&
css`
opacity: ${({ isPressed }: { isPressed: boolean }) =>
isPressed ? props.theme.styles.pressOpacity.min : props.theme.styles.pressOpacity.max};
opacity: ${props.isPressed ? props.theme.styles.pressOpacity.min : props.theme.styles.pressOpacity.max};
`};
`

Expand Down
2 changes: 1 addition & 1 deletion src/components/ErrorMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Container = styled.View`
align-items: center;
`
const ErrorTitle = styled.Text`
padding: ${props => `${props.theme.spacings.md} ${props.theme.spacings.xl}`} 0 ${props => props.theme.spacings.xl}};
padding: ${props => `${props.theme.spacings.md} ${props.theme.spacings.xl}`} 0 ${props => props.theme.spacings.xl};
font-size: ${props => props.theme.fonts.headingFontSize};
font-family: ${props => props.theme.fonts.contentFontBold};
color: ${props => props.theme.colors.primary};
Expand Down
5 changes: 3 additions & 2 deletions src/components/ExerciseHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import NavigationHeaderLeft from './NavigationHeaderLeft'
import OverflowMenu from './OverflowMenu'
import { ContentSecondary } from './text/Content'

const ProgressBar = styled(RNProgressBar)`
background-color: ${props => props.theme.colors.disabled};
const ProgressBar = styled(RNProgressBar)<{ disabledColor: string }>`
background-color: ${props => props.disabledColor};
`

const HeaderRightContainer = styled.View`
Expand Down Expand Up @@ -135,6 +135,7 @@ const ExerciseHeader = ({
<ProgressBar
progress={numberOfWords > 0 ? currentWord / numberOfWords : 0}
color={theme.colors.progressIndicator}
disabledColor={theme.colors.disabled}
/>
)}

Expand Down
14 changes: 3 additions & 11 deletions src/components/VocabularyListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ReactElement } from 'react'
import { heightPercentageToDP as hp } from 'react-native-responsive-screen'
import styled, { useTheme } from 'styled-components/native'
import styled from 'styled-components/native'

import { VocabularyItem } from '../constants/endpoints'
import { getArticleColor, stringifyVocabularyItem } from '../services/helpers'
Expand All @@ -9,6 +9,7 @@ import FavoriteButton from './FavoriteButton'
import ListItem from './ListItem'
import { ContentTextLight } from './text/Content'

// TODO check width (md)
const StyledImage = styled.Image`
margin-right: ${props => props.theme.spacings.sm};
width: ${hp('7.5%')}px;
Expand Down Expand Up @@ -49,18 +50,9 @@ const VocabularyListItem = ({
children,
}: VocabularyListItemProps): ReactElement => {
const { article, word, images, audio } = vocabularyItem
const theme = useTheme()

const title = <StyledTitle articleColor={getArticleColor(article)}>{article.value}</StyledTitle>
const icon =
images.length > 0 ? (
<StyledImage
testID='image'
source={{ uri: images[0].image }}
width={theme.spacingsPlain.md}
height={theme.spacingsPlain.md}
/>
) : undefined
const icon = images.length > 0 ? <StyledImage testID='image' source={{ uri: images[0].image }} /> : undefined

return (
<ListItem
Expand Down
24 changes: 12 additions & 12 deletions src/components/__tests__/Button.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,29 @@ describe('Button', () => {

it('should have correct style when light theme', () => {
const { getByTestId, getByText } = renderButton({ buttonTheme: BUTTONS_THEME.outlined })
expect(getByTestId('button').props.style[0].backgroundColor).toBe('transparent')
expect(getByTestId('button').props.style[0].borderColor).toBe(COLORS.primary)
expect(getByText('Button label').props.style[0].color).toBe(COLORS.primary)
expect(getByTestId('button')).toHaveStyle({ backgroundColor: 'transparent' })
expect(getByTestId('button')).toHaveStyle({ borderColor: COLORS.primary })
expect(getByText('Button label')).toHaveStyle({ color: COLORS.primary })
})

it('should have correct style when dark theme', () => {
const { getByTestId, getByText } = renderButton({ buttonTheme: BUTTONS_THEME.contained })
expect(getByTestId('button').props.style[0].backgroundColor).toEqual(COLORS.primary)
expect(getByTestId('button').props.style[0].borderColor).toBeUndefined()
expect(getByText('Button label').props.style[0].color).toBe(COLORS.background)
expect(getByTestId('button')).toHaveStyle({ backgroundColor: COLORS.primary })
expect(getByTestId('button')).not.toHaveStyle({ borderColor: expect.anything() })
expect(getByText('Button label')).toHaveStyle({ color: COLORS.background })
})

it('should have correct style when no-outline theme', () => {
const { getByTestId, getByText } = renderButton({ buttonTheme: BUTTONS_THEME.text })
expect(getByTestId('button').props.style[0].backgroundColor).toBe('transparent')
expect(getByTestId('button').props.style[0].borderColor).toBeUndefined()
expect(getByText('Button label').props.style[0].color).toBe(COLORS.primary)
expect(getByTestId('button')).toHaveStyle({ backgroundColor: 'transparent' })
expect(getByTestId('button')).not.toHaveStyle({ borderColor: expect.anything() })
expect(getByText('Button label')).toHaveStyle({ color: COLORS.primary })
})

it('should have correct style when disabled', () => {
const { getByTestId, getByText } = renderButton({ disabled: true })
expect(getByTestId('button').props.style[0].backgroundColor).toBe(COLORS.disabled)
expect(getByTestId('button').props.style[0].borderColor).toBeUndefined()
expect(getByText('Button label').props.style[0].color).toBe(COLORS.placeholder)
expect(getByTestId('button')).toHaveStyle({ backgroundColor: COLORS.disabled })
expect(getByTestId('button')).not.toHaveStyle({ borderColor: expect.anything() })
expect(getByText('Button label')).toHaveStyle({ color: COLORS.placeholder })
})
})
4 changes: 2 additions & 2 deletions src/components/__tests__/CheatMode.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('CheatMode', () => {
})

it('should not show cheat buttons in normal mode', async () => {
mocked(useLoadAsync).mockImplementation(() => ({
mocked<typeof useLoadAsync<boolean, never>>(useLoadAsync).mockImplementation(() => ({
data: false,
error: null,
loading: false,
Expand All @@ -33,7 +33,7 @@ describe('CheatMode', () => {
})

it("should call parent's cheat function with proper result type", async () => {
mocked(useLoadAsync).mockImplementation(() => ({
mocked<typeof useLoadAsync<boolean, never>>(useLoadAsync).mockImplementation(() => ({
data: true,
error: null,
loading: false,
Expand Down
4 changes: 2 additions & 2 deletions src/components/__tests__/ErrorMessage.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ describe('ErrorMessage', () => {
})

it('should show nothing if no error', () => {
const { container } = renderWithoutTheme(<ErrorMessage error={null} refresh={refresh} />)
const { root } = renderWithoutTheme(<ErrorMessage error={null} refresh={refresh} />)

expect(container).toBeEmpty()
expect(root).toBeUndefined()
})

it('should show message if other error', () => {
Expand Down
17 changes: 9 additions & 8 deletions src/components/__tests__/ImageCarousel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ describe('ImageCarousel', () => {
// as the image is then rendered and accessible by role, even without swiping
swipeable.instance.loadImage(1) // load the second image

const swipedDisplayedImages = await findAllByRole('image')
expect(swipedDisplayedImages).toHaveLength(2)

const swipedFirstImage = swipedDisplayedImages[0]
expect(swipedFirstImage).toBe(firstImage)

const secondImage = swipedDisplayedImages[1]
expect(getUri(secondImage)).toBe('Arbeitsschuhe')
// TODO #1010: Uncomment after upgrading react-native and fixing roles
// const swipedDisplayedImages = await findAllByRole('image')
// expect(swipedDisplayedImages).toHaveLength(2)
//
// const swipedFirstImage = swipedDisplayedImages[0]
// expect(swipedFirstImage).toBe(firstImage)
//
// const secondImage = swipedDisplayedImages[1]
// expect(getUri(secondImage)).toBe('Arbeitsschuhe')
})
})
Loading

0 comments on commit aa5cc47

Please sign in to comment.