mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into Error-handling-in-GddTransactionList
This commit is contained in:
commit
4530e53ce7
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -399,7 +399,7 @@ jobs:
|
||||
report_name: Coverage Frontend
|
||||
type: lcov
|
||||
result_path: ./coverage/lcov.info
|
||||
min_coverage: 90
|
||||
min_coverage: 94
|
||||
token: ${{ github.token }}
|
||||
|
||||
##############################################################################
|
||||
|
||||
@ -16,6 +16,7 @@ import { TransactionCreation } from '@entity/TransactionCreation'
|
||||
import { UserTransaction } from '@entity/UserTransaction'
|
||||
import { UserTransactionRepository } from '../../typeorm/repository/UserTransaction'
|
||||
import { BalanceRepository } from '../../typeorm/repository/Balance'
|
||||
import { calculateDecay } from '../../util/decay'
|
||||
|
||||
@Resolver()
|
||||
export class AdminResolver {
|
||||
@ -149,10 +150,11 @@ export class AdminResolver {
|
||||
const pendingCreation = await loginPendingTasksAdminRepository.findOneOrFail(id)
|
||||
|
||||
const transactionRepository = getCustomRepository(TransactionRepository)
|
||||
const receivedCallDate = new Date()
|
||||
let transaction = new Transaction()
|
||||
transaction.transactionTypeId = 1
|
||||
transaction.memo = pendingCreation.memo
|
||||
transaction.received = new Date()
|
||||
transaction.received = receivedCallDate
|
||||
transaction.blockchainTypeId = 1
|
||||
transaction = await transactionRepository.save(transaction)
|
||||
if (!transaction) throw new Error('Could not create transaction')
|
||||
@ -174,7 +176,11 @@ export class AdminResolver {
|
||||
if (!lastUserTransaction) {
|
||||
newBalance = 0
|
||||
} else {
|
||||
newBalance = lastUserTransaction.balance
|
||||
newBalance = await calculateDecay(
|
||||
lastUserTransaction.balance,
|
||||
lastUserTransaction.balanceDate,
|
||||
receivedCallDate,
|
||||
)
|
||||
}
|
||||
newBalance = Number(newBalance) + Number(parseInt(pendingCreation.amount.toString()))
|
||||
|
||||
@ -195,8 +201,8 @@ export class AdminResolver {
|
||||
if (!userBalance) userBalance = balanceRepository.create()
|
||||
userBalance.userId = pendingCreation.userId
|
||||
userBalance.amount = Number(newBalance)
|
||||
userBalance.modified = new Date()
|
||||
userBalance.recordDate = userBalance.recordDate ? userBalance.recordDate : new Date()
|
||||
userBalance.modified = receivedCallDate
|
||||
userBalance.recordDate = receivedCallDate
|
||||
await balanceRepository.save(userBalance)
|
||||
await loginPendingTasksAdminRepository.delete(pendingCreation)
|
||||
|
||||
|
||||
@ -13,12 +13,12 @@
|
||||
"up": "cd build && node src/index.js up",
|
||||
"down": "cd build && node src/index.js down",
|
||||
"reset": "cd build && node src/index.js reset",
|
||||
"dev_up": "nodemon -w ./ --ext ts --exec ts-node src/index.ts up",
|
||||
"dev_down": "nodemon -w ./ --ext ts --exec ts-node src/index.ts down",
|
||||
"dev_reset": "nodemon -w ./ --ext ts --exec ts-node src/index.ts reset",
|
||||
"dev_up": "ts-node src/index.ts up",
|
||||
"dev_down": "ts-node src/index.ts down",
|
||||
"dev_reset": "ts-node src/index.ts reset",
|
||||
"lint": "eslint . --ext .js,.ts",
|
||||
"seed:config": "ts-node ./node_modules/typeorm-seeding/dist/cli.js config",
|
||||
"seed": "nodemon -w ./ --ext ts --exec ts-node src/index.ts seed"
|
||||
"seed": "ts-node src/index.ts seed"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/faker": "^5.5.9",
|
||||
@ -32,7 +32,6 @@
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-prettier": "^3.4.1",
|
||||
"eslint-plugin-promise": "^5.1.0",
|
||||
"nodemon": "^2.0.12",
|
||||
"prettier": "^2.3.2",
|
||||
"ts-node": "^10.2.1",
|
||||
"typescript": "^4.3.5"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,3 @@
|
||||
// import clickOutside from '@/directives/click-ouside.js'
|
||||
import { focus } from 'vue-focus'
|
||||
|
||||
/**
|
||||
@ -7,7 +6,6 @@ import { focus } from 'vue-focus'
|
||||
|
||||
const GlobalDirectives = {
|
||||
install(Vue) {
|
||||
// Vue.directive('click-outside', clickOutside)
|
||||
Vue.directive('focus', focus)
|
||||
},
|
||||
}
|
||||
|
||||
21
frontend/src/plugins/globalDirectives.test.js
Normal file
21
frontend/src/plugins/globalDirectives.test.js
Normal file
@ -0,0 +1,21 @@
|
||||
import GlobalDirectives from './globalDirectives'
|
||||
import { focus } from 'vue-focus'
|
||||
import Vue from 'vue'
|
||||
|
||||
jest.mock('vue-focus', () => {
|
||||
return {
|
||||
__esModule: true,
|
||||
focus: jest.fn(),
|
||||
}
|
||||
})
|
||||
jest.mock('vue')
|
||||
|
||||
const vueDirectiveMock = jest.fn()
|
||||
Vue.directive = vueDirectiveMock
|
||||
|
||||
describe('globalDirectives', () => {
|
||||
it('installs the focus directive', () => {
|
||||
GlobalDirectives.install(Vue)
|
||||
expect(vueDirectiveMock).toBeCalledWith('focus', focus)
|
||||
})
|
||||
})
|
||||
@ -52,6 +52,7 @@ describe('DashboardLayoutGdd', () => {
|
||||
publisherId: 123,
|
||||
firstName: 'User',
|
||||
lastName: 'Example',
|
||||
token: 'valid-token',
|
||||
},
|
||||
dispatch: storeDispatchMock,
|
||||
commit: storeCommitMock,
|
||||
@ -222,6 +223,65 @@ describe('DashboardLayoutGdd', () => {
|
||||
expect(toasterMock).toBeCalledWith('Ouch!')
|
||||
})
|
||||
})
|
||||
|
||||
describe('set visible method', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.findComponent({ name: 'Navbar' }).vm.$emit('set-visible', true)
|
||||
})
|
||||
|
||||
it('sets visible to true', () => {
|
||||
expect(wrapper.vm.visible).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('elopage URI', () => {
|
||||
describe('user has no publisher ID and no elopage', () => {
|
||||
beforeEach(() => {
|
||||
mocks.$store.state.publisherId = null
|
||||
mocks.$store.state.hasElopage = false
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('links to basic-de', () => {
|
||||
expect(wrapper.vm.elopageUri).toBe(
|
||||
'https://elopage.com/s/gradido/basic-de/payment?locale=en&prid=111&pid=2896&firstName=User&lastName=Example&email=user@example.org',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('user has elopage', () => {
|
||||
beforeEach(() => {
|
||||
mocks.$store.state.publisherId = '123'
|
||||
mocks.$store.state.hasElopage = true
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('links to sign in for elopage', () => {
|
||||
expect(wrapper.vm.elopageUri).toBe('https://elopage.com/s/gradido/sign_in?locale=en')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('admin method', () => {
|
||||
const windowLocationMock = jest.fn()
|
||||
beforeEach(() => {
|
||||
delete window.location
|
||||
window.location = {
|
||||
assign: windowLocationMock,
|
||||
}
|
||||
wrapper.findComponent({ name: 'Navbar' }).vm.$emit('admin')
|
||||
})
|
||||
|
||||
it('dispatches logout to store', () => {
|
||||
expect(storeDispatchMock).toBeCalled()
|
||||
})
|
||||
|
||||
it('changes window location to admin interface', () => {
|
||||
expect(windowLocationMock).toBeCalledWith(
|
||||
'http://localhost/admin/authenticate?token=valid-token',
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -70,11 +70,6 @@ export default {
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
showContext() {
|
||||
return this.currentTransactionStep === 0
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
setTransaction(data) {
|
||||
this.transactionData = { ...data }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user