Established Participants and Tickets model. Migrated concepts.

This commit is contained in:
Pen Anderson 2026-03-04 10:53:42 -06:00
parent 0df93e1886
commit cd8e1e3b3b
22 changed files with 1345 additions and 191 deletions

View file

@ -71,25 +71,25 @@ func TestPublicSignup(t *testing.T) {
t.Error("should not be confirmed yet")
}
// Attendee should be auto-created and linked
if vol.AttendeeID == nil {
t.Fatal("expected attendee to be linked")
// Participant should be auto-created and linked
if vol.ParticipantID == nil {
t.Fatal("expected participant to be linked")
}
a, _ := app.getAttendee(*vol.AttendeeID)
if a == nil {
t.Fatal("linked attendee not found")
p, _ := app.getParticipant(*vol.ParticipantID)
if p == nil {
t.Fatal("linked participant not found")
}
if a.Email != "titania@example.com" {
t.Errorf("attendee email = %q, want titania@example.com", a.Email)
if p.Email != "titania@example.com" {
t.Errorf("participant email = %q, want titania@example.com", p.Email)
}
}
func TestPublicSignupAutoMatchAttendee(t *testing.T) {
func TestPublicSignupAutoMatchParticipant(t *testing.T) {
app := testApp(t)
mux := testMux(app)
// Pre-existing attendee
existing, _ := app.createAttendee(Attendee{Name: "Titania Fairweather", Email: "titania@example.com"})
// Pre-existing participant
existing, _ := app.createParticipant(Participant{PreferredName: "Titania Fairweather", Email: "titania@example.com"})
w := httptest.NewRecorder()
mux.ServeHTTP(w, testRequest("POST", "/api/public/signup", map[string]any{
@ -105,8 +105,8 @@ func TestPublicSignupAutoMatchAttendee(t *testing.T) {
if vol == nil {
t.Fatal("volunteer not created")
}
if vol.AttendeeID == nil || *vol.AttendeeID != existing.ID {
t.Errorf("expected volunteer linked to existing attendee %d, got %v", existing.ID, vol.AttendeeID)
if vol.ParticipantID == nil || *vol.ParticipantID != existing.ID {
t.Errorf("expected volunteer linked to existing participant %d, got %v", existing.ID, vol.ParticipantID)
}
}
@ -277,13 +277,13 @@ func TestConfirmEmailWithSignupsOpen(t *testing.T) {
app.db.Exec(`INSERT OR REPLACE INTO config (key, value) VALUES ('shift_signups_open', 'true')`)
app.baseURL = "https://example.com"
attendee, _ := app.createAttendee(Attendee{Name: "Titania", Email: "titania@example.com"})
participant, _ := app.createParticipant(Participant{PreferredName: "Titania", Email: "titania@example.com"})
token := "abc123def456"
app.createVolunteer(Volunteer{
Name: "Titania",
PreferredName: "Titania",
Email: "titania@example.com",
AttendeeID: &attendee.ID,
ParticipantID: &participant.ID,
ConfirmationToken: &token,
})
@ -301,10 +301,17 @@ func TestConfirmEmailWithSignupsOpen(t *testing.T) {
t.Error("expected kiosk_link when signups are open")
}
// Attendee should now have a kiosk token
a, _ := app.getAttendee(attendee.ID)
if a.VolunteerToken == nil {
t.Error("attendee should have kiosk token after confirm with signups open")
// Ticket for participant should now have a code
tickets, _ := app.listTickets(&participant.ID, "")
hasCode := false
for _, tk := range tickets {
if tk.Code != nil && *tk.Code != "" {
hasCode = true
break
}
}
if !hasCode {
t.Error("participant should have a ticket with code after confirm with signups open")
}
}