Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
wip(daemon): include various versions in test
Browse files Browse the repository at this point in the history
  • Loading branch information
juligasa committed May 20, 2024
1 parent e506abf commit 4b08a77
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/daemon/api/documents/v1alpha/documents.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ func (api *Server) MergeChanges(ctx context.Context, in *documents.MergeChangesR
}

if entity == nil {
return nil, fmt.Errorf("Error merging. Are all the versions coming from the same document?")
return nil, fmt.Errorf("nothing to merge, aborting")
}

del, err := api.getDelegation(ctx)
Expand Down
22 changes: 20 additions & 2 deletions backend/daemon/api/documents/v1alpha/documents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,12 +592,30 @@ func TestMerge(t *testing.T) {
})
require.NoError(t, err)
require.Equal(t, pub1.Document.Id, pub2.Document.Id)

draft, err = api.CreateDraft(ctx, &documents.CreateDraftRequest{ExistingDocumentId: pub1.Document.Id})
require.NoError(t, err)
updated3 := updateDraft(ctx, t, api, draft.Id, []*documents.DocumentChange{
{Op: &documents.DocumentChange_SetTitle{SetTitle: "Linked with the first"}},
{Op: &documents.DocumentChange_MoveBlock_{MoveBlock: &documents.DocumentChange_MoveBlock{BlockId: "b1"}}},
{Op: &documents.DocumentChange_ReplaceBlock{ReplaceBlock: &documents.Block{
Id: "b1",
Type: "statement",
Text: "Some content",
}}},
})
require.NoError(t, err)
pub3, err := api.PublishDraft(ctx, &documents.PublishDraftRequest{
DocumentId: updated3.Id,
})
require.NoError(t, err)
require.Equal(t, pub1.Document.Id, pub3.Document.Id)
mergedPub, err := api.MergeChanges(ctx, &documents.MergeChangesRequest{
Id: pub1.Document.Id,
Versions: []string{pub1.Version, pub2.Version},
Versions: []string{pub1.Version, pub3.Version},
})
require.NoError(t, err)
require.Equal(t, updated2.Version, mergedPub.PreviousVersion)
require.Equal(t, updated3.Version, mergedPub.PreviousVersion)
}
func TestAPIUpdateDraft_WithList(t *testing.T) {
api := newTestDocsAPI(t, "alice")
Expand Down

0 comments on commit 4b08a77

Please sign in to comment.