mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Test for the klicktipp tag export.
This commit is contained in:
parent
4da0f8d0f7
commit
10c0cf8370
@ -14,6 +14,8 @@ import { creationFactory } from '@/seeds/factory/creation'
|
|||||||
import { userFactory } from '@/seeds/factory/user'
|
import { userFactory } from '@/seeds/factory/user'
|
||||||
import { login } from '@/seeds/graphql/mutations'
|
import { login } from '@/seeds/graphql/mutations'
|
||||||
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
||||||
|
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||||
|
import { connection } from '@/typeorm/connection'
|
||||||
|
|
||||||
import { exportEventDataToKlickTipp } from './klicktipp'
|
import { exportEventDataToKlickTipp } from './klicktipp'
|
||||||
|
|
||||||
@ -27,6 +29,15 @@ jest.mock('@/apis/KlicktippController', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// jest.mock('@/typeorm/connection', () => {
|
||||||
|
// const originalModule = jest.requireActual('@/typeorm/connection')
|
||||||
|
// return {
|
||||||
|
// __esModule: true,
|
||||||
|
// ...originalModule,
|
||||||
|
// connection: jest.fn(() => Promise.resolve(con)),
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
let mutate: ApolloServerTestClient['mutate'],
|
let mutate: ApolloServerTestClient['mutate'],
|
||||||
query: ApolloServerTestClient['query'],
|
query: ApolloServerTestClient['query'],
|
||||||
con: Connection
|
con: Connection
|
||||||
@ -52,6 +63,7 @@ afterAll(async () => {
|
|||||||
describe('klicktipp', () => {
|
describe('klicktipp', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await userFactory(testEnv, bibiBloxberg)
|
await userFactory(testEnv, bibiBloxberg)
|
||||||
|
await userFactory(testEnv, peterLustig)
|
||||||
const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de')
|
const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de')
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
await creationFactory(testEnv, bibisCreation!)
|
await creationFactory(testEnv, bibisCreation!)
|
||||||
@ -59,11 +71,11 @@ describe('klicktipp', () => {
|
|||||||
mutation: login,
|
mutation: login,
|
||||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||||
})
|
})
|
||||||
|
await con.close()
|
||||||
void exportEventDataToKlickTipp()
|
void exportEventDataToKlickTipp()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(() => {
|
||||||
await cleanDB()
|
|
||||||
resetToken()
|
resetToken()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
// eslint-disable @typescript-eslint/no-explicit-any
|
// eslint-disable @typescript-eslint/no-explicit-any
|
||||||
|
import { Connection } from '@dbTools/typeorm'
|
||||||
import { User } from '@entity/User'
|
import { User } from '@entity/User'
|
||||||
|
|
||||||
import { getKlickTippUser, addFieldsToSubscriber } from '@/apis/KlicktippController'
|
import { getKlickTippUser, addFieldsToSubscriber } from '@/apis/KlicktippController'
|
||||||
@ -39,29 +40,35 @@ async function klickTippSendFieldToUser(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMyConnection(): Promise<Connection | null> {
|
||||||
|
return connection()
|
||||||
|
}
|
||||||
|
|
||||||
export async function exportEventDataToKlickTipp(): Promise<void> {
|
export async function exportEventDataToKlickTipp(): Promise<void> {
|
||||||
const connectionInstance = await connection()
|
const connectionInstance = await getMyConnection()
|
||||||
if (!connectionInstance) {
|
if (!connectionInstance) {
|
||||||
throw new LogError('No connection to database')
|
throw new LogError('No connection to database')
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastLoginEvents = await lastDateTimeEvents(EventType.USER_LOGIN)
|
const lastLoginEvents = await lastDateTimeEvents(EventType.USER_LOGIN)
|
||||||
void klickTippSendFieldToUser(lastLoginEvents, 'field186060')
|
await klickTippSendFieldToUser(lastLoginEvents, 'field186060')
|
||||||
|
|
||||||
const registeredEvents = await lastDateTimeEvents(EventType.USER_ACTIVATE_ACCOUNT)
|
const registeredEvents = await lastDateTimeEvents(EventType.USER_ACTIVATE_ACCOUNT)
|
||||||
void klickTippSendFieldToUser(registeredEvents, 'field186061')
|
await klickTippSendFieldToUser(registeredEvents, 'field186061')
|
||||||
|
|
||||||
const receiveTransactionEvents = await lastDateTimeEvents(EventType.TRANSACTION_RECEIVE)
|
const receiveTransactionEvents = await lastDateTimeEvents(EventType.TRANSACTION_RECEIVE)
|
||||||
void klickTippSendFieldToUser(receiveTransactionEvents, 'field185674')
|
await klickTippSendFieldToUser(receiveTransactionEvents, 'field185674')
|
||||||
|
|
||||||
const contributionCreateEvents = await lastDateTimeEvents(EventType.TRANSACTION_SEND)
|
const contributionCreateEvents = await lastDateTimeEvents(EventType.TRANSACTION_SEND)
|
||||||
void klickTippSendFieldToUser(contributionCreateEvents, 'field185673')
|
await klickTippSendFieldToUser(contributionCreateEvents, 'field185673')
|
||||||
|
|
||||||
const linkRedeemedEvents = await lastDateTimeEvents(EventType.TRANSACTION_LINK_REDEEM)
|
const linkRedeemedEvents = await lastDateTimeEvents(EventType.TRANSACTION_LINK_REDEEM)
|
||||||
void klickTippSendFieldToUser(linkRedeemedEvents, 'field185676')
|
await klickTippSendFieldToUser(linkRedeemedEvents, 'field185676')
|
||||||
|
|
||||||
const confirmContributionEvents = await lastDateTimeEvents(EventType.ADMIN_CONTRIBUTION_CONFIRM)
|
const confirmContributionEvents = await lastDateTimeEvents(EventType.ADMIN_CONTRIBUTION_CONFIRM)
|
||||||
void klickTippSendFieldToUser(confirmContributionEvents, 'field185675')
|
await klickTippSendFieldToUser(confirmContributionEvents, 'field185675')
|
||||||
|
|
||||||
|
await connectionInstance.close()
|
||||||
}
|
}
|
||||||
void exportEventDataToKlickTipp()
|
void exportEventDataToKlickTipp()
|
||||||
// void retrieveNotRegisteredEmails()
|
// void retrieveNotRegisteredEmails()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user