0.3.32
This commit is contained in:
@@ -90,6 +90,48 @@ func TestJourneyEventRejectsAnUnreadablePlaySession(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Pause and resume are playback steps like start and complete, and carry where playback
|
||||
// was rather than an outcome — the console derives the pause's length from the gap
|
||||
// between a pause row's timestamp and its matching resume's.
|
||||
func TestJourneyEventAcceptsPauseAndResume(t *testing.T) {
|
||||
now := time.Now().UTC()
|
||||
for _, action := range []string{"pause", "resume"} {
|
||||
payload := journeyEventPayload{UserID: "u1", JourneyID: "j1", Category: "playback",
|
||||
Action: action, Screen: "player", Feature: "playback", Source: "continue_watching",
|
||||
Target: "player", ItemID: "42", ItemName: "Whale Rider", ItemType: "Movie",
|
||||
PlaySessionID: "b3d1f0a4-9c22-4f61-8a10-77d0e2c9aa51", PositionMs: 925000}
|
||||
event, ok := toJourneyEvent(payload, "u1", now)
|
||||
if !ok {
|
||||
t.Fatalf("action %q was rejected", action)
|
||||
}
|
||||
if event.PositionMs != 925000 {
|
||||
t.Fatalf("action %q: position was not retained: %+v", action, event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A wild position is clamped rather than dropped: the step it describes is worth more
|
||||
// than one field on it, the same trade dwell time makes on the row events.
|
||||
func TestJourneyEventClampsAWildPosition(t *testing.T) {
|
||||
now := time.Now().UTC()
|
||||
base := journeyEventPayload{UserID: "u1", JourneyID: "j1", Category: "playback",
|
||||
Action: "pause", Screen: "player", Feature: "playback", ItemID: "42"}
|
||||
|
||||
negative := base
|
||||
negative.PositionMs = -500
|
||||
event, ok := toJourneyEvent(negative, "u1", now)
|
||||
if !ok || event.PositionMs != 0 {
|
||||
t.Fatalf("negative position was not clamped to zero: %+v", event)
|
||||
}
|
||||
|
||||
wild := base
|
||||
wild.PositionMs = maxPositionMs + 1
|
||||
event, ok = toJourneyEvent(wild, "u1", now)
|
||||
if !ok || event.PositionMs != maxPositionMs {
|
||||
t.Fatalf("oversized position was not clamped: %+v", event)
|
||||
}
|
||||
}
|
||||
|
||||
func TestJourneyEventRetainsTheItemName(t *testing.T) {
|
||||
now := time.Now().UTC()
|
||||
payload := journeyEventPayload{UserID: "u1", JourneyID: "j1", Category: "content",
|
||||
|
||||
Reference in New Issue
Block a user