platform/webui: add scenario description, show it in the Scenario page's list
ScenarioSpec gains an optional "description" field. Listing (both ListLocalScenarioFiles and ListScenarioFilesOnRemovableMedia, via the new scenarioDescription helper) reads it out of each file without requiring full ParseScenarioJSON validation to succeed, so a listing never hides a scenario over an unrelated validation issue. The webui Scenario page now renders Name/Description/Found-on/Run instead of just Name/Found-on — a bare filename rarely tells anyone but the author what a scenario actually does. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
5a780e96b4
commit
d108df7fe9
@@ -234,7 +234,8 @@ func TestReadScenarioFallsBackToRemovableMediaWhenNotLocal(t *testing.T) {
|
||||
|
||||
func TestListAvailableScenariosMergesLocalAndRemovable(t *testing.T) {
|
||||
localDir := withLocalScenariosDir(t)
|
||||
if err := os.WriteFile(filepath.Join(localDir, "shipped.json"), []byte(`{}`), 0644); err != nil {
|
||||
shipped := []byte(`{"name":"shipped","description":"reproduces the reboot"}`)
|
||||
if err := os.WriteFile(filepath.Join(localDir, "shipped.json"), shipped, 0644); err != nil {
|
||||
t.Fatalf("write local scenario: %v", err)
|
||||
}
|
||||
|
||||
@@ -265,7 +266,13 @@ func TestListAvailableScenariosMergesLocalAndRemovable(t *testing.T) {
|
||||
if got[0].Name != "shipped" || got[0].Device != "local (shipped with image)" {
|
||||
t.Fatalf("got[0]=%+v want local shipped entry first", got[0])
|
||||
}
|
||||
if got[0].Description != "reproduces the reboot" {
|
||||
t.Fatalf("got[0].Description=%q want %q", got[0].Description, "reproduces the reboot")
|
||||
}
|
||||
if got[1].Name != "from-usb" {
|
||||
t.Fatalf("got[1]=%+v want from-usb", got[1])
|
||||
}
|
||||
if got[1].Description != "" {
|
||||
t.Fatalf("got[1].Description=%q want empty (file has no description field)", got[1].Description)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user