feat: add assessment, privacy and support flows
This commit is contained in:
1 parent
ee3738ee73
commit
e4f24fa202
339 files changed
+56454
-1126
No files matched your search
@@ -0,0 +1,61 @@
|
||||
package candidateview
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"lincodex/backend/internal/domain"
|
||||
)
|
||||
|
||||
func TestCardViewAccessEventRecordsOnlyFieldsReturnedInTheProjection(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
key, err := domain.NewCandidateViewPseudonymKey(bytes.Repeat([]byte("candidate-view-key"), 2))
|
||||
if err != nil {
|
||||
t.Fatalf("NewCandidateViewPseudonymKey() error = %v", err)
|
||||
}
|
||||
candidateID, organizationID, actorID := uuid.New(), uuid.New(), uuid.New()
|
||||
pseudonym, err := key.ForOrganization(organizationID, candidateID)
|
||||
if err != nil {
|
||||
t.Fatalf("ForOrganization() error = %v", err)
|
||||
}
|
||||
|
||||
view := domain.AnonymousCandidateViewDTO{Pseudonym: pseudonym}
|
||||
event, err := cardViewAccessEvent(candidateID, organizationID, actorID, view, time.Now())
|
||||
if err != nil {
|
||||
t.Fatalf("cardViewAccessEvent(pseudonym only) error = %v", err)
|
||||
}
|
||||
if got := event.FieldCodes(); len(got) != 0 {
|
||||
t.Fatalf("pseudonym-only field codes = %v, want empty", got)
|
||||
}
|
||||
|
||||
band := domain.CandidateExperienceBandOneToThree
|
||||
compatibility := domain.CandidateViewSalaryCompatible
|
||||
view.Categories = []domain.CandidateViewCategory{{Specialization: domain.SpecializationBackend, Grade: domain.GradeJunior, Strength: domain.CandidateViewStrengthStandard}}
|
||||
view.Skills = []domain.CandidateViewSkillCode{domain.CandidateViewSkillGo}
|
||||
view.ExperienceBand = &band
|
||||
view.WorkFormats = []domain.QuestionnaireWorkFormat{domain.QuestionnaireWorkFormatRemote}
|
||||
view.SalaryCompatibility = &compatibility
|
||||
event, err = cardViewAccessEvent(candidateID, organizationID, actorID, view, time.Now())
|
||||
if err != nil {
|
||||
t.Fatalf("cardViewAccessEvent(projected fields) error = %v", err)
|
||||
}
|
||||
want := []string{"categories", "experience", "salary_compatibility", "stack", "work_formats"}
|
||||
if got := event.FieldCodes(); !slices.Equal(got, want) {
|
||||
t.Fatalf("projected field codes = %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCardViewAccessEventRejectsAHandleThatIsNotAnOpaqueAlias(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := cardViewAccessEvent(uuid.New(), uuid.New(), uuid.New(), domain.AnonymousCandidateViewDTO{Pseudonym: "candidate-id"}, time.Now())
|
||||
if !errors.Is(err, ErrInvalidCandidateHandle) {
|
||||
t.Fatalf("cardViewAccessEvent(invalid alias) error = %v, want ErrInvalidCandidateHandle", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user