Files
bbs/internal/server/app_test.go
T
Claude bccdf2cc6a Deepen the message base: threads, votes, polls, aliases, signatures, groups, retention
For every front end (internal/app), the API and the CLI:

- Threads: from a message, the one it answers (O, PF2) and its whole
  thread (T, PF6), replies under what they answer; GET
  /messages/{id}/thread.
- Votes: up, down or none on a message (V, PF1), shown by its number;
  POST /messages/{id}/vote.
- Polls: a question and 2 to 10 answers posted in an area (L, PF9),
  answered (A, PF12) and shown with each answer's share; POST with
  "poll", POST /messages/{id}/answer.
- Aliases: a user's alias (checked like a new name, no one's name or
  alias) posted under in areas that allow it; the message's From is the
  alias everywhere, newsgroup articles included (they used the real
  name), while the sysop keeps whose it is.
- Signatures: up to three lines under posts and mail written on the BBS.
- Groups: areas listed by group, with a Group column.
- Retention: an area keeps its newest N messages and/or those of the
  last D days, purged hourly and by bbs area purge.

Tested on SQLite, PostgreSQL, MySQL and MariaDB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
2026-10-12 18:06:52 +00:00

64 lines
2.4 KiB
Go

package server
import (
"os/exec"
"strings"
"testing"
"github.com/Neo-Desktop/bbs-sec/internal/ui3270"
)
// TestShared3270: the screens internal/app shares, on a 3270 (s3270): the
// areas, a post from the editor, the message read back, the profile; and
// the post as a text caller reads it.
func TestShared3270(t *testing.T) {
if _, err := exec.LookPath("s3270"); err != nil {
t.Skip("no s3270")
}
addr := freeTCP(t)
e := startFull(t, ui3270.Graphics{}, nil, nil,
&Listener{Name: "telnet", Kind: "telnet", Address: addr, TN3270: true},
&Listener{Name: "modem", Kind: "raw", Address: "modem.sock", ANSI: "no"})
script := strings.Join([]string{
"Connect(" + addr + ")", "Wait(10,InputField)",
`String("alice")`, "Tab()", `String("alicepass1")`, "Enter()", "Wait(5,InputField)", "Ascii()",
`String("m")`, "Enter()", "Wait(5,InputField)", "Ascii()",
`String("s")`, "Enter()", "Wait(5,InputField)",
"PF(6)", "Wait(5,InputField)",
"Tab()", `String("Hello from a 3270")`, "Tab()", `String("A line of the body.")`,
"PF(5)", "Wait(5,InputField)", "Ascii()",
`String("s")`, "Enter()", "Wait(5,InputField)", "Ascii()",
"PF(3)", "Wait(5,InputField)", "PF(3)", "Wait(5,InputField)", "PF(3)", "Wait(5,InputField)",
`String("p")`, "Enter()", "Wait(5,InputField)", "Ascii()",
"PF(3)", "Wait(5,InputField)", "PF(3)", "Wait(3,Seconds)", "Ascii()", "Quit()", ""}, "\n")
cmd := exec.Command("s3270", "-model", "3279-2")
cmd.Stdin = strings.NewReader(script)
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("s3270: %v\n%s", err, out)
}
for _, want := range []string{"Welcome, alice.", "Message areas", "General", "PF5=New", "PF10=Find",
"Posted as #1.", "Hello from a 3270", "A line of the body.", "PF4=Reply",
"Your profile", "Access:", "Terminal:", "PF5=Location"} {
if !strings.Contains(string(out), want) {
t.Errorf("no %q:\n%s", want, out)
}
}
d := login(e, "sysop", "sysoppass1")
d.send("M")
d.expect("Area number, [N]ew scan, [T]o you, [F]ind, [S]can setup, [+] add area, [Q]uit: ")
d.send("1\r")
d.expect("Hello from a 3270")
d.expect("Number to read, [R]ead new, [P]ost, [L] New poll, [Q]uit: ")
d.send("1\r")
d.expect("A line of the body.")
d.expect("[N]ext, [P]revious, [R]eply, [M]ail reply, [D]elete, [V]ote, [T]hread, [Q]uit: ")
d.send("Q")
d.expect("[P]ost, [L] New poll, [Q]uit: ")
d.send("Q\r")
d.expect("[+] add area, [Q]uit: ")
d.send("Q\r")
d.expect("Command: ")
}