mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into delete-build-folders
This commit is contained in:
commit
a4ba61cccc
@ -2,7 +2,6 @@ import { User as dbUser } from '@entity/User'
|
||||
import { ObjectType, Field, Int } from 'type-graphql'
|
||||
|
||||
import { KlickTipp } from './KlickTipp'
|
||||
import { UserContact } from './UserContact'
|
||||
|
||||
@ObjectType()
|
||||
export class User {
|
||||
@ -10,10 +9,7 @@ export class User {
|
||||
this.id = user.id
|
||||
this.gradidoID = user.gradidoID
|
||||
this.alias = user.alias
|
||||
this.emailId = user.emailId
|
||||
if (user.emailContact) {
|
||||
this.email = user.emailContact.email
|
||||
this.emailContact = new UserContact(user.emailContact)
|
||||
this.emailChecked = user.emailContact.emailChecked
|
||||
}
|
||||
this.firstName = user.firstName
|
||||
@ -38,16 +34,6 @@ export class User {
|
||||
@Field(() => String, { nullable: true })
|
||||
alias: string | null
|
||||
|
||||
@Field(() => Int, { nullable: true })
|
||||
emailId: number | null
|
||||
|
||||
// TODO privacy issue here
|
||||
@Field(() => String, { nullable: true })
|
||||
email: string | null
|
||||
|
||||
@Field(() => UserContact)
|
||||
emailContact: UserContact
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
firstName: string | null
|
||||
|
||||
|
||||
@ -20,12 +20,15 @@ import {
|
||||
login,
|
||||
sendCoins,
|
||||
} from '@/seeds/graphql/mutations'
|
||||
import { transactionsQuery } from '@/seeds/graphql/queries'
|
||||
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'
|
||||
|
||||
let mutate: ApolloServerTestClient['mutate'], con: Connection
|
||||
let query: ApolloServerTestClient['query']
|
||||
|
||||
let testEnv: {
|
||||
mutate: ApolloServerTestClient['mutate']
|
||||
query: ApolloServerTestClient['query']
|
||||
@ -35,6 +38,7 @@ let testEnv: {
|
||||
beforeAll(async () => {
|
||||
testEnv = await testEnvironment(logger)
|
||||
mutate = testEnv.mutate
|
||||
query = testEnv.query
|
||||
con = testEnv.con
|
||||
await cleanDB()
|
||||
})
|
||||
@ -442,3 +446,42 @@ describe('send coins', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('transactionList', () => {
|
||||
describe('unauthenticated', () => {
|
||||
it('throws an error', async () => {
|
||||
await expect(query({ query: transactionsQuery })).resolves.toMatchObject({
|
||||
errors: [new GraphQLError('401 Unauthorized')],
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('authenticated', () => {
|
||||
describe('no transactions', () => {
|
||||
beforeAll(async () => {
|
||||
await userFactory(testEnv, bobBaumeister)
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: {
|
||||
email: 'bob@baumeister.de',
|
||||
password: 'Aa12345_',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('has no transactions and balance 0', async () => {
|
||||
await expect(query({ query: transactionsQuery })).resolves.toMatchObject({
|
||||
data: {
|
||||
transactionList: {
|
||||
balance: expect.objectContaining({
|
||||
balance: expect.decimalEqual(0),
|
||||
}),
|
||||
transactions: [],
|
||||
},
|
||||
},
|
||||
errors: undefined,
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -680,7 +680,6 @@ describe('UserResolver', () => {
|
||||
expect.objectContaining({
|
||||
data: {
|
||||
login: {
|
||||
email: 'bibi@bloxberg.de',
|
||||
firstName: 'Bibi',
|
||||
hasElopage: false,
|
||||
id: expect.any(Number),
|
||||
@ -953,7 +952,6 @@ describe('UserResolver', () => {
|
||||
expect.objectContaining({
|
||||
data: {
|
||||
verifyLogin: {
|
||||
email: 'bibi@bloxberg.de',
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
language: 'de',
|
||||
@ -1310,7 +1308,7 @@ describe('UserResolver', () => {
|
||||
expect.objectContaining({
|
||||
data: {
|
||||
login: expect.objectContaining({
|
||||
email: 'bibi@bloxberg.de',
|
||||
firstName: 'Benjamin',
|
||||
}),
|
||||
},
|
||||
}),
|
||||
@ -1457,7 +1455,6 @@ describe('UserResolver', () => {
|
||||
expect.objectContaining({
|
||||
data: {
|
||||
login: {
|
||||
email: 'bibi@bloxberg.de',
|
||||
firstName: 'Bibi',
|
||||
hasElopage: false,
|
||||
id: expect.any(Number),
|
||||
|
||||
@ -130,7 +130,7 @@ export class UserResolver {
|
||||
// Elopage Status & Stored PublisherId
|
||||
user.hasElopage = await this.hasElopage(context)
|
||||
|
||||
logger.debug(`verifyLogin... successful: ${user.firstName}.${user.lastName}, ${user.email}`)
|
||||
logger.debug(`verifyLogin... successful: ${user.firstName}.${user.lastName}`)
|
||||
return user
|
||||
}
|
||||
|
||||
@ -238,7 +238,6 @@ export class UserResolver {
|
||||
const user = new User(communityDbUser)
|
||||
user.id = sodium.randombytes_random() % (2048 * 16) // TODO: for a better faking derive id from email so that it will be always the same id when the same email comes in?
|
||||
user.gradidoID = uuidv4()
|
||||
user.email = email
|
||||
user.firstName = firstName
|
||||
user.lastName = lastName
|
||||
user.language = language
|
||||
|
||||
@ -305,7 +305,6 @@ export const login = gql`
|
||||
mutation ($email: String!, $password: String!, $publisherId: Int) {
|
||||
login(email: $email, password: $password, publisherId: $publisherId) {
|
||||
id
|
||||
email
|
||||
firstName
|
||||
lastName
|
||||
language
|
||||
|
||||
@ -3,7 +3,6 @@ import { gql } from 'graphql-tag'
|
||||
export const verifyLogin = gql`
|
||||
query {
|
||||
verifyLogin {
|
||||
email
|
||||
firstName
|
||||
lastName
|
||||
language
|
||||
@ -24,31 +23,26 @@ export const queryOptIn = gql`
|
||||
`
|
||||
|
||||
export const transactionsQuery = gql`
|
||||
query (
|
||||
$currentPage: Int = 1
|
||||
$pageSize: Int = 25
|
||||
$order: Order = DESC
|
||||
$onlyCreations: Boolean = false
|
||||
) {
|
||||
transactionList(
|
||||
currentPage: $currentPage
|
||||
pageSize: $pageSize
|
||||
order: $order
|
||||
onlyCreations: $onlyCreations
|
||||
) {
|
||||
balanceGDT
|
||||
count
|
||||
balance
|
||||
query ($currentPage: Int = 1, $pageSize: Int = 25, $order: Order = DESC) {
|
||||
transactionList(currentPage: $currentPage, pageSize: $pageSize, order: $order) {
|
||||
balance {
|
||||
balance
|
||||
balanceGDT
|
||||
count
|
||||
linkCount
|
||||
}
|
||||
transactions {
|
||||
id
|
||||
typeId
|
||||
amount
|
||||
balance
|
||||
previousBalance
|
||||
balanceDate
|
||||
memo
|
||||
linkedUser {
|
||||
firstName
|
||||
lastName
|
||||
gradidoID
|
||||
}
|
||||
decay {
|
||||
decay
|
||||
@ -56,6 +50,7 @@ export const transactionsQuery = gql`
|
||||
end
|
||||
duration
|
||||
}
|
||||
linkId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ export default defineConfig({
|
||||
mailserverURL: 'http://localhost:1080',
|
||||
loginQuery: `mutation ($email: String!, $password: String!, $publisherId: Int) {
|
||||
login(email: $email, password: $password, publisherId: $publisherId) {
|
||||
email
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
language
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user