feat: 增加档口入库码独立页面 (#233)
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestInnerCodeTemplate_独立导航与安全表单(t *testing.T) {
|
||||
if _, err := template.ParseFS(templateFS, "templates/*/*.html"); err != nil {
|
||||
t.Fatalf("模板必须可解析: %v", err)
|
||||
}
|
||||
header, err := os.ReadFile("templates/partials/header.html")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
headerText := string(header)
|
||||
clientIndex := strings.Index(headerText, `href="/clients"`)
|
||||
innerCodeIndex := strings.Index(headerText, `href="/inner-codes"`)
|
||||
if clientIndex < 0 || innerCodeIndex < 0 || innerCodeIndex < clientIndex {
|
||||
t.Fatal("档口入库码导航必须紧跟在客户端列表之后")
|
||||
}
|
||||
|
||||
raw, err := os.ReadFile("templates/inner_code/list.html")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
page := string(raw)
|
||||
for _, want := range []string{
|
||||
`action="/inner-codes/import"`, `action="/inner-codes/match"`,
|
||||
`action="/inner-codes/apply"`, `action="/inner-codes/recheck"`,
|
||||
`name="csrf_token"`, `data-check-all`, `data-inner-code-apply-open`,
|
||||
`{{if not .CanSelect}}disabled{{end}}`, `aria-label="档口入库码记录列表"`,
|
||||
} {
|
||||
if !strings.Contains(page, want) {
|
||||
t.Errorf("正式页面缺少 %s", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInnerCodeTemplate_模块状态白名单已登记(t *testing.T) {
|
||||
raw, err := os.ReadFile("static/js/app.js")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(string(raw), `"/inner-codes": ["date", "status", "q", "page"]`) {
|
||||
t.Fatal("档口入库码页面切换模块后应保持稳定筛选和页码")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user