Files
aego/tools/gendocs/site/studio_test.go
sanspie 50be5c04bc
ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Stage 12.5: Art Workspace and asset authoring
Add dockable Art tools, animation and previews, guarded asset workflows,
and the Web Asset Studio built on the shared Art Core. Expand English and
Russian documentation, interactive Try scenes, examples and editor icons.

Add audio waveform navigation, source analysis, guarded previews and a
browser Worker mixer. Preserve source changes and recovery with bounded
checks, and strengthen native, browser and interoperability CI.

Prepare version 0.12.5 and manually built native artifact candidates.
Fix the production site image demo build dependency.
Reuse immutable scene indices when capturing keyframes.
Wait for real Persist save/load completion in component tests.
Stabilize browser Game View captures outside pointer hover.
Aseprite interchange and persistent Audio EDL recovery remain limited;
the artifact workflow does not publish releases or change stable.
2026-11-15 10:37:50 +03:00

96 lines
3.7 KiB
Go

package site
import (
"os"
"path/filepath"
"strings"
"testing"
)
func TestStudioIsOptionalLazyAndMustExist(t *testing.T) {
dir := t.TempDir()
if _, err := Build(fixture(), dir, Options{Studio: true}); err == nil {
t.Fatal("a dead Studio link was generated")
}
if err := os.Mkdir(filepath.Join(dir, "studio"), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(dir, "studio", "index.html"), []byte("<!doctype html><title>Studio</title>"), 0o644); err != nil {
t.Fatal(err)
}
if _, err := Build(fixture(), dir, Options{Studio: true}); err != nil {
t.Fatal(err)
}
for _, spec := range []struct{ page, link, label string }{
{"index.html", `href="studio/"`, "Art Studio"},
{"ru/index.html", `href="../studio/"`, "Art Studio"},
} {
b, err := os.ReadFile(filepath.Join(dir, filepath.FromSlash(spec.page)))
if err != nil {
t.Fatal(err)
}
if !strings.Contains(string(b), spec.link) || !strings.Contains(string(b), spec.label) {
t.Fatalf("%s has no localized studio link", spec.page)
}
for _, eager := range []string{"artstudio.wasm", "studio.js", "wasm_exec.js"} {
if strings.Contains(string(b), eager) {
t.Fatalf("%s eagerly includes %s", spec.page, eager)
}
}
}
}
func TestPinnedStudioLinksUseIntegratedGuidesWithoutLocalWASM(t *testing.T) {
dir := t.TempDir()
for _, lang := range []string{"en", "ru"} {
path := filepath.Join(dir, "asset-studio", lang, "first-sprite")
if err := os.MkdirAll(path, 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(path, "index.html"), []byte("guide"), 0o644); err != nil {
t.Fatal(err)
}
}
const pinned = "https://aeditor.akarpov.ru/r/build-1/"
if _, err := Build(fixture(), dir, Options{StudioURL: pinned, StudioGuides: true}); err != nil {
t.Fatal(err)
}
for _, spec := range []struct{ page, guide, label, action string }{
{"index.html", `href="asset-studio/en/first-sprite/"`, "Art Studio lessons", "Open Art Studio"},
{"ru/index.html", `href="../asset-studio/ru/first-sprite/"`, "Уроки Art Studio", "Открыть Art Studio"},
} {
b, err := os.ReadFile(filepath.Join(dir, filepath.FromSlash(spec.page)))
if err != nil {
t.Fatal(err)
}
if !strings.Contains(string(b), `href="`+pinned+`editor/"`) || !strings.Contains(string(b), spec.guide) || !strings.Contains(string(b), spec.label) {
t.Fatalf("%s does not link pinned editor and localized guide", spec.page)
}
if !strings.Contains(string(b), `<a class="button" href="`+pinned+`editor/">`+spec.action+`</a>`) {
t.Fatalf("%s does not show a localized Studio launch button", spec.page)
}
if strings.Contains(string(b), `href="studio/"`) || strings.Contains(string(b), `href="../studio/"`) {
t.Fatalf("%s links to the legacy local Studio", spec.page)
}
for _, eager := range []string{"artstudio.wasm", "docs-embed.", "protocol."} {
if strings.Contains(string(b), eager) {
t.Fatalf("%s eagerly includes %s", spec.page, eager)
}
}
}
if _, err := os.Stat(filepath.Join(dir, "studio")); !os.IsNotExist(err) {
t.Fatal("pinned integration unexpectedly created a second local Studio")
}
}
func TestPinnedStudioRejectsInvalidURLsAndMissingGuides(t *testing.T) {
for _, bad := range []string{"javascript:alert(1)", "http://example.com/r/build/", "https://user@example.com/r/build/", "https://example.com/editor/", "https://example.com/r/build/?x=1", "https://example.com/r/%2e%2e/"} {
if _, err := Build(fixture(), t.TempDir(), Options{StudioURL: bad}); err == nil {
t.Fatalf("accepted unsafe or unpinned URL %q", bad)
}
}
if _, err := Build(fixture(), t.TempDir(), Options{StudioURL: "https://example.com/r/build/", StudioGuides: true}); err == nil {
t.Fatal("linked missing guides")
}
}