I want to do simple testing return single record using scenario test api
I have one simple describe in applications.test.ts
import { application } from './applications'
describe('application', () => {
scenario('returns single application', async (scenario) => {
const result = await application({ id: scenario.data.one.id})
expect(result.id).toEqual(scenario.application.one.id)
})
})
And its applications.scenario.ts
export const standard = defineScenario({
application: {
one: {
data: {
message: "String",
application_for_type: "events",
// application_for_id: 1,
created_by: 1,
updated_by: 1,
// user_id: 1,
user: {
create: {
name: "ryan",
password: "123456",
email: "ryan@gmail.com"
}
},
job: {
create: {
title: "Job 1",
}
},
}
},
two: {
data: {
message: "String",
application_for_type: "programs",
// application_for_id: 1,
created_by: 1,
updated_by: 1,
// user_id: 1,
user: {
create: {
name: "ryan",
password: "123456",
email: "ryan2@gmail.com"
}
},
job: {
create: {
title: "Job 2",
}
},
}
},
},
})
When i run it always return Unknown arg user
But when i remove user and run again, its foreign key failed
I see generated file index.d.ts, ApplicationCreateArgs that is scenario use, look at the XOR
export type ApplicationCreateArgs = {
/**
* Select specific fields to fetch from the Application
*
**/
select?: ApplicationSelect | null
/**
* Choose, which related nodes to fetch as well.
*
**/
include?: ApplicationInclude | null
/**
* The data needed to create a Application.
*
**/
data: XOR<ApplicationCreateInput, ApplicationUncheckedCreateInput>
}
export type ApplicationCreateInput = {
uuid?: string | null
message: string
application_for_type: string
status?: string
created_by: number
updated_by: number
deleted_at?: Date | string | null
created_at?: Date | string | null
updated_at?: Date | string | null
user: UserCreateNestedOneWithoutApplicationsInput
job: JobCreateNestedOneWithoutApplicationsInput
tenant?: TenantCreateNestedOneWithoutApplicationsInput
}
export type ApplicationUncheckedCreateInput = {
id?: number
uuid?: string | null
user_id: number
message: string
application_for_type: string
application_for_id: number
status?: string
created_by: number
updated_by: number
tenant_id?: number | null
deleted_at?: Date | string | null
created_at?: Date | string | null
updated_at?: Date | string | null
}
I see there is “user” in ApplicationCreateInput but always unknown args “user”
What should i do, to make scenario create user data relation successfully ?