fix(assessment): return confirmed categories with their basis and label demonstration categories
This commit is contained in:
1 parent
623d41b969
commit
d4903a3796
77 files changed
+1441
-288
No files matched your search
@@ -37,6 +37,11 @@ type AssessmentCategorySource string
|
||||
|
||||
const AssessmentCategorySourceSyntheticDemo AssessmentCategorySource = "synthetic_demo"
|
||||
|
||||
// IsKnown reports whether source is a value that the category contract names.
|
||||
func (source AssessmentCategorySource) IsKnown() bool {
|
||||
return source == AssessmentCategorySourceSyntheticDemo
|
||||
}
|
||||
|
||||
// AssessmentSyntheticCategoryReviewSnapshot pins the reviewed synthetic bank
|
||||
// opening to the exact product policy under which demo categories may be assigned.
|
||||
type AssessmentSyntheticCategoryReviewSnapshot struct {
|
||||
|
||||
@@ -119,6 +119,10 @@ var specializationCodes = []SpecializationCode{
|
||||
// IsKnown reports whether code is a specialization of the catalog.
|
||||
func (code SpecializationCode) IsKnown() bool { return slices.Contains(specializationCodes, code) }
|
||||
|
||||
// SpecializationCatalog returns the specializations in catalog order. The
|
||||
// result is a copy that the caller may change.
|
||||
func SpecializationCatalog() []SpecializationCode { return slices.Clone(specializationCodes) }
|
||||
|
||||
// GradeCode is a grade of the MVP scale. The same codes describe a
|
||||
// self-assessed grade, which the candidate states, and a confirmed grade,
|
||||
// which only an assessment result establishes; a profile stores only the
|
||||
|
||||
@@ -176,6 +176,9 @@ type CandidateViewConfirmedCategoryInput struct {
|
||||
Specialization SpecializationCode
|
||||
Grade GradeCode
|
||||
Strength CandidateViewConfirmationStrength
|
||||
// Basis says what the grade rests on. It is required: a category without
|
||||
// a basis would read as a real confirmation.
|
||||
Basis AssessmentCategorySource
|
||||
}
|
||||
|
||||
type candidateViewStackClaim struct {
|
||||
@@ -228,12 +231,15 @@ func CandidateViewProfileFromContent(content CandidateProfileContent) CandidateV
|
||||
return profile
|
||||
}
|
||||
|
||||
// CandidateViewCategory is the category and coarse strength shown only when
|
||||
// categories were explicitly included in the publication.
|
||||
// CandidateViewCategory is the category, its coarse strength, and its basis,
|
||||
// shown only when categories were explicitly included in the publication.
|
||||
// The field order matches CandidateViewConfirmedCategoryInput so that the two
|
||||
// convert into each other.
|
||||
type CandidateViewCategory struct {
|
||||
Specialization SpecializationCode `json:"specialization"`
|
||||
Grade GradeCode `json:"grade"`
|
||||
Strength CandidateViewConfirmationStrength `json:"strength"`
|
||||
Basis AssessmentCategorySource `json:"basis"`
|
||||
}
|
||||
|
||||
// CandidateViewSelfAssessment is a candidate-declared specialization and
|
||||
@@ -381,7 +387,8 @@ func IsCandidateViewPseudonym(value string) bool {
|
||||
func validateCandidateViewConfirmations(confirmations []CandidateViewConfirmedCategoryInput) error {
|
||||
seen := make(map[SpecializationCode]struct{}, len(confirmations))
|
||||
for _, confirmation := range confirmations {
|
||||
if !confirmation.Specialization.IsKnown() || !confirmation.Grade.IsKnown() || !confirmation.Strength.IsKnown() {
|
||||
if !confirmation.Specialization.IsKnown() || !confirmation.Grade.IsKnown() || !confirmation.Strength.IsKnown() ||
|
||||
!confirmation.Basis.IsKnown() {
|
||||
return ErrInvalidAnonymousCandidateView
|
||||
}
|
||||
if _, duplicate := seen[confirmation.Specialization]; duplicate {
|
||||
|
||||
@@ -144,6 +144,7 @@ func TestAnonymousCandidateViewUsesPublishedAllowlist(t *testing.T) {
|
||||
AsOf: time.Date(2026, 10, 6, 0, 0, 0, 0, time.UTC),
|
||||
ConfirmedCategories: []CandidateViewConfirmedCategoryInput{{
|
||||
Specialization: SpecializationBackend, Grade: GradeMiddle, Strength: CandidateViewStrengthStrong,
|
||||
Basis: AssessmentCategorySourceSyntheticDemo,
|
||||
}},
|
||||
WorkFormats: []QuestionnaireWorkFormat{QuestionnaireWorkFormatRemote, QuestionnaireWorkFormatHybrid},
|
||||
})
|
||||
@@ -250,6 +251,7 @@ func TestAnonymousCandidateViewKeepsCategoriesSeparateFromSelfAssessment(t *test
|
||||
}
|
||||
category := CandidateViewConfirmedCategoryInput{
|
||||
Specialization: SpecializationBackend, Grade: GradeMiddle, Strength: CandidateViewStrengthStandard,
|
||||
Basis: AssessmentCategorySourceSyntheticDemo,
|
||||
}
|
||||
newView := func(field CardField) AnonymousCandidateViewDTO {
|
||||
t.Helper()
|
||||
@@ -417,3 +419,24 @@ func containsCandidateViewSkill(skills []CandidateViewSkillCode, wanted Candidat
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// A category without a known basis would read as a real confirmation, so the
|
||||
// anonymous view refuses it instead of defaulting the basis.
|
||||
func TestAnonymousCandidateViewRequiresTheBasisOfEveryCategory(t *testing.T) {
|
||||
fields, err := NewCardFieldSet([]CardField{CardFieldCategories})
|
||||
if err != nil {
|
||||
t.Fatalf("NewCardFieldSet() error = %v", err)
|
||||
}
|
||||
for _, basis := range []AssessmentCategorySource{"", "real"} {
|
||||
_, err := NewAnonymousCandidateView(CandidateViewInput{
|
||||
Pseudonym: candidateViewTestPseudonym(t, uuid.New(), uuid.New()), PublishedFields: fields,
|
||||
AsOf: time.Date(2026, 10, 6, 0, 0, 0, 0, time.UTC),
|
||||
ConfirmedCategories: []CandidateViewConfirmedCategoryInput{{
|
||||
Specialization: SpecializationBackend, Grade: GradeJunior, Strength: CandidateViewStrengthStandard, Basis: basis,
|
||||
}},
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatalf("NewAnonymousCandidateView(basis %q) error = nil, want rejection", basis)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user