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:
parent
24bb6528ec
commit
e34ffe9d5b
4 changed files with 41 additions and 4 deletions
|
@ -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) {
|
||||
|
|
BIN
tests/integration/testdata/import/markdown with files/files/4399421398_87191e276a_w.jpg
vendored
Normal file
BIN
tests/integration/testdata/import/markdown with files/files/4399421398_87191e276a_w.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
3
tests/integration/testdata/import/markdown with files/test-markdown-import-with-files.md
vendored
Normal file
3
tests/integration/testdata/import/markdown with files/test-markdown-import-with-files.md
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
Test markdown import with files
|
||||
|
||||

|
Loading…
Add table
Add a link
Reference in a new issue