package slidestest
// Editing a scene by hand, the server's half (scenes and clips spec ยง5;
// templates/editor.html's scene group, editor.go): the words are Paul's
// approved ones, the Insert menu's Scene row waits for the deck to have
// a scene, and the out-of-date note's Ask an agent goes to the
// assistant where there is one and to the Agents page where there is
// not. The browser's half is scenes_editor_browser_test.go.
import (
"encoding/json"
"net/http"
"os"
"path/filepath"
"regexp"
"strings"
"testing"
)
// editorScene is the scene the editor's tests edit. It answers ready to
// every init (a preview, or a frame made afresh, is a document of its
// own) and tells the page, under a name of its own, what each message
// said: the state, its words' title, its data as JSON and its MARK, the
// line the code panel's tests change.
const editorScene = `
`
// sceneEditorWords are the scene card's words as Paul approved them
// (copy review, 2026-11-24), by catalog key.
var sceneEditorWords = map[string]string{
"slides.editor.block.scene": "Scene",
"slides.editor.scene.from": "From",
"slides.editor.scene.to": "To",
"slides.editor.scene.words": "Words in this scene",
"slides.editor.scene.stale": "These pictures are older than the scene.",
"slides.editor.scene.stale.ask": "Ask an agent to redraw them",
"slides.editor.scene.missing": "{n} states have no picture yet.",
"slides.editor.scene.missing.one": "1 state has no picture yet.",
"slides.editor.scene.data": "Data",
"slides.editor.scene.data.table": "Table",
"slides.editor.scene.data.json": "JSON",
"slides.editor.scene.data.add": "Add a row",
"slides.editor.scene.data.remove": "Remove row",
"slides.editor.scene.data.invalid": "That isn't valid JSON.",
"slides.editor.scene.data.big": "This data is over 960 KB, so it wasn't saved.",
"slides.editor.scene.missing.list": "Scenes still missing pictures",
"slides.editor.scene.code": "Code",
"slides.editor.scene.code.preview": "Preview",
"slides.editor.scene.code.save": "Save code",
"slides.editor.scene.code.author": "Last changed by {name}",
"slides.refused.scene": "{name} isn't a single HTML page.",
"slides.refused.scene.big": "{name} is over 2 MB.",
}
// TestTheSceneCardSaysPaulsWords: every key is in en.toml with the
// approved English, and every editor key is listed in editorStrings.
func TestTheSceneCardSaysPaulsWords(t *testing.T) {
toml := readSource(t, "locales/en.toml")
listed := map[string]bool{}
for _, k := range goStrings(t, readSource(t, "editor.go"), "editorStrings") {
listed[k] = true
}
for key, english := range sceneEditorWords {
m := regexp.MustCompile(`(?m)^` + regexp.QuoteMeta(key) + ` = "(.*)"$`).FindStringSubmatch(toml)
if m == nil {
t.Errorf("en.toml has no %s", key)
} else if got := strings.ReplaceAll(m[1], `\"`, `"`); got != english {
t.Errorf("%s is %q, want Paul's %q", key, got, english)
}
if short, ok := strings.CutPrefix(key, "slides.editor."); ok && !listed[short] {
t.Errorf("editorStrings does not list %s", short)
}
}
}
// sceneRowRE is the Insert menu's Scene row.
var sceneRowRE = regexp.MustCompile(`