1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 09:35:00 +09:00

GO-2911: Add import markdown test

This commit is contained in:
Sergey 2024-02-26 13:59:59 +01:00
parent 24bb6528ec
commit e34ffe9d5b
No known key found for this signature in database
GPG key ID: 3B6BEF79160221C6
4 changed files with 41 additions and 4 deletions

View file

@ -20,9 +20,6 @@ import (
)
func TestImportFiles(t *testing.T) {
t.Run("import from version with Files as Objects: just file object", func(t *testing.T) {
t.Skip()
})
t.Run("import from version with Files as Objects: from relation (iconImage)", func(t *testing.T) {
ctx := context.Background()
app := createAccountAndStartApp(t)
@ -110,6 +107,43 @@ func TestImportFiles(t *testing.T) {
assertImageAvailableInGateway(t, app, fileObjectId)
})
})
t.Run("import markdown", func(t *testing.T) {
ctx := context.Background()
app := createAccountAndStartApp(t)
fileSub := newTestSubscription(t, app, []domain.RelationKey{bundle.RelationKeyId}, []*model.BlockContentDataviewFilter{
filterEqualsToInteger(bundle.RelationKeyFileIndexingStatus, model.FileIndexingStatus_Indexed),
filterEqualsToInteger(bundle.RelationKeyLayout, model.ObjectType_image),
filterEqualsToString(bundle.RelationKeyName, "4399421398_87191e276a_w"), // Name comes from file's name
filterEqualsToString(bundle.RelationKeyFileMimeType, "image/jpeg"),
filterNotEmpty(bundle.RelationKeyFileId),
})
importerService := getService[importer.Importer](app)
_, processId, err := importerService.Import(ctx, &pb.RpcObjectImportRequest{
SpaceId: app.personalSpaceId(),
Mode: pb.RpcObjectImportRequest_IGNORE_ERRORS,
Type: model.Import_Markdown,
Params: &pb.RpcObjectImportRequestParamsOfMarkdownParams{
MarkdownParams: &pb.RpcObjectImportRequestMarkdownParams{
Path: []string{"./testdata/import/markdown with files/"},
},
},
}, objectorigin.Import(model.Import_Markdown), nil)
require.NoError(t, err)
app.waitEventMessage(t, func(msg *pb.EventMessage) bool {
if v := msg.GetProcessDone(); v != nil {
return v.Process.Id == processId
}
return false
})
fileSub.waitOneObjectDetailsSet(t, app, func(t *testing.T, msg *pb.EventObjectDetailsSet) {
fileObjectId := pbtypes.GetString(msg.Details, bundle.RelationKeyId.String())
assertImageAvailableInGateway(t, app, fileObjectId)
})
})
}
func assertImageAvailableInGateway(t *testing.T, app *testApplication, fileObjectId string) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View file

@ -0,0 +1,3 @@
Test markdown import with files
![4399421398\_87191e276a\_w.jpg](files/4399421398_87191e276a_w.jpg)