Skip to content

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

1.2 KB
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 (
	"reflect"
	"testing"
)

func TestMigrateChartHeightMenu(t *testing.T) {
	for _, existing := range []string{"unset", "visible", "hidden"} {
		profile := &EntryVisibilityProfile{
			Entries: map[string]bool{"gutter.single.chart.height": false},
			Orders: map[string][]string{
				"gutter.single":       {"pluginBefore", "width", "height", "pluginAfter"},
				"gutter.single.chart": {"pluginBefore", "height", "update", "pluginAfter"},
			},
		}
		if existing != "unset" {
			profile.Entries["gutter.single.height"] = existing == "visible"
		}
		for range 2 {
			migrateChartHeightMenu(profile)
			if !reflect.DeepEqual(profile.Entries, map[string]bool{"gutter.single.height": existing == "visible"}) ||
				!reflect.DeepEqual(profile.Orders["gutter.single.chart"], []string{"pluginBefore", "update", "pluginAfter"}) ||
				!reflect.DeepEqual(profile.Orders["gutter.single"], []string{"pluginBefore", "width", "height", "pluginAfter"}) {
				t.Fatalf("unexpected migration for %s: %+v", existing, profile)
			}
		}
	}
}