feat(15-02): register journal export/import commands and Posts toolbar
JSON CLI matching PHP ExportPosts/ImportPosts ships as HasCommands, and Posts toolbar actions reuse that logic behind access_import_export. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
package journal
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/pact"
|
||||
)
|
||||
|
||||
func TestPostTranslatableSmoke(t *testing.T) {
|
||||
p := &Plugin{}
|
||||
@@ -12,3 +17,38 @@ func TestPostTranslatableSmoke(t *testing.T) {
|
||||
t.Fatalf("Requires = %#v, want exactly [golem15.translate]", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestJournalCommands(t *testing.T) {
|
||||
p := &Plugin{}
|
||||
names := map[string]bool{}
|
||||
for _, cmd := range p.Commands() {
|
||||
names[cmd.Name] = true
|
||||
}
|
||||
for _, want := range []string{"journal:export-posts", "journal:import-posts"} {
|
||||
if !names[want] {
|
||||
t.Fatalf("Commands() missing %s", want)
|
||||
}
|
||||
}
|
||||
foundExport, foundImport := false, false
|
||||
for _, ctl := range p.AdminControllers() {
|
||||
src, ok := ctl.(pact.HasAdminActions)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
for _, action := range src.AdminActions() {
|
||||
perm := strings.Join(action.Permissions, ",")
|
||||
if !strings.Contains(perm, "golem15.journal.access_import_export") {
|
||||
continue
|
||||
}
|
||||
switch action.Name {
|
||||
case "exportPosts":
|
||||
foundExport = true
|
||||
case "importPosts":
|
||||
foundImport = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if !foundExport || !foundImport {
|
||||
t.Fatalf("Posts AdminActions missing import/export with access_import_export (export=%v import=%v)", foundExport, foundImport)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user