feat: recent activity card on Home and Retention card on Settings
This commit is contained in:
1 parent
35db442cd3
commit
43469ef08d
33 files changed
+2748
-204
No files matched your search
@@ -0,0 +1,57 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestActivityRecentPageSize(t *testing.T) {
|
||||
const homeCardQuery = "/v1/activity?size=5"
|
||||
|
||||
t.Run("The query the Home card sends returns the first five rows", func(t *testing.T) {
|
||||
e := newActivityHTTPEnv(t, 1000)
|
||||
var newest []uint64
|
||||
for minute := 1; minute <= 8; minute++ {
|
||||
event := e.seedBy(t, userActor(activityOwnerID, "Marta Alves"), time.Duration(minute)*time.Minute)
|
||||
if minute <= 5 {
|
||||
newest = append(newest, event.ID)
|
||||
}
|
||||
}
|
||||
|
||||
list := decodeActivityList(t, e.get(homeCardQuery, asUser(e, activityOwnerID)))
|
||||
|
||||
if list.Size != 5 || list.Page != 1 || list.Total != 8 || len(list.Items) != 5 {
|
||||
t.Fatalf("unexpected page %d/%d total %d with %d items", list.Page, list.Size, list.Total, len(list.Items))
|
||||
}
|
||||
if !sameIDs(list.ids(), newest) {
|
||||
t.Errorf("expected %v, got %v", newest, list.ids())
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("A non-owner at size 5 only gets their own events", func(t *testing.T) {
|
||||
e := newActivityHTTPEnv(t, 1000)
|
||||
var own []uint64
|
||||
for minute := 1; minute <= 7; minute++ {
|
||||
event := e.seedBy(t, userActor(activityEditorID, "ed"), time.Duration(minute)*time.Minute)
|
||||
if minute <= 5 {
|
||||
own = append(own, event.ID)
|
||||
}
|
||||
}
|
||||
for minute := 1; minute <= 3; minute++ {
|
||||
e.seedBy(t, userActor(activityOwnerID, "Marta Alves"), time.Duration(minute)*time.Second)
|
||||
}
|
||||
|
||||
list := decodeActivityList(t, e.get(homeCardQuery, asUser(e, activityEditorID)))
|
||||
|
||||
if list.Size != 5 || list.Total != 7 || !sameIDs(list.ids(), own) {
|
||||
t.Errorf("expected own %v of 7, got %v of %d (size %d)", own, list.ids(), list.Total, list.Size)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Sizes other than 5, 25, 50 and 100 stay refused", func(t *testing.T) {
|
||||
for _, size := range []string{"4", "6", "10", "200"} {
|
||||
e := newActivityHTTPEnv(t, 1000)
|
||||
assertPlain(t, e.get("/v1/activity?size="+size, asUser(e, activityOwnerID)), 400, activityMismatch)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user