feat(workspace): add hashtag indexing, tag pages and bullet group view
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m0s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m0s
This commit is contained in:
1 parent
c4b2a00348
commit
1310f8102e
8 files changed
+893
-11
No files matched your search
@@ -619,3 +619,95 @@ func TestSpaceMembersDirectInvitationAPI(t *testing.T) {
|
||||
t.Fatalf("expected 200 OK for remove member, got %d: %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkspaceTagsAPI(t *testing.T) {
|
||||
srv, store, _ := setupTestServer(t)
|
||||
router := srv.Router()
|
||||
|
||||
user, _ := store.CreateUser("api_tag_user@example.com", "hash", "API Tag User", "member")
|
||||
token, _ := auth.GenerateToken(srv.cfg.JWTSecret, user.ID, user.Email, user.DisplayName)
|
||||
|
||||
// Create document with hashtags
|
||||
blocks := []domain.DocumentBlock{
|
||||
{ID: "b1", Type: "bullet", Content: "Planung #Sprint12", Level: 0},
|
||||
{ID: "b2", Type: "bullet", Content: "Subtask 1", Level: 1},
|
||||
}
|
||||
_, err := store.CreateDocument(user.ID, "", "Sprint Plan", "🚀", "", blocks, nil, false)
|
||||
if err != nil {
|
||||
t.Fatalf("CreateDocument failed: %v", err)
|
||||
}
|
||||
|
||||
// 1. GET /api/v1/workspace/tags
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/v1/workspace/tags", nil)
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
rec := httptest.NewRecorder()
|
||||
router.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("expected 200 OK, got %d: %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
var tagList []domain.TagSummary
|
||||
_ = json.Unmarshal(rec.Body.Bytes(), &tagList)
|
||||
if len(tagList) != 1 || tagList[0].Tag != "sprint12" {
|
||||
t.Fatalf("expected tag 'sprint12', got %+v", tagList)
|
||||
}
|
||||
|
||||
// 2. GET /api/v1/workspace/tags/Sprint12
|
||||
req = httptest.NewRequest(http.MethodGet, "/api/v1/workspace/tags/Sprint12", nil)
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
rec = httptest.NewRecorder()
|
||||
router.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("expected 200 OK, got %d: %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
var details domain.TagDetails
|
||||
_ = json.Unmarshal(rec.Body.Bytes(), &details)
|
||||
if details.Tag != "sprint12" || details.TotalMatches != 1 || len(details.Documents) != 1 {
|
||||
t.Fatalf("unexpected tag details: %+v", details)
|
||||
}
|
||||
matched := details.Documents[0].MatchedBlocks[0]
|
||||
if matched.RootBlock.ID != "b1" || len(matched.Children) != 1 || matched.Children[0].ID != "b2" {
|
||||
t.Fatalf("unexpected matched blocks or children: %+v", matched)
|
||||
}
|
||||
|
||||
// 3. Folder endpoints test
|
||||
// Create folder
|
||||
createFolderBody := []byte(`{"path":"TestOrdner"}`)
|
||||
req = httptest.NewRequest(http.MethodPost, "/api/v1/folders", bytes.NewReader(createFolderBody))
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
rec = httptest.NewRecorder()
|
||||
router.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusCreated {
|
||||
t.Fatalf("expected 201 Created from /api/v1/folders, got %d: %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
|
||||
// Get folders
|
||||
req = httptest.NewRequest(http.MethodGet, "/api/v1/folders", nil)
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
rec = httptest.NewRecorder()
|
||||
router.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("expected 200 OK from /api/v1/folders, got %d", rec.Code)
|
||||
}
|
||||
var folders []string
|
||||
_ = json.Unmarshal(rec.Body.Bytes(), &folders)
|
||||
foundFolder := false
|
||||
for _, f := range folders {
|
||||
if f == "TestOrdner" {
|
||||
foundFolder = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !foundFolder {
|
||||
t.Fatalf("expected TestOrdner in folders list, got %v", folders)
|
||||
}
|
||||
|
||||
// Delete folder
|
||||
req = httptest.NewRequest(http.MethodDelete, "/api/v1/folders?path=TestOrdner", nil)
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
rec = httptest.NewRecorder()
|
||||
router.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("expected 200 OK from DELETE /api/v1/folders, got %d", rec.Code)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user