Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

830 B
Raw Blame
// SiYuan - https://github.com/siyuan-note/siyuan
// Copyright (c) 2020-present, b3log.org
// SPDX-License-Identifier: AGPL-3.0-or-later

package conf

import (
	"encoding/json"
	"strings"
	"testing"
)

func TestCustomBlockSearchCompatibility(t *testing.T) {
	for _, tc := range []struct {
		body string
		want bool
	}{{`{}`, true}, {`{"customBlock":null}`, true}, {`{"customBlock":true}`, true}, {`{"customBlock":false}`, false}} {
		var search Search
		if err := json.Unmarshal([]byte(tc.body), &search); err != nil {
			t.Fatal(err)
		}
		if search.CustomBlockEnabled() != tc.want || strings.Contains(search.TypeFilter(), "'custom'") != tc.want {
			t.Fatalf("unexpected filter for %s: %s", tc.body, search.TypeFilter())
		}
	}
	if !NewSearch().CustomBlockEnabled() {
		t.Fatal("custom blocks must be enabled by default")
	}
}