Files
zeekay 8feb24ea1f One name for this fork, and it is ours
The server module named github.com/hanzoai/team/server/v8 — a path that
resolves to the retired workspace's repository, not this one — while
server/public still published github.com/mattermost/mattermost/server/public.
Both are github.com/hanzoteam/server/... now, which is where this code
actually lives.

That second half is what made the binary unbootable. Upstream's public path
stayed claimed by upstream, mattermost-plugin-ai imported it, and the build
linked public/model twice; public/plugin's gob.Register then ran twice under
one name and panicked at init, before main. Reverting the rename traded the
brand for a working binary. Rebranding the plugin alongside it needs no such
trade: the agents fork is github.com/hanzoteam/agents/v2 against our public
module, so no module named mattermost/mattermost is in the graph at all.

Measured: `go list -deps ./cmd/mattermost` names exactly one public/model, and
it is ours.
2026-08-28 23:35:36 -07:00

95 lines
2.9 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package app
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/hanzoteam/server/server/public/model"
)
func TestBuildBoardKanbanView(t *testing.T) {
t.Run("rejects status field with no options attribute", func(t *testing.T) {
statusField := &model.PropertyField{
ID: model.NewId(),
Attrs: map[string]any{},
}
view, err := buildBoardKanbanView(model.NewId(), statusField)
require.Nil(t, view)
require.NotNil(t, err)
require.Contains(t, err.DetailedError, "status field has no options")
})
t.Run("rejects status field with empty options", func(t *testing.T) {
statusField := &model.PropertyField{
ID: model.NewId(),
Attrs: map[string]any{"options": []any{}},
}
view, err := buildBoardKanbanView(model.NewId(), statusField)
require.Nil(t, view)
require.NotNil(t, err)
})
t.Run("builds a column per valid option", func(t *testing.T) {
creatorID := model.NewId()
statusField := &model.PropertyField{
ID: model.NewId(),
Attrs: map[string]any{
"options": []any{
map[string]any{"id": "opt-todo", "name": "Todo"},
map[string]any{"id": "opt-doing", "name": "Doing"},
map[string]any{"id": "opt-done", "name": "Done"},
},
},
}
view, err := buildBoardKanbanView(creatorID, statusField)
require.Nil(t, err)
require.NotNil(t, view)
assert.Equal(t, model.ViewTypeKanban, view.Type)
assert.Equal(t, creatorID, view.CreatorId)
assert.Equal(t, "Board", view.Title)
kanban, kErr := model.KanbanPropsFromProps(view.Props)
require.NoError(t, kErr)
assert.Equal(t, statusField.ID, kanban.GroupBy.FieldID)
require.Len(t, kanban.GroupBy.Columns, 3)
assert.Equal(t, "Todo", kanban.GroupBy.Columns[0].Name)
assert.Equal(t, []string{"opt-todo"}, kanban.GroupBy.Columns[0].OptionIDs)
assert.Equal(t, "Doing", kanban.GroupBy.Columns[1].Name)
assert.Equal(t, "Done", kanban.GroupBy.Columns[2].Name)
for _, col := range kanban.GroupBy.Columns {
assert.NotEmpty(t, col.ID, "column should have a generated ID")
}
})
t.Run("skips options that are not maps or have missing fields", func(t *testing.T) {
statusField := &model.PropertyField{
ID: model.NewId(),
Attrs: map[string]any{
"options": []any{
"not-a-map", // skipped
map[string]any{"id": "", "name": "blank-id"}, // skipped (empty id)
map[string]any{"id": "opt-x", "name": ""}, // skipped (empty name)
map[string]any{"id": "opt-todo", "name": "Todo"},
},
},
}
view, err := buildBoardKanbanView(model.NewId(), statusField)
require.Nil(t, err)
require.NotNil(t, view)
kanban, kErr := model.KanbanPropsFromProps(view.Props)
require.NoError(t, kErr)
require.Len(t, kanban.GroupBy.Columns, 1)
assert.Equal(t, "Todo", kanban.GroupBy.Columns[0].Name)
})
}