style: 压缩档口入库码筛选工具栏 (#239)
This commit is contained in:
@@ -65,3 +65,57 @@ func TestInnerCodeTemplate_模块状态白名单已登记(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInnerCodeTemplate_筛选顺序与紧凑宽度(t *testing.T) {
|
||||
raw, err := os.ReadFile("templates/inner_code/list.html")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
page := string(raw)
|
||||
parts := []string{
|
||||
`id="inner-code-status"`,
|
||||
`id="inner-code-date" type="date" name="date"`,
|
||||
`id="inner-code-keyword"`,
|
||||
`class="button-link" href="/inner-codes?date={{.BusinessDate}}">清除</a>`,
|
||||
`<button type="submit">搜索</button>`,
|
||||
}
|
||||
lastIndex := -1
|
||||
for _, part := range parts {
|
||||
index := strings.Index(page, part)
|
||||
if index < 0 {
|
||||
t.Fatalf("筛选工具栏缺少 %s", part)
|
||||
}
|
||||
if index <= lastIndex {
|
||||
t.Fatalf("筛选工具栏顺序不正确,%s 没有位于上一控件之后", part)
|
||||
}
|
||||
lastIndex = index
|
||||
}
|
||||
filterStart := strings.Index(page, `<form id="inner-code-filter"`)
|
||||
if filterStart < 0 {
|
||||
t.Fatal("没有找到档口入库码筛选表单")
|
||||
}
|
||||
filterEnd := strings.Index(page[filterStart:], `</form>`)
|
||||
if filterEnd < 0 {
|
||||
t.Fatal("没有找到完整的档口入库码筛选表单")
|
||||
}
|
||||
filter := page[filterStart : filterStart+filterEnd]
|
||||
if strings.Contains(filter, `type="hidden" name="date"`) {
|
||||
t.Fatal("筛选表单应直接提交可见业务日期,不能继续保留重复隐藏字段")
|
||||
}
|
||||
|
||||
css, err := os.ReadFile("static/css/app.css")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
styles := string(css)
|
||||
for _, want := range []string{
|
||||
`.inner-code-toolbar input[type="text"].inner-code-search`,
|
||||
`flex: 0 0 150px`, `width: 150px`, `min-width: 150px`,
|
||||
`.inner-code-toolbar .inner-code-filter-form { flex-wrap: wrap; }`,
|
||||
`.inner-code-toolbar .inner-code-filter-form { flex-basis: 100%; }`,
|
||||
} {
|
||||
if !strings.Contains(styles, want) {
|
||||
t.Errorf("筛选工具栏样式缺少 %s", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user