From c4cbc50da0cf5227c1dd940ccea63d632e316b83 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 10 Jan 2022 16:33:52 +0100 Subject: [PATCH 1/3] address correct db column for only creations filter --- backend/src/typeorm/repository/UserTransaction.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/typeorm/repository/UserTransaction.ts b/backend/src/typeorm/repository/UserTransaction.ts index 57f89d5a5..386145d03 100644 --- a/backend/src/typeorm/repository/UserTransaction.ts +++ b/backend/src/typeorm/repository/UserTransaction.ts @@ -1,6 +1,7 @@ import { EntityRepository, Repository } from 'typeorm' import { Order } from '../../graphql/enum/Order' import { UserTransaction } from '@entity/UserTransaction' +import { TransactionTypeId } from '../../graphql/enum/TransactionTypeId' @EntityRepository(UserTransaction) export class UserTransactionRepository extends Repository { @@ -14,7 +15,9 @@ export class UserTransactionRepository extends Repository { if (onlyCreation) { return this.createQueryBuilder('userTransaction') .where('userTransaction.userId = :userId', { userId }) - .andWhere('userTransaction.type = "creation"') + .andWhere('userTransaction.transactionTypeId = :transactionTypeId', { + transactionTypeId: TransactionTypeId.CREATION, + }) .orderBy('userTransaction.balanceDate', order) .limit(limit) .offset(offset) From 3abce024baf8cd309c443ea0ff383f11c3f09b21 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 10 Jan 2022 16:40:30 +0100 Subject: [PATCH 2/3] filter transactions for type creation due to the first transaction is always a decay --- .../components/CreationTransactionListFormular.spec.js | 8 +++----- admin/src/components/CreationTransactionListFormular.vue | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/admin/src/components/CreationTransactionListFormular.spec.js b/admin/src/components/CreationTransactionListFormular.spec.js index 9817d6b8f..32dcb6c9d 100644 --- a/admin/src/components/CreationTransactionListFormular.spec.js +++ b/admin/src/components/CreationTransactionListFormular.spec.js @@ -8,7 +8,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ transactionList: { transactions: [ { - type: 'created', + type: 'creation', balance: 100, decayStart: 0, decayEnd: 0, @@ -27,7 +27,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ }, }, { - type: 'created', + type: 'creation', balance: 200, decayStart: 0, decayEnd: 0, @@ -58,9 +58,7 @@ const mocks = { query: apolloQueryMock, }, $toasted: { - global: { - error: toastedErrorMock, - }, + error: toastedErrorMock, }, } diff --git a/admin/src/components/CreationTransactionListFormular.vue b/admin/src/components/CreationTransactionListFormular.vue index 09e1fa92a..7fed4adcc 100644 --- a/admin/src/components/CreationTransactionListFormular.vue +++ b/admin/src/components/CreationTransactionListFormular.vue @@ -30,10 +30,10 @@ export default { }, }) .then((result) => { - this.items = result.data.transactionList.transactions + this.items = result.data.transactionList.transactions.filter((t) => t.type === 'creation') }) .catch((error) => { - this.$toasted.global.error(error.message) + this.$toasted.error(error.message) }) }, }, From d07755f95aa9e1f26df35045dfc3355051eef56b Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 10 Jan 2022 13:45:38 +0100 Subject: [PATCH 3/3] get the tests running --- admin/src/components/UserTable.spec.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/admin/src/components/UserTable.spec.js b/admin/src/components/UserTable.spec.js index 80bdf6047..e26a548cc 100644 --- a/admin/src/components/UserTable.spec.js +++ b/admin/src/components/UserTable.spec.js @@ -3,6 +3,9 @@ import UserTable from './UserTable.vue' const localVue = global.localVue +const apolloQueryMock = jest.fn() +apolloQueryMock.mockResolvedValue() + describe('UserTable', () => { let wrapper @@ -114,6 +117,12 @@ describe('UserTable', () => { }), } }), + $apollo: { + query: apolloQueryMock, + }, + $store: { + commit: jest.fn(), + }, } const Wrapper = (propsData) => {