mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
extent voteSendCoins result and increase coverage for backend and
federation
This commit is contained in:
parent
9ddecd95ac
commit
c0a09c2a28
@ -7,7 +7,7 @@ module.exports = {
|
||||
collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!src/seeds/**', '!build/**'],
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
lines: 85,
|
||||
lines: 88,
|
||||
},
|
||||
},
|
||||
setupFiles: ['<rootDir>/test/testSetup.ts'],
|
||||
|
||||
@ -48,7 +48,11 @@ export class SendCoinsClient {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
||||
result.recipGradidoID = data.voteForSendCoins.recipGradidoID
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
||||
result.recipName = data.voteForSendCoins.recipName
|
||||
result.recipFirstName = data.voteForSendCoins.recipFirstName
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
||||
result.recipLastName = data.voteForSendCoins.recipLastName
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
||||
result.recipAlias = data.voteForSendCoins.recipAlias
|
||||
logger.debug('X-Com: voteForSendCoins successful with result=', result)
|
||||
return result
|
||||
} catch (err) {
|
||||
|
||||
@ -13,5 +13,11 @@ export class SendCoinsResult {
|
||||
recipGradidoID: string | null
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
recipName: string | null
|
||||
recipFirstName: string | null
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
recipLastName: string | null
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
recipAlias: string | null
|
||||
}
|
||||
|
||||
@ -5,37 +5,9 @@ export const voteForSendCoins = gql`
|
||||
voteForSendCoins(data: $args) {
|
||||
vote
|
||||
recipGradidoID
|
||||
recipName
|
||||
recipFirstName
|
||||
recipLastName
|
||||
recipAlias
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
/*
|
||||
mutation (
|
||||
$recipientCommunityUuid: String!
|
||||
$recipientUserIdentifier: String!
|
||||
$creationDate: String!
|
||||
$amount: Decimal!
|
||||
$memo: String!
|
||||
$senderCommunityUuid: String!
|
||||
$senderUserUuid: String!
|
||||
$senderUserName: String!
|
||||
) {
|
||||
voteForSendCoins(
|
||||
data: {
|
||||
recipientCommunityUuid: $recipientCommunityUuid
|
||||
recipientUserIdentifier: $recipientUserIdentifier
|
||||
creationDate: $creationDate
|
||||
amount: $amount
|
||||
memo: $memo
|
||||
senderCommunityUuid: $senderCommunityUuid
|
||||
senderUserUuid: $senderUserUuid
|
||||
senderUserName: $senderUserName
|
||||
}
|
||||
) {
|
||||
vote
|
||||
recipGradidoID
|
||||
recipName
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@ -34,7 +34,6 @@ import { bobBaumeister } from '@/seeds/users/bob-baumeister'
|
||||
import { garrickOllivander } from '@/seeds/users/garrick-ollivander'
|
||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||
import { stephenHawking } from '@/seeds/users/stephen-hawking'
|
||||
import { fullName } from '@/util/utilities'
|
||||
|
||||
let mutate: ApolloServerTestClient['mutate'], con: Connection
|
||||
let query: ApolloServerTestClient['query']
|
||||
@ -618,18 +617,20 @@ describe('send coins', () => {
|
||||
jest
|
||||
.spyOn(SendCoinsClient.prototype, 'voteForSendCoins')
|
||||
.mockImplementation(async (args: SendCoinsArgs): Promise<SendCoinsResult> => {
|
||||
// console.log('mock of voteForSendCoins...', args)
|
||||
logger.debug('mock of voteForSendCoins...', args)
|
||||
return Promise.resolve({
|
||||
vote: true,
|
||||
recipName: fullName(peter.firstName, peter.lastName),
|
||||
recipFirstName: peter.firstName,
|
||||
recipLastName: peter.lastName,
|
||||
recipGradidoID: args.recipientUserIdentifier,
|
||||
recipAlias: peter.alias,
|
||||
})
|
||||
})
|
||||
|
||||
jest
|
||||
.spyOn(SendCoinsClient.prototype, 'settleSendCoins')
|
||||
.mockImplementation(async (args: SendCoinsArgs): Promise<boolean> => {
|
||||
// console.log('mock of settleSendCoins...', args)
|
||||
logger.debug('mock of settleSendCoins...', args)
|
||||
return Promise.resolve(true)
|
||||
})
|
||||
|
||||
|
||||
@ -258,7 +258,7 @@ export class TransactionResolver {
|
||||
const remoteUser = new User(null)
|
||||
remoteUser.gradidoID = transaction.linkedUserGradidoID
|
||||
remoteUser.firstName = transaction.linkedUserName
|
||||
remoteUser.lastName = 'GradidoID: ' + transaction.linkedUserGradidoID
|
||||
remoteUser.lastName = '(GradidoID: ' + transaction.linkedUserGradidoID + ')'
|
||||
involvedRemoteUsers.push(remoteUser)
|
||||
}
|
||||
})
|
||||
|
||||
@ -104,8 +104,8 @@ export async function processXComPendingSendCoins(
|
||||
if (voteResult.recipGradidoID) {
|
||||
pendingTx.linkedUserGradidoID = voteResult.recipGradidoID
|
||||
}
|
||||
if (voteResult.recipName) {
|
||||
pendingTx.linkedUserName = voteResult.recipName
|
||||
if (voteResult.recipFirstName && voteResult.recipLastName) {
|
||||
pendingTx.linkedUserName = fullName(voteResult.recipFirstName, voteResult.recipLastName)
|
||||
}
|
||||
pendingTx.memo = memo
|
||||
pendingTx.previous = senderBalance ? senderBalance.lastTransactionId : null
|
||||
@ -224,7 +224,16 @@ export async function processXComCommittingSendCoins(
|
||||
pendingTx,
|
||||
)
|
||||
if (sendCoinsResult.vote) {
|
||||
sendCoinsResult.recipName = pendingTx.linkedUserName
|
||||
if (pendingTx.linkedUserName) {
|
||||
sendCoinsResult.recipFirstName = pendingTx.linkedUserName.slice(
|
||||
0,
|
||||
pendingTx.linkedUserName.indexOf(' '),
|
||||
)
|
||||
sendCoinsResult.recipLastName = pendingTx.linkedUserName.slice(
|
||||
pendingTx.linkedUserName.indexOf(' '),
|
||||
pendingTx.linkedUserName.length,
|
||||
)
|
||||
}
|
||||
sendCoinsResult.recipGradidoID = pendingTx.linkedUserGradidoID
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
@ -6,7 +6,7 @@ module.exports = {
|
||||
collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!src/seeds/**', '!build/**'],
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
lines: 75,
|
||||
lines: 77,
|
||||
},
|
||||
},
|
||||
setupFiles: ['<rootDir>/test/testSetup.ts'],
|
||||
|
||||
@ -13,5 +13,11 @@ export class SendCoinsResult {
|
||||
recipGradidoID: string | null
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
recipName: string | null
|
||||
recipFirstName: string | null
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
recipLastName: string | null
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
recipAlias: string | null
|
||||
}
|
||||
|
||||
@ -50,7 +50,9 @@ describe('SendCoinsResolver', () => {
|
||||
voteForSendCoins(data: $args) {
|
||||
vote
|
||||
recipGradidoID
|
||||
recipName
|
||||
recipFirstName
|
||||
recipLastName
|
||||
recipAlias
|
||||
}
|
||||
}`
|
||||
const settleSendCoinsMutation = `
|
||||
@ -204,7 +206,9 @@ describe('SendCoinsResolver', () => {
|
||||
data: {
|
||||
voteForSendCoins: {
|
||||
recipGradidoID: '56a55482-909e-46a4-bfa2-cd025e894ebd',
|
||||
recipName: 'recipUser-FirstName recipUser-LastName',
|
||||
recipFirstName: 'recipUser-FirstName',
|
||||
recipLastName: 'recipUser-LastName',
|
||||
recipAlias: 'recipUser-alias',
|
||||
vote: true,
|
||||
},
|
||||
},
|
||||
|
||||
@ -99,8 +99,10 @@ export class SendCoinsResolver {
|
||||
|
||||
await DbPendingTransaction.insert(pendingTx)
|
||||
result.vote = true
|
||||
result.recipName = pendingTx.userName
|
||||
result.recipGradidoID = pendingTx.userGradidoID
|
||||
result.recipFirstName = receiverUser.firstName
|
||||
result.recipLastName = receiverUser.lastName
|
||||
result.recipAlias = receiverUser.alias
|
||||
result.recipGradidoID = receiverUser.gradidoID
|
||||
logger.debug(`voteForSendCoins()-1_0... successfull`)
|
||||
} catch (err) {
|
||||
throw new LogError(`Error in voteForSendCoins: `, err)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user