This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
gitgram-ai/gitgram/web/tests/talentGraphService.test.ts
caelum0x 7275b79df9 feat(web): surface talent-graph need-coverage / gap analysis in the UI
The backend shipped GET /talent-graph/opportunities/:id/coverage and
talentGapAnalysisService (ARCHITECTURE §3.1 CQ#7 — "which required skills does
the pool cover, and which are unmet gaps?") but no web client consumed it.
Institutions could see top candidates yet not their skill gaps.

- talentGraphService: add getOpportunityCoverage() + NeedCoverageAnalysis,
  SkillCoverage, CoverageStrength types mirroring the backend contract.
- talent-network page: fetch coverage alongside matches for the selected
  opportunity and render a "Beceri kapsama" panel — per-skill strength badges
  (verified/evidenced/interest/unmet), the unmet-skill gap list, coverage ratio
  and roll-up status. Coverage is a public read (skill tokens + counts only, no
  private free text), so it renders for any viewer of the need.
- CSS: coverage panel styled in the existing Swiss/editorial system.
- tests: web service test for the coverage endpoint (path + shape).

Additive, read-only slice. No backend changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-26 17:11:33 +03:00

51 lines
1.9 KiB
TypeScript

/// <reference types="vitest/globals" />
import { describe, it, expect, beforeEach } from 'vitest'
import MockAdapter from 'axios-mock-adapter'
import api from '@/services/api'
import { talentGraphService, type NeedCoverageAnalysis } from '@/services/talentGraphService'
const mock = new MockAdapter(api)
describe('talentGraphService.getOpportunityCoverage', () => {
beforeEach(() => {
mock.reset()
})
it('reads the coverage endpoint and returns the gap analysis for an opportunity', async () => {
const coverage: NeedCoverageAnalysis = {
requiredSkills: ['javascript', 'kubernetes'],
coverage: [
{ skill: 'javascript', strength: 'verified', candidateCount: 3, evidencedCount: 2, verifiedCount: 1 },
{ skill: 'kubernetes', strength: 'unmet', candidateCount: 0, evidencedCount: 0, verifiedCount: 0 },
],
unmetSkills: ['kubernetes'],
coverageRatio: 0.5,
status: 'partially-covered',
candidatePool: 4,
}
mock.onGet('/v1/talent-graph/opportunities/opp-1/coverage').reply(200, {
data: { opportunity: { id: 'opp-1' }, coverage },
})
const result = await talentGraphService.getOpportunityCoverage('opp-1')
expect(result.opportunity.id).toBe('opp-1')
expect(result.coverage.status).toBe('partially-covered')
expect(result.coverage.unmetSkills).toEqual(['kubernetes'])
expect(result.coverage.coverage[0].strength).toBe('verified')
})
it('encodes the opportunity id in the request path', async () => {
let requestedUrl = ''
mock.onGet(/\/talent-graph\/opportunities\/.*\/coverage/).reply((config) => {
requestedUrl = config.url || ''
return [200, { data: { opportunity: { id: 'a/b' }, coverage: { requiredSkills: [], coverage: [], unmetSkills: [], coverageRatio: 0, status: 'unmet', candidatePool: 0 } } }]
})
await talentGraphService.getOpportunityCoverage('a/b')
expect(requestedUrl).toContain('/talent-graph/opportunities/a%2Fb/coverage')
})
})