From 61f3da38fa3d1f0610fae7f424ab5bc64f47e20f Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 27 Apr 2022 12:13:57 +0200 Subject: [PATCH] creation factory returns unconfirmed creation object --- backend/src/seeds/factory/creation.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/src/seeds/factory/creation.ts b/backend/src/seeds/factory/creation.ts index 88a681ef7..3c319fb9f 100644 --- a/backend/src/seeds/factory/creation.ts +++ b/backend/src/seeds/factory/creation.ts @@ -17,7 +17,7 @@ export const nMonthsBefore = (date: Date, months = 1): string => { export const creationFactory = async ( client: ApolloServerTestClient, creation: CreationInterface, -): Promise => { +): Promise => { const { mutate, query } = client await query({ query: login, variables: { email: 'peter@lustig.de', password: 'Aa12345_' } }) @@ -27,12 +27,12 @@ export const creationFactory = async ( // get User const user = await User.findOneOrFail({ where: { email: creation.email } }) - if (creation.confirmed) { - const pendingCreation = await AdminPendingCreation.findOneOrFail({ - where: { userId: user.id }, - order: { created: 'DESC' }, - }) + const pendingCreation = await AdminPendingCreation.findOneOrFail({ + where: { userId: user.id }, + order: { created: 'DESC' }, + }) + if (creation.confirmed) { await mutate({ mutation: confirmPendingCreation, variables: { id: pendingCreation.id } }) if (creation.moveCreationDate) { @@ -50,5 +50,7 @@ export const creationFactory = async ( await transaction.save() } } + } else { + return pendingCreation } }