An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
// SiYuan - https://github.com/siyuan-note/siyuan
// Copyright (c) 2020-present, b3log.org
// SPDX-License-Identifier: AGPL-3.0-or-later
package api
import (
"net/http/httptest"
"strings"
"testing"
"github.com/gin-gonic/gin"
)
func TestAPIContractWPSFailurePayload(t *testing.T) {
engine := gin.New()
engine.POST("/api/lute/wpsPresentation2BlockDOM", wpsPresentation2BlockDOM)
for _, body := range []string{"{", `{}`, `{"data":null,"type":"objects"}`, `{"data":"x","text":42,"type":"objects"}`} {
recorder := httptest.NewRecorder()
engine.ServeHTTP(recorder, httptest.NewRequest("POST", "/api/lute/wpsPresentation2BlockDOM", strings.NewReader(body)))
requireAPIContract(t, "POST", "/api/lute/wpsPresentation2BlockDOM", recorder)
if !strings.Contains(recorder.Body.String(), `"code":-1`) || !strings.Contains(recorder.Body.String(), `"data":{"converted":false,"dom":""}`) {
t.Fatalf("WPS failure payload changed: %s", recorder.Body.String())
}
}
}