mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into refactor-listUnconfirmedContribution-to-adminListAllContribution
This commit is contained in:
commit
a15b3265de
158
.github/workflows/test.yml
vendored
158
.github/workflows/test.yml
vendored
@ -163,7 +163,6 @@ jobs:
|
|||||||
locales_frontend:
|
locales_frontend:
|
||||||
name: Locales - Frontend
|
name: Locales - Frontend
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build_test_frontend]
|
|
||||||
steps:
|
steps:
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# CHECKOUT CODE ##########################################################
|
# CHECKOUT CODE ##########################################################
|
||||||
@ -171,20 +170,10 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# DOWNLOAD DOCKER IMAGE ##################################################
|
|
||||||
##########################################################################
|
|
||||||
- name: Download Docker Image (Frontend)
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: docker-frontend-test
|
|
||||||
path: /tmp
|
|
||||||
- name: Load Docker Image
|
|
||||||
run: docker load < /tmp/frontend.tar
|
|
||||||
##########################################################################
|
|
||||||
# LOCALES FRONTEND #######################################################
|
# LOCALES FRONTEND #######################################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
- name: Frontend | Locales
|
- name: Frontend | Locales
|
||||||
run: docker run --rm gradido/frontend:test yarn run locales
|
run: cd frontend && yarn && yarn run locales
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# JOB: LINT FRONTEND #########################################################
|
# JOB: LINT FRONTEND #########################################################
|
||||||
@ -192,7 +181,6 @@ jobs:
|
|||||||
lint_frontend:
|
lint_frontend:
|
||||||
name: Lint - Frontend
|
name: Lint - Frontend
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build_test_frontend]
|
|
||||||
steps:
|
steps:
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# CHECKOUT CODE ##########################################################
|
# CHECKOUT CODE ##########################################################
|
||||||
@ -200,20 +188,10 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# DOWNLOAD DOCKER IMAGE ##################################################
|
|
||||||
##########################################################################
|
|
||||||
- name: Download Docker Image (Frontend)
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: docker-frontend-test
|
|
||||||
path: /tmp
|
|
||||||
- name: Load Docker Image
|
|
||||||
run: docker load < /tmp/frontend.tar
|
|
||||||
##########################################################################
|
|
||||||
# LINT FRONTEND ##########################################################
|
# LINT FRONTEND ##########################################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
- name: Frontend | Lint
|
- name: Frontend | Lint
|
||||||
run: docker run --rm gradido/frontend:test yarn run lint
|
run: cd frontend && yarn && yarn run lint
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# JOB: STYLELINT FRONTEND ####################################################
|
# JOB: STYLELINT FRONTEND ####################################################
|
||||||
@ -221,7 +199,6 @@ jobs:
|
|||||||
stylelint_frontend:
|
stylelint_frontend:
|
||||||
name: Stylelint - Frontend
|
name: Stylelint - Frontend
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build_test_frontend]
|
|
||||||
steps:
|
steps:
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# CHECKOUT CODE ##########################################################
|
# CHECKOUT CODE ##########################################################
|
||||||
@ -229,20 +206,10 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# DOWNLOAD DOCKER IMAGE ##################################################
|
|
||||||
##########################################################################
|
|
||||||
- name: Download Docker Image (Frontend)
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: docker-frontend-test
|
|
||||||
path: /tmp
|
|
||||||
- name: Load Docker Image
|
|
||||||
run: docker load < /tmp/frontend.tar
|
|
||||||
##########################################################################
|
|
||||||
# STYLELINT FRONTEND #####################################################
|
# STYLELINT FRONTEND #####################################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
- name: Frontend | Stylelint
|
- name: Frontend | Stylelint
|
||||||
run: docker run --rm gradido/frontend:test yarn run stylelint
|
run: cd frontend && yarn && yarn run stylelint
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# JOB: LINT ADMIN INTERFACE ##################################################
|
# JOB: LINT ADMIN INTERFACE ##################################################
|
||||||
@ -250,7 +217,6 @@ jobs:
|
|||||||
lint_admin:
|
lint_admin:
|
||||||
name: Lint - Admin Interface
|
name: Lint - Admin Interface
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build_test_admin]
|
|
||||||
steps:
|
steps:
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# CHECKOUT CODE ##########################################################
|
# CHECKOUT CODE ##########################################################
|
||||||
@ -258,20 +224,10 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# DOWNLOAD DOCKER IMAGE ##################################################
|
|
||||||
##########################################################################
|
|
||||||
- name: Download Docker Image (Admin Interface)
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: docker-admin-test
|
|
||||||
path: /tmp
|
|
||||||
- name: Load Docker Image
|
|
||||||
run: docker load < /tmp/admin.tar
|
|
||||||
##########################################################################
|
|
||||||
# LINT ADMIN INTERFACE ###################################################
|
# LINT ADMIN INTERFACE ###################################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
- name: Admin Interface | Lint
|
- name: Admin Interface | Lint
|
||||||
run: docker run --rm gradido/admin:test yarn run lint
|
run: cd admin && yarn && yarn run lint
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# JOB: STYLELINT ADMIN INTERFACE #############################################
|
# JOB: STYLELINT ADMIN INTERFACE #############################################
|
||||||
@ -279,7 +235,6 @@ jobs:
|
|||||||
stylelint_admin:
|
stylelint_admin:
|
||||||
name: Stylelint - Admin Interface
|
name: Stylelint - Admin Interface
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build_test_admin]
|
|
||||||
steps:
|
steps:
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# CHECKOUT CODE ##########################################################
|
# CHECKOUT CODE ##########################################################
|
||||||
@ -287,20 +242,10 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# DOWNLOAD DOCKER IMAGE ##################################################
|
|
||||||
##########################################################################
|
|
||||||
- name: Download Docker Image (Admin Interface)
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: docker-admin-test
|
|
||||||
path: /tmp
|
|
||||||
- name: Load Docker Image
|
|
||||||
run: docker load < /tmp/admin.tar
|
|
||||||
##########################################################################
|
|
||||||
# STYLELINT ADMIN INTERFACE ##############################################
|
# STYLELINT ADMIN INTERFACE ##############################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
- name: Admin Interface | Stylelint
|
- name: Admin Interface | Stylelint
|
||||||
run: docker run --rm gradido/admin:test yarn run stylelint
|
run: cd admin && yarn && yarn run stylelint
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# JOB: LOCALES ADMIN #########################################################
|
# JOB: LOCALES ADMIN #########################################################
|
||||||
@ -308,7 +253,6 @@ jobs:
|
|||||||
locales_admin:
|
locales_admin:
|
||||||
name: Locales - Admin Interface
|
name: Locales - Admin Interface
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build_test_admin]
|
|
||||||
steps:
|
steps:
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# CHECKOUT CODE ##########################################################
|
# CHECKOUT CODE ##########################################################
|
||||||
@ -316,20 +260,10 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# DOWNLOAD DOCKER IMAGE ##################################################
|
|
||||||
##########################################################################
|
|
||||||
- name: Download Docker Image (Admin Interface)
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: docker-admin-test
|
|
||||||
path: /tmp
|
|
||||||
- name: Load Docker Image
|
|
||||||
run: docker load < /tmp/admin.tar
|
|
||||||
##########################################################################
|
|
||||||
# LOCALES FRONTEND #######################################################
|
# LOCALES FRONTEND #######################################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
- name: admin | Locales
|
- name: Admin | Locales
|
||||||
run: docker run --rm gradido/admin:test yarn run locales
|
run: cd admin && yarn && yarn run locales
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# JOB: LINT BACKEND ##########################################################
|
# JOB: LINT BACKEND ##########################################################
|
||||||
@ -337,7 +271,6 @@ jobs:
|
|||||||
lint_backend:
|
lint_backend:
|
||||||
name: Lint - Backend
|
name: Lint - Backend
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build_test_backend]
|
|
||||||
steps:
|
steps:
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# CHECKOUT CODE ##########################################################
|
# CHECKOUT CODE ##########################################################
|
||||||
@ -345,20 +278,10 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# DOWNLOAD DOCKER IMAGE ##################################################
|
|
||||||
##########################################################################
|
|
||||||
- name: Download Docker Image (Backend)
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: docker-backend-test
|
|
||||||
path: /tmp
|
|
||||||
- name: Load Docker Image
|
|
||||||
run: docker load < /tmp/backend.tar
|
|
||||||
##########################################################################
|
|
||||||
# LINT BACKEND ###########################################################
|
# LINT BACKEND ###########################################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
- name: backend | Lint
|
- name: backend | Lint
|
||||||
run: docker run --rm gradido/backend:test yarn run lint
|
run: cd backend && yarn && yarn run lint
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# JOB: LOCALES BACKEND #######################################################
|
# JOB: LOCALES BACKEND #######################################################
|
||||||
@ -366,7 +289,6 @@ jobs:
|
|||||||
locales_backend:
|
locales_backend:
|
||||||
name: Locales - Backend
|
name: Locales - Backend
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build_test_backend]
|
|
||||||
steps:
|
steps:
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# CHECKOUT CODE ##########################################################
|
# CHECKOUT CODE ##########################################################
|
||||||
@ -385,7 +307,6 @@ jobs:
|
|||||||
lint_database_up:
|
lint_database_up:
|
||||||
name: Lint - Database Up
|
name: Lint - Database Up
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build_test_database_up]
|
|
||||||
steps:
|
steps:
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# CHECKOUT CODE ##########################################################
|
# CHECKOUT CODE ##########################################################
|
||||||
@ -393,20 +314,10 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# DOWNLOAD DOCKER IMAGE ##################################################
|
|
||||||
##########################################################################
|
|
||||||
- name: Download Docker Image (Backend)
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: docker-database-test_up
|
|
||||||
path: /tmp
|
|
||||||
- name: Load Docker Image
|
|
||||||
run: docker load < /tmp/database_up.tar
|
|
||||||
##########################################################################
|
|
||||||
# LINT DATABASE ##########################################################
|
# LINT DATABASE ##########################################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
- name: database | Lint
|
- name: Database | Lint
|
||||||
run: docker run --rm gradido/database:test_up yarn run lint
|
run: cd database && yarn && yarn run lint
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# JOB: UNIT TEST FRONTEND ###################################################
|
# JOB: UNIT TEST FRONTEND ###################################################
|
||||||
@ -414,7 +325,6 @@ jobs:
|
|||||||
unit_test_frontend:
|
unit_test_frontend:
|
||||||
name: Unit tests - Frontend
|
name: Unit tests - Frontend
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build_test_frontend]
|
|
||||||
steps:
|
steps:
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# CHECKOUT CODE ##########################################################
|
# CHECKOUT CODE ##########################################################
|
||||||
@ -422,30 +332,12 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# DOWNLOAD DOCKER IMAGES #################################################
|
|
||||||
##########################################################################
|
|
||||||
- name: Download Docker Image (Frontend)
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: docker-frontend-test
|
|
||||||
path: /tmp
|
|
||||||
- name: Load Docker Image
|
|
||||||
run: docker load < /tmp/frontend.tar
|
|
||||||
##########################################################################
|
|
||||||
# UNIT TESTS FRONTEND ####################################################
|
# UNIT TESTS FRONTEND ####################################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
- name: frontend | Unit tests
|
- name: Frontend | Unit tests
|
||||||
run: |
|
run: |
|
||||||
docker run --env NODE_ENV=test -v ~/coverage:/app/coverage --rm gradido/frontend:test yarn run test
|
cd frontend && yarn && yarn run test
|
||||||
cp -r ~/coverage ./coverage
|
cp -r ./coverage ../
|
||||||
##########################################################################
|
|
||||||
# COVERAGE REPORT FRONTEND ###############################################
|
|
||||||
##########################################################################
|
|
||||||
#- name: frontend | Coverage report
|
|
||||||
# uses: romeovs/lcov-reporter-action@v0.2.21
|
|
||||||
# with:
|
|
||||||
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
# lcov-file: ./coverage/lcov.info
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# COVERAGE CHECK FRONTEND ################################################
|
# COVERAGE CHECK FRONTEND ################################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
@ -454,7 +346,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
report_name: Coverage Frontend
|
report_name: Coverage Frontend
|
||||||
type: lcov
|
type: lcov
|
||||||
result_path: ./coverage/lcov.info
|
result_path: ./frontend/coverage/lcov.info
|
||||||
min_coverage: 95
|
min_coverage: 95
|
||||||
token: ${{ github.token }}
|
token: ${{ github.token }}
|
||||||
|
|
||||||
@ -464,7 +356,6 @@ jobs:
|
|||||||
unit_test_admin:
|
unit_test_admin:
|
||||||
name: Unit tests - Admin Interface
|
name: Unit tests - Admin Interface
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build_test_admin]
|
|
||||||
steps:
|
steps:
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# CHECKOUT CODE ##########################################################
|
# CHECKOUT CODE ##########################################################
|
||||||
@ -472,22 +363,12 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# DOWNLOAD DOCKER IMAGES #################################################
|
|
||||||
##########################################################################
|
|
||||||
- name: Download Docker Image (Admin Interface)
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: docker-admin-test
|
|
||||||
path: /tmp
|
|
||||||
- name: Load Docker Image
|
|
||||||
run: docker load < /tmp/admin.tar
|
|
||||||
##########################################################################
|
|
||||||
# UNIT TESTS ADMIN INTERFACE #############################################
|
# UNIT TESTS ADMIN INTERFACE #############################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
- name: Admin Interface | Unit tests
|
- name: Admin Interface | Unit tests
|
||||||
run: |
|
run: |
|
||||||
docker run -v ~/coverage:/app/coverage --rm gradido/admin:test yarn run test
|
cd admin && yarn && yarn run test
|
||||||
cp -r ~/coverage ./coverage
|
cp -r ./coverage ../
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# COVERAGE CHECK ADMIN INTERFACE #########################################
|
# COVERAGE CHECK ADMIN INTERFACE #########################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
@ -496,7 +377,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
report_name: Coverage Admin Interface
|
report_name: Coverage Admin Interface
|
||||||
type: lcov
|
type: lcov
|
||||||
result_path: ./coverage/lcov.info
|
result_path: ./admin/coverage/lcov.info
|
||||||
min_coverage: 97
|
min_coverage: 97
|
||||||
token: ${{ github.token }}
|
token: ${{ github.token }}
|
||||||
|
|
||||||
@ -534,8 +415,9 @@ jobs:
|
|||||||
- name: backend | docker-compose database
|
- name: backend | docker-compose database
|
||||||
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database
|
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database
|
||||||
- name: backend Unit tests | test
|
- name: backend Unit tests | test
|
||||||
run: cd database && yarn && yarn build && cd ../backend && yarn && yarn test
|
run: |
|
||||||
# run: docker-compose -f docker-compose.yml -f docker-compose.test.yml exec -T backend yarn test
|
cd database && yarn && yarn build && cd ../backend && yarn && yarn test
|
||||||
|
cp -r ./coverage ../
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# COVERAGE CHECK BACKEND #################################################
|
# COVERAGE CHECK BACKEND #################################################
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|||||||
@ -257,17 +257,13 @@ describe('Contribution Links', () => {
|
|||||||
}),
|
}),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
errors: [
|
errors: [new GraphQLError('A Start-Date must be set')],
|
||||||
new GraphQLError('Start-Date is not initialized. A Start-Date must be set!'),
|
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error thrown', () => {
|
it('logs the error thrown', () => {
|
||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith('A Start-Date must be set')
|
||||||
'Start-Date is not initialized. A Start-Date must be set!',
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns an error if missing endDate', async () => {
|
it('returns an error if missing endDate', async () => {
|
||||||
@ -282,15 +278,13 @@ describe('Contribution Links', () => {
|
|||||||
}),
|
}),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
errors: [new GraphQLError('End-Date is not initialized. An End-Date must be set!')],
|
errors: [new GraphQLError('An End-Date must be set')],
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error thrown', () => {
|
it('logs the error thrown', () => {
|
||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith('An End-Date must be set')
|
||||||
'End-Date is not initialized. An End-Date must be set!',
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns an error if endDate is before startDate', async () => {
|
it('returns an error if endDate is before startDate', async () => {
|
||||||
@ -307,7 +301,7 @@ describe('Contribution Links', () => {
|
|||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
errors: [
|
errors: [
|
||||||
new GraphQLError(`The value of validFrom must before or equals the validTo!`),
|
new GraphQLError(`The value of validFrom must before or equals the validTo`),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@ -315,7 +309,7 @@ describe('Contribution Links', () => {
|
|||||||
|
|
||||||
it('logs the error thrown', () => {
|
it('logs the error thrown', () => {
|
||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith(
|
||||||
`The value of validFrom must before or equals the validTo!`,
|
`The value of validFrom must before or equals the validTo`,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -245,8 +245,8 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
it('logs the error found', () => {
|
it('logs the error found', () => {
|
||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith(
|
||||||
'No information for available creations with the given creationDate=',
|
'No information for available creations for the given date',
|
||||||
'Invalid Date',
|
expect.any(Date),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -268,8 +268,8 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
it('logs the error found', () => {
|
it('logs the error found', () => {
|
||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith(
|
||||||
'No information for available creations with the given creationDate=',
|
'No information for available creations for the given date',
|
||||||
'Invalid Date',
|
expect.any(Date),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -526,14 +526,16 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
expect(errorObjects).toEqual([
|
expect(errorObjects).toEqual([
|
||||||
new GraphQLError(
|
new GraphQLError(
|
||||||
'The amount (1019 GDD) to be created exceeds the amount (600 GDD) still available for this month.',
|
'The amount to be created exceeds the amount still available for this month',
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error found', () => {
|
it('logs the error found', () => {
|
||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith(
|
||||||
'The amount (1019 GDD) to be created exceeds the amount (600 GDD) still available for this month.',
|
'The amount to be created exceeds the amount still available for this month',
|
||||||
|
new Decimal(1019),
|
||||||
|
new Decimal(600),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -2009,8 +2011,8 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
it('logs the error thrown', () => {
|
it('logs the error thrown', () => {
|
||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith(
|
||||||
'No information for available creations with the given creationDate=',
|
'No information for available creations for the given date',
|
||||||
new Date(variables.creationDate).toString(),
|
new Date(variables.creationDate),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -2034,8 +2036,8 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
it('logs the error thrown', () => {
|
it('logs the error thrown', () => {
|
||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith(
|
||||||
'No information for available creations with the given creationDate=',
|
'No information for available creations for the given date',
|
||||||
new Date(variables.creationDate).toString(),
|
new Date(variables.creationDate),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -2050,7 +2052,7 @@ describe('ContributionResolver', () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
errors: [
|
errors: [
|
||||||
new GraphQLError(
|
new GraphQLError(
|
||||||
'The amount (2000 GDD) to be created exceeds the amount (790 GDD) still available for this month.',
|
'The amount to be created exceeds the amount still available for this month',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
@ -2059,7 +2061,9 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
it('logs the error thrown', () => {
|
it('logs the error thrown', () => {
|
||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith(
|
||||||
'The amount (2000 GDD) to be created exceeds the amount (790 GDD) still available for this month.',
|
'The amount to be created exceeds the amount still available for this month',
|
||||||
|
new Decimal(2000),
|
||||||
|
new Decimal(790),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -2099,7 +2103,7 @@ describe('ContributionResolver', () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
errors: [
|
errors: [
|
||||||
new GraphQLError(
|
new GraphQLError(
|
||||||
'The amount (1000 GDD) to be created exceeds the amount (590 GDD) still available for this month.',
|
'The amount to be created exceeds the amount still available for this month',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
@ -2108,7 +2112,9 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
it('logs the error thrown', () => {
|
it('logs the error thrown', () => {
|
||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith(
|
||||||
'The amount (1000 GDD) to be created exceeds the amount (590 GDD) still available for this month.',
|
'The amount to be created exceeds the amount still available for this month',
|
||||||
|
new Decimal(1000),
|
||||||
|
new Decimal(590),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -2301,7 +2307,7 @@ describe('ContributionResolver', () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
errors: [
|
errors: [
|
||||||
new GraphQLError(
|
new GraphQLError(
|
||||||
'The amount (1900 GDD) to be created exceeds the amount (1000 GDD) still available for this month.',
|
'The amount to be created exceeds the amount still available for this month',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
@ -2310,7 +2316,9 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
it('logs the error thrown', () => {
|
it('logs the error thrown', () => {
|
||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith(
|
||||||
'The amount (1900 GDD) to be created exceeds the amount (1000 GDD) still available for this month.',
|
'The amount to be created exceeds the amount still available for this month',
|
||||||
|
new Decimal(1900),
|
||||||
|
new Decimal(1000),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -362,7 +362,7 @@ describe('TransactionLinkResolver', () => {
|
|||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith(
|
||||||
'Creation from contribution link was not successful',
|
'Creation from contribution link was not successful',
|
||||||
new Error(
|
new Error(
|
||||||
'The amount (5 GDD) to be created exceeds the amount (0 GDD) still available for this month.',
|
'The amount to be created exceeds the amount still available for this month',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import LogError from '@/server/LogError'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
import { getConnection } from '@dbTools/typeorm'
|
import { getConnection } from '@dbTools/typeorm'
|
||||||
import { Contribution } from '@entity/Contribution'
|
import { Contribution } from '@entity/Contribution'
|
||||||
@ -19,19 +20,14 @@ export const validateContribution = (
|
|||||||
const index = getCreationIndex(creationDate.getMonth(), timezoneOffset)
|
const index = getCreationIndex(creationDate.getMonth(), timezoneOffset)
|
||||||
|
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
logger.error(
|
throw new LogError('No information for available creations for the given date', creationDate)
|
||||||
'No information for available creations with the given creationDate=',
|
|
||||||
creationDate.toString(),
|
|
||||||
)
|
|
||||||
throw new Error('No information for available creations for the given date')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount.greaterThan(creations[index].toString())) {
|
if (amount.greaterThan(creations[index].toString())) {
|
||||||
logger.error(
|
throw new LogError(
|
||||||
`The amount (${amount} GDD) to be created exceeds the amount (${creations[index]} GDD) still available for this month.`,
|
'The amount to be created exceeds the amount still available for this month',
|
||||||
)
|
amount,
|
||||||
throw new Error(
|
creations[index],
|
||||||
`The amount (${amount} GDD) to be created exceeds the amount (${creations[index]} GDD) still available for this month.`,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,19 +122,16 @@ export const isStartEndDateValid = (
|
|||||||
endDate: string | null | undefined,
|
endDate: string | null | undefined,
|
||||||
): void => {
|
): void => {
|
||||||
if (!startDate) {
|
if (!startDate) {
|
||||||
logger.error('Start-Date is not initialized. A Start-Date must be set!')
|
throw new LogError('A Start-Date must be set')
|
||||||
throw new Error('Start-Date is not initialized. A Start-Date must be set!')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!endDate) {
|
if (!endDate) {
|
||||||
logger.error('End-Date is not initialized. An End-Date must be set!')
|
throw new LogError('An End-Date must be set')
|
||||||
throw new Error('End-Date is not initialized. An End-Date must be set!')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if endDate is before startDate
|
// check if endDate is before startDate
|
||||||
if (new Date(endDate).getTime() - new Date(startDate).getTime() < 0) {
|
if (new Date(endDate).getTime() - new Date(startDate).getTime() < 0) {
|
||||||
logger.error(`The value of validFrom must before or equals the validTo!`)
|
throw new LogError(`The value of validFrom must before or equals the validTo`)
|
||||||
throw new Error(`The value of validFrom must before or equals the validTo!`)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user