anytype-kotlin-wild/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridPrimitiveRelationTest.kt
Evgenii Kozlov 36fe52e5ad
DROID-607 Relations & types and options | Refactoring | Everything-is-an-object refactoring (#2720)
* DROID-439 App | Relations refactoring, use SearchObjects for object types (#2592)
* DROID-446 Objects | Enhancement | Store relation links and process its updates (#2597)
* DROID-456 Tech | Remove deprecated API for creating object types (#2601)
* DROID-455 Object types | Enhancement Get object type list from ObjectSearch on Global search screen (#2602)
* DROID-459 Sets | Refactoring | Use relations links instead of relations for building search params to get data view data (#2603)
* DROID-458 Objects | Refactoring | Integrate new api for creating objets (#2604)
* DROID-464 Relations | Refactoring | New API for creating a relation from scratch - for data view or for an object (#2605)
* DROID-467 Relations | Refactoring | New API for creating options - for tags and statuses (#2607)
* DROID-470 Relations | Refactoring | New API for removing any relation from an object or from a data view (#2608)
* DROID-460 Tech | Object relations list (#2610)
* DROID-486 Sets | Refactoring | Displaying and controlling visibility of data view relations (#2611)
* DROID-500 Relations | Refactoring | Extend API of ObjectStore to be able to get a relation by its id (#2619)
* DROID-459 Sets | Fix | Get relations from store by id and not by key (#2618)
* DROID-489 Tech | Relations as object, add relationKey to relation connected screens (#2622)
* DROID-490 Sets | Refactoring | Displaying relation values for current object in bottom sheet cells (#2629)
* DROID-505 Relations | Refactoring | New interface for relations store (#2633)
* DROID-509 Relations | Refactoring | Bind new relations store with subscription container (#2635)
* DROID-507 Tech | MW , migration + relation links (#2636)
* DROID-507 Tech | MW , migration + relation links, fixes (#2637)
* DROID-517 Sets | Fix | Provide correct keys for data view search-and-subscribe query (#2641)
* DROID-409 Relations | Refactoring | Use relation key instead of id when creating new relation (#2642)
* DROID-521 Sets & Objects | Refactoring | Add relation to a data view or to an object from existing relations (#2644)
* DROID-522 Relations | Refactoring | Add objects to relations with object format (#2645)
* DROID-523 Object types | Refactoring | Implement global store for object types (#2646)
* DROID-527 Object types | Refactoring | Integrate global store for object types (#2647)
* DROID-531 Relations | Refactoring | Parse tag and status relations values (#2649)
* DROID-535 Tech | Integrate new MW lib with migration fixes (#2653)
* DROID-535 Tech | MW integration fixes (#2660)
* DROID-559 Relations | Refactoring | Parse tag and status values in editor (#2662)
* DROID-560 Relations | Refactoring | Integrate new lib with fixes (#2663)
* DROID-561 Relations | Refactoring | Parsing tag and status values in dv (#2665)
* DROID-562 Dashboard | Refactoring | Use store of object types as object type provider for favorites tab on dashboard (#2667)
* DROID-567 Relations | Refactoring | Suggest available options to populate a relation (#2671)
* DROID-604 Relations | Refactoring | Use details from Object.CreateRelation.Response to populate relation store (#2705)
* DROID-603 Relations | Refactoring | Creating relation options + Deleting relation from object (#2706)
* DROID-619 Relations | Refactoring | Migrate data view sorts and filters to the new relation-as-object paradigm (#2711)
* DROID-622 Relations | Tech | Update MW to 0.24.0-rc1 (#2714)
* DROID-598 Sets | Refactoring | Provide relation format for date filters (#2715)
* DROID-625 Protocol | Enhancement | Integrate v0.24.0-rc2 (#2718)
2022-11-24 18:11:19 +03:00

272 lines
9.3 KiB
Kotlin

package com.anytypeio.anytype.features.sets.dv
import androidx.core.os.bundleOf
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import com.anytypeio.anytype.R
import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.DVViewerRelation
import com.anytypeio.anytype.core_models.ObjectType
import com.anytypeio.anytype.core_models.Relation
import com.anytypeio.anytype.core_models.SmartBlockType
import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider
import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubTextContent
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
import com.anytypeio.anytype.test_utils.MockDataFactory
import com.anytypeio.anytype.test_utils.utils.checkHasChildViewCount
import com.anytypeio.anytype.test_utils.utils.checkHasChildViewWithText
import com.anytypeio.anytype.test_utils.utils.checkHasText
import com.anytypeio.anytype.test_utils.utils.checkIsRecyclerSize
import com.anytypeio.anytype.test_utils.utils.onItemView
import com.anytypeio.anytype.test_utils.utils.rVMatcher
import com.anytypeio.anytype.ui.sets.ObjectSetFragment
import com.bartoszlipinski.disableanimationsrule.DisableAnimationsRule
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@LargeTest
class ObjectSetGridPrimitiveRelationTest : TestObjectSetSetup() {
@get:Rule
val animationsRule = DisableAnimationsRule()
override val title: Block = Block(
id = MockDataFactory.randomUuid(),
content = StubTextContent(
style = Block.Content.Text.Style.TITLE,
text = "Data View UI Testing",
marks = emptyList()
),
children = emptyList(),
fields = Block.Fields.empty()
)
@Before
override fun setup() {
super.setup()
}
@Test
fun shouldRenderAllObjectPrimitiveRelationsValuesFromTwoRecords() {
val type = ObjectType(
url = MockDataFactory.randomUuid(),
name = MockDataFactory.randomString(),
emoji = MockDataFactory.randomString(),
layout = ObjectType.Layout.BASIC,
relationLinks = emptyList(),
description = "",
isHidden = false,
smartBlockTypes = listOf(),
isArchived = false,
isReadOnly = false
)
val relation1 = Relation(
key = MockDataFactory.randomString(),
name = "Description",
format = Relation.Format.SHORT_TEXT,
source = Relation.Source.values().random()
)
val relation2 = Relation(
key = MockDataFactory.randomString(),
name = "Year",
format = Relation.Format.NUMBER,
source = Relation.Source.values().random()
)
val relation3 = Relation(
key = MockDataFactory.randomString(),
name = "Phone",
format = Relation.Format.PHONE,
source = Relation.Source.values().random()
)
val relation4 = Relation(
key = MockDataFactory.randomString(),
name = "Website",
format = Relation.Format.URL,
source = Relation.Source.values().random()
)
val relation5 = Relation(
key = MockDataFactory.randomString(),
name = "Email",
format = Relation.Format.EMAIL,
source = Relation.Source.values().random()
)
val object1value1 = "Operating environment for the new Internet"
val object1value2 = "2021"
val object1value3 = "+00000000000"
val object1value4 = "https://anytype.io/"
val object1value5 = "team@anytype.io"
val object2value1 = "A peer-to-peer hypermedia protocol designed to make the web faster, safer, and more open."
val object2value2 = "2021"
val object2value3 = "+00000000000"
val object2value4 = "https://ipfs.io/"
val object2value5 = "team@ipfs.io"
val record1 = mapOf(
ObjectSetConfig.ID_KEY to MockDataFactory.randomUuid(),
ObjectSetConfig.TYPE_KEY to type.url,
ObjectSetConfig.NAME_KEY to "Anytype",
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
relation1.key to object1value1,
relation2.key to object1value2,
relation3.key to object1value3,
relation4.key to object1value4,
relation5.key to object1value5,
)
val record2 = mapOf(
ObjectSetConfig.ID_KEY to MockDataFactory.randomUuid(),
ObjectSetConfig.TYPE_KEY to type.url,
ObjectSetConfig.NAME_KEY to "IPFS",
"iconEmoji" to DefaultDocumentEmojiIconProvider.DOCUMENT_SET.random(),
relation1.key to object2value1,
relation2.key to object2value2,
relation3.key to object2value3,
relation4.key to object2value4,
relation5.key to object2value5,
)
val viewer = Block.Content.DataView.Viewer(
id = MockDataFactory.randomUuid(),
name = "Default Grid View",
filters = emptyList(),
sorts = emptyList(),
viewerRelations = listOf(
DVViewerRelation(
key = relation1.key,
isVisible = true
),
DVViewerRelation(
key = relation2.key,
isVisible = true
),
DVViewerRelation(
key = relation3.key,
isVisible = true
),
DVViewerRelation(
key = relation4.key,
isVisible = true
),
DVViewerRelation(
key = relation5.key,
isVisible = true
)
),
type = Block.Content.DataView.Viewer.Type.GRID
)
val dataview = Block(
id = MockDataFactory.randomUuid(),
children = emptyList(),
fields = Block.Fields.empty(),
content = Block.Content.DataView(
relations = listOf(relation1, relation2, relation3, relation4, relation5),
viewers = listOf(viewer),
sources = listOf(
MockDataFactory.randomUuid()
)
)
)
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
children = listOf(header.id, dataview.id)
)
val set = listOf(root, header, title, dataview)
stubInterceptEvents()
stubInterceptThreadStatus()
stubOpenObjectSetWithRecord(
set = set,
relations = listOf(relation1, relation2, relation3, relation4, relation5),
details = defaultDetails,
objectTypes = listOf(type)
)
// TESTING
launchFragment(bundleOf(ObjectSetFragment.CONTEXT_ID_KEY to ctx))
with(R.id.rvRows.rVMatcher()) {
checkIsRecyclerSize(2)
onItemView(0, R.id.rowCellRecycler)
.checkHasChildViewCount(5)
// .checkHasChildViewWithText(
// pos = 0,
// text = "",
// target = R.id.tvText
// )
.checkHasChildViewWithText(
pos = 0,
text = object1value1,
target = R.id.tvText
)
.checkHasChildViewWithText(
pos = 1,
text = object1value2,
target = R.id.tvText
)
.checkHasChildViewWithText(
pos = 2,
text = object1value3,
target = R.id.tvText
)
.checkHasChildViewWithText(
pos = 3,
text = object1value4,
target = R.id.tvText
)
.checkHasChildViewWithText(
pos = 4,
text = object1value5,
target = R.id.tvText
)
onItemView(0, R.id.tvTitle).checkHasText("Anytype")
onItemView(1, R.id.rowCellRecycler)
.checkHasChildViewCount(5)
.checkHasChildViewWithText(
pos = 0,
text = object2value1,
target = R.id.tvText
)
.checkHasChildViewWithText(
pos = 1,
text = object2value2,
target = R.id.tvText
)
.checkHasChildViewWithText(
pos = 2,
text = object2value3,
target = R.id.tvText
)
.checkHasChildViewWithText(
pos = 3,
text = object2value4,
target = R.id.tvText
)
.checkHasChildViewWithText(
pos = 4,
text = object2value5,
target = R.id.tvText
)
onItemView(1, R.id.tvTitle).checkHasText("IPFS")
}
}
}