From 89adcb8d3bda5fb94c02816c10497bc59f4d9d82 Mon Sep 17 00:00:00 2001 From: Thien Nguyen <94078395+thienguen@users.noreply.github.com> Date: Mon, 15 Apr 2024 09:32:04 -0700 Subject: [PATCH] 198 chore files allocation across repo and assign writing tests tasks to team (#199) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🚰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 80d1940c7a41c499b012713eaf4e741e60d1740f. * 🐧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: https://github.com/marklawlor/nativewind/issues/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: https://github.com/gorhom/react-native-bottom-sheet/issues/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 5a6ad2f37d1e963b5ab5f0c01652600e6d6ca308. * 🤦‍♂️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 --- apps/expo/app.config.ts | 17 +- apps/expo/jest.config.ts | 9 +- .../__tests__/FriendRequestNotif.test.tsx | 2 +- .../notif => }/__tests__/NudgeNotif.test.tsx | 0 .../timeAgo => __tests__}/TimeAgo.test.tsx | 2 +- .../FriendRequestNotif.test.tsx.snap | 2 +- .../__snapshots__/NudgeNotif.test.tsx.snap | 2 +- .../__snapshots__/TimeAgo.test.tsx.snap | 0 .../__snapshots__/messageInput.test.tsx.snap | 0 .../__snapshots__/toggle.test.tsx.snap} | 10 +- apps/expo/src/__tests__/headers.test.tsx | 62 +++ .../messageInput.test.tsx | 2 +- .../sign-in-w-google.test.tsx.txt} | 0 .../auth => __tests__}/sign-out.test.tsx | 2 +- apps/expo/src/__tests__/toggle.test.tsx | 97 +++++ .../set-entry-header.test.tsx.snap | 0 .../tracker/exercise-entry.test.tsx | 0 .../tracker/set-entry-header.test.tsx | 0 .../tracker/set-entry.test.tsx | 0 .../tracker/workout-timer.test.tsx | 0 .../tracker/workout-tracker-header.test.tsx | 0 .../tracker/workout-tracker.test.tsx | 0 .../ui}/SearchBar.test.tsx | 5 +- .../__snapshots__/bottom-sheet.test.tsx.snap | 0 .../ui}/__snapshots__/button.test.tsx.snap | 0 .../ui}/bottom-sheet.test.tsx | 2 +- .../button => __tests__/ui}/button.test.tsx | 2 +- .../__snapshots__/action-button.test.tsx.snap | 73 ++++ .../__snapshots__/divider.test.tsx.snap | 17 + .../__snapshots__/picker-modal.test.tsx.snap | 262 ++++++++++++ .../ui/picker-modal/action-button.test.tsx | 51 +++ .../ui/picker-modal/divider.test.tsx | 23 + .../ui/picker-modal/picker-modal.test.tsx | 27 ++ .../src/__tests__/util/calculate-time.test.ts | 80 ++++ apps/expo/src/__tests__/util/common.test.ts | 59 +++ .../util}/timeFormatter.test.ts | 2 +- .../util}/usernameGenerator.test.ts | 0 apps/expo/src/app/(dashboard)/_layout.tsx | 2 +- .../src/app/(dashboard)/account-settings.tsx | 16 +- apps/expo/src/app/(dashboard)/index.tsx | 2 +- apps/expo/src/app/(inbox)/index.tsx | 2 +- apps/expo/src/app/[...unmatched].tsx | 16 - apps/expo/src/app/_layout.tsx | 4 +- apps/expo/src/app/award/index.tsx | 22 +- apps/expo/src/app/messages/index.tsx | 2 +- apps/expo/src/app/muscleGroup/index.tsx | 399 ++++++++++-------- apps/expo/src/app/notif/dm/index.tsx | 4 +- apps/expo/src/app/tracker/index.tsx | 2 +- .../src/components/auth/sign-in-w-google.tsx | 47 ++- apps/expo/src/components/auth/sign-out.tsx | 22 +- .../muscleGroup/FrontBackSwitch.test.tsx | 16 +- .../muscleGroup/FrontBackSwitch.tsx | 61 +-- .../FrontBackSwitch.test.tsx.snap | 119 ++++++ .../src/components/notif/Conversation.tsx | 4 +- .../components/notif/dmNotifs/dmNotifs.tsx | 2 +- .../components/notif/gcNotifs/gcNotifs.tsx | 2 +- .../notif/miscNotifs/FriendRequestNotif.tsx | 2 +- .../notif/miscNotifs/miscNotifs.tsx | 2 +- apps/expo/src/components/spotify/spotify.tsx | 2 +- .../src/components/toggle/Toggle.test.tsx | 8 - .../toggle/{Toggle.tsx => toggle.tsx} | 22 +- .../tracker/workout-tracker-header.tsx | 2 +- .../components/tracker/workout-tracker.tsx | 2 +- .../custom-bottom-sheet-modal.tsx | 0 .../action-button/action-button.tsx | 3 +- .../ui/picker-modal/divider/divider.tsx | 2 +- .../{picker.modal.tsx => picker-modal.tsx} | 42 +- apps/expo/src/components/ui/svgMock.tsx | 18 + .../src/components/workout/exerciseList.tsx | 8 +- .../src/components/workout/workoutList.tsx | 2 +- apps/expo/src/context/global-context.tsx | 2 +- apps/expo/src/hooks/useWarmUpBrowser.tsx | 5 + apps/expo/src/utils/common.ts | 4 + apps/expo/src/utils/{ => trpc}/api.tsx | 2 +- apps/expo/tsconfig.json | 4 +- packages/api/src/__test__/exercise.test.ts | 6 +- packages/api/src/__test__/user.test.ts | 17 - packages/api/src/__test__/workout.test.ts | 4 +- .../{post.test.ts => post.router.test.ts} | 0 .../api/src/__tests__/user.router.test.ts | 23 + packages/api/src/root.ts | 14 +- .../{exercise.ts => exercise.router.ts} | 6 +- .../router/{friend.ts => friend.router.ts} | 0 .../src/router/{notif.ts => notif.router.ts} | 0 .../src/router/{post.ts => post.router.ts} | 0 .../router/{spotify.ts => spotify.router.ts} | 0 .../src/router/{user.ts => user.router.ts} | 0 .../router/{workout.ts => workout.router.ts} | 0 packages/db/prisma/schema.prisma | 4 +- 89 files changed, 1370 insertions(+), 390 deletions(-) rename apps/expo/src/{components/notif => }/__tests__/FriendRequestNotif.test.tsx (97%) rename apps/expo/src/{components/notif => }/__tests__/NudgeNotif.test.tsx (100%) rename apps/expo/src/{components/timeAgo => __tests__}/TimeAgo.test.tsx (97%) rename apps/expo/src/{components/notif => }/__tests__/__snapshots__/FriendRequestNotif.test.tsx.snap (99%) rename apps/expo/src/{components/notif => }/__tests__/__snapshots__/NudgeNotif.test.tsx.snap (99%) rename apps/expo/src/{components/timeAgo => __tests__}/__snapshots__/TimeAgo.test.tsx.snap (100%) rename apps/expo/src/{components/message => __tests__}/__snapshots__/messageInput.test.tsx.snap (100%) rename apps/expo/src/{components/toggle/__snapshots__/Toggle.test.tsx.snap => __tests__/__snapshots__/toggle.test.tsx.snap} (89%) create mode 100644 apps/expo/src/__tests__/headers.test.tsx rename apps/expo/src/{components/message => __tests__}/messageInput.test.tsx (74%) rename apps/expo/src/{components/auth/sign-in-w-google.test.tsx => __tests__/sign-in-w-google.test.tsx.txt} (100%) rename apps/expo/src/{components/auth => __tests__}/sign-out.test.tsx (94%) create mode 100644 apps/expo/src/__tests__/toggle.test.tsx rename apps/expo/src/{components => __tests__}/tracker/__snapshots__/set-entry-header.test.tsx.snap (100%) rename apps/expo/src/{components => __tests__}/tracker/exercise-entry.test.tsx (100%) rename apps/expo/src/{components => __tests__}/tracker/set-entry-header.test.tsx (100%) rename apps/expo/src/{components => __tests__}/tracker/set-entry.test.tsx (100%) rename apps/expo/src/{components => __tests__}/tracker/workout-timer.test.tsx (100%) rename apps/expo/src/{components => __tests__}/tracker/workout-tracker-header.test.tsx (100%) rename apps/expo/src/{components => __tests__}/tracker/workout-tracker.test.tsx (100%) rename apps/expo/src/{components/ui/search-bar => __tests__/ui}/SearchBar.test.tsx (83%) rename apps/expo/src/{components/ui/bottom-sheet => __tests__/ui}/__snapshots__/bottom-sheet.test.tsx.snap (100%) rename apps/expo/src/{components/ui/button => __tests__/ui}/__snapshots__/button.test.tsx.snap (100%) rename apps/expo/src/{components/ui/bottom-sheet => __tests__/ui}/bottom-sheet.test.tsx (91%) rename apps/expo/src/{components/ui/button => __tests__/ui}/button.test.tsx (94%) create mode 100644 apps/expo/src/__tests__/ui/picker-modal/__snapshots__/action-button.test.tsx.snap create mode 100644 apps/expo/src/__tests__/ui/picker-modal/__snapshots__/divider.test.tsx.snap create mode 100644 apps/expo/src/__tests__/ui/picker-modal/__snapshots__/picker-modal.test.tsx.snap create mode 100644 apps/expo/src/__tests__/ui/picker-modal/action-button.test.tsx create mode 100644 apps/expo/src/__tests__/ui/picker-modal/divider.test.tsx create mode 100644 apps/expo/src/__tests__/ui/picker-modal/picker-modal.test.tsx create mode 100644 apps/expo/src/__tests__/util/calculate-time.test.ts create mode 100644 apps/expo/src/__tests__/util/common.test.ts rename apps/expo/src/{utils => __tests__/util}/timeFormatter.test.ts (90%) rename apps/expo/src/{utils => __tests__/util}/usernameGenerator.test.ts (100%) delete mode 100644 apps/expo/src/app/[...unmatched].tsx create mode 100644 apps/expo/src/components/muscleGroup/__snapshots__/FrontBackSwitch.test.tsx.snap delete mode 100644 apps/expo/src/components/toggle/Toggle.test.tsx rename apps/expo/src/components/toggle/{Toggle.tsx => toggle.tsx} (89%) rename apps/expo/src/components/ui/{ => bottom-sheet}/custom-bottom-sheet-modal.tsx (100%) rename apps/expo/src/components/ui/picker-modal/{picker.modal.tsx => picker-modal.tsx} (77%) create mode 100644 apps/expo/src/components/ui/svgMock.tsx rename apps/expo/src/utils/{ => trpc}/api.tsx (98%) delete mode 100644 packages/api/src/__test__/user.test.ts rename packages/api/src/__tests__/{post.test.ts => post.router.test.ts} (100%) create mode 100644 packages/api/src/__tests__/user.router.test.ts rename packages/api/src/router/{exercise.ts => exercise.router.ts} (98%) rename packages/api/src/router/{friend.ts => friend.router.ts} (100%) rename packages/api/src/router/{notif.ts => notif.router.ts} (100%) rename packages/api/src/router/{post.ts => post.router.ts} (100%) rename packages/api/src/router/{spotify.ts => spotify.router.ts} (100%) rename packages/api/src/router/{user.ts => user.router.ts} (100%) rename packages/api/src/router/{workout.ts => workout.router.ts} (100%) diff --git a/apps/expo/app.config.ts b/apps/expo/app.config.ts index 5d7f2f8c..e1a4c295 100644 --- a/apps/expo/app.config.ts +++ b/apps/expo/app.config.ts @@ -21,6 +21,7 @@ const defineConfig = (): ExpoConfig => ({ ios: { bundleIdentifier: 'your.bundle.identifier', supportsTablet: true, + // associatedDomains: ['applinks:clerk.helping.lemming-64.lclstage.dev'], }, android: { package: 'your.bundle.identifier', @@ -28,6 +29,20 @@ const defineConfig = (): ExpoConfig => ({ 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: { @@ -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', diff --git a/apps/expo/jest.config.ts b/apps/expo/jest.config.ts index 9fd9ce81..28910567 100644 --- a/apps/expo/jest.config.ts +++ b/apps/expo/jest.config.ts @@ -3,6 +3,7 @@ import type { Config } from 'jest' const config: Config = { coverageDirectory: './jest-coverage/', setupFilesAfterEnv: ['/setup-jest.js'], + testTimeout: 60000, collectCoverageFrom: [ '**/*.{ts,tsx}', '!**/node_modules/**', @@ -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/**', @@ -31,8 +34,6 @@ const config: Config = { '!**/(inbox)/**', '!**/(friends)/**', '!**/(workout)/**', - - '!**/picker-modal/**', ], // coverageThreshold: { // global: { @@ -52,8 +53,8 @@ const config: Config = { preset: 'jest-expo', moduleNameMapper: { - '~/(.*)': '/src/$1', - '\\.svg$': '/src/layouts/headers/svgMock.tsx', + '~/(.*)' : '/src/$1', + '\\.svg$': '/src/components/ui/svgMock.tsx', }, } diff --git a/apps/expo/src/components/notif/__tests__/FriendRequestNotif.test.tsx b/apps/expo/src/__tests__/FriendRequestNotif.test.tsx similarity index 97% rename from apps/expo/src/components/notif/__tests__/FriendRequestNotif.test.tsx rename to apps/expo/src/__tests__/FriendRequestNotif.test.tsx index fa102f71..b328d74a 100644 --- a/apps/expo/src/components/notif/__tests__/FriendRequestNotif.test.tsx +++ b/apps/expo/src/__tests__/FriendRequestNotif.test.tsx @@ -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(() => ({ diff --git a/apps/expo/src/components/notif/__tests__/NudgeNotif.test.tsx b/apps/expo/src/__tests__/NudgeNotif.test.tsx similarity index 100% rename from apps/expo/src/components/notif/__tests__/NudgeNotif.test.tsx rename to apps/expo/src/__tests__/NudgeNotif.test.tsx diff --git a/apps/expo/src/components/timeAgo/TimeAgo.test.tsx b/apps/expo/src/__tests__/TimeAgo.test.tsx similarity index 97% rename from apps/expo/src/components/timeAgo/TimeAgo.test.tsx rename to apps/expo/src/__tests__/TimeAgo.test.tsx index 7aaecd90..df3b798d 100644 --- a/apps/expo/src/components/timeAgo/TimeAgo.test.tsx +++ b/apps/expo/src/__tests__/TimeAgo.test.tsx @@ -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', () => { /* */ diff --git a/apps/expo/src/components/notif/__tests__/__snapshots__/FriendRequestNotif.test.tsx.snap b/apps/expo/src/__tests__/__snapshots__/FriendRequestNotif.test.tsx.snap similarity index 99% rename from apps/expo/src/components/notif/__tests__/__snapshots__/FriendRequestNotif.test.tsx.snap rename to apps/expo/src/__tests__/__snapshots__/FriendRequestNotif.test.tsx.snap index 16bf51d5..284f2ed1 100644 --- a/apps/expo/src/components/notif/__tests__/__snapshots__/FriendRequestNotif.test.tsx.snap +++ b/apps/expo/src/__tests__/__snapshots__/FriendRequestNotif.test.tsx.snap @@ -152,7 +152,7 @@ exports[`FriendRequestNotif should render sender's username and content 1`] = ` } testID="timeAgoText" > - 3 weeks ago + 4 weeks ago diff --git a/apps/expo/src/components/notif/__tests__/__snapshots__/NudgeNotif.test.tsx.snap b/apps/expo/src/__tests__/__snapshots__/NudgeNotif.test.tsx.snap similarity index 99% rename from apps/expo/src/components/notif/__tests__/__snapshots__/NudgeNotif.test.tsx.snap rename to apps/expo/src/__tests__/__snapshots__/NudgeNotif.test.tsx.snap index d2b060a5..d3bc3d4f 100644 --- a/apps/expo/src/components/notif/__tests__/__snapshots__/NudgeNotif.test.tsx.snap +++ b/apps/expo/src/__tests__/__snapshots__/NudgeNotif.test.tsx.snap @@ -106,7 +106,7 @@ exports[`NudgeNotif 1`] = ` } testID="timeAgoText" > - 3 weeks ago + 4 weeks ago diff --git a/apps/expo/src/components/timeAgo/__snapshots__/TimeAgo.test.tsx.snap b/apps/expo/src/__tests__/__snapshots__/TimeAgo.test.tsx.snap similarity index 100% rename from apps/expo/src/components/timeAgo/__snapshots__/TimeAgo.test.tsx.snap rename to apps/expo/src/__tests__/__snapshots__/TimeAgo.test.tsx.snap diff --git a/apps/expo/src/components/message/__snapshots__/messageInput.test.tsx.snap b/apps/expo/src/__tests__/__snapshots__/messageInput.test.tsx.snap similarity index 100% rename from apps/expo/src/components/message/__snapshots__/messageInput.test.tsx.snap rename to apps/expo/src/__tests__/__snapshots__/messageInput.test.tsx.snap diff --git a/apps/expo/src/components/toggle/__snapshots__/Toggle.test.tsx.snap b/apps/expo/src/__tests__/__snapshots__/toggle.test.tsx.snap similarity index 89% rename from apps/expo/src/components/toggle/__snapshots__/Toggle.test.tsx.snap rename to apps/expo/src/__tests__/__snapshots__/toggle.test.tsx.snap index afce40b2..93189015 100644 --- a/apps/expo/src/components/toggle/__snapshots__/Toggle.test.tsx.snap +++ b/apps/expo/src/__tests__/__snapshots__/toggle.test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Toggle 1`] = ` +exports[`Toggle component should match snapshop 1`] = ` @@ -78,6 +81,9 @@ exports[`Toggle 1`] = ` "fontSize": 30, } } - /> + testID="toggle-label" + > + Test + `; diff --git a/apps/expo/src/__tests__/headers.test.tsx b/apps/expo/src/__tests__/headers.test.tsx new file mode 100644 index 00000000..ac908338 --- /dev/null +++ b/apps/expo/src/__tests__/headers.test.tsx @@ -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() + expect(getByText('BARBELL')).toBeTruthy() + }) +}) + +describe('FriendsHeader', () => { + it('renders correctly', () => { + const { getByText } = render() + expect(getByText('Friends List')).toBeTruthy() + }) + + it('navigates back on press', () => { + const { getByTestId } = render() + 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() + const button = getByTestId('inbox-header-button') + expect(button).toBeTruthy() + fireEvent.press(button) + expect(router.back).toHaveBeenCalled() + }) +}) + +describe('WorkoutHeader', () => { + it('renders correctly', () => { + const { getByText } = render() + expect(getByText('BARBELL')).toBeTruthy() + const { getByTestId } = render() + const button = getByTestId('workout-header-button') + fireEvent.press(button) + expect(router.back).toHaveBeenCalled() + }) +}) diff --git a/apps/expo/src/components/message/messageInput.test.tsx b/apps/expo/src/__tests__/messageInput.test.tsx similarity index 74% rename from apps/expo/src/components/message/messageInput.test.tsx rename to apps/expo/src/__tests__/messageInput.test.tsx index bbd6019e..98b47199 100644 --- a/apps/expo/src/components/message/messageInput.test.tsx +++ b/apps/expo/src/__tests__/messageInput.test.tsx @@ -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() diff --git a/apps/expo/src/components/auth/sign-in-w-google.test.tsx b/apps/expo/src/__tests__/sign-in-w-google.test.tsx.txt similarity index 100% rename from apps/expo/src/components/auth/sign-in-w-google.test.tsx rename to apps/expo/src/__tests__/sign-in-w-google.test.tsx.txt diff --git a/apps/expo/src/components/auth/sign-out.test.tsx b/apps/expo/src/__tests__/sign-out.test.tsx similarity index 94% rename from apps/expo/src/components/auth/sign-out.test.tsx rename to apps/expo/src/__tests__/sign-out.test.tsx index 90faa611..f12a0b6c 100644 --- a/apps/expo/src/components/auth/sign-out.test.tsx +++ b/apps/expo/src/__tests__/sign-out.test.tsx @@ -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 } diff --git a/apps/expo/src/__tests__/toggle.test.tsx b/apps/expo/src/__tests__/toggle.test.tsx new file mode 100644 index 00000000..3387d234 --- /dev/null +++ b/apps/expo/src/__tests__/toggle.test.tsx @@ -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( {}} 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( + , + ) + 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( + {}} label='Test' />, + ) + const toggleCircle = getByTestId('toggle-circle') + + expect(toggleCircle.props.style.marginLeft).toBeCloseTo(screenWidth * 0.01, 1) + + await act(async () => { + rerender( {}} 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( + {}} 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( {}} 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( {}} label='Test' />) + expect(toJSON()).toMatchSnapshot() + }) +}) diff --git a/apps/expo/src/components/tracker/__snapshots__/set-entry-header.test.tsx.snap b/apps/expo/src/__tests__/tracker/__snapshots__/set-entry-header.test.tsx.snap similarity index 100% rename from apps/expo/src/components/tracker/__snapshots__/set-entry-header.test.tsx.snap rename to apps/expo/src/__tests__/tracker/__snapshots__/set-entry-header.test.tsx.snap diff --git a/apps/expo/src/components/tracker/exercise-entry.test.tsx b/apps/expo/src/__tests__/tracker/exercise-entry.test.tsx similarity index 100% rename from apps/expo/src/components/tracker/exercise-entry.test.tsx rename to apps/expo/src/__tests__/tracker/exercise-entry.test.tsx diff --git a/apps/expo/src/components/tracker/set-entry-header.test.tsx b/apps/expo/src/__tests__/tracker/set-entry-header.test.tsx similarity index 100% rename from apps/expo/src/components/tracker/set-entry-header.test.tsx rename to apps/expo/src/__tests__/tracker/set-entry-header.test.tsx diff --git a/apps/expo/src/components/tracker/set-entry.test.tsx b/apps/expo/src/__tests__/tracker/set-entry.test.tsx similarity index 100% rename from apps/expo/src/components/tracker/set-entry.test.tsx rename to apps/expo/src/__tests__/tracker/set-entry.test.tsx diff --git a/apps/expo/src/components/tracker/workout-timer.test.tsx b/apps/expo/src/__tests__/tracker/workout-timer.test.tsx similarity index 100% rename from apps/expo/src/components/tracker/workout-timer.test.tsx rename to apps/expo/src/__tests__/tracker/workout-timer.test.tsx diff --git a/apps/expo/src/components/tracker/workout-tracker-header.test.tsx b/apps/expo/src/__tests__/tracker/workout-tracker-header.test.tsx similarity index 100% rename from apps/expo/src/components/tracker/workout-tracker-header.test.tsx rename to apps/expo/src/__tests__/tracker/workout-tracker-header.test.tsx diff --git a/apps/expo/src/components/tracker/workout-tracker.test.tsx b/apps/expo/src/__tests__/tracker/workout-tracker.test.tsx similarity index 100% rename from apps/expo/src/components/tracker/workout-tracker.test.tsx rename to apps/expo/src/__tests__/tracker/workout-tracker.test.tsx diff --git a/apps/expo/src/components/ui/search-bar/SearchBar.test.tsx b/apps/expo/src/__tests__/ui/SearchBar.test.tsx similarity index 83% rename from apps/expo/src/components/ui/search-bar/SearchBar.test.tsx rename to apps/expo/src/__tests__/ui/SearchBar.test.tsx index 4b79a157..f6f8be2e 100644 --- a/apps/expo/src/components/ui/search-bar/SearchBar.test.tsx +++ b/apps/expo/src/__tests__/ui/SearchBar.test.tsx @@ -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 = () => { @@ -20,8 +20,7 @@ test('SearchBar', async () => { } const listToFilter = [item1, item2, item3] - const [filteredList, setFilteredList] = useState(listToFilter) - + const [filteredList, setFilteredList] = useState(listToFilter) return } diff --git a/apps/expo/src/components/ui/bottom-sheet/__snapshots__/bottom-sheet.test.tsx.snap b/apps/expo/src/__tests__/ui/__snapshots__/bottom-sheet.test.tsx.snap similarity index 100% rename from apps/expo/src/components/ui/bottom-sheet/__snapshots__/bottom-sheet.test.tsx.snap rename to apps/expo/src/__tests__/ui/__snapshots__/bottom-sheet.test.tsx.snap diff --git a/apps/expo/src/components/ui/button/__snapshots__/button.test.tsx.snap b/apps/expo/src/__tests__/ui/__snapshots__/button.test.tsx.snap similarity index 100% rename from apps/expo/src/components/ui/button/__snapshots__/button.test.tsx.snap rename to apps/expo/src/__tests__/ui/__snapshots__/button.test.tsx.snap diff --git a/apps/expo/src/components/ui/bottom-sheet/bottom-sheet.test.tsx b/apps/expo/src/__tests__/ui/bottom-sheet.test.tsx similarity index 91% rename from apps/expo/src/components/ui/bottom-sheet/bottom-sheet.test.tsx rename to apps/expo/src/__tests__/ui/bottom-sheet.test.tsx index 872b7d47..00431727 100644 --- a/apps/expo/src/components/ui/bottom-sheet/bottom-sheet.test.tsx +++ b/apps/expo/src/__tests__/ui/bottom-sheet.test.tsx @@ -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 diff --git a/apps/expo/src/components/ui/button/button.test.tsx b/apps/expo/src/__tests__/ui/button.test.tsx similarity index 94% rename from apps/expo/src/components/ui/button/button.test.tsx rename to apps/expo/src/__tests__/ui/button.test.tsx index 0b0d1e2d..da0e075f 100644 --- a/apps/expo/src/components/ui/button/button.test.tsx +++ b/apps/expo/src/__tests__/ui/button.test.tsx @@ -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' diff --git a/apps/expo/src/__tests__/ui/picker-modal/__snapshots__/action-button.test.tsx.snap b/apps/expo/src/__tests__/ui/picker-modal/__snapshots__/action-button.test.tsx.snap new file mode 100644 index 00000000..8a85ac3f --- /dev/null +++ b/apps/expo/src/__tests__/ui/picker-modal/__snapshots__/action-button.test.tsx.snap @@ -0,0 +1,73 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ActionButton matches snapshot 1`] = ` +[ + + + Snapshot Test + + , + , +] +`; diff --git a/apps/expo/src/__tests__/ui/picker-modal/__snapshots__/divider.test.tsx.snap b/apps/expo/src/__tests__/ui/picker-modal/__snapshots__/divider.test.tsx.snap new file mode 100644 index 00000000..bd7a7b4e --- /dev/null +++ b/apps/expo/src/__tests__/ui/picker-modal/__snapshots__/divider.test.tsx.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Divider matches snapshot 1`] = ` + +`; diff --git a/apps/expo/src/__tests__/ui/picker-modal/__snapshots__/picker-modal.test.tsx.snap b/apps/expo/src/__tests__/ui/picker-modal/__snapshots__/picker-modal.test.tsx.snap new file mode 100644 index 00000000..df75c3fa --- /dev/null +++ b/apps/expo/src/__tests__/ui/picker-modal/__snapshots__/picker-modal.test.tsx.snap @@ -0,0 +1,262 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PickerModal renders correctly and matches snapshot 1`] = ` + + + + + + + + + Option 1 + + + + + + Option 2 + + + + + + +`; diff --git a/apps/expo/src/__tests__/ui/picker-modal/action-button.test.tsx b/apps/expo/src/__tests__/ui/picker-modal/action-button.test.tsx new file mode 100644 index 00000000..166a3258 --- /dev/null +++ b/apps/expo/src/__tests__/ui/picker-modal/action-button.test.tsx @@ -0,0 +1,51 @@ +import React from 'react' +import { TouchableOpacity, TouchableOpacityProps } from 'react-native' + +import { fireEvent, render } from '@testing-library/react-native' + +import ActionButton from '~/components/ui/picker-modal/action-button/action-button' + +interface MockTouchableProps extends TouchableOpacityProps { + testID?: string +} + +const MockTouchable: React.FC = ({ children, onPress, testID, ...props }) => ( + + {children} + +) + +describe('ActionButton', () => { + it('renders correctly with text', () => { + const { getByText } = render( + , + ) + expect(getByText('thienguen')).toBeTruthy() + }) + + it('handles press events', () => { + const onPressMock = jest.fn() + const { getByTestId } = render( + , + ) + fireEvent.press(getByTestId('action-button')) + expect(onPressMock).toHaveBeenCalled() + }) + + it('conditionally renders the Divider', () => { + const { queryByTestId } = render( + , + ) + // since the `queryByTestId` for 'divider' would not work + // because the Divider itself does not accept testID as a prop, + expect(queryByTestId('divider')).toBeNull() + }) + + it('matches snapshot', () => { + const { toJSON } = render( + , + ) + + expect(toJSON()).toMatchSnapshot() + }) +}) diff --git a/apps/expo/src/__tests__/ui/picker-modal/divider.test.tsx b/apps/expo/src/__tests__/ui/picker-modal/divider.test.tsx new file mode 100644 index 00000000..489300df --- /dev/null +++ b/apps/expo/src/__tests__/ui/picker-modal/divider.test.tsx @@ -0,0 +1,23 @@ +import React from 'react' + +import { render } from '@testing-library/react-native' + +import Divider from '~/components/ui/picker-modal/divider/divider' + +describe('Divider', () => { + it('renders correctly', () => { + const { getByTestId } = render() + expect(getByTestId('divider')).toBeTruthy() + }) + + it('applies custom styles', () => { + const customStyle = { backgroundColor: 'blue' } + const { getByTestId } = render() + expect(getByTestId('divider')).toHaveStyle(customStyle) + }) + + it('matches snapshot', () => { + const { toJSON } = render() + expect(toJSON()).toMatchSnapshot() + }) +}) diff --git a/apps/expo/src/__tests__/ui/picker-modal/picker-modal.test.tsx b/apps/expo/src/__tests__/ui/picker-modal/picker-modal.test.tsx new file mode 100644 index 00000000..983bbc21 --- /dev/null +++ b/apps/expo/src/__tests__/ui/picker-modal/picker-modal.test.tsx @@ -0,0 +1,27 @@ +import React from 'react' + +import { render } from '@testing-library/react-native' + +import PickerModal from '~/components/ui/picker-modal/picker-modal' + +describe('PickerModal', () => { + it('renders correctly and matches snapshot', () => { + const mockData = ['Option 1', 'Option 2'] + const mockOnPress = jest.fn() + const mockOnCancelPress = jest.fn() + const mockOnBackdropPress = jest.fn() + + const pickmepickme = render( + , + ) + + expect(pickmepickme).toMatchSnapshot() + }) +}) diff --git a/apps/expo/src/__tests__/util/calculate-time.test.ts b/apps/expo/src/__tests__/util/calculate-time.test.ts new file mode 100644 index 00000000..6b316774 --- /dev/null +++ b/apps/expo/src/__tests__/util/calculate-time.test.ts @@ -0,0 +1,80 @@ +import calculateTimeAgo from '../../utils/calculateTime' + +describe('calculateTimeAgo', () => { + test('returns empty string for future dates', () => { + const futureDate = new Date() + futureDate.setMinutes(futureDate.getMinutes() + 5) // 5 minutes into the future + expect(calculateTimeAgo(futureDate)).toBe('') + }) + + test('returns "Just now" for times less than a minute ago', () => { + const justNow = new Date() + expect(calculateTimeAgo(justNow)).toBe('Just now') + }) + + test('returns minutes correctly', () => { + const tenMinutesAgo = new Date(new Date().getTime() - 10 * 60000) + expect(calculateTimeAgo(tenMinutesAgo)).toBe('10 minutes ago') + }) + + test('returns hours correctly', () => { + const twoHoursAgo = new Date(new Date().getTime() - 2 * 3600000) + expect(calculateTimeAgo(twoHoursAgo)).toBe('2 hours ago') + }) + + test('returns days correctly', () => { + const threeDaysAgo = new Date(new Date().getTime() - 3 * 86400000) + expect(calculateTimeAgo(threeDaysAgo)).toBe('3 days ago') + }) + + test('returns weeks correctly', () => { + const fourWeeksAgo = new Date(new Date().getTime() - 4 * 604800000) + expect(calculateTimeAgo(fourWeeksAgo)).toBe('4 weeks ago') + }) + + test('handles invalid dates gracefully', () => { + const invalidDate = new Date('not a real date') + expect(calculateTimeAgo(invalidDate)).toBe('') + }) + + const oneMinuteAgo = new Date(new Date().getTime() - 60 * 1000) + test('returns "1 minute ago" for times exactly one minute ago', () => { + expect(calculateTimeAgo(oneMinuteAgo)).toBe('1 minute ago') + }) + + const fiftyNineMinutesAgo = new Date(new Date().getTime() - 59 * 60 * 1000) + test('returns minutes correctly just before an hour', () => { + expect(calculateTimeAgo(fiftyNineMinutesAgo)).toBe('59 minutes ago') + }) + + const oneHourAgo = new Date(new Date().getTime() - 60 * 60 * 1000) + test('returns "1 hour ago" for times exactly one hour ago', () => { + expect(calculateTimeAgo(oneHourAgo)).toBe('1 hour ago') + }) + + const twentyThreeHoursAgo = new Date(new Date().getTime() - 23 * 3600 * 1000) + test('returns hours correctly just before a day', () => { + expect(calculateTimeAgo(twentyThreeHoursAgo)).toBe('23 hours ago') + }) + + const oneDayAgo = new Date(new Date().getTime() - 24 * 3600 * 1000) + test('returns "1 day ago" for times exactly one day ago', () => { + expect(calculateTimeAgo(oneDayAgo)).toBe('1 day ago') + }) + + const sixDaysAgo = new Date(new Date().getTime() - 6 * 86400 * 1000) + test('returns days correctly just before a week', () => { + expect(calculateTimeAgo(sixDaysAgo)).toBe('6 days ago') + }) + + const oneWeekAgo = new Date(new Date().getTime() - 7 * 86400 * 1000) + test('returns "1 week ago" for times exactly one week ago', () => { + expect(calculateTimeAgo(oneWeekAgo)).toBe('1 week ago') + }) + + // Edge case: what if the date is right now, ensuring "Just now" is consistent + test('returns "Just now" for the current time', () => { + const rightNow = new Date() + expect(calculateTimeAgo(rightNow)).toBe('Just now') + }) +}) diff --git a/apps/expo/src/__tests__/util/common.test.ts b/apps/expo/src/__tests__/util/common.test.ts new file mode 100644 index 00000000..1d9452ca --- /dev/null +++ b/apps/expo/src/__tests__/util/common.test.ts @@ -0,0 +1,59 @@ +import getErrorMessage, { makeChatName } from '~/utils/common' + +describe('getErrorMessage', () => { + test('returns message for Error instances', () => { + const errorMessage = 'This is an error' + const errorInstance = new Error(errorMessage) + expect(getErrorMessage(errorInstance)).toBe(errorMessage) + }) + + test('returns JSON string for object errors', () => { + const objectError = { msg: 'This is an object error' } + expect(getErrorMessage(objectError)).toBe(JSON.stringify(objectError)) + }) + + test('returns string for string errors', () => { + const stringError = 'This is a string error' + expect(getErrorMessage(stringError)).toBe(stringError) + }) + + test('returns string representation for number errors', () => { + const numberError = 404 + expect(getErrorMessage(numberError)).toBe('404') + }) + + test('handles null gracefully', () => { + const nullError = null + expect(getErrorMessage(nullError)).toBe('null') + }) + + test('handles undefined gracefully', () => { + const undefinedError = undefined + expect(getErrorMessage(undefinedError)).toBe('undefined') + }) +}) + +describe('makeChatName', () => { + const users = [ + { username: 'Alice' }, + { username: 'Bob' }, + { username: 'Charlie' }, + { username: 'Dave' }, + ] + + test('formats chat name for exactly three users, excluding the current user', () => { + const currentUser = { username: 'Dave' } + expect(makeChatName(users, currentUser)).toBe('Alice, Bob, + 1 more') + }) + + test('formats chat name for more than two users, excluding the current user, without additional text', () => { + const currentUser = { username: 'Dave' } + expect(makeChatName(users, currentUser)).toBe('Alice, Bob, + 1 more') + }) + + test('formats chat name for two users exactly, excluding the current user', () => { + const twoUsers = [{ username: 'Alice' }, { username: 'Bob' }, { username: 'Dave' }] + const currentUser = { username: 'Dave' } + expect(makeChatName(twoUsers, currentUser)).toBe('Alice and Bob') + }) +}) diff --git a/apps/expo/src/utils/timeFormatter.test.ts b/apps/expo/src/__tests__/util/timeFormatter.test.ts similarity index 90% rename from apps/expo/src/utils/timeFormatter.test.ts rename to apps/expo/src/__tests__/util/timeFormatter.test.ts index b9fe01ce..e2acd4f2 100644 --- a/apps/expo/src/utils/timeFormatter.test.ts +++ b/apps/expo/src/__tests__/util/timeFormatter.test.ts @@ -1,4 +1,4 @@ -import formatTime from './timerFormatter' +import formatTime from '../../utils/timerFormatter' test('formatTime', () => { expect(formatTime(0)).toBe('0:00') diff --git a/apps/expo/src/utils/usernameGenerator.test.ts b/apps/expo/src/__tests__/util/usernameGenerator.test.ts similarity index 100% rename from apps/expo/src/utils/usernameGenerator.test.ts rename to apps/expo/src/__tests__/util/usernameGenerator.test.ts diff --git a/apps/expo/src/app/(dashboard)/_layout.tsx b/apps/expo/src/app/(dashboard)/_layout.tsx index 7076c183..90e4e205 100644 --- a/apps/expo/src/app/(dashboard)/_layout.tsx +++ b/apps/expo/src/app/(dashboard)/_layout.tsx @@ -12,7 +12,7 @@ import Profile from '~assets/svgs/profile.svg' // import type { CustomBottomSheetModalRef } from '~/components/ui/custom-bottom-sheet-modal' // import Button from '~/components/ui/button/button' // import CustomBottomSheetModal from '~/components/ui/custom-bottom-sheet-modal' -import PickerModal from '~/components/ui/picker-modal/picker.modal' +import PickerModal from '~/components/ui/picker-modal/picker-modal' import colors from '~/styles/colors' import { cn } from '~/utils/cn' diff --git a/apps/expo/src/app/(dashboard)/account-settings.tsx b/apps/expo/src/app/(dashboard)/account-settings.tsx index 2d8e474b..a7758f89 100644 --- a/apps/expo/src/app/(dashboard)/account-settings.tsx +++ b/apps/expo/src/app/(dashboard)/account-settings.tsx @@ -15,8 +15,8 @@ import FontAwesome5 from '@expo/vector-icons/FontAwesome5' import { useGlobalContext } from '~/context/global-context' import colors from '~/styles/colors' -import { api } from '~/utils/api' import { FA } from '~/utils/constants' +import { api } from '~/utils/trpc/api' interface NavigationListItem { title: string @@ -51,26 +51,26 @@ const tailwindClasses = { } const accountItems: NavigationListItem[] = [ - { title: 'Personal Data', iconName: 'user', onPress: () => router.push('/user/personal-data') }, - { title: 'Achievements', iconName: 'award', onPress: () => router.push('/user/achievements') }, + { title: 'Personal Data', iconName: 'user', onPress: () => router.push('user/personal-data') }, + { title: 'Achievements', iconName: 'award', onPress: () => router.push('user/achievements') }, { title: 'Activity History', iconName: 'history', - onPress: () => router.push('/user/activity-history'), + onPress: () => router.push('user/activity-history'), }, { title: 'Workout Progress', iconName: 'chart-pie', - onPress: () => router.push('/user/workout-progress'), + onPress: () => router.push('user/workout-progress'), }, ] const otherItems: NavigationListItem[] = [ - { title: 'Contact Us', iconName: 'envelope', onPress: () => router.push('/contact-us') }, + { title: 'Contact Us', iconName: 'envelope', onPress: () => router.push('/') }, { title: 'Privacy Policy', iconName: 'shield-alt', - onPress: () => router.push('/privacy-policy'), + onPress: () => router.push('/'), }, ] @@ -79,8 +79,6 @@ const AccountSettings = () => { // FIXME: if (!userData) { - // TODO: Add a no user found component - console.log('USER DATA IS NULL, MAKE SURE YOUR DB IS RUNNING...') return null } diff --git a/apps/expo/src/app/(dashboard)/index.tsx b/apps/expo/src/app/(dashboard)/index.tsx index 2d3a6c1e..6eb37d55 100644 --- a/apps/expo/src/app/(dashboard)/index.tsx +++ b/apps/expo/src/app/(dashboard)/index.tsx @@ -14,7 +14,7 @@ const Dashboard = () => { ) } diff --git a/apps/expo/src/components/auth/sign-out.tsx b/apps/expo/src/components/auth/sign-out.tsx index dccbff06..fff68504 100644 --- a/apps/expo/src/components/auth/sign-out.tsx +++ b/apps/expo/src/components/auth/sign-out.tsx @@ -12,15 +12,27 @@ export const SignOut = () => { return null } + const onSignOutPress = async () => { + try { + await signOut() + } catch (err: any) { + // log('Error:> ' + err?.status || '') + // log('Error:> ' + err?.errors ? JSON.stringify(err.errors) : err) + console.log('Error:> ' + err?.status || '') + console.log('Error:> ' + err?.errors ? JSON.stringify(err.errors) : err) + } + } + return (