Add web push notifications for new inbox items
This commit is contained in:
@@ -116,20 +116,22 @@ func TestServesEmbeddedSPA(t *testing.T) {
|
||||
t.Cleanup(hs.Close)
|
||||
|
||||
for path, contentType := range map[string]string{
|
||||
"/": "text/html",
|
||||
"/style.css": "text/css",
|
||||
"/dist/app.js": "text/javascript",
|
||||
"/dist/app.js.map": "",
|
||||
"/src/app.ts": "",
|
||||
"/dist/inbox.js": "text/javascript",
|
||||
"/dist/api.gen.js": "text/javascript",
|
||||
"/dist/tasks.js": "text/javascript",
|
||||
"/dist/navbar.js": "text/javascript",
|
||||
"/dist/panes.js": "text/javascript",
|
||||
"/dist/task.js": "text/javascript",
|
||||
"/dist/state.js": "text/javascript",
|
||||
"/dist/dom.js": "text/javascript",
|
||||
"/dist/api.js": "text/javascript",
|
||||
"/": "text/html",
|
||||
"/style.css": "text/css",
|
||||
"/dist/app.js": "text/javascript",
|
||||
"/dist/app.js.map": "",
|
||||
"/src/app.ts": "",
|
||||
"/dist/inbox.js": "text/javascript",
|
||||
"/dist/api.gen.js": "text/javascript",
|
||||
"/dist/tasks.js": "text/javascript",
|
||||
"/dist/navbar.js": "text/javascript",
|
||||
"/dist/panes.js": "text/javascript",
|
||||
"/dist/task.js": "text/javascript",
|
||||
"/dist/state.js": "text/javascript",
|
||||
"/dist/dom.js": "text/javascript",
|
||||
"/dist/api.js": "text/javascript",
|
||||
"/dist/settings.js": "text/javascript",
|
||||
"/sw.js": "text/javascript",
|
||||
"/fonts/atkinson-hyperlegible-mono-latin-wght-normal.woff2": "font/woff2",
|
||||
"/fonts/LICENSE": "",
|
||||
} {
|
||||
@@ -167,6 +169,40 @@ func TestMe(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotificationSettings(t *testing.T) {
|
||||
h := newHarness(t)
|
||||
|
||||
me := api.User{}
|
||||
h.do("GET", "/api/me", nil, &me)
|
||||
if me.NotificationPrefs != (api.NotificationPrefs{BlockingQuestions: true}) {
|
||||
t.Fatalf("unexpected default prefs %+v", me.NotificationPrefs)
|
||||
}
|
||||
|
||||
code := h.do("PUT", "/api/me/notifications", api.NotificationPrefs{BlockingQuestions: true, Reports: true}, &me)
|
||||
if code != http.StatusOK || me.NotificationPrefs != (api.NotificationPrefs{BlockingQuestions: true, Reports: true}) {
|
||||
t.Fatalf("update prefs: %d %+v", code, me.NotificationPrefs)
|
||||
}
|
||||
|
||||
key := api.PushKey{}
|
||||
h.do("GET", "/api/push/key", nil, &key)
|
||||
if len(key.PublicKey) < 80 {
|
||||
t.Fatalf("unexpected vapid key %q", key.PublicKey)
|
||||
}
|
||||
|
||||
code = h.do("POST", "/api/me/push-subscriptions", api.PushSubscription{Endpoint: "http://push.example/x", P256dh: "k", Auth: "a"}, nil)
|
||||
if code != http.StatusBadRequest {
|
||||
t.Fatalf("want 400 for a non-https endpoint, got %d", code)
|
||||
}
|
||||
code = h.do("POST", "/api/me/push-subscriptions", api.PushSubscription{Endpoint: "https://push.example/x", P256dh: "k", Auth: "a"}, nil)
|
||||
if code != http.StatusNoContent {
|
||||
t.Fatalf("subscribe: %d", code)
|
||||
}
|
||||
code = h.do("DELETE", "/api/me/push-subscriptions?endpoint=https%3A%2F%2Fpush.example%2Fx", nil, nil)
|
||||
if code != http.StatusNoContent {
|
||||
t.Fatalf("unsubscribe: %d", code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProjectAndTaskLifecycle(t *testing.T) {
|
||||
h := newHarness(t)
|
||||
p := h.createProject("demo")
|
||||
|
||||
Reference in New Issue
Block a user