Summary
Test files pass partial mock objects for generated GraphQL types (e.g. User, Submission, Publication). These types have many required fields that tests don't care about, leading to either as any casts or type errors.
Proposed solution
Create factory helpers in test/vitest/ that produce properly typed mock objects with sensible defaults, overridable per-test:
// test/vitest/factories.ts
import type { User } from "src/graphql/generated/graphql"
export function mockUser(overrides: Partial<User> = {}): User {
return {
__typename: "User",
id: "1",
email: "test@example.com",
username: "testuser",
name: "Test User",
...overrides
}
}
Files needing factory usage
src/components/AssignedSubmissionUsers.vitest.spec.ts — partial User in reviewers arrays
src/components/AssignedPublicationUsers.vitest.spec.ts — partial User in editors arrays
src/components/forms/AccountProfileForm.vitest.spec.ts — accountProfile: {} as any
src/use/forms/graphQLValidation.vitest.spec.ts — error.value = {} as any
src/components/PublicationStyleCriteria.vitest.spec.ts — (form().at(0) as any).vm.$emit(...)
src/components/forms/StyleCriteriaForm.vitest.spec.ts — (wrapper.emitted("delete")![0][0] as any).id
Summary
Test files pass partial mock objects for generated GraphQL types (e.g.
User,Submission,Publication). These types have many required fields that tests don't care about, leading to eitheras anycasts or type errors.Proposed solution
Create factory helpers in
test/vitest/that produce properly typed mock objects with sensible defaults, overridable per-test:Files needing factory usage
src/components/AssignedSubmissionUsers.vitest.spec.ts— partialUserinreviewersarrayssrc/components/AssignedPublicationUsers.vitest.spec.ts— partialUserineditorsarrayssrc/components/forms/AccountProfileForm.vitest.spec.ts—accountProfile: {} as anysrc/use/forms/graphQLValidation.vitest.spec.ts—error.value = {} as anysrc/components/PublicationStyleCriteria.vitest.spec.ts—(form().at(0) as any).vm.$emit(...)src/components/forms/StyleCriteriaForm.vitest.spec.ts—(wrapper.emitted("delete")![0][0] as any).id