Skip to content

Commit

Permalink
198 chore files allocation across repo and assign writing tests tasks…
Browse files Browse the repository at this point in the history
… to team (#199)

* 🚰ci: collect coverage from api, and rename testing command

* 🗑️chore: shadcn removal, reduce bundle size

* 🗑️chore: where else do we delete useless stuff

* 🗑️chore: nah, fk nextjs

* 🐛fix: resolve conflict of tsconfig

and added fonts, a shit tons of it

* ✨feat: default header with gap, ass

* 🐛fix: expo jest now instead of test

* 🐛fix: fk snapshot got hands

* 🐧chore: try to manage packages, but realized we are too late for that

* 🐧chore: wasting

* ♻️chore: versions control

* ♻️chore: versions control II

* ♻️ feat: TUI turbo ITS FK GREAT

* 🐞bugs: fixed tailwind works on sum,d oesn't on others

https://www.nativewind.dev/quick-starts/react-native-cli

setup tailwind section

* 🐞fixed: single quote fixed, no body against it

* 🐧bug: attempt to use marcos bottom sheet,agasin, FAILED

* ♻️code: trash

* Revert "♻️code: trash"

This reverts commit 80d1940.

* 🐧fk: imma need input

* 🐧 ui: lets help others

* 🗑️chore: fixed pnpm audit and versions control, prisma latest

* 📁chore: sleep first, code after,

* 🐞bugS: fixed all your silly mistakes

* 🐞fixed: ts

* 🐧ui: atta boi, google gap-2

* 🐞fixed: help stef before

* 🐧masdasmdlkasd

* 🐧chore: chore

* ♻️ bugs: deployment realted

* 📁bug: wher am i

* ♻️fixed: testin and trpc typed

* 🐧ui: default header

* 🐞bugs: version version of pnpm up caniuse-lite

* 🐧 fluc: better message

* 🐞fluc: aight, real works this time

* 🐧ui: default header, background new color

* 🐧fluc: why tf I keep doing sidequest

* 🐞fixing: sdk 50 maybe, nativewind is ASS

* 🐧fluc: BEEFIEST update sdk

jesus why you do this to me

* ♻️tldr: nativewind/nativewind#628

* Auto stash before merge of "165-frontend-move-header-to-the-correct-location" and "origin/165-frontend-move-header-to-the-correct-location"

* Auto stash before merge of "165-frontend-move-header-to-the-correct-location" and "origin/165-frontend-move-header-to-the-correct-location"

* ⚙️tldr: java 17 instead of 11 now, FK YOU EXPO

* ⚙️tldr: fixing

https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation

* 🐞bug: gorhom/react-native-bottom-sheet#1332

another broken lib

* 🐞bug: can't fix the bottom sheet, is beyond us

* 🐧feat: layout, 1

* 🐧fluc: layout 1 done,2 more to go

and get rid of the unsued import

* 🐧ui: picker...watf

* 🐧ui: im so sorry guys, workout screen

* 🐧ui: inbox screen structure

* 🐧ui: inbox structure done, now to friends

* 🐧ui: friends done,ui ready

* 🐧ci/cd: tesgting added

* 🐞fix: will write test in the next issue

* 🐧good to go

* 📁fixed: the damn LOGIN of CLERTK

* ♻️build: prisma schema migration init

* ♻️build: standardize ti

* 🐧build: comment out the eas

* 📁chore: fixed

* 📁chore: fixed

seed prod

* 🗑️chore: files name and relative path

1. change all routers to..duh routers
2. update all relative path, even if it is test files
3. move all test file to a dedicated folder, avoid clutter
4. about to write picker-modal test

* 🗑️chore: okay, got it, WHO TF WROTE TOGGLE

* 🗑️chore: files name, dadadada

* 🗑️chore:f iles name change again

* 🤦‍♂️ci/cd; divider test pass, failed action-button

rename tests in api to router, specifically

* 🐧ci/cd: passed action-button, now onto picker-modal

* 🐧fluc: testing passed, more snapshot, fk me

* 🤦‍♂️ fluc: revertable, af FK CLERK

* 🤦‍♂️attempt: to fixed the stupid warning

* Revert "🤦‍♂️attempt: to fixed the stupid warning"

This reverts commit 5a6ad2f.

* 🤦‍♂️fixed: signed out fixed, now doing sign in, Jesus

* 🤦‍♂️idk: fk it

* 🐧updateD: snapshot

* ♻️chore: snapshot II

* 🐧fixed: jesus, writeing unit test and fix aaron toggle

* 🐧fluc: extend timeout

* 🤦‍♂️fluc: extend timeout

* 👑fluic: fk

* 🤦‍♂️remove: un need file

* ♻️fixed: ts error from main

* ♻️coverage: brrrr brrrrr
  • Loading branch information
thienguen authored Apr 15, 2024
1 parent 5ca69fc commit 89adcb8
Show file tree
Hide file tree
Showing 89 changed files with 1,370 additions and 390 deletions.
17 changes: 16 additions & 1 deletion apps/expo/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,28 @@ const defineConfig = (): ExpoConfig => ({
ios: {
bundleIdentifier: 'your.bundle.identifier',
supportsTablet: true,
// associatedDomains: ['applinks:clerk.helping.lemming-64.lclstage.dev'],
},
android: {
package: 'your.bundle.identifier',
adaptiveIcon: {
foregroundImage: './assets/icon.png',
backgroundColor: '#1F104A',
},
// intentFilters: [
// {
// action: 'VIEW',
// autoVerify: true,
// data: [
// {
// scheme: 'https',
// host: 'clerk.helping.lemming-64.lclstage.dev',
// pathPrefix: '/v1/oauth-native-callback',
// },
// ],
// category: ['BROWSABLE', 'DEFAULT'],
// },
// ],
jsEngine: 'hermes',
},
extra: {
Expand All @@ -48,7 +63,7 @@ const defineConfig = (): ExpoConfig => ({
// jsEngine: 'hermes',
plugins: [
/* don't touch this */
["expo-router", { "root": "./src/app/" }],
['expo-router', { root: './src/app/' }],
'expo-font',
'expo-secure-store',
// 'expo-router',
Expand Down
9 changes: 5 additions & 4 deletions apps/expo/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Config } from 'jest'
const config: Config = {
coverageDirectory: './jest-coverage/',
setupFilesAfterEnv: ['<rootDir>/setup-jest.js'],
testTimeout: 60000,
collectCoverageFrom: [
'**/*.{ts,tsx}',
'!**/node_modules/**',
Expand All @@ -15,11 +16,13 @@ const config: Config = {
'!**/*.d.ts',
'!index.ts',
'!**/api.tsx',
'!**/sign-in-w-google.tsx',
'!**/constants.ts',

/* need to remove in the future */
'!**/app/**',
'!**/custom-bottom-sheet-modal.tsx',
'!**/sign-in-with-google.tsx',
'!**/svgMock.tsx',
'!**/notif/**',
'!**/hooks/**',
Expand All @@ -31,8 +34,6 @@ const config: Config = {
'!**/(inbox)/**',
'!**/(friends)/**',
'!**/(workout)/**',

'!**/picker-modal/**',
],
// coverageThreshold: {
// global: {
Expand All @@ -52,8 +53,8 @@ const config: Config = {

preset: 'jest-expo',
moduleNameMapper: {
'~/(.*)': '<rootDir>/src/$1',
'\\.svg$': '<rootDir>/src/layouts/headers/svgMock.tsx',
'~/(.*)' : '<rootDir>/src/$1',
'\\.svg$': '<rootDir>/src/components/ui/svgMock.tsx',
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { render, screen } from '@testing-library/react-native'

import FriendRequestNotif from '~/components/notif/miscNotifs/FriendRequestNotif'

jest.mock('~/utils/api', () => ({
jest.mock('~/utils/trpc/api', () => ({
__esModule: true,
api: {
useUtils: jest.fn(() => ({
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import { render, screen } from '@testing-library/react-native'

import calculateTimeAgo from '~/utils/calculateTime'
import TimeAgo from './TimeAgo'
import TimeAgo from '~/components/timeAgo/TimeAgo'

describe('TimeAgo', () => {
/* */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ exports[`FriendRequestNotif should render sender's username and content 1`] = `
}
testID="timeAgoText"
>
3 weeks ago
4 weeks ago
</Text>
</View>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ exports[`NudgeNotif 1`] = `
}
testID="timeAgoText"
>
3 weeks ago
4 weeks ago
</Text>
</View>
</View>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Toggle 1`] = `
exports[`Toggle component should match snapshop 1`] = `
<View
style={
{
Expand All @@ -9,6 +9,7 @@ exports[`Toggle 1`] = `
"marginBottom": 11.25,
}
}
testID="toggle-container"
>
<View
accessibilityState={
Expand Down Expand Up @@ -56,6 +57,7 @@ exports[`Toggle 1`] = `
"width": 112.5,
}
}
testID="toggle-switch"
>
<View
collapsable={false}
Expand All @@ -68,6 +70,7 @@ exports[`Toggle 1`] = `
"width": 26.250000000000004,
}
}
testID="toggle-circle"
/>
</View>
</View>
Expand All @@ -78,6 +81,9 @@ exports[`Toggle 1`] = `
"fontSize": 30,
}
}
/>
testID="toggle-label"
>
Test
</Text>
</View>
`;
62 changes: 62 additions & 0 deletions apps/expo/src/__tests__/headers.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React from 'react'
import { router } from 'expo-router'

import { fireEvent, render } from '@testing-library/react-native'

import { DashboardHeader } from '../layouts/headers/dashboard-header'
import { FriendsHeader } from '../layouts/headers/friends-header'
import { InboxHeader } from '../layouts/headers/inbox-headers'
import { WorkoutHeader } from '../layouts/headers/workout-headers'

jest.mock('~assets/svgs/notification.svg', () => 'NotificationSVG')
jest.mock('~assets/svgs/arrow-left.svg', () => 'ArrowLeftSVG')
jest.mock('~assets/svgs/friends.svg', () => 'FriendsSVG')
jest.mock('~assets/svgs/write.svg', () => 'WriteSVG')
jest.mock('expo-router', () => ({
router: {
back: jest.fn(),
},
}))

describe('DashboardHeader', () => {
it('renders correctly', () => {
const { getByText } = render(<DashboardHeader />)
expect(getByText('BARBELL')).toBeTruthy()
})
})

describe('FriendsHeader', () => {
it('renders correctly', () => {
const { getByText } = render(<FriendsHeader />)
expect(getByText('Friends List')).toBeTruthy()
})

it('navigates back on press', () => {
const { getByTestId } = render(<FriendsHeader />)
const button = getByTestId('friends-header-button')
fireEvent.press(button)
expect(router.back).toHaveBeenCalled()
})
})

describe('InboxHeader', () => {
it('renders with dynamic title', () => {
const title = 'Inbox'
const { getByTestId } = render(<InboxHeader title={title} />)
const button = getByTestId('inbox-header-button')
expect(button).toBeTruthy()
fireEvent.press(button)
expect(router.back).toHaveBeenCalled()
})
})

describe('WorkoutHeader', () => {
it('renders correctly', () => {
const { getByText } = render(<WorkoutHeader />)
expect(getByText('BARBELL')).toBeTruthy()
const { getByTestId } = render(<WorkoutHeader />)
const button = getByTestId('workout-header-button')
fireEvent.press(button)
expect(router.back).toHaveBeenCalled()
})
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/react-native'

import MessageInput from './messageInput'
import MessageInput from '~/components/message/messageInput'

test('MessageInput', async () => {
render(<MessageInput />)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as useAuth from '@clerk/clerk-expo'
import { fireEvent, render, screen } from '@testing-library/react-native'
import { act } from 'react-test-renderer'

import { SignOut } from './sign-out'
import { SignOut } from '~/components/auth/sign-out'

const mockUseAuth = useAuth as { useAuth: any }

Expand Down
97 changes: 97 additions & 0 deletions apps/expo/src/__tests__/toggle.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React, { Component } from 'react'
import { Dimensions } from 'react-native'

import { fireEvent, render, waitFor } from '@testing-library/react-native'
import { act } from 'react-test-renderer'

import Toggle from '~/components/toggle/toggle'

/**
* @see https://github.com/orgs/react-hook-form/discussions/4232
*/

describe('Toggle component', () => {
beforeAll(() => {
jest.setTimeout(30000)
})

/* git force */
const originalConsoleError = console.error
beforeAll(() => {
console.error = (message, ...args) => {
if (/not wrapped in act\(...\)/.test(message)) {
return
}
originalConsoleError(message, ...args)
}
})

afterAll(() => {
console.error = originalConsoleError
})

const { width: screenWidth } = Dimensions.get('window')

it('should render correctly', async () => {
const { getByTestId } = render(<Toggle value={false} onValueChange={() => {}} label='Test' />)

await waitFor(() => expect(getByTestId('toggle-container')).toBeDefined())
await waitFor(() => expect(getByTestId('toggle-switch')).toBeDefined())
await waitFor(() => expect(getByTestId('toggle-label')).toBeDefined())
})

it('should call onValueChange function when toggled', async () => {
const onValueChange = jest.fn()
const { getByTestId } = render(
<Toggle value={false} onValueChange={onValueChange} label='Test' />,
)
const toggleSwitch = getByTestId('toggle-switch')

await act(async () => {
fireEvent.press(toggleSwitch)
})

await waitFor(() => expect(onValueChange).toHaveBeenCalledTimes(1))
})

it('should animate the switch when the value prop changes', async () => {
const { getByTestId, rerender } = render(
<Toggle value={false} onValueChange={() => {}} label='Test' />,
)
const toggleCircle = getByTestId('toggle-circle')

expect(toggleCircle.props.style.marginLeft).toBeCloseTo(screenWidth * 0.01, 1)

await act(async () => {
rerender(<Toggle value={true} onValueChange={() => {}} label='Test' />)
})
// await waitFor(() => expect(myInput).toHaveValue('value'))
await waitFor(() => expect(toggleCircle.props.style.marginLeft).toBeCloseTo(79.5))
})

it('should update the background color of the switch when the value prop changes', async () => {
const { getByTestId, rerender } = render(
<Toggle value={false} onValueChange={() => {}} label='Test' />,
)
const toggleSwitch = getByTestId('toggle-switch')

// expect(toggleSwitch.props.style.backgroundColor).toContain('rgba(58, 58, 58, 1)')
await waitFor(() =>
expect(toggleSwitch.props.style.backgroundColor).toContain('rgba(58, 58, 58, 1)'),
)

await act(async () => {
rerender(<Toggle value={true} onValueChange={() => {}} label='Test' />)
})

// await waitFor(() => expect(myInput).toHaveValue('value'));
await waitFor(() =>
expect(toggleSwitch.props.style.backgroundColor).toContain('rgba(58, 58, 58, 1)'),
)
})

it('should match snapshop', () => {
const { toJSON } = render(<Toggle value={false} onValueChange={() => {}} label='Test' />)
expect(toJSON()).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react'

import { fireEvent, render, screen } from '@testing-library/react-native'

import SearchBar from './SearchBar'
import SearchBar from '~/components/ui/search-bar/SearchBar'

test('SearchBar', async () => {
const TestComponent = () => {
Expand All @@ -20,8 +20,7 @@ test('SearchBar', async () => {
}

const listToFilter = [item1, item2, item3]
const [filteredList, setFilteredList] = useState(listToFilter)

const [filteredList, setFilteredList] = useState<any[] | undefined>(listToFilter)
return <SearchBar list={listToFilter} placeholder="Search..." setFilteredList={setFilteredList} filterBy="name" />
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'

import { render } from '@testing-library/react-native'

import CustomBottomSheet from './bottom-sheet'
import CustomBottomSheet from '~/components/ui/bottom-sheet/bottom-sheet'

/**
* @bug https://github.com/software-mansion/react-native-reanimated/issues/1555
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { fireEvent, render, screen } from '@testing-library/react-native'

import Button from './button'
import Button from '~/components/ui/button/button'

test('Button', async () => {
const expectedButtonText = 'Button Text'
Expand Down
Loading

0 comments on commit 89adcb8

Please sign in to comment.