feat(tasks): add keyboard index and productivity dashboard improvements
This commit is contained in:
1 parent
02edb51b8a
commit
667776e43f
44 files changed
+1224
-138
No files matched your search
@@ -0,0 +1,66 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestTaskIndexChromium(t *testing.T) {
|
||||
if os.Getenv("PAGESWIKI_BROWSER_TEST") != "1" {
|
||||
t.Skip("opt-in Chromium")
|
||||
}
|
||||
for _, width := range []string{"1440", "390"} {
|
||||
t.Run(width, func(t *testing.T) {
|
||||
s, token, domain, actor := taskFixture(t)
|
||||
for i, title := range []string{"**Alpha**", "Beta", "Gamma"} {
|
||||
task := newTaskRecord("task", title)
|
||||
if i < 2 {
|
||||
project, err := s.store.SaveTask(context.Background(), domain, actor, newTaskRecord("project", "Project "+title), 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
task.ProjectUUID = project.UUID
|
||||
}
|
||||
if i == 1 {
|
||||
task.Status = "doing"
|
||||
}
|
||||
if _, err := s.store.SaveTask(context.Background(), domain, actor, task, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
script, err := os.ReadFile("internal/server/testdata/task-index.js")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Host = "localhost"
|
||||
r.Header.Set("Authorization", "Bearer "+token)
|
||||
if r.URL.Path == "/v/plan/tasks/index" {
|
||||
rec := httptest.NewRecorder()
|
||||
s.withAuthorization(s.mux).ServeHTTP(rec, r)
|
||||
for k, v := range rec.Header() {
|
||||
w.Header()[k] = v
|
||||
}
|
||||
w.WriteHeader(rec.Code)
|
||||
w.Write([]byte(strings.Replace(rec.Body.String(), "</body>", browserFixtureScript(rec.Header(), script)+"</body>", 1)))
|
||||
return
|
||||
}
|
||||
s.withAuthorization(s.mux).ServeHTTP(w, r)
|
||||
}))
|
||||
defer server.Close()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
|
||||
defer cancel()
|
||||
cmd := exec.CommandContext(ctx, "node", "internal/server/testdata/vim-browser-smoke.mjs", strings.Replace(server.URL, "127.0.0.1", "localhost", 1)+"/v/plan/tasks/index", t.TempDir(), "/tmp/pages-task-index-"+width+".png", width, "900")
|
||||
cmd.Env = append(os.Environ(), "PAGESWIKI_TASK_INDEX_BROWSER=1")
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("browser %v: %s", err, out)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user