mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
The screens after the login (menus, message areas, reading and writing, mail, file areas, who's online, the user list, system info, the profile and SSH keys, validation, paging the sysop) were written twice, once for text terminals and once for 3270s. They are now written once in internal/app, as descriptions in internal/view's terms (menus, tables, messages, forms, panels, drafts), and each front end draws them its own way: prompts and keys a page at a time (RIP buttons for menus) on a text terminal, fields and PF keys on a 3270. What only a front end can do stays with it, behind app.Frontend: the logins, display files, chat, doors, transfers (protocols, or IND$FILE), the terminal's line on the profile and the goodbye. The 3270 gains what it lacked: the main menu by letter like the text BBS's, a new scan, messages to other nodes from who's online, validation, SSH keys, editing and removing files, paging with a message left when the sysop is away. The text prompts are as before. Tests: internal/app driven by a scripted front end; the column layout and text key labels; a 3270 (s3270) through areas, posting, reading and the profile, with a text caller reading its post. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
64 lines
2.3 KiB
Go
64 lines
2.3 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 scan",
|
|
"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, [+] add area, [Q]uit: ")
|
|
d.send("1\r")
|
|
d.expect("Hello from a 3270")
|
|
d.expect("Number to read, [R]ead new, [P]ost, [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, [Q]uit: ")
|
|
d.send("Q")
|
|
d.expect("[P]ost, [Q]uit: ")
|
|
d.send("Q\r")
|
|
d.expect("[+] add area, [Q]uit: ")
|
|
d.send("Q\r")
|
|
d.expect("Command: ")
|
|
}
|