Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GO-3189: sort order doesn't work properly when Done is at the top of the sort #1668

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/block/editor/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (p *Page) CreationStateMigration(ctx *smartblock.InitContext) migration.Mig
case model.ObjectType_todo:
templates = append(templates,
template.WithTitle,
template.WithRelations([]domain.RelationKey{bundle.RelationKeyDone}),
template.WithDetail(bundle.RelationKeyDone, pbtypes.Bool(false)),
)
case model.ObjectType_bookmark:
templates = append(templates,
Expand Down
53 changes: 53 additions & 0 deletions core/block/editor/page_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package editor

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/anyproto/anytype-heart/core/block/editor/smartblock"
"github.com/anyproto/anytype-heart/core/block/editor/smartblock/smarttest"
"github.com/anyproto/anytype-heart/core/block/editor/state"
"github.com/anyproto/anytype-heart/core/block/migration"
"github.com/anyproto/anytype-heart/core/domain"
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore"
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
"github.com/anyproto/anytype-heart/util/pbtypes"
)

func TestPage_CreationStateMigration(t *testing.T) {
t.Run("todo layout migration", func(t *testing.T) {
// given

initContext := &smartblock.InitContext{
IsNewObject: true,
State: state.NewDoc("rootId", nil).(*state.State),
ObjectTypeKeys: []domain.TypeKey{bundle.TypeKeyTask},
}

storeFixture := objectstore.NewStoreFixture(t)
storeFixture.AddObjects(t, []objectstore.TestObject{
{
bundle.RelationKeyId: pbtypes.String("task"),
bundle.RelationKeyUniqueKey: pbtypes.String(bundle.TypeKeyTask.URL()),
bundle.RelationKeyRecommendedLayout: pbtypes.Int64(int64(model.ObjectType_todo)),
bundle.RelationKeySpaceId: pbtypes.String("spaceId"),
},
})

p := &Page{}
test := smarttest.New("rootId")
test.SetSpaceId("spaceId")
p.SmartBlock = test
p.objectStore = storeFixture

// when
migration.RunMigrations(p, initContext)

// then
done := pbtypes.Get(initContext.State.Details(), bundle.RelationKeyDone.String())
assert.NotNil(t, done)
assert.False(t, done.GetBoolValue())
})
}
Loading