feat(ui): skill levels + titles on CREW tab and team-builder (#45)
CI / build + unit + e2e (pull_request) Successful in 3m7s
CI / build + unit + e2e (pull_request) Successful in 3m7s
This commit is contained in:
@@ -259,6 +259,43 @@ describe('getCrewState', () => {
|
||||
expect(crew.map((c) => c.role)).toEqual(expected.map((m) => m.role))
|
||||
expect(crew.map((c) => [c.traitGood, c.traitBad])).toEqual(expected.map((m) => [m.traitGood, m.traitBad]))
|
||||
})
|
||||
|
||||
it('attaches per-member skill levels + title: the four crew_skills rows in fixed order, SENIOR from L3, null below', async () => {
|
||||
const { db } = await freshFile()
|
||||
const { crew: seeded } = await getCrewState(db) // ensureSave seeds the starting crew + their crew_skills rows (v8)
|
||||
expect(seeded.length).toBeGreaterThanOrEqual(2)
|
||||
const [pinned, other] = [seeded[0], seeded[1]]
|
||||
|
||||
// Pin the first member to NAVIGATION L3 (xp 15 — the L3 threshold, so levelFromXp round-trips)
|
||||
// with the other three skills L0, and reset the second member to all-L0 (a specialist role
|
||||
// would otherwise seed L2).
|
||||
for (const skill of ['NAVIGATION', 'SCANNING', 'ENGINEERING', 'RESEARCH'] as const) {
|
||||
const level = skill === 'NAVIGATION' ? 3 : 0
|
||||
await db.db.update(schema.crewSkills).set({ level, xp: level > 0 ? XP_THRESHOLDS[level - 1] : 0 }).where(and(eq(schema.crewSkills.crewId, pinned.id), eq(schema.crewSkills.skill, skill)))
|
||||
}
|
||||
for (const r of (await db.db.select().from(schema.crewSkills)).filter((r) => r.crewId === other.id)) {
|
||||
await db.db.update(schema.crewSkills).set({ level: 0, xp: 0 }).where(eq(schema.crewSkills.id, r.id))
|
||||
}
|
||||
|
||||
const { crew } = await getCrewState(db)
|
||||
const p = crew.find((c) => c.id === pinned.id)!
|
||||
expect(p.skills).toEqual([
|
||||
{ skill: 'NAVIGATION', level: 3 },
|
||||
{ skill: 'SCANNING', level: 0 },
|
||||
{ skill: 'ENGINEERING', level: 0 },
|
||||
{ skill: 'RESEARCH', level: 0 },
|
||||
])
|
||||
expect(p.title).toBe(`SENIOR ${p.role}`) // the pinned skill is the member's highest — L3 → SENIOR
|
||||
|
||||
const o = crew.find((c) => c.id === other.id)!
|
||||
expect(o.skills).toEqual([
|
||||
{ skill: 'NAVIGATION', level: 0 },
|
||||
{ skill: 'SCANNING', level: 0 },
|
||||
{ skill: 'ENGINEERING', level: 0 },
|
||||
{ skill: 'RESEARCH', level: 0 },
|
||||
])
|
||||
expect(o.title).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('explorePlanet crew finds', () => {
|
||||
|
||||
Reference in New Issue
Block a user