-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
135 cicd jest integration step 1 (#145)
* 🗑️chore: install vitest, but wtf * 🗑️chore: install jst, BUT WTF * 🗑️chore: install jst II * 🗑️chore: init of api testing * Setup Jest testing for expo * Move cn to utils folder * 🗑️chore: 1.5 api tested PASSED * 🧙♀️api: users, excersize done * add unit tests for notif APIs * Add react testing library and fix jest config * Fix jest config to allow ts custom paths * 🚽api: sptofiy stuf * 🐛fix: sync sync syc2 * Fix expo vector icons import * unit tests for gcNotifs and RotatingBarbellIcon * Add MessageInput and TimeAgo unit tests * 🐛fix: sync sync sync33 * ✨feature: api testing done * ✨feature: acionaction * ✨feature: action action * Add unit tests for toggle component and privacy policy page * ✨feature: action 2 * ✨feature: action 3 * ✨feature: action 4 * ✨feature: action 5 * ✨feature: WE COOKED * ✨feature: forgor we seed * ✨feature: forgor we seed 2 * ✨feature: forgor we seed 3 * ✨feature: forgor we seed 4 * ✨feature: forgor we seed 5 * ✨feature: forgor we seed 6 * ✨feature: forgor we seed 7 * ✨feature: forgor we seed 8 --------- Co-authored-by: Marcos Villanueva <mva919@gmail.com> Co-authored-by: Taylor Finelli <taylorfinelli@Taylors-MacBook-Pro.local>
- Loading branch information
1 parent
71931ef
commit 68b6720
Showing
46 changed files
with
4,216 additions
and
1,276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,54 @@ | ||
name: Workflow for Codecov | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
env: | ||
DATABASE_URL: ${{ secrets.DATABASE_URL }} | ||
DIRECT_URL: ${{ secrets.DIRECT_URL }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8.x | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 18.x | ||
cache: 'pnpm' | ||
cache-dependency-path: '**/pnpm-lock.yaml' | ||
|
||
- name: Install root dependencies | ||
run: pnpm install --no-frozen-lockfile | ||
|
||
- name: Install dependencies and setup Prisma | ||
run: | | ||
cd packages/db && pnpm prisma generate && pnpm dotenv -e ../../.env prisma db push | ||
working-directory: . | ||
|
||
- name: Run tests and collect coverage | ||
run: | | ||
pnpm run jest | ||
env: | ||
CI: true | ||
|
||
- name: Run tests in expo | ||
run: | | ||
cd apps/expo && pnpm run test | ||
working-directory: . | ||
env: | ||
CI: true | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v4.0.1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
slug: UNLV-CS472-672/2024-S-GROUP3-Barbell | ||
slug: UNLV-CS472-672/2024-S-GROUP3-Barbell | ||
directory: ./coverage/ | ||
fail_ci_if_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type {Config} from 'jest'; | ||
|
||
const config: Config = { | ||
setupFilesAfterEnv: ['<rootDir>/setup-jest.js'], | ||
collectCoverageFrom: [ | ||
'**/*.{ts,tsx}', | ||
'!**/node_modules/**', | ||
'!**/vendor/**', | ||
'!**/app.config.ts', | ||
'!**/babel.config.ts', | ||
'!**/tailwind.config.ts', | ||
'!**/jest.config.ts', | ||
'!**/.expo/**', | ||
'!**/*.d.ts', | ||
'!index.ts', | ||
'!**/api.tsx', | ||
// need to remove in future v | ||
'!**/app/**', | ||
'!**/custom-bottom-sheet-modal.tsx', | ||
'!**/auth/**', | ||
"!**/notif/**", | ||
'!**/hooks/**', | ||
'!**/context/**', | ||
], | ||
// coverageThreshold: { | ||
// global: { | ||
// branches: 80, | ||
// functions: 80, | ||
// lines: 80, | ||
// statements: -10, | ||
// }, | ||
// }, | ||
// preset: 'ts-jest', | ||
// transform: { | ||
// '^.+\\.(ts|tsx)?$': 'ts-jest', | ||
// '^.+\\.(js|jsx)$': 'babel-jest', | ||
// } | ||
preset: 'jest-expo', | ||
moduleNameMapper: { | ||
"~/(.*)": "<rootDir>/src/$1" | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import '@testing-library/react-native/extend-expect'; |
25 changes: 25 additions & 0 deletions
25
apps/expo/src/app/__snapshots__/privacy-policy.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Privacy Policy Page 1`] = ` | ||
<RNCSafeAreaView | ||
edges={ | ||
{ | ||
"bottom": "additive", | ||
"left": "additive", | ||
"right": "additive", | ||
"top": "additive", | ||
} | ||
} | ||
> | ||
<Text | ||
style={ | ||
{ | ||
"padding": 30, | ||
"textAlign": "center", | ||
} | ||
} | ||
> | ||
PrivacyPolicy! | ||
</Text> | ||
</RNCSafeAreaView> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { render, screen } from '@testing-library/react-native' | ||
|
||
import PrivacyPolicy from './privacy-policy' | ||
|
||
test('Privacy Policy Page', () => { | ||
render(<PrivacyPolicy />) | ||
expect(screen.toJSON()).toMatchSnapshot() | ||
}) |
This file was deleted.
Oops, something went wrong.
95 changes: 95 additions & 0 deletions
95
apps/expo/src/components/message/__snapshots__/messageInput.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`MessageInput 1`] = ` | ||
<View | ||
onLayout={[Function]} | ||
style={ | ||
{ | ||
"flex": 1, | ||
"paddingBottom": 10, | ||
} | ||
} | ||
> | ||
<View | ||
style={ | ||
{ | ||
"flex": 1, | ||
"justifyContent": "flex-end", | ||
} | ||
} | ||
> | ||
<View | ||
style={ | ||
{ | ||
"alignItems": "center", | ||
"flexDirection": "row", | ||
"paddingHorizontal": 10, | ||
} | ||
} | ||
> | ||
<TextInput | ||
keyboardAppearance="dark" | ||
placeholder="Message..." | ||
placeholderTextColor="#CACACA" | ||
style={ | ||
{ | ||
"borderColor": "#272727", | ||
"borderRadius": 20, | ||
"borderWidth": 1, | ||
"color": "white", | ||
"flex": 1, | ||
"padding": 10, | ||
} | ||
} | ||
/> | ||
<View | ||
accessibilityState={ | ||
{ | ||
"busy": undefined, | ||
"checked": undefined, | ||
"disabled": undefined, | ||
"expanded": undefined, | ||
"selected": undefined, | ||
} | ||
} | ||
accessibilityValue={ | ||
{ | ||
"max": undefined, | ||
"min": undefined, | ||
"now": undefined, | ||
"text": undefined, | ||
} | ||
} | ||
accessible={true} | ||
collapsable={false} | ||
focusable={false} | ||
onClick={[Function]} | ||
onResponderGrant={[Function]} | ||
onResponderMove={[Function]} | ||
onResponderRelease={[Function]} | ||
onResponderTerminate={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
style={ | ||
{ | ||
"opacity": 1, | ||
} | ||
} | ||
> | ||
<View | ||
style={ | ||
{ | ||
"backgroundColor": "#48476D", | ||
"borderRadius": 20, | ||
"marginLeft": 10, | ||
"padding": 10, | ||
} | ||
} | ||
> | ||
<Text /> | ||
</View> | ||
</View> | ||
</View> | ||
</View> | ||
</View> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { render, screen } from '@testing-library/react-native' | ||
|
||
import MessageInput from './messageInput' | ||
|
||
test('MessageInput', async () => { | ||
render(<MessageInput />) | ||
expect(screen.toJSON()).toMatchSnapshot() | ||
}) |
9 changes: 9 additions & 0 deletions
9
apps/expo/src/components/notif/__tests__/RotatingBarbellIcon.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react-native' | ||
import RotatingBarbellIcon from '../dmNotifs/RotatingBarbellIcon' | ||
|
||
test('RotatingBarbellIcon', async () => { | ||
render(<RotatingBarbellIcon />) | ||
|
||
expect(screen.toJSON()).toMatchSnapshot() | ||
}) |
28 changes: 28 additions & 0 deletions
28
apps/expo/src/components/notif/__tests__/__snapshots__/RotatingBarbellIcon.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`RotatingBarbellIcon 1`] = ` | ||
<View | ||
style={ | ||
{ | ||
"alignItems": "center", | ||
"justifyContent": "center", | ||
"paddingTop": 20, | ||
} | ||
} | ||
> | ||
<View | ||
collapsable={false} | ||
style={ | ||
{ | ||
"transform": [ | ||
{ | ||
"rotate": "0deg", | ||
}, | ||
], | ||
} | ||
} | ||
> | ||
<Text /> | ||
</View> | ||
</View> | ||
`; |
3 changes: 3 additions & 0 deletions
3
apps/expo/src/components/notif/__tests__/__snapshots__/gcNotifs.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`RotatingBarbellIcon 1`] = `<View />`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react-native' | ||
import GcNotifs from '../gcNotifs' | ||
|
||
test('RotatingBarbellIcon', async () => { | ||
render(<GcNotifs />) | ||
|
||
expect(screen.toJSON()).toMatchSnapshot() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { render, screen } from '@testing-library/react-native' | ||
import TimeAgo from './TimeAgo' | ||
|
||
// Adjust the timeout for this test | ||
test('TimeAgo', async () => { | ||
const expectedCreatedAt = new Date('2021-01-01T00:00:00Z') // Corrected date string | ||
const expectedTimeAgo = '168 weeks ago' | ||
|
||
render(<TimeAgo createdAt={expectedCreatedAt} />) | ||
const timeAgoOutput = await screen.findByTestId('timeAgoText') | ||
|
||
expect(timeAgoOutput).toHaveTextContent(expectedTimeAgo) | ||
expect(screen.toJSON()).toMatchSnapshot() | ||
|
||
// The part below seems to be intended for testing bad date handling. | ||
// Ensure that your TimeAgo component and calculateTimeAgo function are designed to handle and test such cases correctly. | ||
// It's also not clear from the provided code how 'timeAgoBadDate' is set since the 'calculateTimeAgo' handling of bad dates is not shown. | ||
}, 10000); // Increase the timeout for this test |
Oops, something went wrong.