filter args optional, now default values

This commit is contained in:
Moriz Wahl 2022-06-01 14:11:50 +02:00
parent 70b1119840
commit 2c67d5f5fe
3 changed files with 7 additions and 12 deletions

View File

@ -2,12 +2,12 @@ import { Field, InputType } from 'type-graphql'
@InputType()
export default class TransactionLinkFilters {
@Field(() => Boolean, { nullable: true, defaultValue: true })
@Field(() => Boolean, { nullable: true })
withDeleted: boolean
@Field(() => Boolean, { nullable: true, defaultValue: true })
@Field(() => Boolean, { nullable: true })
withExpired: boolean
@Field(() => Boolean, { nullable: true, defaultValue: true })
@Field(() => Boolean, { nullable: true })
withRedeemed: boolean
}

View File

@ -21,9 +21,8 @@ import {
updatePendingCreation,
deletePendingCreation,
confirmPendingCreation,
listTransactionLinksAdmin,
} from '@/seeds/graphql/mutations'
import { getPendingCreations, login } from '@/seeds/graphql/queries'
import { getPendingCreations, login, listTransactionLinksAdmin } from '@/seeds/graphql/queries'
import { GraphQLError } from 'graphql'
import { User } from '@entity/User'
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
@ -1388,6 +1387,7 @@ describe('AdminResolver', () => {
user = await userFactory(testEnv, bibiBloxberg)
variables.userId = user.id
variables.pageSize = 25
// bibi needs GDDs
const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de')
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@ -1486,8 +1486,6 @@ describe('AdminResolver', () => {
...variables,
filters: {
withDeleted: true,
withExpired: null,
withRedeemed: null,
},
},
}),
@ -1513,8 +1511,7 @@ describe('AdminResolver', () => {
})
})
// TODO: works not as expected, because the expired link is not in the result eventhogh a link has 'createdAt' at the very first of 2022 and should be expired
describe.skip('filter by expired', () => {
describe('filter by expired', () => {
it('finds 6 open transaction links and 1 deleted and no redeemed', async () => {
await expect(
query({
@ -1522,9 +1519,7 @@ describe('AdminResolver', () => {
variables: {
...variables,
filters: {
withDeleted: null,
withExpired: true,
withRedeemed: null,
},
},
}),

View File

@ -426,7 +426,7 @@ export class AdminResolver {
async listTransactionLinksAdmin(
@Args()
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
@Arg('filters', () => TransactionLinkFilters, { nullable: true, defaultValue: null })
@Arg('filters', () => TransactionLinkFilters, { nullable: true })
filters: TransactionLinkFilters,
@Arg('userId', () => Int)
userId: number,