fix(demo): advance seeded candidates past onboarding and show the express summary in Russian
This commit is contained in:
1 parent
41206abbcf
commit
945ab6d6a9
9 files changed
+296
-10
No files matched your search
@@ -84,11 +84,13 @@ type Input struct {
|
||||
Password domain.Password
|
||||
}
|
||||
|
||||
// Report lists what one run created and what it found. It holds addresses
|
||||
// of synthetic accounts and identifiers only.
|
||||
// Report lists what one run created, what it changed in an existing record,
|
||||
// and what it found. It holds addresses of synthetic accounts and identifiers
|
||||
// only.
|
||||
type Report struct {
|
||||
PolicyVersion int32
|
||||
Created []string
|
||||
Updated []string
|
||||
Present []string
|
||||
Logins []Login
|
||||
PreparedAttempts []PreparedAttempt
|
||||
@@ -114,6 +116,13 @@ func (report *Report) record(created bool, item string) {
|
||||
report.Present = append(report.Present, item)
|
||||
}
|
||||
|
||||
// update notes a change to a record that already existed. It is kept apart
|
||||
// from the created records, so a repeated run that repairs a stand reports no
|
||||
// new record.
|
||||
func (report *Report) update(item string) {
|
||||
report.Updated = append(report.Updated, item)
|
||||
}
|
||||
|
||||
// Seed builds the demo world or finds it complete.
|
||||
func (seeder *Seeder) Seed(ctx context.Context, input Input) (Report, error) {
|
||||
const location = "Seeder.Seed"
|
||||
@@ -565,8 +574,9 @@ func (seeder *Seeder) ensureMembership(ctx context.Context, organizationID, user
|
||||
}
|
||||
|
||||
// ensureCandidate gives a candidate its consents, manual profile, and
|
||||
// questionnaire; a prepared candidate also gets the prepared full attempt and
|
||||
// a published card. It returns the prepared attempt, or a zero ID.
|
||||
// questionnaire, then sets the onboarding step that the questionnaire leaves;
|
||||
// a prepared candidate also gets the prepared full attempt and a published
|
||||
// card. It returns the prepared attempt, or a zero ID.
|
||||
func (seeder *Seeder) ensureCandidate(
|
||||
ctx context.Context,
|
||||
spec accountSpec,
|
||||
@@ -593,6 +603,9 @@ func (seeder *Seeder) ensureCandidate(
|
||||
return domain.AssessmentAttemptID{}, fmt.Errorf("%s - %w", location, err)
|
||||
}
|
||||
report.record(created, "questionnaire of "+spec.email())
|
||||
if err := seeder.ensureOnboarding(ctx, user.ID, spec.email(), report); err != nil {
|
||||
return domain.AssessmentAttemptID{}, fmt.Errorf("%s - %w", location, err)
|
||||
}
|
||||
if spec.role != rolePrepared {
|
||||
return domain.AssessmentAttemptID{}, nil
|
||||
}
|
||||
@@ -609,6 +622,20 @@ func (seeder *Seeder) ensureCandidate(
|
||||
return attemptID, nil
|
||||
}
|
||||
|
||||
// ensureOnboarding leaves the candidate at candidate_assessment, the step that
|
||||
// a saved questionnaire leaves in the ordinary flow. A stand that already has
|
||||
// the step, or a later one, is unchanged, so a repeat reports no update.
|
||||
func (seeder *Seeder) ensureOnboarding(ctx context.Context, userID uuid.UUID, email string, report *Report) error {
|
||||
changed, err := seeder.deps.Store.AdvanceCandidateOnboarding(ctx, userID, seeder.now())
|
||||
if err != nil {
|
||||
return fmt.Errorf("advance onboarding of %s: %w", email, err)
|
||||
}
|
||||
if changed {
|
||||
report.update("onboarding of " + email + " at candidate_assessment")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// grantConsent grants the current text of the purpose; a repeat of the same
|
||||
// version is idempotent in the ledger.
|
||||
func (seeder *Seeder) grantConsent(ctx context.Context, subjectID uuid.UUID, purpose domain.ConsentPurpose) error {
|
||||
|
||||
Reference in new issue
Block a user