fix: Phase 4 - fix test fixture type errors (42 -> 38 errors)

Fixed all test fixture mock data to match actual type definitions across
4 test files. Resolved 9 distinct type errors by correcting mock object
structures.

Files modified:
- entity.adapter.test.ts: Fixed Character mock to use nested hp/atk objects
- grid.adapter.test.ts: Fixed GridWeapon/GridCharacter/GridSummon mocks
  - Added proper entity objects (mockWeapon, mockCharacter, mockSummon)
  - Fixed transcendenceStage -> transcendenceStep
  - Removed invalid partyId/weaponId/characterId/summonId properties
- party.adapter.test.ts: Fixed Party mock
  - Changed visibility from 'public' string to 0 number
  - Removed invalid skills array from Job object
  - Added complete RaidGroup with all required properties
- user.adapter.test.ts: Fixed User/Party mocks
  - Created separate mockUser (User type) vs mockUserInfo (UserInfo type)
  - Fixed role type mismatch (number vs string)
  - Added required arrays (weapons, characters, summons) to Party objects

Result: 42 → 38 errors (-4)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Justin Edmund 2025-11-28 19:29:53 -08:00
parent 45b51d8880
commit 7caa34452f
4 changed files with 106 additions and 43 deletions

View file

@ -53,28 +53,29 @@ describe('EntityAdapter', () => {
}, },
rarity: 5, rarity: 5,
element: 2, element: 2,
proficiency1: 1, maxLevel: 100,
proficiency2: 2, uncap: {
series: 1, flb: true,
minHp: 150, ulb: true
maxHp: 750, },
minAttack: 250,
maxAttack: 1250,
flbHp: 900,
flbAttack: 1500,
ulbHp: 1050,
ulbAttack: 1750,
transcendenceHp: 1200,
transcendenceAttack: 2000,
special: false, special: false,
seasonalId: 'summer-1', recruits: null,
awakenings: [ gender: 0,
{ race: {
id: 'awk-2', race1: 1,
name: { en: 'HP Boost' }, race2: 2
level: 2 },
} proficiency: [1, 2],
] hp: {
minHp: 150,
maxHp: 750,
maxHpFlb: 900
},
atk: {
minAtk: 250,
maxAtk: 1250,
maxAtkFlb: 1500
}
} }
const mockSummon: Summon = { const mockSummon: Summon = {

View file

@ -8,38 +8,80 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { GridAdapter } from '../grid.adapter' import { GridAdapter } from '../grid.adapter'
import type { GridWeapon, GridCharacter, GridSummon } from '../grid.adapter' import type { GridWeapon, GridCharacter, GridSummon } from '../grid.adapter'
import type { Weapon, Character, Summon } from '$lib/types/api/entities'
describe('GridAdapter', () => { describe('GridAdapter', () => {
let adapter: GridAdapter let adapter: GridAdapter
let originalFetch: typeof global.fetch let originalFetch: typeof global.fetch
const mockWeapon: Weapon = {
id: 'weapon-1',
granblueId: '1040001',
name: { en: 'Test Weapon', ja: 'テスト武器' },
rarity: 5,
element: 1,
maxLevel: 150,
series: 1,
proficiency: 1,
uncap: { flb: true, ulb: true, transcendence: false },
hp: { minHp: 100, maxHp: 500, maxHpFlb: 600 },
atk: { minAtk: 200, maxAtk: 1000, maxAtkFlb: 1200 }
}
const mockCharacter: Character = {
id: 'char-1',
granblueId: '3040001',
name: { en: 'Test Character', ja: 'テストキャラ' },
rarity: 5,
element: 1,
maxLevel: 100,
uncap: { flb: true, ulb: true },
special: false,
recruits: null,
gender: 0,
race: { race1: 1, race2: 0 },
proficiency: [1],
hp: { minHp: 150, maxHp: 750, maxHpFlb: 900 },
atk: { minAtk: 250, maxAtk: 1250, maxAtkFlb: 1500 }
}
const mockSummon: Summon = {
id: 'summon-1',
granblueId: '2040001',
name: { en: 'Test Summon', ja: 'テスト召喚石' },
rarity: 5,
element: 1,
maxLevel: 150,
series: 1,
uncap: { flb: true, ulb: true, transcendence: false },
hp: { minHp: 100, maxHp: 500, maxHpFlb: 600 },
atk: { minAtk: 200, maxAtk: 1000, maxAtkFlb: 1200 }
}
const mockGridWeapon: GridWeapon = { const mockGridWeapon: GridWeapon = {
id: 'gw-1', id: 'gw-1',
partyId: 'party-1',
weaponId: 'weapon-1',
position: 1, position: 1,
mainhand: true, mainhand: true,
uncapLevel: 5, uncapLevel: 5,
transcendenceStage: 0 transcendenceStep: 0,
weapon: mockWeapon
} }
const mockGridCharacter: GridCharacter = { const mockGridCharacter: GridCharacter = {
id: 'gc-1', id: 'gc-1',
partyId: 'party-1',
characterId: 'char-1',
position: 1, position: 1,
uncapLevel: 5, uncapLevel: 5,
transcendenceStage: 1 transcendenceStep: 1,
character: mockCharacter
} }
const mockGridSummon: GridSummon = { const mockGridSummon: GridSummon = {
id: 'gs-1', id: 'gs-1',
partyId: 'party-1',
summonId: 'summon-1',
position: 1, position: 1,
quickSummon: true, quickSummon: true,
uncapLevel: 5, uncapLevel: 5,
transcendenceStage: 2 transcendenceStep: 2,
summon: mockSummon
} }
beforeEach(() => { beforeEach(() => {

View file

@ -18,28 +18,34 @@ describe('PartyAdapter', () => {
shortcode: 'ABC123', shortcode: 'ABC123',
name: 'Test Party', name: 'Test Party',
description: 'Test description', description: 'Test description',
visibility: 'public', visibility: 0,
user: { user: {
id: 'user-1', id: 'user-1',
username: 'testuser' username: 'testuser'
}, },
job: { job: {
id: 'job-1', id: 'job-1',
granblueId: 'job-1',
name: { en: 'Warrior', ja: 'ウォリアー' }, name: { en: 'Warrior', ja: 'ウォリアー' },
skills: [ row: 1,
{ order: 1,
id: 'skill-1', proficiency: [1, 2]
name: { en: 'Rage', ja: 'レイジ' },
slot: 1
}
]
}, },
raid: { raid: {
id: 'raid-1', id: 'raid-1',
slug: 'proto-bahamut',
name: { en: 'Proto Bahamut', ja: 'プロトバハムート' }, name: { en: 'Proto Bahamut', ja: 'プロトバハムート' },
level: 50,
element: 0,
group: { group: {
id: 'group-1', id: 'group-1',
name: { en: 'Tier 1', ja: 'ティア1' } name: { en: 'Tier 1', ja: 'ティア1' },
section: 'omega',
order: 1,
difficulty: 1,
hl: false,
extra: false,
guidebooks: true
} }
}, },
weapons: [], weapons: [],

View file

@ -2,6 +2,7 @@ import { describe, it, expect, beforeEach, vi } from 'vitest'
import { UserAdapter } from '../user.adapter' import { UserAdapter } from '../user.adapter'
import type { UserInfo, UserProfile } from '../user.adapter' import type { UserInfo, UserProfile } from '../user.adapter'
import type { Party } from '$lib/types/api/party' import type { Party } from '$lib/types/api/party'
import type { User } from '$lib/types/api/entities'
describe('UserAdapter', () => { describe('UserAdapter', () => {
let adapter: UserAdapter let adapter: UserAdapter
@ -21,6 +22,16 @@ describe('UserAdapter', () => {
} }
} }
const mockUser: User = {
id: 'user-1',
username: 'testuser',
role: 'user',
avatar: {
picture: 'avatar.jpg',
element: 'fire'
}
}
const mockUserProfile: UserProfile = { const mockUserProfile: UserProfile = {
...mockUserInfo, ...mockUserInfo,
parties: [ parties: [
@ -28,8 +39,11 @@ describe('UserAdapter', () => {
id: 'party-1', id: 'party-1',
shortcode: 'abc123', shortcode: 'abc123',
name: 'Test Party', name: 'Test Party',
user: mockUserInfo user: mockUser,
} as Party weapons: [],
characters: [],
summons: []
}
] ]
} }
@ -37,13 +51,13 @@ describe('UserAdapter', () => {
id: 'party-1', id: 'party-1',
shortcode: 'abc123', shortcode: 'abc123',
name: 'Fire Team', name: 'Fire Team',
user: mockUserInfo, user: mockUser,
visibility: 0, visibility: 0,
element: 1, element: 1,
characters: [], characters: [],
weapons: [], weapons: [],
summons: [] summons: []
} as Party }
beforeEach(() => { beforeEach(() => {
mockFetch = vi.fn() mockFetch = vi.fn()