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

feat: Added test infrastructure and initial component tests #253

Closed
wants to merge 26 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
38b9fd1
feat(security): implemented pre-signed URL upload approach
amjedidiah Nov 6, 2024
9569c41
fix(upload): resolved CORS issues in pre-signed URL upload
amjedidiah Nov 6, 2024
801c4ec
fix(app): build and prettier fixes
amjedidiah Nov 6, 2024
355cde2
chore(app): undoing unnecessary commit changes
amjedidiah Nov 12, 2024
ad9be44
feat(storage): implemented and refined cloud storage SDK integrations
amjedidiah Nov 14, 2024
61dc085
feat(storage): implemented Azure SDK integrations
amjedidiah Nov 15, 2024
7d7a98b
chore(app): removed todo from commit
amjedidiah Nov 15, 2024
cb659dc
refactor(app): streamline storageConfig prop values
amjedidiah Nov 17, 2024
84c8946
feat(storage): implemented DO SDK integrations
amjedidiah Nov 18, 2024
d9504af
feat(app): s3 compliant support
amjedidiah Nov 20, 2024
93a2502
feat(app): merged azure and s3 SDK into one
amjedidiah Nov 20, 2024
edfe2ea
fix(app): fixed console warning about ETag header
amjedidiah Nov 21, 2024
b0da73a
feat(app): backend logic
amjedidiah Nov 21, 2024
8a030c4
chore(app): build fixes and clean up
amjedidiah Nov 22, 2024
b565959
chore(app): better path resolutions and prettier fixes
amjedidiah Nov 22, 2024
a46fc3d
feat(app): dual builds
amjedidiah Nov 22, 2024
0291443
feat(app): successful merged builds
amjedidiah Nov 22, 2024
0320120
fix(app): prettier fixes
amjedidiah Nov 22, 2024
135ca18
fix(app): review fixes
amjedidiah Nov 25, 2024
d35a853
feat(tests): added comprehensive test setup
amjedidiah Nov 26, 2024
7602ba9
test(s3): added comprehensive tests for s3GeneratePresignedUrl and up…
amjedidiah Nov 26, 2024
6b9be4f
chore(test): setting threshold to 1 pending when others tests will be…
amjedidiah Nov 26, 2024
a06ad62
chore(app): fixed deprecated artifact actions version
amjedidiah Nov 26, 2024
a5b68a7
Merge branch 'master' into feat/test-setup
amjedidiah Nov 27, 2024
2f313a5
Merge branch 'master' into feat/test-setup
amjedidiah Dec 4, 2024
7e0af09
refactor(test): better arrangement in tests in central folder
amjedidiah Dec 4, 2024
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
Prev Previous commit
Next Next commit
feat(tests): added comprehensive test setup
- Configured Jest environment for React components and JSDOM
- Added setupTests with necessary mocks for Google, Framer Motion
- Implemented detailed test suite for MetaVersion, checkFileType, and s3GeneratePresignedUrl
amjedidiah committed Nov 26, 2024
commit d35a8538040b93b1adf90225f692dfc8b89a95d3
59 changes: 58 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -39,11 +39,52 @@ jobs:
- name: Prettier Check
run: pnpm run prettier-check

Test:
name: Run Tests
runs-on: ubuntu-latest
needs: [Prettier-check]
steps:
- name: Checkout repo
uses: actions/checkout@v3

- uses: actions/setup-node@v3
id: cache-primes
with:
node-version-file: '.nvmrc'

- name: Setup PNPM environment
if: steps.cache-primes.outputs.cache-hit != 'true'
run: |
npm install -g pnpm@latest
pnpm config set store-dir ~/.pnpm-store

- name: Cache PNPM dependencies
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-v3-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-v3-

- name: Install dependencies
if: steps.cache-primes.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile

- name: Run Tests
run: pnpm run test:ci

- name: Upload coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
fail_ci_if_error: true
verbose: true

Build:
name: Build project
runs-on: ubuntu-latest
needs: [ Prettier-check ]
needs: [Prettier-check, Test]
steps:
- name: Checkout repo
uses: actions/checkout@v3
@@ -73,3 +114,19 @@ jobs:

- name: Build
run: pnpm run build

Status-Check:
name: Status Check
runs-on: ubuntu-latest
needs: [Prettier-check, Test, Build]
if: always()
steps:
- name: Check status
run: |
if [ "${{ needs.Prettier-check.result }}" != "success" ] || \
[ "${{ needs.Test.result }}" != "success" ] || \
[ "${{ needs.Build.result }}" != "success" ]; then
echo "One or more jobs failed"
exit 1
fi
echo "All jobs passed successfully"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -18,3 +18,5 @@ storybook-static
# public folder temp files
public
/stories/Uploader.stories.js

coverage
41 changes: 41 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/** @type {import('jest').Config} */
module.exports = {
roots: ['<rootDir>/src'],
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'],
moduleNameMapper: {
'^frontend/(.*)$': '<rootDir>/src/frontend/$1',
'^backend/(.*)$': '<rootDir>/src/backend/$1',
'^lib/(.*)$': '<rootDir>/src/lib/$1',
'\\.css$': 'identity-obj-proxy',
'^@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+\\.(t|j)sx?$': [
'ts-jest',
{
tsconfig: 'tsconfig.json',
},
],
},
transformIgnorePatterns: ['node_modules/(?!(@mui|framer-motion)/)'],
testMatch: [
'<rootDir>/src/**/__tests__/**/*.{ts,tsx}',
'<rootDir>/src/**/*.{spec,test}.{ts,tsx}',
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!src/**/*.stories.{ts,tsx}',
'!src/**/*.d.ts',
'!src/version.ts',
],
coverageThreshold: {
global: {
branches: 1,
functions: 1,
lines: 1,
statements: 1,
},
},
}
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -57,7 +57,10 @@
"build:browser": "tsdx build --entry ./src/index.browser.ts --tsconfig ./tsconfig.browser.json --format esm,cjs --name browser",
"build:node": "tsdx build --entry ./src/index.node.ts --tsconfig ./tsconfig.node.json --format cjs --name node",
"build": "node scripts/build.js",
"test": "tsdx test --passWithNoTests",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"test:ci": "jest --coverage --ci --maxWorkers=2",
"lint": "tsdx lint",
"prepare": "tsdx build",
"size": "size-limit",
@@ -99,6 +102,10 @@
"@storybook/react": "^7.6.20",
"@storybook/react-webpack5": "^7.6.20",
"@storybook/testing-library": "^0.2.2",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "29.5.11",
"@types/node": "^20.10.0",
"@types/pako": "^2.0.3",
"@types/react": "^18.2.39",
@@ -110,6 +117,10 @@
"babel-loader": "^9.1.3",
"highlight.js": "10.7.3",
"husky": "^8.0.3",
"identity-obj-proxy": "^3.0.0",
"jest": "29.7.0",
"jest-canvas-mock": "^2.5.2",
"jest-environment-jsdom": "29.7.0",
"lowlight": "1.20.0",
"postcss": "^8.4.31",
"prettier": "3.0.3",
@@ -124,6 +135,7 @@
"size-limit": "^10.0.3",
"storybook": "^7.5.3",
"tailwindcss": "^3.3.5",
"ts-jest": "29.1.1",
"tsdx": "^0.14.1",
"tslib": "^2.6.2",
"typescript": "^5.3.2",
Loading