Inline question choices, compact one-click inbox cards, drop snooze
This commit is contained in:
@@ -194,6 +194,59 @@ func TestBlobsMigrationOverPositionalCopy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestInlineQuestionChoicesMigration(t *testing.T) {
|
||||
db := openTestDB(t, filepath.Join(t.TempDir(), "byre.db"))
|
||||
i := slices.IndexFunc(migrations, func(m migration) bool { return m.name == "inline-question-choices" })
|
||||
err := migrate(db, migrations[:i])
|
||||
if err != nil {
|
||||
t.Fatalf("migrate: %v", err)
|
||||
}
|
||||
insertReport(t, db, "r1", `{"text":"x"}`)
|
||||
_, err = db.Exec(`
|
||||
INSERT INTO inbox_items (id, project_id, task_id, agent_session_id, thread_id, kind, priority, blocking, payload, state, created_at)
|
||||
VALUES ('q1', 'p1', 't1', 's1', 'q1', 'question', 0, 1,
|
||||
'{"context":"Pick a color.","question":"Which?","why_blocked":"w","options":["red","blue"],"recommended_option":"blue","attachments":[]}', 'answered', 'x');
|
||||
INSERT INTO inbox_responses (id, item_id, user_login, type, option, text, attachments, created_at) VALUES ('a1', 'q1', 'alice', 'option', 'red', NULL, '[]', 'x');
|
||||
INSERT INTO inbox_responses (id, item_id, user_login, type, option, text, attachments, created_at) VALUES ('a2', 'q1', 'alice', 'other', NULL, 'green', '[]', 'x');
|
||||
`)
|
||||
if err != nil {
|
||||
t.Fatalf("insert question: %v", err)
|
||||
}
|
||||
|
||||
err = migrate(db, migrations)
|
||||
if err != nil {
|
||||
t.Fatalf("migrate: %v", err)
|
||||
}
|
||||
|
||||
payload := reportPayload(t, db, "q1")
|
||||
want := `{"context":"Pick a color.\n\n- ( ) red\n- (*) blue","question":"Which?","why_blocked":"w","options":["red","blue"],"attachments":[],"multiple":false,"recommended":["blue"]}`
|
||||
if payload != want {
|
||||
t.Fatalf("question payload\n got %s\nwant %s", payload, want)
|
||||
}
|
||||
if reportPayload(t, db, "r1") != `{"text":"x"}` {
|
||||
t.Fatalf("report payload changed")
|
||||
}
|
||||
|
||||
options := map[string]sql.NullString{}
|
||||
rows, err := db.Query(`SELECT id, options FROM inbox_responses`)
|
||||
if err != nil {
|
||||
t.Fatalf("responses: %v", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
id := ""
|
||||
o := sql.NullString{}
|
||||
err = rows.Scan(&id, &o)
|
||||
if err != nil {
|
||||
t.Fatalf("scan: %v", err)
|
||||
}
|
||||
options[id] = o
|
||||
}
|
||||
if options["a1"].String != `["red"]` || options["a2"].Valid {
|
||||
t.Fatalf("response options %+v", options)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlattenReportPayloadsRunsTwice(t *testing.T) {
|
||||
db := openTestDB(t, filepath.Join(t.TempDir(), "byre.db"))
|
||||
err := migrate(db, migrations)
|
||||
|
||||
Reference in New Issue
Block a user