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
Show file tree
Hide file tree
Changes from 20 commits
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
51 changes: 22 additions & 29 deletions .babelrc.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
{
"sourceType": "unambiguous",
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"targets": {
"chrome": 100
"node": "14",
"browsers": ">0.25%, not ie 11, not op_mini all"
}
}
],
"@babel/preset-typescript",
["@babel/preset-react", { "runtime": "automatic" }]
"@babel/preset-react",
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-proposal-optional-chaining",
[
"module-resolver",
{
"extensions": [".ts", ".tsx"],
"root": "./src",
"alias": {
"#components": "./src/components",
"#types": ["./src/types"],
"#hooks": ["./src/hooks"],
"#lib": ["./src/lib"]
}
}
],
[
"@emotion",
{
"sourceMap": true,
"autoLabel": "dev-only",
"labelFormat": "[local]",
"cssPropOptimization": true
}
]
]
"env": {
"node": {
"plugins": [
[
"babel-plugin-transform-import-ignore",
{
"patterns": [
"*.css",
"react",
"react-dom",
"framer-motion"
]
}
]
]
}
}
}
59 changes: 58 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules
.cache
dist
.idea
.vscode


# storybook
Expand All @@ -17,3 +18,5 @@ storybook-static
# public folder temp files
public
/stories/Uploader.stories.js

coverage
3 changes: 1 addition & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ tsconfig.json
postcss.config.js
tailwind.config.js
tsdx.config.js
dist/hooks/useUpup.d.ts
dist/version.ts
!dist
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
strict-peer-dependencies=false
legacy-peer-deps=true
auto-install-peers=true
node-linker=hoisted
shamefully-hoist=true
5 changes: 4 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"plugins": [
"prettier-plugin-organize-imports",
"prettier-plugin-tailwindcss"
]
],
"importOrder": ["^react$", "^[^.]", "^\\."],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true
}
30 changes: 0 additions & 30 deletions .storybook/main.js

This file was deleted.

83 changes: 64 additions & 19 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,77 @@
// Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite)
import type { StorybookConfig } from '@storybook/react-webpack5'

const config: StorybookConfig = {
framework: '@storybook/react-webpack5',
stories: ['../**/*.mdx', '../**/*.stories.@(js|jsx|mjs|ts|tsx)'],
/** @type { import('@storybook/react-webpack5').StorybookConfig } */
const config = {
framework: {
name: '@storybook/react-webpack5',
options: {},
},
stories: ['../stories/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
// Other addons go here
// {
// name: '@storybook/addon-docs',
// options: {
// mdxPluginOptions: {
// mdxCompileOptions: {
// remarkPlugins: [remarkGfm],
// },
// },
// },
// },
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-docs',
{
name: '@storybook/addon-styling',
options: {
// Check out https://github.com/storybookjs/addon-styling/blob/main/docs/api.md
// For more details on this addon's options.
postCss: {
implementation: require.resolve('postcss'),
},
},
},
],
core: {
builder: '@storybook/builder-webpack5',
},
webpackFinal: async config => {
// Remove default rules for .md files
config.module.rules = config.module.rules.filter(
rule => !rule.test?.test?.('.md'),
)

return {
...config,
resolve: {
...config.resolve,
fallback: {
...config.resolve?.fallback,
'highlight.js/lib/core': require.resolve(
'highlight.js/lib/core',
),
'highlight.js/lib/languages/c-like': false,
'highlight.js/lib/languages/sql_more': false,
},
alias: {
...config.resolve?.alias,
'lowlight/lib/core': require.resolve('lowlight'),
'react-syntax-highlighter/dist/esm/light': require.resolve(
'react-syntax-highlighter/dist/cjs/light',
),
'react-syntax-highlighter/dist/esm/light-async':
require.resolve(
'react-syntax-highlighter/dist/cjs/light-async',
),
'@emotion/react': require.resolve('@emotion/react'),
'@emotion/styled': require.resolve('@emotion/styled'),
},
},
module: {
...config.module,
rules: [
...config.module.rules,
{
test: /\.md$/,
type: 'javascript/auto',
},
{
test: /\.m?js$/,
resolve: {
fullySpecified: false,
},
},
],
},
}
},
}

export default config
2 changes: 1 addition & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../src/tailwind.css'
import '../src/frontend/tailwind.css'

// https://storybook.js.org/docs/react/writing-stories/parameters#global-parameters
export const parameters = {
Expand Down
15 changes: 15 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Preview } from '@storybook/react'

const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
}

export default preview
16 changes: 16 additions & 0 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
resolve: {
fallback: {
'highlight.js/lib/core': require.resolve('highlight.js/lib/core'),
},
},
module: {
rules: [
{
test: /\.js$/,
include: /node_modules\/lowlight/,
type: 'javascript/auto',
},
],
},
}
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,
},
},
}
Loading
Loading