diff --git a/analytics/build.gradle b/analytics/build.gradle index 7f20b2b222..d90d6e918d 100644 --- a/analytics/build.gradle +++ b/analytics/build.gradle @@ -14,15 +14,6 @@ android { } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } - namespace 'com.anytypeio.anytype.analytics' } diff --git a/app/build.gradle b/app/build.gradle index ed3b69ec43..1f4331e63b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -127,15 +127,6 @@ android { compose true } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } - splits { // Configures multiple APKs based on ABI. abi { diff --git a/app/src/main/java/com/anytypeio/anytype/app/AndroidApplication.kt b/app/src/main/java/com/anytypeio/anytype/app/AndroidApplication.kt index e09b976556..c968095463 100644 --- a/app/src/main/java/com/anytypeio/anytype/app/AndroidApplication.kt +++ b/app/src/main/java/com/anytypeio/anytype/app/AndroidApplication.kt @@ -36,7 +36,6 @@ class AndroidApplication : Application(), HasComponentDependencies { @Inject override lateinit var dependencies: ComponentDependenciesProvider - protected set private val main: MainComponent by lazy { DaggerMainComponent diff --git a/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt b/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt index 5e0dc3fea0..bddaf7427f 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt @@ -144,7 +144,7 @@ interface MainComponent : } @Module -private abstract class ComponentDependenciesModule private constructor() { +abstract class ComponentDependenciesModule { @Binds @IntoMap diff --git a/build.gradle b/build.gradle index 7e718a3348..48dee18b82 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,5 @@ import com.android.build.gradle.LibraryPlugin +import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper buildscript { ext.compile_sdk = 34 @@ -70,6 +71,18 @@ subprojects { } } } + if (plugin instanceof KotlinAndroidPluginWrapper) { + android { + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + + kotlin { + jvmToolchain(17) + } + } + } } plugins.withId("kotlin") { diff --git a/clipboard/build.gradle b/clipboard/build.gradle index 6c65773ae5..70b9c8adae 100644 --- a/clipboard/build.gradle +++ b/clipboard/build.gradle @@ -16,15 +16,6 @@ android { } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } - namespace 'com.anytypeio.anytype.clipboard' } diff --git a/core-ui/build.gradle b/core-ui/build.gradle index 42a3dabf84..caed5e84ad 100644 --- a/core-ui/build.gradle +++ b/core-ui/build.gradle @@ -19,15 +19,6 @@ android { compose true } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } - namespace 'com.anytypeio.anytype.core_ui' } diff --git a/core-utils/build.gradle b/core-utils/build.gradle index 286231529a..7f59c8ec44 100644 --- a/core-utils/build.gradle +++ b/core-utils/build.gradle @@ -13,15 +13,6 @@ android { viewBinding true } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } - namespace 'com.anytypeio.anytype.core_utils' } diff --git a/crash-reporting/build.gradle b/crash-reporting/build.gradle index 4612f46144..cf215c0424 100644 --- a/crash-reporting/build.gradle +++ b/crash-reporting/build.gradle @@ -18,19 +18,11 @@ android { includeDependenciesReport = true } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } - namespace 'com.anytypeio.anytype.crash_reporting' } dependencies { + implementation libs.timber implementation libs.sentry implementation libs.sentryTimber implementation project(path: ':core-utils') diff --git a/device/build.gradle b/device/build.gradle index 0a230d3724..be7c4daa21 100644 --- a/device/build.gradle +++ b/device/build.gradle @@ -24,14 +24,5 @@ dependencies { } android { - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } - namespace 'com.anytypeio.anytype.device' } \ No newline at end of file diff --git a/gallery-experience/build.gradle b/gallery-experience/build.gradle index d9f6397d91..a4699da2a9 100644 --- a/gallery-experience/build.gradle +++ b/gallery-experience/build.gradle @@ -15,13 +15,6 @@ android { kotlinCompilerExtensionVersion libs.versions.composeKotlinCompilerVersion.get() } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - kotlin { - jvmToolchain(17) - } namespace 'com.anytypeio.anytype.galleryexperience' } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 15f2a30334..2ec9c47d8d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,33 +1,33 @@ [versions] middlewareVersion = "v0.33.0-rc2" -kotlinVersion = '1.8.22' +kotlinVersion = '1.9.22' androidxCoreVersion = "1.12.0" -androidxComposeVersion = '1.5.0' -composeKotlinCompilerVersion = '1.4.8' -composeMaterial3Version = '1.2.0' -composeMaterialVersion = '1.5.0' +androidxComposeVersion = '1.6.3' +composeKotlinCompilerVersion = '1.5.10' +composeMaterial3Version = '1.2.1' +composeMaterialVersion = '1.6.3' composeConstraintLayoutVersion = '1.0.1' -dokkaVersion = '1.8.20' +dokkaVersion = '1.9.20' -activityComposeVersion = '1.8.1' -composeReorderableVersion = '0.9.6' +activityComposeVersion = '1.8.2' +composeReorderableVersion = 'e9ef693f63' accompanistVersion = "0.34.0" appcompatVersion = '1.6.1' -androidXAnnotationVersion = '1.7.0' +androidXAnnotationVersion = '1.7.1' fragmentVersion = "1.6.2" exoplayerVersion = "2.19.1" -wireVersion = "4.5.2" +wireVersion = "4.9.8" glideVersion = "4.14.2" -mockitoKotlinVersion = "5.1.0" +mockitoKotlinVersion = "5.2.1" junitVersion = '4.13.2' -androidJunitVersion = "1.1.4" +androidJunitVersion = "1.1.5" runnerVersion = "1.5.0" -mockitoAndroidVersion = '4.10.0' -kotlinCoroutinesVersion = '1.6.4' -coroutineTestingVersion = '1.6.4' +mockitoAndroidVersion = '5.11.0' +kotlinCoroutinesVersion = '1.8.0' +coroutineTestingVersion = '1.8.0' androidxTestCoreVersion = '1.5.0' androidxCoreTestingVersion = '2.2.0' androidxSecurityCryptoVersion = '1.0.0' @@ -37,37 +37,37 @@ recyclerviewVersion = '1.3.2' cardviewVersion = '1.0.0' emojiCompatVersion = '1.1.0' viewPager2Version = '1.0.0' -lifecycleVersion = '2.6.2' -lifecycleRuntimeComposeVersion = '2.7.0-rc01' -navigationVersion = '2.7.5' -navigationComposeVersion = '2.7.5' +lifecycleVersion = '2.7.0' +lifecycleRuntimeComposeVersion = '2.7.0' +navigationVersion = '2.7.7' +navigationComposeVersion = '2.7.7' shimmerLayoutVersion = '0.5.0' photoViewVersion = '2.3.0' -daggerVersion = '2.45' +daggerVersion = '2.51' javaxAnnotationsVersion = '1.0' javaxInjectVersion = '1' -gsonVersion = '2.10' +gsonVersion = '2.10.1' betterLinkMethodVersion = '2.2.0' -picktVersion = '2.0.2' -zxingVersion = '4.1.0' +picktVersion = '2.0.5' +zxingVersion = '4.3.0' urlcleanerVersion = '0.4.0' katexVersion = '1.0.2' -robolectricLatestVersion = '4.10.3' +robolectricLatestVersion = '4.11.1' kluentVersion = '1.14' timberJunitVersion = '1.0.1' -turbineVersion = '0.12.1' -liveDataTestingVersion = '1.2.0' +turbineVersion = '1.1.0' +liveDataTestingVersion = '1.3.0' espressoVersion = '3.5.1' disableAnimationVersion = '2.0.0' leakCanaryVersion = '2.12' timberVersion = '5.0.1' protobufJavaVersion = '3.9.2' protocVersion = '3.9.0' -roomVersion = '2.5.2' +roomVersion = '2.6.1' dataStoreVersion = '1.0.0' -amplitudeVersion = '2.36.1' -coilComposeVersion = '2.2.2' -sentryVersion = '6.0.0' +amplitudeVersion = '3.35.1' +coilComposeVersion = '2.6.0' +sentryVersion = '7.6.0' [libraries] middleware = { module = "io.anyproto:anytype-heart-android", version.ref = "middlewareVersion" } @@ -85,12 +85,12 @@ composeAccompanistPermissions = { module = "com.google.accompanist:accompanist-p composeAccompanistPagerIndicators = { module = "com.google.accompanist:accompanist-pager-indicators", version.ref = "accompanistVersion" } composeAccompanistThemeAdapter = { module = "com.google.accompanist:accompanist-themeadapter-material", version.ref = "accompanistVersion" } composeAccompanistNavigation = { module = "com.google.accompanist:accompanist-navigation-material", version.ref = "accompanistVersion" } -composeReorderable = { module = "org.burnoutcrew.composereorderable:reorderable", version.ref = "composeReorderableVersion" } +composeReorderable = { module = "com.github.fat-fellow.ComposeReorderable:reorderable", version.ref = "composeReorderableVersion" } composeConstraintLayout = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "composeConstraintLayoutVersion" } -kotlinxSerializationJson = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.4.1" } +kotlinxSerializationJson = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.6.3" } appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompatVersion" } androidAnnotations = { module = "androidx.annotation:annotation", version.ref = "androidXAnnotationVersion" } -design = { module = "com.google.android.material:material", version = "1.7.0" } +design = { module = "com.google.android.material:material", version = "1.11.0" } fragment = { module = "androidx.fragment:fragment-ktx", version.ref = "fragmentVersion" } fragmentTesting = { module = "androidx.fragment:fragment-testing", version.ref = "fragmentVersion" } exoPlayerCore = { module = "com.google.android.exoplayer:exoplayer-core", version.ref = "exoplayerVersion" } @@ -168,12 +168,12 @@ appUpdater = { module = "com.github.PLPsiSoft:AndroidAppUpdater", version = "991 [bundles] [plugins] -application = { id = "com.android.application", version = "8.2.0" } -library = { id = "com.android.library", version = "8.2.0" } +application = { id = "com.android.application", version = "8.3.1" } +library = { id = "com.android.library", version = "8.3.1" } kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokkaVersion" } kserialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlinVersion" } -wire = { id = "com.squareup.wire", version = "4.4.3" } -firebaseDistribution = { id = "com.google.firebase.appdistribution", version = "4.0.1" } +wire = { id = "com.squareup.wire", version = "4.9.8" } +firebaseDistribution = { id = "com.google.firebase.appdistribution", version = "4.2.0" } kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlinVersion" } -gms = { id = "com.google.gms.google-services", version = "4.4.0" } \ No newline at end of file +gms = { id = "com.google.gms.google-services", version = "4.4.1" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2a..d64cd49177 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4466424467..a80b22ce5c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Thu Dec 14 17:20:55 CET 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787337..1aa94a4269 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +131,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ @@ -205,6 +214,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index ac1b06f938..6689b85bee 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/library-emojifier/build.gradle b/library-emojifier/build.gradle index b7be8550e0..659c8dc9d9 100644 --- a/library-emojifier/build.gradle +++ b/library-emojifier/build.gradle @@ -16,14 +16,5 @@ dependencies { } android { - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } - namespace 'com.anytypeio.anytype.emojifier' } \ No newline at end of file diff --git a/library-page-icon-picker-widget/build.gradle b/library-page-icon-picker-widget/build.gradle index 45db7e1b12..719d89be42 100644 --- a/library-page-icon-picker-widget/build.gradle +++ b/library-page-icon-picker-widget/build.gradle @@ -7,14 +7,6 @@ android { buildFeatures { viewBinding true } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } namespace 'com.anytypeio.anytype.library_page_icon_picker_widget' } diff --git a/library-syntax-highlighter/build.gradle b/library-syntax-highlighter/build.gradle index 8820c03dca..b1801aa8ef 100644 --- a/library-syntax-highlighter/build.gradle +++ b/library-syntax-highlighter/build.gradle @@ -20,13 +20,5 @@ dependencies { } android { - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } namespace 'com.anytypeio.anytype.library_syntax_highlighter' } \ No newline at end of file diff --git a/localization/build.gradle b/localization/build.gradle index cd89750b7d..28219f6d35 100644 --- a/localization/build.gradle +++ b/localization/build.gradle @@ -9,13 +9,5 @@ dependencies { } android { - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } namespace 'com.anytypeio.anytype.localization' } \ No newline at end of file diff --git a/middleware/build.gradle b/middleware/build.gradle index 521dfc018a..87ac892d65 100644 --- a/middleware/build.gradle +++ b/middleware/build.gradle @@ -26,13 +26,5 @@ dependencies { } android { - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } namespace 'com.anytypeio.anytype.middleware' } \ No newline at end of file diff --git a/payments/build.gradle b/payments/build.gradle index 39005685b1..1fcfef0e5d 100644 --- a/payments/build.gradle +++ b/payments/build.gradle @@ -14,14 +14,6 @@ android { composeOptions { kotlinCompilerExtensionVersion libs.versions.composeKotlinCompilerVersion.get() } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - kotlin { - jvmToolchain(17) - } namespace 'com.anytypeio.anytype.peyments' } diff --git a/persistence/build.gradle b/persistence/build.gradle index 23d6df199e..0b205aacea 100644 --- a/persistence/build.gradle +++ b/persistence/build.gradle @@ -37,13 +37,6 @@ dependencies { } android { - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - kotlin { - jvmToolchain(17) - } namespace 'com.anytypeio.anytype.persistence' } diff --git a/presentation/build.gradle b/presentation/build.gradle index dfe0b5754c..286e9ebdee 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -19,14 +19,6 @@ android { buildConfigField "boolean", "ENABLE_WIDGETS", "false" buildConfigField "boolean", "ENABLE_VIEWS_MENU", "true" } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } namespace 'com.anytypeio.anytype.presentation' } diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/CollectionAddRelationTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/CollectionAddRelationTest.kt index fc816a3f16..edc820d6db 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/CollectionAddRelationTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/CollectionAddRelationTest.kt @@ -50,6 +50,7 @@ class CollectionAddRelationTest : ObjectSetViewModelTestSetup() { MockitoAnnotations.openMocks(this) objectCollection = MockCollection(context = root, space = defaultSpace) viewModel = givenViewModel() + stubNetworkMode() } @After diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/CollectionDataViewUpdateTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/CollectionDataViewUpdateTest.kt index d576ef3a96..31975d0ddf 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/CollectionDataViewUpdateTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/CollectionDataViewUpdateTest.kt @@ -31,6 +31,7 @@ class CollectionDataViewUpdateTest : ObjectSetViewModelTestSetup() { viewModel = givenViewModel() objectCollection = MockCollection(context = root, space = defaultSpace) stubGetDefaultPageType() + stubNetworkMode() } @After diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/ObjectCreateTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/ObjectCreateTest.kt index cf4d4d58da..cecd35eb04 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/ObjectCreateTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/ObjectCreateTest.kt @@ -1,6 +1,6 @@ package com.anytypeio.anytype.presentation.collections -import app.cash.turbine.testIn +import app.cash.turbine.turbineScope import com.anytypeio.anytype.core_models.ObjectType import com.anytypeio.anytype.core_models.ObjectTypeIds import com.anytypeio.anytype.core_models.ObjectWrapper @@ -36,6 +36,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() { MockitoAnnotations.openMocks(this) viewModel = givenViewModel() stubNetworkMode() + stubCreateDataViewObject() } @After @@ -122,61 +123,41 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() { @Test fun `Should create and open Not-Note Object when clicking on New button in Set by Type`() = runTest { + turbineScope { + val setOfId = "setOf-id-${RandomString.make()}" + val setOfKey = ObjectTypeIds.PAGE - val setOfId = "setOf-id-${RandomString.make()}" - val setOfKey = ObjectTypeIds.PAGE - - mockObjectSet = MockSet( - context = root, - space = defaultSpace, - setOfValue = setOfId, - setOfKey = setOfKey - ) - - // SETUP - stubSpaceManager(mockObjectSet.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), - details = mockObjectSet.details - ) - stubSubscriptionResults( - subscription = mockObjectSet.subscriptionId, - spaceId = mockObjectSet.spaceId, - storeOfRelations = storeOfRelations, - keys = mockObjectSet.dvKeys, - sources = listOf(mockObjectSet.setOf), - dvFilters = mockObjectSet.filters, - objects = listOf(mockObjectSet.obj1, mockObjectSet.obj2) - ) - val newObjectId = "objNewPage-${RandomString.make()}" - val result = CreateDataViewObject.Result( - objectId = newObjectId, - objectType = TypeKey(ObjectTypeIds.PAGE) - ) - doReturn(Resultat.success(result)).`when`(createDataViewObject).async( - CreateDataViewObject.Params.SetByType( - type = TypeKey(setOfKey), - filters = mockObjectSet.filters, - template = null, - prefilled = emptyMap() + mockObjectSet = MockSet( + context = root, + space = defaultSpace, + setOfValue = setOfId, + setOfKey = setOfKey ) - ) - doReturn(Resultat.success(Unit)).`when`(closeBlock).async(mockObjectSet.root) - // TESTING - proceedWithStartingViewModel() - val commandFlow = viewModel.commands.testIn(backgroundScope) - - advanceUntilIdle() - - viewModel.proceedWithDataViewObjectCreate() - - advanceUntilIdle() - - verifyBlocking(createDataViewObject, times(1)) { - async( + // SETUP + stubSpaceManager(mockObjectSet.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), + details = mockObjectSet.details + ) + stubSubscriptionResults( + subscription = mockObjectSet.subscriptionId, + spaceId = mockObjectSet.spaceId, + storeOfRelations = storeOfRelations, + keys = mockObjectSet.dvKeys, + sources = listOf(mockObjectSet.setOf), + dvFilters = mockObjectSet.filters, + objects = listOf(mockObjectSet.obj1, mockObjectSet.obj2) + ) + val newObjectId = "objNewPage-${RandomString.make()}" + val result = CreateDataViewObject.Result( + objectId = newObjectId, + objectType = TypeKey(ObjectTypeIds.PAGE), + struct = mapOf("spaceId" to "spaceId") + ) + doReturn(Resultat.success(result)).`when`(createDataViewObject).async( CreateDataViewObject.Params.SetByType( type = TypeKey(setOfKey), filters = mockObjectSet.filters, @@ -184,6 +165,29 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() { prefilled = emptyMap() ) ) + doReturn(Resultat.success(Unit)).`when`(closeBlock).async(mockObjectSet.root) + + // TESTING + proceedWithStartingViewModel() + val commandFlow = viewModel.commands.testIn(backgroundScope) + + advanceUntilIdle() + + viewModel.proceedWithDataViewObjectCreate() + + advanceUntilIdle() + + verifyBlocking(createDataViewObject, times(1)) { + async( + CreateDataViewObject.Params.SetByType( + type = TypeKey(setOfKey), + filters = mockObjectSet.filters, + template = null, + prefilled = emptyMap() + ) + ) + } + commandFlow.cancelAndIgnoreRemainingEvents() } } @@ -225,6 +229,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() { stubSpaceManager(mockObjectSet.spaceId) stubInterceptEvents() stubInterceptThreadStatus() + stubCreateDataViewObject() stubOpenObject( doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), details = mockObjectSet.detailsSetByRelation(relationSetBy) @@ -279,85 +284,87 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() { } @Test - fun `Should create new Object and not close Set when clicking on New button in Collection`() = runTest { + fun `Should create new Object and not close Set when clicking on New button in Collection`() = + runTest { - val objectCollection = MockCollection(context = root, space = defaultSpace) + val objectCollection = MockCollection(context = root, space = defaultSpace) - // SETUP - stubSpaceManager(objectCollection.spaceId) - stubStoreOfRelations(objectCollection) - stubSubscriptionResults( - subscription = objectCollection.subscriptionId, - collection = root, - spaceId = objectCollection.spaceId, - storeOfRelations = storeOfRelations, - keys = objectCollection.dvKeys, - objects = listOf(objectCollection.obj1, objectCollection.obj2), - dvSorts = objectCollection.sorts - ) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf( - objectCollection.header, - objectCollection.title, - objectCollection.dataView - ), - details = objectCollection.details - ) - - val pageTypeId = ObjectState.VIEW_DEFAULT_OBJECT_TYPE - val pageTypeMap = mapOf( - Relations.ID to MockDataFactory.randomString(), - Relations.UNIQUE_KEY to pageTypeId, - Relations.TYPE to ObjectTypeIds.OBJECT_TYPE, - Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.BASIC.code.toDouble(), - Relations.LAYOUT to ObjectType.Layout.OBJECT_TYPE.code.toDouble(), - Relations.NAME to MockDataFactory.randomString(), - Relations.DEFAULT_TEMPLATE_ID to null - ) - with(storeOfObjectTypes) { - set(pageTypeId, pageTypeMap) - } - - val newObjectId = "objNew-${RandomString.make()}" - val result = CreateDataViewObject.Result( - objectId = newObjectId, - objectType = TypeKey(pageTypeId), - struct = null - ) - doReturn(Resultat.success(result)).`when`(createDataViewObject).async( - CreateDataViewObject.Params.Collection( - template = null, - type = TypeKey(pageTypeId), - filters = emptyList(), - prefilled = emptyMap() + // SETUP + stubSpaceManager(objectCollection.spaceId) + stubStoreOfRelations(objectCollection) + stubSubscriptionResults( + subscription = objectCollection.subscriptionId, + collection = root, + spaceId = objectCollection.spaceId, + storeOfRelations = storeOfRelations, + keys = objectCollection.dvKeys, + objects = listOf(objectCollection.obj1, objectCollection.obj2), + dvSorts = objectCollection.sorts + ) + stubInterceptEvents() + stubInterceptThreadStatus() + stubAddObjectToCollection() + stubOpenObject( + doc = listOf( + objectCollection.header, + objectCollection.title, + objectCollection.dataView + ), + details = objectCollection.details ) - ) - doReturn(Resultat.success(Unit)).`when`(closeBlock).async(objectCollection.root) - // TESTING - proceedWithStartingViewModel() + val pageTypeId = ObjectState.VIEW_DEFAULT_OBJECT_TYPE + val pageTypeMap = mapOf( + Relations.ID to MockDataFactory.randomString(), + Relations.UNIQUE_KEY to pageTypeId, + Relations.TYPE to ObjectTypeIds.OBJECT_TYPE, + Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.BASIC.code.toDouble(), + Relations.LAYOUT to ObjectType.Layout.OBJECT_TYPE.code.toDouble(), + Relations.NAME to MockDataFactory.randomString(), + Relations.DEFAULT_TEMPLATE_ID to null + ) + with(storeOfObjectTypes) { + set(pageTypeId, pageTypeMap) + } - advanceUntilIdle() - - viewModel.proceedWithDataViewObjectCreate() - - advanceUntilIdle() - - verifyBlocking(createDataViewObject, times(1)) { - async( + val newObjectId = "objNew-${RandomString.make()}" + val result = CreateDataViewObject.Result( + objectId = newObjectId, + objectType = TypeKey(pageTypeId), + struct = mapOf("spaceId" to "spaceId") + ) + doReturn(Resultat.success(result)).`when`(createDataViewObject).async( CreateDataViewObject.Params.Collection( - type = TypeKey(pageTypeId), template = null, + type = TypeKey(pageTypeId), filters = emptyList(), prefilled = emptyMap() ) ) - } + doReturn(Resultat.success(Unit)).`when`(closeBlock).async(objectCollection.root) - verifyNoInteractions(closeBlock) - } + // TESTING + proceedWithStartingViewModel() + + advanceUntilIdle() + + viewModel.proceedWithDataViewObjectCreate() + + advanceUntilIdle() + + verifyBlocking(createDataViewObject, times(1)) { + async( + CreateDataViewObject.Params.Collection( + type = TypeKey(pageTypeId), + template = null, + filters = emptyList(), + prefilled = emptyMap() + ) + ) + } + + verifyNoInteractions(closeBlock) + } private fun proceedWithStartingViewModel() { viewModel.onStart(ctx = root, space = defaultSpace) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/ObjectStateCollectionViewTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/ObjectStateCollectionViewTest.kt index cde2928e7c..b6183e3904 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/ObjectStateCollectionViewTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/ObjectStateCollectionViewTest.kt @@ -1,6 +1,8 @@ package com.anytypeio.anytype.presentation.collections import app.cash.turbine.testIn +import app.cash.turbine.turbineScope +import app.cash.turbine.turbineScope import com.anytypeio.anytype.core_models.DV import com.anytypeio.anytype.core_models.ObjectType import com.anytypeio.anytype.core_models.ObjectTypeIds @@ -52,741 +54,785 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() { @Test fun `should display init state when opening object without DataView block`() = runTest { - // SETUP - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf(mockObjectCollection.header, mockObjectCollection.title), - details = mockObjectCollection.details - ) + turbineScope { + // SETUP + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf(mockObjectCollection.header, mockObjectCollection.title), + details = mockObjectCollection.details + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val headerFlow = viewModel.header.testIn(backgroundScope) - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val headerFlow = viewModel.header.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - assertIs(headerFlow.awaitItem()) - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + assertIs(headerFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - assertIs(stateFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) - assertEquals( - expected = mockObjectCollection.details.details[mockObjectCollection.root]?.name, - actual = (headerFlow.awaitItem() as SetOrCollectionHeaderState.Default).title.text - ) - viewerFlow.expectNoEvents() + assertEquals( + expected = mockObjectCollection.details.details[mockObjectCollection.root]?.name, + actual = (headerFlow.awaitItem() as SetOrCollectionHeaderState.Default).title.text + ) + viewerFlow.expectNoEvents() + } } @Test fun `should display collection no view state when opening object without view`() = runTest { - // SETUP - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - mockObjectCollection.dataViewEmpty - ), - details = mockObjectCollection.details - ) + turbineScope { + // SETUP + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + mockObjectCollection.dataViewEmpty + ), + details = mockObjectCollection.details + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - viewerFlow.expectNoEvents() + viewerFlow.expectNoEvents() + } } @Test fun `should display collection no items state when opening object without records`() = runTest { - // SETUP - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - mockObjectCollection.dataView - ), - details = mockObjectCollection.details - ) - stubStoreOfRelations(mockObjectCollection) - stubSubscriptionResults( - subscription = mockObjectCollection.subscriptionId, - spaceId = mockObjectCollection.spaceId, - collection = root, - storeOfRelations = storeOfRelations, - keys = mockObjectCollection.dvKeys, - dvSorts = mockObjectCollection.sorts - ) + turbineScope { + // SETUP + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + mockObjectCollection.dataView + ), + details = mockObjectCollection.details + ) + stubStoreOfRelations(mockObjectCollection) + stubSubscriptionResults( + subscription = mockObjectCollection.subscriptionId, + spaceId = mockObjectCollection.spaceId, + collection = root, + storeOfRelations = storeOfRelations, + keys = mockObjectCollection.dvKeys, + dvSorts = mockObjectCollection.sorts + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + } } @Test fun `should display collection default state when opening object with records`() = runTest { - // SETUP - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - mockObjectCollection.dataView - ), - details = mockObjectCollection.details - ) - stubStoreOfRelations(mockObjectCollection) - stubSubscriptionResults( - subscription = mockObjectCollection.subscriptionId, - spaceId = mockObjectCollection.spaceId, - collection = root, - storeOfRelations = storeOfRelations, - keys = mockObjectCollection.dvKeys, - objects = listOf(mockObjectCollection.obj1, mockObjectCollection.obj2), - dvSorts = mockObjectCollection.sorts - ) + turbineScope { + // SETUP + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + mockObjectCollection.dataView + ), + details = mockObjectCollection.details + ) + stubStoreOfRelations(mockObjectCollection) + stubSubscriptionResults( + subscription = mockObjectCollection.subscriptionId, + spaceId = mockObjectCollection.spaceId, + collection = root, + storeOfRelations = storeOfRelations, + keys = mockObjectCollection.dvKeys, + objects = listOf(mockObjectCollection.obj1, mockObjectCollection.obj2), + dvSorts = mockObjectCollection.sorts + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - assertIs(stateFlow.awaitItem()) - //assertIs(viewerFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) + //assertIs(viewerFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + } } @Test fun `should sort LIST collection objects by data view object order`() = runTest { - // SETUP - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - mockObjectCollection.dataViewWithObjectOrder - ), - details = mockObjectCollection.details - ) - stubStoreOfRelations(mockObjectCollection) - stubSubscriptionResults( - subscription = mockObjectCollection.subscriptionId, - spaceId = mockObjectCollection.spaceId, - collection = root, - storeOfRelations = storeOfRelations, - keys = mockObjectCollection.dvKeys, - objects = listOf( - mockObjectCollection.obj1, - mockObjectCollection.obj2, - mockObjectCollection.obj3, - mockObjectCollection.obj4, - mockObjectCollection.obj5 - ), - dvSorts = mockObjectCollection.sorts - ) + turbineScope { + // SETUP + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + mockObjectCollection.dataViewWithObjectOrder + ), + details = mockObjectCollection.details + ) + stubStoreOfRelations(mockObjectCollection) + stubSubscriptionResults( + subscription = mockObjectCollection.subscriptionId, + spaceId = mockObjectCollection.spaceId, + collection = root, + storeOfRelations = storeOfRelations, + keys = mockObjectCollection.dvKeys, + objects = listOf( + mockObjectCollection.obj1, + mockObjectCollection.obj2, + mockObjectCollection.obj3, + mockObjectCollection.obj4, + mockObjectCollection.obj5 + ), + dvSorts = mockObjectCollection.sorts + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()).also {dataViewState -> - val rows = (dataViewState.viewer as Viewer.ListView).items - assertEquals(5, rows.size) + assertIs(viewerFlow.awaitItem()).also { dataViewState -> + val rows = (dataViewState.viewer as Viewer.ListView).items + assertEquals(5, rows.size) - // SHOULD BE 3, 2, 4, 5, 1 - assertEquals(mockObjectCollection.obj3.id, rows[0].objectId) - assertEquals(mockObjectCollection.obj2.id, rows[1].objectId) - assertEquals(mockObjectCollection.obj4.id, rows[2].objectId) - assertEquals(mockObjectCollection.obj5.id, rows[3].objectId) - assertEquals(mockObjectCollection.obj1.id, rows[4].objectId) + // SHOULD BE 3, 2, 4, 5, 1 + assertEquals(mockObjectCollection.obj3.id, rows[0].objectId) + assertEquals(mockObjectCollection.obj2.id, rows[1].objectId) + assertEquals(mockObjectCollection.obj4.id, rows[2].objectId) + assertEquals(mockObjectCollection.obj5.id, rows[3].objectId) + assertEquals(mockObjectCollection.obj1.id, rows[4].objectId) + } + stateFlow.cancelAndIgnoreRemainingEvents() + viewerFlow.cancelAndIgnoreRemainingEvents() } } @Test fun `should not sort LIST collection objects by empty data view object order`() = runTest { - // SETUP - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - mockObjectCollection.dataView - ), - details = mockObjectCollection.details - ) - stubStoreOfRelations(mockObjectCollection) - stubSubscriptionResults( - subscription = mockObjectCollection.subscriptionId, - spaceId = mockObjectCollection.spaceId, - collection = root, - storeOfRelations = storeOfRelations, - keys = mockObjectCollection.dvKeys, - objects = listOf( - mockObjectCollection.obj5, - mockObjectCollection.obj2, - mockObjectCollection.obj3, - mockObjectCollection.obj4, - mockObjectCollection.obj1 - ), - dvSorts = mockObjectCollection.sorts - ) + turbineScope { + // SETUP + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + mockObjectCollection.dataView + ), + details = mockObjectCollection.details + ) + stubStoreOfRelations(mockObjectCollection) + stubSubscriptionResults( + subscription = mockObjectCollection.subscriptionId, + spaceId = mockObjectCollection.spaceId, + collection = root, + storeOfRelations = storeOfRelations, + keys = mockObjectCollection.dvKeys, + objects = listOf( + mockObjectCollection.obj5, + mockObjectCollection.obj2, + mockObjectCollection.obj3, + mockObjectCollection.obj4, + mockObjectCollection.obj1 + ), + dvSorts = mockObjectCollection.sorts + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()).also {dataViewState -> - val rows = (dataViewState.viewer as Viewer.ListView).items - assertEquals(5, rows.size) + assertIs(viewerFlow.awaitItem()).also { dataViewState -> + val rows = (dataViewState.viewer as Viewer.ListView).items + assertEquals(5, rows.size) - // SHOULD BE NOT SORTED 5, 2, 3, 4, 1 - assertEquals(mockObjectCollection.obj5.id, rows[0].objectId) - assertEquals(mockObjectCollection.obj2.id, rows[1].objectId) - assertEquals(mockObjectCollection.obj3.id, rows[2].objectId) - assertEquals(mockObjectCollection.obj4.id, rows[3].objectId) - assertEquals(mockObjectCollection.obj1.id, rows[4].objectId) + // SHOULD BE NOT SORTED 5, 2, 3, 4, 1 + assertEquals(mockObjectCollection.obj5.id, rows[0].objectId) + assertEquals(mockObjectCollection.obj2.id, rows[1].objectId) + assertEquals(mockObjectCollection.obj3.id, rows[2].objectId) + assertEquals(mockObjectCollection.obj4.id, rows[3].objectId) + assertEquals(mockObjectCollection.obj1.id, rows[4].objectId) + } + stateFlow.cancelAndIgnoreRemainingEvents() + viewerFlow.cancelAndIgnoreRemainingEvents() } } @Test fun `should sort GRID collection objects by data view object order`() = runTest { - // SETUP - session.currentViewerId.value = mockObjectCollection.viewerGrid.id - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - mockObjectCollection.dataViewWithObjectOrder - ), - details = mockObjectCollection.details - ) - stubStoreOfRelations(mockObjectCollection) - stubSubscriptionResults( - subscription = mockObjectCollection.subscriptionId, - spaceId = mockObjectCollection.spaceId, - collection = root, - storeOfRelations = storeOfRelations, - keys = mockObjectCollection.dvKeys, - objects = listOf( - mockObjectCollection.obj1, - mockObjectCollection.obj2, - mockObjectCollection.obj3, - mockObjectCollection.obj4, - mockObjectCollection.obj5 - ), - dvSorts = listOf(mockObjectCollection.sortGrid) - ) + turbineScope { + // SETUP + session.currentViewerId.value = mockObjectCollection.viewerGrid.id + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + mockObjectCollection.dataViewWithObjectOrder + ), + details = mockObjectCollection.details + ) + stubStoreOfRelations(mockObjectCollection) + stubSubscriptionResults( + subscription = mockObjectCollection.subscriptionId, + spaceId = mockObjectCollection.spaceId, + collection = root, + storeOfRelations = storeOfRelations, + keys = mockObjectCollection.dvKeys, + objects = listOf( + mockObjectCollection.obj1, + mockObjectCollection.obj2, + mockObjectCollection.obj3, + mockObjectCollection.obj4, + mockObjectCollection.obj5 + ), + dvSorts = listOf(mockObjectCollection.sortGrid) + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - //assertIs(viewerFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()).also { dataViewState -> - val rows = (dataViewState.viewer as Viewer.GridView).rows - assertEquals(5, rows.size) + //assertIs(viewerFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()).also { dataViewState -> + val rows = (dataViewState.viewer as Viewer.GridView).rows + assertEquals(5, rows.size) - // SHOULD BE SORTED 1, 2, 4, 3, 5 - assertEquals(mockObjectCollection.obj1.id, rows[0].id) - assertEquals(mockObjectCollection.obj2.id, rows[1].id) - assertEquals(mockObjectCollection.obj4.id, rows[2].id) - assertEquals(mockObjectCollection.obj3.id, rows[3].id) - assertEquals(mockObjectCollection.obj5.id, rows[4].id) + // SHOULD BE SORTED 1, 2, 4, 3, 5 + assertEquals(mockObjectCollection.obj1.id, rows[0].id) + assertEquals(mockObjectCollection.obj2.id, rows[1].id) + assertEquals(mockObjectCollection.obj4.id, rows[2].id) + assertEquals(mockObjectCollection.obj3.id, rows[3].id) + assertEquals(mockObjectCollection.obj5.id, rows[4].id) + } + stateFlow.cancelAndIgnoreRemainingEvents() + viewerFlow.cancelAndIgnoreRemainingEvents() } } @Test fun `should NOT sort GRID collection objects by empty data view object order`() = runTest { - // SETUP - session.currentViewerId.value = mockObjectCollection.viewerGrid.id - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - mockObjectCollection.dataViewGrid - ), - details = mockObjectCollection.details - ) - stubStoreOfRelations(mockObjectCollection) - stubSubscriptionResults( - subscription = mockObjectCollection.subscriptionId, - spaceId = mockObjectCollection.spaceId, - collection = root, - storeOfRelations = storeOfRelations, - keys = mockObjectCollection.dvKeys, - objects = listOf( - mockObjectCollection.obj1, - mockObjectCollection.obj2, - mockObjectCollection.obj3, - mockObjectCollection.obj4, - mockObjectCollection.obj5 - ), - dvSorts = listOf(mockObjectCollection.sortGrid) - ) + turbineScope { + // SETUP + session.currentViewerId.value = mockObjectCollection.viewerGrid.id + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + mockObjectCollection.dataViewGrid + ), + details = mockObjectCollection.details + ) + stubStoreOfRelations(mockObjectCollection) + stubSubscriptionResults( + subscription = mockObjectCollection.subscriptionId, + spaceId = mockObjectCollection.spaceId, + collection = root, + storeOfRelations = storeOfRelations, + keys = mockObjectCollection.dvKeys, + objects = listOf( + mockObjectCollection.obj1, + mockObjectCollection.obj2, + mockObjectCollection.obj3, + mockObjectCollection.obj4, + mockObjectCollection.obj5 + ), + dvSorts = listOf(mockObjectCollection.sortGrid) + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()).also {dataViewState -> - val rows = (dataViewState.viewer as Viewer.GridView).rows - assertEquals(5, rows.size) + assertIs(viewerFlow.awaitItem()).also { dataViewState -> + val rows = (dataViewState.viewer as Viewer.GridView).rows + assertEquals(5, rows.size) - // SHOULD BE SORTED 1, 2, 4, 3, 5 - assertEquals(mockObjectCollection.obj1.id, rows[0].id) - assertEquals(mockObjectCollection.obj2.id, rows[1].id) - assertEquals(mockObjectCollection.obj3.id, rows[2].id) - assertEquals(mockObjectCollection.obj4.id, rows[3].id) - assertEquals(mockObjectCollection.obj5.id, rows[4].id) + // SHOULD BE SORTED 1, 2, 4, 3, 5 + assertEquals(mockObjectCollection.obj1.id, rows[0].id) + assertEquals(mockObjectCollection.obj2.id, rows[1].id) + assertEquals(mockObjectCollection.obj3.id, rows[2].id) + assertEquals(mockObjectCollection.obj4.id, rows[3].id) + assertEquals(mockObjectCollection.obj5.id, rows[4].id) + } + stateFlow.cancelAndIgnoreRemainingEvents() + viewerFlow.cancelAndIgnoreRemainingEvents() } } @Test fun `should sort GALLERY collection objects by data view object order`() = runTest { - // SETUP - session.currentViewerId.value = mockObjectCollection.viewerGallery.id - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - mockObjectCollection.dataViewWithObjectOrder - ), - details = mockObjectCollection.details - ) - stubStoreOfRelations(mockObjectCollection) - stubSubscriptionResults( - subscription = mockObjectCollection.subscriptionId, - spaceId = mockObjectCollection.spaceId, - collection = root, - storeOfRelations = storeOfRelations, - keys = mockObjectCollection.dvKeys, - objects = listOf( - mockObjectCollection.obj1, - mockObjectCollection.obj2, - mockObjectCollection.obj3, - mockObjectCollection.obj4, - mockObjectCollection.obj5 - ), - dvSorts = listOf(mockObjectCollection.sortGallery) - ) + turbineScope { + // SETUP + session.currentViewerId.value = mockObjectCollection.viewerGallery.id + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + mockObjectCollection.dataViewWithObjectOrder + ), + details = mockObjectCollection.details + ) + stubStoreOfRelations(mockObjectCollection) + stubSubscriptionResults( + subscription = mockObjectCollection.subscriptionId, + spaceId = mockObjectCollection.spaceId, + collection = root, + storeOfRelations = storeOfRelations, + keys = mockObjectCollection.dvKeys, + objects = listOf( + mockObjectCollection.obj1, + mockObjectCollection.obj2, + mockObjectCollection.obj3, + mockObjectCollection.obj4, + mockObjectCollection.obj5 + ), + dvSorts = listOf(mockObjectCollection.sortGallery) + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()).also {dataViewState -> - val rows = (dataViewState.viewer as Viewer.GalleryView).items - assertEquals(5, rows.size) + assertIs(viewerFlow.awaitItem()).also { dataViewState -> + val rows = (dataViewState.viewer as Viewer.GalleryView).items + assertEquals(5, rows.size) - // SHOULD BE SORTED 5, 4, 3, 2, 1 - assertEquals(mockObjectCollection.obj5.id, rows[0].objectId) - assertEquals(mockObjectCollection.obj4.id, rows[1].objectId) - assertEquals(mockObjectCollection.obj3.id, rows[2].objectId) - assertEquals(mockObjectCollection.obj2.id, rows[3].objectId) - assertEquals(mockObjectCollection.obj1.id, rows[4].objectId) + // SHOULD BE SORTED 5, 4, 3, 2, 1 + assertEquals(mockObjectCollection.obj5.id, rows[0].objectId) + assertEquals(mockObjectCollection.obj4.id, rows[1].objectId) + assertEquals(mockObjectCollection.obj3.id, rows[2].objectId) + assertEquals(mockObjectCollection.obj2.id, rows[3].objectId) + assertEquals(mockObjectCollection.obj1.id, rows[4].objectId) + } + stateFlow.cancelAndIgnoreRemainingEvents() + viewerFlow.cancelAndIgnoreRemainingEvents() } } @Test fun `should NOT sort GALLERY collection objects by empty data view object order`() = runTest { - // SETUP - session.currentViewerId.value = mockObjectCollection.viewerGallery.id - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - mockObjectCollection.dataViewGallery - ), - details = mockObjectCollection.details - ) - stubStoreOfRelations(mockObjectCollection) - stubSubscriptionResults( - subscription = mockObjectCollection.subscriptionId, - spaceId = mockObjectCollection.spaceId, - collection = root, - storeOfRelations = storeOfRelations, - keys = mockObjectCollection.dvKeys, - objects = listOf( - mockObjectCollection.obj1, - mockObjectCollection.obj2, - mockObjectCollection.obj3, - mockObjectCollection.obj4, - mockObjectCollection.obj5 - ), - dvSorts = listOf(mockObjectCollection.sortGallery) - ) - stubTemplatesForTemplatesContainer() + turbineScope { + // SETUP + session.currentViewerId.value = mockObjectCollection.viewerGallery.id + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + mockObjectCollection.dataViewGallery + ), + details = mockObjectCollection.details + ) + stubStoreOfRelations(mockObjectCollection) + stubSubscriptionResults( + subscription = mockObjectCollection.subscriptionId, + spaceId = mockObjectCollection.spaceId, + collection = root, + storeOfRelations = storeOfRelations, + keys = mockObjectCollection.dvKeys, + objects = listOf( + mockObjectCollection.obj1, + mockObjectCollection.obj2, + mockObjectCollection.obj3, + mockObjectCollection.obj4, + mockObjectCollection.obj5 + ), + dvSorts = listOf(mockObjectCollection.sortGallery) + ) + stubTemplatesForTemplatesContainer() - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()).also {dataViewState -> - val rows = (dataViewState.viewer as Viewer.GalleryView).items - assertEquals(5, rows.size) + assertIs(viewerFlow.awaitItem()).also { dataViewState -> + val rows = (dataViewState.viewer as Viewer.GalleryView).items + assertEquals(5, rows.size) - // SHOULD BE SORTED 5, 4, 3, 2, 1 - assertEquals(mockObjectCollection.obj1.id, rows[0].objectId) - assertEquals(mockObjectCollection.obj2.id, rows[1].objectId) - assertEquals(mockObjectCollection.obj3.id, rows[2].objectId) - assertEquals(mockObjectCollection.obj4.id, rows[3].objectId) - assertEquals(mockObjectCollection.obj5.id, rows[4].objectId) + // SHOULD BE SORTED 5, 4, 3, 2, 1 + assertEquals(mockObjectCollection.obj1.id, rows[0].objectId) + assertEquals(mockObjectCollection.obj2.id, rows[1].objectId) + assertEquals(mockObjectCollection.obj3.id, rows[2].objectId) + assertEquals(mockObjectCollection.obj4.id, rows[3].objectId) + assertEquals(mockObjectCollection.obj5.id, rows[4].objectId) + } + stateFlow.cancelAndIgnoreRemainingEvents() + viewerFlow.cancelAndIgnoreRemainingEvents() } } @Test - fun `should be collection with templates present when active view hasn't defaultTemplateId`() = runTest { - // SETUP + fun `should be collection with templates present when active view hasn't defaultTemplateId`() = + runTest { + turbineScope { + // SETUP - val defaultObjectType = TypeKey(MockDataFactory.randomString()) - val defaultObjectTypeName = "CustomName" + val defaultObjectType = TypeKey(MockDataFactory.randomString()) + val defaultObjectTypeName = "CustomName" - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubTemplatesForTemplatesContainer( - type = VIEW_DEFAULT_OBJECT_TYPE, - templates = listOf(StubObject(objectType = VIEW_DEFAULT_OBJECT_TYPE)) - ) - - session.currentViewerId.value = mockObjectCollection.viewerList.id - val dataview = mockObjectCollection.dataView.copy( - content = (mockObjectCollection.dataView.content as DV).copy( - viewers = listOf( - mockObjectCollection.viewerGrid.copy(defaultObjectType = ObjectTypeIds.PROFILE), - mockObjectCollection.viewerList.copy(defaultObjectType = ObjectTypeIds.PAGE) + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubTemplatesForTemplatesContainer( + type = VIEW_DEFAULT_OBJECT_TYPE, + templates = listOf(StubObject(objectType = VIEW_DEFAULT_OBJECT_TYPE)) ) - ) - ) - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - dataview - ), - details = mockObjectCollection.details - ) - stubStoreOfObjectTypes( - VIEW_DEFAULT_OBJECT_TYPE, - mapOf( - Relations.ID to VIEW_DEFAULT_OBJECT_TYPE, - Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.BASIC.code.toDouble(), - Relations.NAME to "VIEW_DEFAULT_OBJECT_TYPE" - ) - ) - stubStoreOfRelations(mockObjectCollection) - stubSubscriptionResults( - subscription = mockObjectCollection.subscriptionId, - spaceId = mockObjectCollection.spaceId, - collection = root, - storeOfRelations = storeOfRelations, - keys = mockObjectCollection.dvKeys, - dvSorts = mockObjectCollection.sorts - ) + session.currentViewerId.value = mockObjectCollection.viewerList.id + val dataview = mockObjectCollection.dataView.copy( + content = (mockObjectCollection.dataView.content as DV).copy( + viewers = listOf( + mockObjectCollection.viewerGrid.copy(defaultObjectType = ObjectTypeIds.PROFILE), + mockObjectCollection.viewerList.copy(defaultObjectType = ObjectTypeIds.PAGE) + ) + ) + ) - // TESTING - proceedWithStartingViewModel() + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + dataview + ), + details = mockObjectCollection.details + ) + stubStoreOfObjectTypes( + VIEW_DEFAULT_OBJECT_TYPE, + mapOf( + Relations.ID to VIEW_DEFAULT_OBJECT_TYPE, + Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.BASIC.code.toDouble(), + Relations.NAME to "VIEW_DEFAULT_OBJECT_TYPE" + ) + ) + stubStoreOfRelations(mockObjectCollection) + stubSubscriptionResults( + subscription = mockObjectCollection.subscriptionId, + spaceId = mockObjectCollection.spaceId, + collection = root, + storeOfRelations = storeOfRelations, + keys = mockObjectCollection.dvKeys, + dvSorts = mockObjectCollection.sorts + ) - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + // TESTING + proceedWithStartingViewModel() - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - assertIs(stateFlow.awaitItem()) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - val item = viewerFlow.awaitItem() - assertIs(item) - assertTrue(item.isCreateObjectAllowed) - } + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) + + val item = viewerFlow.awaitItem() + assertIs(item) + assertTrue(item.isCreateObjectAllowed) + } + } @Test - fun `should be collection with object create templates allowed when active viewer default type is NOTE`() = runTest { - // SETUP + fun `should be collection with object create templates allowed when active viewer default type is NOTE`() = + runTest { + turbineScope { + // SETUP - val noteTypeId = MockDataFactory.randomString() - val noteTypeUniqueKey = TypeKey(ObjectTypeIds.NOTE) - val noteTypeName = "Note" + val noteTypeId = MockDataFactory.randomString() + val noteTypeUniqueKey = TypeKey(ObjectTypeIds.NOTE) + val noteTypeName = "Note" - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubTemplatesForTemplatesContainer() + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubTemplatesForTemplatesContainer() - session.currentViewerId.value = mockObjectCollection.viewerList.id - val dataview = mockObjectCollection.dataView.copy( - content = (mockObjectCollection.dataView.content as DV).copy( - viewers = listOf( - mockObjectCollection.viewerGrid.copy(defaultObjectType = RandomString.make()), - mockObjectCollection.viewerList.copy(defaultObjectType = noteTypeId) + session.currentViewerId.value = mockObjectCollection.viewerList.id + val dataview = mockObjectCollection.dataView.copy( + content = (mockObjectCollection.dataView.content as DV).copy( + viewers = listOf( + mockObjectCollection.viewerGrid.copy(defaultObjectType = RandomString.make()), + mockObjectCollection.viewerList.copy(defaultObjectType = noteTypeId) + ) + ) ) - ) - ) - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - dataview - ), - details = mockObjectCollection.details - ) - stubStoreOfObjectTypes( - noteTypeId, - mapOf( - Relations.ID to noteTypeId, - Relations.UNIQUE_KEY to noteTypeUniqueKey.key, - Relations.LAYOUT to ObjectType.Layout.OBJECT_TYPE.code.toDouble(), - Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.NOTE.code.toDouble(), - Relations.NAME to noteTypeName - ) - ) - stubStoreOfRelations(mockObjectCollection) - stubSubscriptionResults( - subscription = mockObjectCollection.subscriptionId, - spaceId = mockObjectCollection.spaceId, - collection = root, - storeOfRelations = storeOfRelations, - keys = mockObjectCollection.dvKeys, - dvSorts = mockObjectCollection.sorts - ) + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + dataview + ), + details = mockObjectCollection.details + ) + stubStoreOfObjectTypes( + noteTypeId, + mapOf( + Relations.ID to noteTypeId, + Relations.UNIQUE_KEY to noteTypeUniqueKey.key, + Relations.LAYOUT to ObjectType.Layout.OBJECT_TYPE.code.toDouble(), + Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.NOTE.code.toDouble(), + Relations.NAME to noteTypeName + ) + ) + stubStoreOfRelations(mockObjectCollection) + stubSubscriptionResults( + subscription = mockObjectCollection.subscriptionId, + spaceId = mockObjectCollection.spaceId, + collection = root, + storeOfRelations = storeOfRelations, + keys = mockObjectCollection.dvKeys, + dvSorts = mockObjectCollection.sorts + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - assertIs(stateFlow.awaitItem()) + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) - val item = viewerFlow.awaitItem() - assertIs(item) - assertTrue(item.isCreateObjectAllowed) - } + val item = viewerFlow.awaitItem() + assertIs(item) + assertTrue(item.isCreateObjectAllowed) + } + } @Test - fun `should be collection without object create allowed when restriction is present`() = runTest { - // SETUP + fun `should be collection without object create allowed when restriction is present`() = + runTest { + turbineScope { + // SETUP - val defaultObjectType = RandomString.make() - val defaultObjectTypeName = RandomString.make() + val defaultObjectType = RandomString.make() + val defaultObjectTypeName = RandomString.make() - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() - session.currentViewerId.value = mockObjectCollection.viewerList.id - val dataview = mockObjectCollection.dataView.copy( - content = (mockObjectCollection.dataView.content as DV).copy( - viewers = listOf( - mockObjectCollection.viewerGrid.copy(defaultObjectType = ObjectTypeIds.PROFILE), - mockObjectCollection.viewerList.copy(defaultObjectType = defaultObjectType) + session.currentViewerId.value = mockObjectCollection.viewerList.id + val dataview = mockObjectCollection.dataView.copy( + content = (mockObjectCollection.dataView.content as DV).copy( + viewers = listOf( + mockObjectCollection.viewerGrid.copy(defaultObjectType = ObjectTypeIds.PROFILE), + mockObjectCollection.viewerList.copy(defaultObjectType = defaultObjectType) + ) + ) ) - ) - ) - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - dataview - ), - details = mockObjectCollection.details, - dataViewRestrictions = listOf( - DataViewRestrictions( - block = dataview.id, - restrictions = listOf(DataViewRestriction.CREATE_OBJECT) + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + dataview + ), + details = mockObjectCollection.details, + dataViewRestrictions = listOf( + DataViewRestrictions( + block = dataview.id, + restrictions = listOf(DataViewRestriction.CREATE_OBJECT) + ) + ) + ) + stubStoreOfObjectTypes( + defaultObjectType, + mapOf( + Relations.ID to defaultObjectType, + Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.COLLECTION.code.toDouble(), + Relations.NAME to defaultObjectTypeName + ) + ) + stubStoreOfRelations(mockObjectCollection) + stubSubscriptionResults( + subscription = mockObjectCollection.subscriptionId, + spaceId = mockObjectCollection.spaceId, + collection = root, + storeOfRelations = storeOfRelations, + keys = mockObjectCollection.dvKeys, + dvSorts = mockObjectCollection.sorts ) - ) - ) - stubStoreOfObjectTypes( - defaultObjectType, - mapOf( - Relations.ID to defaultObjectType, - Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.COLLECTION.code.toDouble(), - Relations.NAME to defaultObjectTypeName - ) - ) - stubStoreOfRelations(mockObjectCollection) - stubSubscriptionResults( - subscription = mockObjectCollection.subscriptionId, - spaceId = mockObjectCollection.spaceId, - collection = root, - storeOfRelations = storeOfRelations, - keys = mockObjectCollection.dvKeys, - dvSorts = mockObjectCollection.sorts - ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - assertIs(stateFlow.awaitItem()) + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) - val item = viewerFlow.awaitItem() - assertIs(item) - assertFalse(item.isCreateObjectAllowed) - } + val item = viewerFlow.awaitItem() + assertIs(item) + assertFalse(item.isCreateObjectAllowed) + } + } @Test - fun `should be collection with object create allowed when active viewer default type is custom type with recommended layouts`() = runTest { - // SETUP + fun `should be collection with object create allowed when active viewer default type is custom type with recommended layouts`() = + runTest { + turbineScope { + // SETUP - val defaultObjectTypeId = RandomString.make() - val defaultObjectTypeUniqueKey = TypeKey(ObjectTypeIds.PAGE) - val defaultObjectTypeName = "Page" + val defaultObjectTypeId = RandomString.make() + val defaultObjectTypeUniqueKey = TypeKey(ObjectTypeIds.PAGE) + val defaultObjectTypeName = "Page" - stubSpaceManager(mockObjectCollection.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() + stubSpaceManager(mockObjectCollection.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() - session.currentViewerId.value = mockObjectCollection.viewerList.id - val dataview = mockObjectCollection.dataView.copy( - content = (mockObjectCollection.dataView.content as DV).copy( - viewers = listOf( - mockObjectCollection.viewerGrid.copy(defaultObjectType = ObjectTypeIds.NOTE), - mockObjectCollection.viewerList.copy(defaultObjectType = defaultObjectTypeId) + session.currentViewerId.value = mockObjectCollection.viewerList.id + val dataview = mockObjectCollection.dataView.copy( + content = (mockObjectCollection.dataView.content as DV).copy( + viewers = listOf( + mockObjectCollection.viewerGrid.copy(defaultObjectType = ObjectTypeIds.NOTE), + mockObjectCollection.viewerList.copy(defaultObjectType = defaultObjectTypeId) + ) + ) ) - ) - ) - stubOpenObject( - doc = listOf( - mockObjectCollection.header, - mockObjectCollection.title, - dataview - ), - details = mockObjectCollection.details - ) - stubStoreOfObjectTypes( - defaultObjectTypeId, - mapOf( - Relations.ID to defaultObjectTypeId, - Relations.UNIQUE_KEY to defaultObjectTypeUniqueKey.key, - Relations.RECOMMENDED_LAYOUT to SupportedLayouts.editorLayouts.random().code.toDouble(), - Relations.NAME to defaultObjectTypeName - ) - ) - stubStoreOfRelations(mockObjectCollection) - stubSubscriptionResults( - subscription = mockObjectCollection.subscriptionId, - spaceId = mockObjectCollection.spaceId, - collection = root, - storeOfRelations = storeOfRelations, - keys = mockObjectCollection.dvKeys, - dvSorts = mockObjectCollection.sorts - ) + stubOpenObject( + doc = listOf( + mockObjectCollection.header, + mockObjectCollection.title, + dataview + ), + details = mockObjectCollection.details + ) + stubStoreOfObjectTypes( + defaultObjectTypeId, + mapOf( + Relations.ID to defaultObjectTypeId, + Relations.UNIQUE_KEY to defaultObjectTypeUniqueKey.key, + Relations.RECOMMENDED_LAYOUT to SupportedLayouts.editorLayouts.random().code.toDouble(), + Relations.NAME to defaultObjectTypeName + ) + ) + stubStoreOfRelations(mockObjectCollection) + stubSubscriptionResults( + subscription = mockObjectCollection.subscriptionId, + spaceId = mockObjectCollection.spaceId, + collection = root, + storeOfRelations = storeOfRelations, + keys = mockObjectCollection.dvKeys, + dvSorts = mockObjectCollection.sorts + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - assertIs(stateFlow.awaitItem()) + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) - val item = viewerFlow.awaitItem() - assertIs(item) - assertTrue(item.isCreateObjectAllowed) - } + val item = viewerFlow.awaitItem() + assertIs(item) + assertTrue(item.isCreateObjectAllowed) + } + } private fun proceedWithStartingViewModel() { viewModel.onStart(ctx = root, space = defaultSpace) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/ObjectStateSetViewTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/ObjectStateSetViewTest.kt index 374cbf3d7d..4f15bdcc01 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/ObjectStateSetViewTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/collections/ObjectStateSetViewTest.kt @@ -2,6 +2,7 @@ package com.anytypeio.anytype.presentation.collections import app.cash.turbine.test import app.cash.turbine.testIn +import app.cash.turbine.turbineScope import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.ObjectType import com.anytypeio.anytype.core_models.ObjectTypeIds @@ -41,6 +42,7 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() { MockitoAnnotations.openMocks(this) viewModel = givenViewModel() mockObjectSet = MockSet(context = root, space = defaultSpace) + stubNetworkMode() } @After @@ -50,404 +52,418 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() { @Test fun `displaying error state when object with layout other than set or collection`() = runTest { - // SETUP - stubSpaceManager(mockObjectSet.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() + turbineScope { + // SETUP + stubSpaceManager(mockObjectSet.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() - val objectDetails = Block.Details( - details = mapOf( - root to Block.Fields( - mapOf( - Relations.ID to root, - Relations.LAYOUT to ObjectType.Layout.BASIC.code.toDouble() + val objectDetails = Block.Details( + details = mapOf( + root to Block.Fields( + mapOf( + Relations.ID to root, + Relations.LAYOUT to ObjectType.Layout.BASIC.code.toDouble() + ) ) ) ) - ) - stubOpenObject( - doc = listOf(mockObjectSet.header, mockObjectSet.title), - details = objectDetails - ) + stubOpenObject( + doc = listOf(mockObjectSet.header, mockObjectSet.title), + details = objectDetails + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - // ASSERT COLLECTION OBJECT STATE - stateReducer.state.test { - val first = awaitItem() - assertIs(first) - expectNoEvents() - } + // ASSERT COLLECTION OBJECT STATE + stateReducer.state.test { + val first = awaitItem() + assertIs(first) + expectNoEvents() + } - // ASSERT DATA VIEW STATE - viewModel.currentViewer.test { - val first = awaitItem() - assertIs(first) + // ASSERT DATA VIEW STATE + viewModel.currentViewer.test { + val first = awaitItem() + assertIs(first) - val second = awaitItem() - assertIs(second) + val second = awaitItem() + assertIs(second) - assertEquals(expected = "Wrong layout, couldn't open object", actual = second.msg) - expectNoEvents() + assertEquals(expected = "Wrong layout, couldn't open object", actual = second.msg) + expectNoEvents() + } } } @Test fun `displaying set init state when object with SET layout and no DataView`() = runTest { - // SETUP - stubSpaceManager(mockObjectSet.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() + turbineScope { + // SETUP + stubSpaceManager(mockObjectSet.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() - stubOpenObject( - doc = listOf(mockObjectSet.header, mockObjectSet.title), - details = mockObjectSet.details - ) + stubOpenObject( + doc = listOf(mockObjectSet.header, mockObjectSet.title), + details = mockObjectSet.details + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - // ASSERT SET OBJECT STATE - stateReducer.state.test { - val first = awaitItem() - assertIs(first) - expectNoEvents() - } + // ASSERT SET OBJECT STATE + stateReducer.state.test { + val first = awaitItem() + assertIs(first) + expectNoEvents() + } - // ASSERT DATA VIEW STATE - viewModel.currentViewer.test { - val first = awaitItem() - assertIs(first) - expectNoEvents() + // ASSERT DATA VIEW STATE + viewModel.currentViewer.test { + val first = awaitItem() + assertIs(first) + expectNoEvents() + } } } @Test fun `displaying set no query state when object with DataView and empty setOf`() = runTest { - // SETUP - stubSpaceManager(mockObjectSet.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), - details = mockObjectSet.detailsEmptySetOf - ) - - // TESTING - proceedWithStartingViewModel() - - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) - - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - } - - @Test - fun `displaying set no view state when object with DataView and nullable view`() = runTest { - // SETUP - stubSpaceManager(mockObjectSet.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataViewNoViews), - details = mockObjectSet.details - ) - - // TESTING - proceedWithStartingViewModel() - - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) - - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - } - - @Test - fun `displaying set with items state when object set with two records`() = runTest { - // SETUP - stubSpaceManager(mockObjectSet.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), - details = mockObjectSet.details - ) - stubSubscriptionResults( - subscription = mockObjectSet.subscriptionId, - spaceId = mockObjectSet.spaceId, - storeOfRelations = storeOfRelations, - keys = mockObjectSet.dvKeys, - sources = listOf(mockObjectSet.setOf), - objects = listOf(mockObjectSet.obj1, mockObjectSet.obj2), - dvFilters = mockObjectSet.filters - ) - - // TESTING - proceedWithStartingViewModel() - - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) - - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - } - - @Test - fun `displaying set with no items when opening object set with no records`() = runTest { - // SETUP - stubSpaceManager(mockObjectSet.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), - details = mockObjectSet.details - ) - stubSubscriptionResults( - subscription = mockObjectSet.subscriptionId, - spaceId = mockObjectSet.spaceId, - storeOfRelations = storeOfRelations, - keys = mockObjectSet.dvKeys, - sources = listOf(mockObjectSet.setOf), - dvFilters = mockObjectSet.filters - ) - - // TESTING - proceedWithStartingViewModel() - - // ASSERT STATES - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) - - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - } - - @Test - fun `Displaying Object Sets with Non-Deleted Types Only`() = runTest { - // SETUP - stubSpaceManager(mockObjectSet.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - - val typeDeleted1 = ObjectWrapper.Type( - mapOf( - Relations.ID to RandomString.make(), - Relations.IS_DELETED to true + turbineScope { + // SETUP + stubSpaceManager(mockObjectSet.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), + details = mockObjectSet.detailsEmptySetOf ) - ) - val type2 = ObjectWrapper.Type( - mapOf( - Relations.ID to RandomString.make(), - Relations.TYPE to ObjectTypeIds.OBJECT_TYPE - ) - ) - val typeDeleted3 = ObjectWrapper.Type( - mapOf( - Relations.ID to RandomString.make(), - ) - ) - val detailsDeletedSetOf = Block.Details( - details = mapOf( - root to Block.Fields( - mapOf( - Relations.ID to root, - Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(), - Relations.SET_OF to listOf(typeDeleted1.id, type2.id, typeDeleted3.id) - ) - ), - typeDeleted1.id to Block.Fields( - mapOf( - Relations.ID to typeDeleted1.id, - Relations.IS_DELETED to true - ) - ), - type2.id to Block.Fields( - mapOf( - Relations.ID to type2.id, - Relations.TYPE to ObjectTypeIds.OBJECT_TYPE - ) - ) - ) - ) + // TESTING + proceedWithStartingViewModel() - stubOpenObject( - doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), - details = detailsDeletedSetOf - ) - stubSubscriptionResults( - subscription = mockObjectSet.subscriptionId, - spaceId = mockObjectSet.spaceId, - storeOfRelations = storeOfRelations, - keys = mockObjectSet.dvKeys, - sources = listOf(type2.id), - objects = listOf(mockObjectSet.obj1, mockObjectSet.obj2), - dvFilters = mockObjectSet.filters - ) + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // TESTING - proceedWithStartingViewModel() + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - // ASSERT STATES - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) - - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) - - stateFlow.ensureAllEventsConsumed() - viewerFlow.ensureAllEventsConsumed() - - advanceUntilIdle() - verifyBlocking(repo, times(1)) { - searchObjectsWithSubscription( - eq(mockObjectSet.subscriptionId), - eq(listOf()), - eq( - mockObjectSet.filters + ObjectSearchConstants.defaultDataViewFilters( - spaces = listOf(spaceConfig.space, spaceConfig.techSpace) - ) - ), - eq(ObjectSearchConstants.defaultDataViewKeys + mockObjectSet.dvKeys), - eq(listOf(type2.id)), - eq(0L), - eq(ObjectSetConfig.DEFAULT_LIMIT), - eq(null), - eq(null), - eq(null), - eq(null), - eq(null) - ) + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) } } @Test - fun `Displaying Object Set with No Query State When All Types are Deleted`() = runTest { - // SETUP - stubSpaceManager(mockObjectSet.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - - val typeDeleted1 = ObjectWrapper.Type( - mapOf( - Relations.ID to RandomString.make(), - Relations.IS_DELETED to true - ) - ) - val typeDeleted3 = ObjectWrapper.Type( - mapOf( - Relations.ID to RandomString.make(), - ) - ) - - val detailsDeletedSetOf = Block.Details( - details = mapOf( - root to Block.Fields( - mapOf( - Relations.ID to root, - Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(), - Relations.SET_OF to listOf(typeDeleted1.id, typeDeleted3.id) - ) + fun `displaying set no view state when object with DataView and nullable view`() = runTest { + turbineScope { + // SETUP + stubSpaceManager(mockObjectSet.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf( + mockObjectSet.header, + mockObjectSet.title, + mockObjectSet.dataViewNoViews ), - typeDeleted1.id to Block.Fields( - mapOf( - Relations.ID to typeDeleted1.id, - Relations.IS_DELETED to true + details = mockObjectSet.details + ) + + // TESTING + proceedWithStartingViewModel() + + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) + + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + } + + @Test + fun `displaying set with items state when object set with two records`() = runTest { + // SETUP + stubSpaceManager(mockObjectSet.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), + details = mockObjectSet.details + ) + stubSubscriptionResults( + subscription = mockObjectSet.subscriptionId, + spaceId = mockObjectSet.spaceId, + storeOfRelations = storeOfRelations, + keys = mockObjectSet.dvKeys, + sources = listOf(mockObjectSet.setOf), + objects = listOf(mockObjectSet.obj1, mockObjectSet.obj2), + dvFilters = mockObjectSet.filters + ) + + // TESTING + proceedWithStartingViewModel() + + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) + + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + } + + @Test + fun `displaying set with no items when opening object set with no records`() = runTest { + // SETUP + stubSpaceManager(mockObjectSet.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), + details = mockObjectSet.details + ) + stubSubscriptionResults( + subscription = mockObjectSet.subscriptionId, + spaceId = mockObjectSet.spaceId, + storeOfRelations = storeOfRelations, + keys = mockObjectSet.dvKeys, + sources = listOf(mockObjectSet.setOf), + dvFilters = mockObjectSet.filters + ) + + // TESTING + proceedWithStartingViewModel() + + // ASSERT STATES + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) + + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + } + + @Test + fun `Displaying Object Sets with Non-Deleted Types Only`() = runTest { + // SETUP + stubSpaceManager(mockObjectSet.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + + val typeDeleted1 = ObjectWrapper.Type( + mapOf( + Relations.ID to RandomString.make(), + Relations.IS_DELETED to true + ) + ) + val type2 = ObjectWrapper.Type( + mapOf( + Relations.ID to RandomString.make(), + Relations.TYPE to ObjectTypeIds.OBJECT_TYPE + ) + ) + val typeDeleted3 = ObjectWrapper.Type( + mapOf( + Relations.ID to RandomString.make(), + ) + ) + + val detailsDeletedSetOf = Block.Details( + details = mapOf( + root to Block.Fields( + mapOf( + Relations.ID to root, + Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(), + Relations.SET_OF to listOf(typeDeleted1.id, type2.id, typeDeleted3.id) + ) + ), + typeDeleted1.id to Block.Fields( + mapOf( + Relations.ID to typeDeleted1.id, + Relations.IS_DELETED to true + ) + ), + type2.id to Block.Fields( + mapOf( + Relations.ID to type2.id, + Relations.TYPE to ObjectTypeIds.OBJECT_TYPE + ) ) ) ) - ) - stubOpenObject( - doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), - details = detailsDeletedSetOf - ) + stubOpenObject( + doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), + details = detailsDeletedSetOf + ) + stubSubscriptionResults( + subscription = mockObjectSet.subscriptionId, + spaceId = mockObjectSet.spaceId, + storeOfRelations = storeOfRelations, + keys = mockObjectSet.dvKeys, + sources = listOf(type2.id), + objects = listOf(mockObjectSet.obj1, mockObjectSet.obj2), + dvFilters = mockObjectSet.filters + ) - // TESTING - proceedWithStartingViewModel() + // TESTING + proceedWithStartingViewModel() - // ASSERT STATES - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + // ASSERT STATES + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) - stateFlow.ensureAllEventsConsumed() - viewerFlow.ensureAllEventsConsumed() - } + stateFlow.ensureAllEventsConsumed() + viewerFlow.ensureAllEventsConsumed() - @Test - fun `displaying set with templates present when opening object set of pages with templates`() = runTest { - // SETUP + advanceUntilIdle() + verifyBlocking(repo, times(1)) { + searchObjectsWithSubscription( + eq(mockObjectSet.subscriptionId), + eq(listOf()), + eq( + mockObjectSet.filters + ObjectSearchConstants.defaultDataViewFilters( + spaces = listOf(spaceConfig.space, spaceConfig.techSpace) + ) + ), + eq(ObjectSearchConstants.defaultDataViewKeys + mockObjectSet.dvKeys), + eq(listOf(type2.id)), + eq(0L), + eq(ObjectSetConfig.DEFAULT_LIMIT), + eq(null), + eq(null), + eq(null), + eq(null), + eq(null) + ) + } + } - mockObjectSet = MockSet(context = root, setOfValue = ObjectTypeIds.PAGE, space = defaultSpace) - val pageTypeMap = mapOf( - Relations.ID to ObjectTypeIds.PAGE, - Relations.TYPE to ObjectTypeIds.OBJECT_TYPE, - Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.BASIC.code.toDouble(), - Relations.NAME to MockDataFactory.randomString() - ) - stubSpaceManager(mockObjectSet.spaceId) - stubInterceptEvents() - stubInterceptThreadStatus() - stubOpenObject( - doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), - details = mockObjectSet.details - ) - stubSubscriptionResults( - subscription = mockObjectSet.subscriptionId, - spaceId = mockObjectSet.spaceId, - storeOfRelations = storeOfRelations, - keys = mockObjectSet.dvKeys, - sources = listOf(ObjectTypeIds.PAGE), - dvFilters = mockObjectSet.filters - ) - stubStoreOfObjectTypes(ObjectTypeIds.PAGE, pageTypeMap) - stubTemplatesForTemplatesContainer( - type = ObjectTypeIds.PAGE, - templates = listOf(StubObject(objectType = ObjectTypeIds.PAGE)) - ) + @Test + fun `Displaying Object Set with No Query State When All Types are Deleted`() = runTest { + // SETUP + stubSpaceManager(mockObjectSet.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() - // TESTING - proceedWithStartingViewModel() + val typeDeleted1 = ObjectWrapper.Type( + mapOf( + Relations.ID to RandomString.make(), + Relations.IS_DELETED to true + ) + ) + val typeDeleted3 = ObjectWrapper.Type( + mapOf( + Relations.ID to RandomString.make(), + ) + ) - // ASSERT STATES - val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val detailsDeletedSetOf = Block.Details( + details = mapOf( + root to Block.Fields( + mapOf( + Relations.ID to root, + Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(), + Relations.SET_OF to listOf(typeDeleted1.id, typeDeleted3.id) + ) + ), + typeDeleted1.id to Block.Fields( + mapOf( + Relations.ID to typeDeleted1.id, + Relations.IS_DELETED to true + ) + ) + ) + ) - // ASSERT STATES - assertIs(stateFlow.awaitItem()) - assertIs(stateFlow.awaitItem()) - assertIs(viewerFlow.awaitItem()) + stubOpenObject( + doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), + details = detailsDeletedSetOf + ) - val item = viewerFlow.awaitItem() - assertIs(item) - assertTrue(item.isCreateObjectAllowed) + // TESTING + proceedWithStartingViewModel() + + // ASSERT STATES + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) + + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + + stateFlow.ensureAllEventsConsumed() + viewerFlow.ensureAllEventsConsumed() + } + + @Test + fun `displaying set with templates present when opening object set of pages with templates`() = + runTest { + // SETUP + + mockObjectSet = + MockSet(context = root, setOfValue = ObjectTypeIds.PAGE, space = defaultSpace) + val pageTypeMap = mapOf( + Relations.ID to ObjectTypeIds.PAGE, + Relations.TYPE to ObjectTypeIds.OBJECT_TYPE, + Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.BASIC.code.toDouble(), + Relations.NAME to MockDataFactory.randomString() + ) + stubSpaceManager(mockObjectSet.spaceId) + stubInterceptEvents() + stubInterceptThreadStatus() + stubOpenObject( + doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), + details = mockObjectSet.details + ) + stubSubscriptionResults( + subscription = mockObjectSet.subscriptionId, + spaceId = mockObjectSet.spaceId, + storeOfRelations = storeOfRelations, + keys = mockObjectSet.dvKeys, + sources = listOf(ObjectTypeIds.PAGE), + dvFilters = mockObjectSet.filters + ) + stubStoreOfObjectTypes(ObjectTypeIds.PAGE, pageTypeMap) + stubTemplatesForTemplatesContainer( + type = ObjectTypeIds.PAGE, + templates = listOf(StubObject(objectType = ObjectTypeIds.PAGE)) + ) + + // TESTING + proceedWithStartingViewModel() + + // ASSERT STATES + val viewerFlow = viewModel.currentViewer.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) + + // ASSERT STATES + assertIs(stateFlow.awaitItem()) + assertIs(stateFlow.awaitItem()) + assertIs(viewerFlow.awaitItem()) + + val item = viewerFlow.awaitItem() + assertIs(item) + assertTrue(item.isCreateObjectAllowed) + } } private fun proceedWithStartingViewModel() { diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/BlockReadModeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/BlockReadModeTest.kt index 3770198a77..20dddb7dea 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/BlockReadModeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/BlockReadModeTest.kt @@ -14,6 +14,7 @@ import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow @@ -22,6 +23,7 @@ import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config +@OptIn(ExperimentalCoroutinesApi::class) @Config(sdk = [Build.VERSION_CODES.P]) @RunWith(RobolectricTestRunner::class) class BlockReadModeTest : EditorViewModelTest() { diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/DataViewBlockTargetObjectSetTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/DataViewBlockTargetObjectSetTest.kt index 05a1a3ae96..fd181027fb 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/DataViewBlockTargetObjectSetTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/DataViewBlockTargetObjectSetTest.kt @@ -48,6 +48,9 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() + stubInterceptEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/EditorViewModelTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/EditorViewModelTest.kt index a0aa84f221..72293f245b 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/EditorViewModelTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/EditorViewModelTest.kt @@ -132,15 +132,22 @@ import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertNotNull import kotlin.test.assertTrue +import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOf +import kotlinx.coroutines.launch +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.advanceUntilIdle import kotlinx.coroutines.test.runBlockingTest import kotlinx.coroutines.test.runTest +import org.junit.After +import org.junit.Assert.assertThrows import org.junit.Before +import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -350,7 +357,6 @@ open class EditorViewModelTest { private lateinit var updateDetail: UpdateDetail @Mock - lateinit var fileLimitsEventChannel: FileLimitsEventChannel lateinit var interceptFileLimitEvents: InterceptFileLimitEvents @Mock @@ -401,11 +407,29 @@ open class EditorViewModelTest { MockitoAnnotations.openMocks(this) builder = UrlBuilder(gateway) stubNetworkMode() + stubObserveEvents() + stubInterceptEvents() spaceManager.stub { onBlocking { get() } doReturn defaultSpace } + stubFileLimitEvents() + stubUpdateBlocksMark() + stubOpenPage(root, emptyList()) + stubUpdateText() + openPage.stub { + onBlocking { + async(any()) + } doReturn Resultat.success( + Result.Success( + Payload( + context = root, + events = emptyList() + ) + ) + ) + } } @Test @@ -498,21 +522,21 @@ open class EditorViewModelTest { @Test fun `should close page when the system back button is pressed`() { + runTest { + val root = MockDataFactory.randomUuid() - val root = MockDataFactory.randomUuid() + stubOpenPage(root) + stubInterceptEvents() + stubClosePage(null, null) - stubOpenPage(root) - stubInterceptEvents() + givenViewModel() - givenViewModel() + vm.onStart(id = root, space = defaultSpace) - vm.onStart(id = root, space = defaultSpace) + verifyNoInteractions(closePage) - verifyNoInteractions(closePage) + vm.onSystemBackPressed(editorHasChildrenScreens = false) - vm.onSystemBackPressed(editorHasChildrenScreens = false) - - runBlockingTest { verify(closePage, times(1)).async(any()) } } @@ -534,29 +558,6 @@ open class EditorViewModelTest { .assertValue { value -> value.peekContent() == AppNavigation.Command.Exit } } - @Test - fun `should not emit any navigation command if there is an error while closing the page`() { - - val root = MockDataFactory.randomUuid() - - val error = Exception("Error while closing this page") - - stubOpenPage(root) - stubClosePage(error) - stubInterceptEvents() - givenViewModel() - - vm.onStart(id = root, space = defaultSpace) - - val testObserver = vm.navigation.test() - - verifyNoInteractions(closePage) - - vm.onSystemBackPressed(editorHasChildrenScreens = false) - - testObserver.assertNoValue() - } - @Test fun `should update block when its text changes`() { @@ -2815,7 +2816,6 @@ open class EditorViewModelTest { } stubObserveEvents(flow) - stubOpenPage(context = root) stubClosePage() givenViewModel() @@ -3650,11 +3650,14 @@ open class EditorViewModelTest { } private fun stubClosePage( - exception: Exception? = null + exception: Exception? = null, + context: Id? = root, ) { closePage.stub { - onBlocking { async(root) } doReturn Resultat.success(Unit) + onBlocking { if (context == null) async(any()) else async(root) } doReturn Resultat.success( + Unit + ) } exception?.let { @@ -3678,6 +3681,12 @@ open class EditorViewModelTest { } } + fun stubFileLimitEvents() { + interceptFileLimitEvents.stub { + onBlocking { run(Unit) } doReturn emptyFlow() + } + } + fun stubOpenPage( context: Id = MockDataFactory.randomString(), events: List = emptyList() @@ -3702,6 +3711,22 @@ open class EditorViewModelTest { } } + private fun stubUpdateBlocksMark() { + updateBlocksMark.stub { + onBlocking { + invoke(any()) + } doReturn Either.Right(Payload("", emptyList())) + } + } + + private fun stubUpdateText() { + updateText.stub { + onBlocking { + invoke(any()) + } doReturn Either.Right(Unit) + } + } + fun stubObserveEvents( flow: Flow> = flowOf(), stubInterceptThreadStatus: Boolean = true @@ -3729,12 +3754,6 @@ open class EditorViewModelTest { if (stubInterceptThreadStatus) stubInterceptThreadStatus() } - private fun stubUpdateText() { - updateText.stub { - onBlocking { invoke(any()) } doReturn Either.Right(Unit) - } - } - private fun stubReplaceBlock(root: String) { replaceBlock.stub { onBlocking { invoke(any()) } doReturn Either.Right( @@ -3776,7 +3795,12 @@ open class EditorViewModelTest { private fun givenSharedFile() { documentFileShareDownloader.stub { - onBlocking { async(any()) } doReturn Resultat.success(MiddlewareShareDownloader.Response(Uri.EMPTY, "")) + onBlocking { async(any()) } doReturn Resultat.success( + MiddlewareShareDownloader.Response( + Uri.EMPTY, + "" + ) + ) } } @@ -3832,7 +3856,7 @@ open class EditorViewModelTest { downloadUnsplashImage = DownloadUnsplashImage(unsplashRepo) clearBlockContent = ClearBlockContent(repo) clearBlockStyle = ClearBlockStyle(repo) - interceptFileLimitEvents = InterceptFileLimitEvents(fileLimitsEventChannel, dispatchers) + interceptFileLimitEvents = interceptFileLimitEvents setObjectInternalFlags = SetObjectInternalFlags(repo, dispatchers) getObjectTypes = GetObjectTypes(repo, dispatchers) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBackButtonTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBackButtonTest.kt index cc1d6f96d1..e01a95e12f 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBackButtonTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBackButtonTest.kt @@ -6,6 +6,7 @@ import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import kotlin.test.assertFalse import kotlin.test.assertNotNull import kotlin.test.assertTrue +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -18,6 +19,7 @@ class EditorBackButtonTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -25,6 +27,10 @@ class EditorBackButtonTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubClosePage() + stubGetNetworkMode() + stubFileLimitEvents() + stubInterceptEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBackspaceDeleteTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBackspaceDeleteTest.kt index 4897ef9532..66f1998e31 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBackspaceDeleteTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBackspaceDeleteTest.kt @@ -32,6 +32,7 @@ import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Rule @@ -46,6 +47,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -57,6 +59,10 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() + stubInterceptEvents() + stubClosePage() } @Test @@ -697,6 +703,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() { stubOpenDocument(document = document) stubUpdateTextStyle() + stubGetObjectTypes(emptyList()) val vm = buildViewModel() @@ -832,6 +839,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() { stubOpenDocument(document = document) stubUpdateTextStyle() + stubGetObjectTypes(emptyList()) val vm = buildViewModel() @@ -1133,6 +1141,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() { stubOpenDocument(document = document) stubUpdateText() stubUpdateTextStyle() + stubGetObjectTypes(emptyList()) val vm = buildViewModel() diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBlockActionsTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBlockActionsTest.kt index 2b5e6edc46..268aa682ac 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBlockActionsTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBlockActionsTest.kt @@ -30,6 +30,9 @@ class EditorBlockActionsTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubFileLimitEvents() + stubGetNetworkMode() + stubInterceptEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorCheckboxTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorCheckboxTest.kt index 71c3a7471a..824d218800 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorCheckboxTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorCheckboxTest.kt @@ -9,6 +9,7 @@ import com.anytypeio.anytype.domain.block.interactor.UpdateCheckbox import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -25,12 +26,17 @@ class EditorCheckboxTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @Before fun setup() { MockitoAnnotations.openMocks(this) + stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() + stubInterceptEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorCreateBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorCreateBlockTest.kt index 9ee719dfc3..3d76b72584 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorCreateBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorCreateBlockTest.kt @@ -11,6 +11,7 @@ import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.editor.editor.slash.SlashItem import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Rule @@ -25,6 +26,7 @@ class EditorCreateBlockTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -33,6 +35,7 @@ class EditorCreateBlockTest : EditorPresentationTestSetup() { MockitoAnnotations.openMocks(this) stubSpaceManager() stubGetNetworkMode() + stubFileLimitEvents() } val title = StubTitle() diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorDuplicateTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorDuplicateTest.kt index ed1ff16acf..b7f3190de4 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorDuplicateTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorDuplicateTest.kt @@ -15,6 +15,7 @@ import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertTrue +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -27,6 +28,7 @@ class EditorDuplicateTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -45,6 +47,9 @@ class EditorDuplicateTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() + stubDuplicateBlock("", emptyList()) } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorEmptySpaceInteractionTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorEmptySpaceInteractionTest.kt index 868c8e8eb6..5329d73e17 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorEmptySpaceInteractionTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorEmptySpaceInteractionTest.kt @@ -16,6 +16,7 @@ import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -50,6 +51,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -58,6 +60,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() { MockitoAnnotations.openMocks(this) stubSpaceManager() stubGetNetworkMode() + stubFileLimitEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorErrorMessageTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorErrorMessageTest.kt index 82e30bbbb1..db211c262d 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorErrorMessageTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorErrorMessageTest.kt @@ -6,6 +6,7 @@ import com.anytypeio.anytype.domain.base.Either import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.launch import kotlinx.coroutines.test.runBlockingTest import org.junit.Before @@ -21,6 +22,7 @@ class EditorErrorMessageTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -28,6 +30,9 @@ class EditorErrorMessageTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() + stubInterceptEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorEventSubscriptionTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorEventSubscriptionTest.kt index abea4b498b..7091383b5a 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorEventSubscriptionTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorEventSubscriptionTest.kt @@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.domain.event.interactor.InterceptEvents import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -18,12 +19,17 @@ class EditorEventSubscriptionTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @Before fun setup() { MockitoAnnotations.openMocks(this) + stubSpaceManager() + stubFileLimitEvents() + stubGetNetworkMode() + stubInterceptEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorFeaturedRelationsTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorFeaturedRelationsTest.kt index 4daed7e29a..b3a092fb09 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorFeaturedRelationsTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorFeaturedRelationsTest.kt @@ -41,6 +41,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -48,6 +49,8 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubFileLimitEvents() + stubGetNetworkMode() } @After diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorFocusTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorFocusTest.kt index e8bf735b89..25014ccb2d 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorFocusTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorFocusTest.kt @@ -19,6 +19,7 @@ import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -31,6 +32,7 @@ class EditorFocusTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -58,6 +60,9 @@ class EditorFocusTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() + stubInterceptEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorGranularChangeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorGranularChangeTest.kt index b4133fdcf1..07bd2c510c 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorGranularChangeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorGranularChangeTest.kt @@ -9,6 +9,7 @@ import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColo import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.flow.flow import org.junit.Before @@ -21,6 +22,7 @@ class EditorGranularChangeTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -28,6 +30,8 @@ class EditorGranularChangeTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorInternalFlagsTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorInternalFlagsTest.kt index 9808216512..1176e9d79a 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorInternalFlagsTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorInternalFlagsTest.kt @@ -35,6 +35,8 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @Test @@ -44,6 +46,7 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() { val page = StubSmartBlock(id = root, children = listOf(header.id)) val document = listOf(page, header, title) stubInterceptEvents() + stubGetObjectTypes(emptyList()) val detailsList = Block.Details( details = mapOf( diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLatexBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLatexBlockTest.kt index 6a40365064..ac0ce40b70 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLatexBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLatexBlockTest.kt @@ -10,6 +10,7 @@ import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -20,6 +21,7 @@ class EditorLatexBlockTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -27,6 +29,9 @@ class EditorLatexBlockTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() + stubInterceptEvents() } val title = Block( diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorListBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorListBlockTest.kt index 85bc0d6121..27535459a9 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorListBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorListBlockTest.kt @@ -14,6 +14,7 @@ import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -28,6 +29,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -46,6 +48,8 @@ class EditorListBlockTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLockPageTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLockPageTest.kt index 7ed850c66d..0fc0c48d92 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLockPageTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLockPageTest.kt @@ -20,6 +20,7 @@ import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Rule @@ -31,6 +32,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -50,6 +52,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() { MockitoAnnotations.openMocks(this) stubGetNetworkMode() stubSpaceManager() + stubFileLimitEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMarkupObjectTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMarkupObjectTest.kt index 4d0bcce3e8..6b80c21ee8 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMarkupObjectTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMarkupObjectTest.kt @@ -29,6 +29,7 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -44,6 +45,8 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @After diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMentionTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMentionTest.kt index 3430d4653a..19310ae123 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMentionTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMentionTest.kt @@ -48,6 +48,7 @@ class EditorMentionTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -86,6 +87,8 @@ class EditorMentionTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMenuTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMenuTest.kt index f0236725ef..da96ef4db1 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMenuTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMenuTest.kt @@ -11,6 +11,7 @@ import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory.profile import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Rule @@ -22,12 +23,15 @@ class EditorMenuTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @Before fun setup() { MockitoAnnotations.openMocks(this) + stubGetNetworkMode() + stubFileLimitEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMergeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMergeTest.kt index 91956ea52a..cec176e65f 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMergeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMergeTest.kt @@ -12,6 +12,7 @@ import com.anytypeio.anytype.presentation.editor.EditorViewModel import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -26,6 +27,7 @@ class EditorMergeTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -33,6 +35,8 @@ class EditorMergeTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @Test @@ -306,6 +310,7 @@ class EditorMergeTest : EditorPresentationTestSetup() { } } + @OptIn(ExperimentalCoroutinesApi::class) @Test fun `should not merge text block with the previous block if this previous block is not a text block`() { @@ -342,6 +347,7 @@ class EditorMergeTest : EditorPresentationTestSetup() { stubInterceptEvents() stubUpdateText() stubMergeBlocks(root) + stubUnlinkBlocks() val vm = buildViewModel() diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMultiSelectModeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMultiSelectModeTest.kt index 6d09d34296..68a759c509 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMultiSelectModeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMultiSelectModeTest.kt @@ -32,6 +32,7 @@ import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -49,6 +50,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -67,6 +69,10 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() + stubUpdateText() + stubCopy() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorNoteLayoutTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorNoteLayoutTest.kt index b386d26cff..9379aa2d18 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorNoteLayoutTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorNoteLayoutTest.kt @@ -18,6 +18,7 @@ import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertEquals import kotlin.time.ExperimentalTime +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import net.lachlanmckee.timberjunit.TimberTestRule import org.junit.After @@ -39,6 +40,7 @@ class EditorNoteLayoutTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -46,8 +48,11 @@ class EditorNoteLayoutTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } + @OptIn(ExperimentalCoroutinesApi::class) @After fun after() { coroutineTestRule.advanceTime(EditorViewModel.TEXT_CHANGES_DEBOUNCE_DURATION) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorObjectTypeChangeWidgetTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorObjectTypeChangeWidgetTest.kt index 94dd4370cf..fb336a3171 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorObjectTypeChangeWidgetTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorObjectTypeChangeWidgetTest.kt @@ -12,6 +12,7 @@ import com.anytypeio.anytype.test_utils.MockDataFactory import kotlin.test.assertFalse import kotlin.test.assertNotNull import kotlin.test.assertTrue +import kotlinx.coroutines.ExperimentalCoroutinesApi import net.lachlanmckee.timberjunit.TimberTestRule import org.junit.After import org.junit.Before @@ -32,6 +33,7 @@ class EditorObjectTypeChangeWidgetTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -39,8 +41,11 @@ class EditorObjectTypeChangeWidgetTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } + @OptIn(ExperimentalCoroutinesApi::class) @After fun after() { coroutineTestRule.advanceTime(EditorViewModel.TEXT_CHANGES_DEBOUNCE_DURATION) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorPresentationTestSetup.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorPresentationTestSetup.kt index f22b80e5f2..6ef8939912 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorPresentationTestSetup.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorPresentationTestSetup.kt @@ -9,6 +9,7 @@ import com.anytypeio.anytype.core_models.ObjectWrapper import com.anytypeio.anytype.core_models.Payload import com.anytypeio.anytype.core_models.Relation import com.anytypeio.anytype.core_models.RelationLink +import com.anytypeio.anytype.core_models.Response import com.anytypeio.anytype.core_models.primitives.SpaceId import com.anytypeio.anytype.core_models.primitives.TypeId import com.anytypeio.anytype.core_models.primitives.TypeKey @@ -118,8 +119,10 @@ import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.flowOf import org.mockito.Mock import org.mockito.kotlin.any +import org.mockito.kotlin.anyOrNull import org.mockito.kotlin.doReturn import org.mockito.kotlin.mock +import org.mockito.kotlin.notNull import org.mockito.kotlin.stub open class EditorPresentationTestSetup { @@ -498,13 +501,15 @@ open class EditorPresentationTestSetup { spaceId: SpaceId = SpaceId(defaultSpace) ) { openPage.stub { - onBlocking { async( - OpenPage.Params( - obj = root, - saveAsLastOpened = true, - space = spaceId + onBlocking { + async( + OpenPage.Params( + obj = root, + saveAsLastOpened = true, + space = spaceId + ) ) - ) } doReturn Resultat.success( + } doReturn Resultat.success( Result.Success( Payload( context = root, @@ -582,11 +587,13 @@ open class EditorPresentationTestSetup { } fun stubUnlinkBlocks( - params: UnlinkBlocks.Params = any(), + params: UnlinkBlocks.Params? = null, events: List = emptyList() ) { unlinkBlocks.stub { - onBlocking { invoke(params) } doReturn Either.Right( + onBlocking { + if (params == null) invoke(any()) else invoke(params) + } doReturn Either.Right( Payload( context = root, events = events @@ -643,6 +650,26 @@ open class EditorPresentationTestSetup { } } + fun stubCopy() { + copy.stub { + onBlocking { invoke(any()) } doReturn Either.Right(Unit) + } + } + + fun stubPaste() { + paste.stub { + onBlocking { invoke(any()) } doReturn Either.Right( + Response.Clipboard.Paste( + 0, + true, + emptyList(), + Payload("", emptyList()) + ) + ) + } + } + + fun stubReplaceBlock() { replaceBlock.stub { onBlocking { invoke(any()) } doReturn Either.Right( diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorQuickStartingScrollAndMoveTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorQuickStartingScrollAndMoveTest.kt index 97a79eee60..db2d2caa87 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorQuickStartingScrollAndMoveTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorQuickStartingScrollAndMoveTest.kt @@ -13,6 +13,7 @@ import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -23,6 +24,7 @@ class EditorQuickStartingScrollAndMoveTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -30,6 +32,8 @@ class EditorQuickStartingScrollAndMoveTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } val title = Block( diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorRelationBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorRelationBlockTest.kt index 1dce7e81ba..a68164832d 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorRelationBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorRelationBlockTest.kt @@ -16,6 +16,7 @@ import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Rule @@ -27,6 +28,7 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -45,6 +47,8 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorScrollAndMoveTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorScrollAndMoveTest.kt index e0fe0c68c3..3540bba263 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorScrollAndMoveTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorScrollAndMoveTest.kt @@ -17,6 +17,7 @@ import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.launch import kotlinx.coroutines.test.runBlockingTest import org.junit.Before @@ -33,6 +34,7 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -60,6 +62,8 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetActionsTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetActionsTest.kt index 66131039c0..05e9790a37 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetActionsTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetActionsTest.kt @@ -18,6 +18,7 @@ import com.jraska.livedata.test import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertNotNull +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.After import org.junit.Before import org.junit.Rule @@ -32,23 +33,23 @@ class EditorSlashWidgetActionsTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() -// @get:Rule -// val timberTestRule: TimberTestRule = TimberTestRule.builder() -// .minPriority(Log.DEBUG) -// .showThread(true) -// .showTimestamp(false) -// .onlyLogWhenTestFails(true) -// .build() - @Before fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() + stubUpdateText() + stubDuplicateBlock("", emptyList()) + stubCopy() + stubPaste() } + @OptIn(ExperimentalCoroutinesApi::class) @After fun after() { coroutineTestRule.advanceTime(TEXT_CHANGES_DEBOUNCE_DURATION) @@ -65,6 +66,8 @@ class EditorSlashWidgetActionsTest : EditorPresentationTestSetup() { stubUpdateText() stubSearchObjects() stubOpenDocument(document = doc) + stubUnlinkBlocks() + val vm = buildViewModel() vm.onStart(id = root, space = defaultSpace) @@ -102,6 +105,7 @@ class EditorSlashWidgetActionsTest : EditorPresentationTestSetup() { stubUpdateText() stubSearchObjects() stubOpenDocument(document = doc) + stubUnlinkBlocks() val vm = buildViewModel() vm.onStart(id = root, space = defaultSpace) @@ -259,6 +263,7 @@ class EditorSlashWidgetActionsTest : EditorPresentationTestSetup() { stubInterceptEvents() stubOpenDocument(document = doc) + val vm = buildViewModel() vm.onStart(id = root, space = defaultSpace) @@ -295,6 +300,8 @@ class EditorSlashWidgetActionsTest : EditorPresentationTestSetup() { stubUpdateText() stubSearchObjects() stubOpenDocument(document = doc) + stubCopy() + val vm = buildViewModel() vm.onStart(id = root, space = defaultSpace) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetClicksTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetClicksTest.kt index 136d814f45..733f45fa0d 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetClicksTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetClicksTest.kt @@ -37,6 +37,8 @@ class EditorSlashWidgetClicksTest: EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } /** diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetColorTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetColorTest.kt index b76aef7e6f..daf0e92b56 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetColorTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetColorTest.kt @@ -18,6 +18,7 @@ import com.anytypeio.anytype.test_utils.MockDataFactory import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertNotNull +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.After import org.junit.Before import org.junit.Rule @@ -36,6 +37,7 @@ class EditorSlashWidgetColorTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -43,8 +45,12 @@ class EditorSlashWidgetColorTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() + stubUpdateText() } + @OptIn(ExperimentalCoroutinesApi::class) @After fun after() { coroutineTestRule.advanceTime(TEXT_CHANGES_DEBOUNCE_DURATION) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetCutFilterTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetCutFilterTest.kt index e59c10af10..aa1cb52c36 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetCutFilterTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetCutFilterTest.kt @@ -11,6 +11,7 @@ import com.anytypeio.anytype.presentation.editor.editor.slash.SlashEvent import com.anytypeio.anytype.presentation.editor.editor.slash.SlashItem import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.After import org.junit.Before import org.junit.Rule @@ -29,6 +30,7 @@ class EditorSlashWidgetCutFilterTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -36,8 +38,12 @@ class EditorSlashWidgetCutFilterTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() + stubGetObjectTypes(emptyList()) } + @OptIn(ExperimentalCoroutinesApi::class) @After fun after() { coroutineTestRule.advanceTime(TEXT_CHANGES_DEBOUNCE_DURATION) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetFilterTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetFilterTest.kt index 976885fce5..07b0bb87eb 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetFilterTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetFilterTest.kt @@ -27,6 +27,7 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertNotNull +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Rule @@ -42,6 +43,7 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -49,6 +51,8 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } /** @@ -2071,6 +2075,7 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() { stubInterceptEvents() stubSearchObjects() stubOpenDocument(doc, customDetails) + stubGetObjectTypes(listOf()) val vm = buildViewModel() vm.onStart(id = root, space = defaultSpace) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetMarksTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetMarksTest.kt index f18ea3ba63..587499ca57 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetMarksTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetMarksTest.kt @@ -16,6 +16,7 @@ import com.anytypeio.anytype.test_utils.MockDataFactory import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertNotNull +import kotlinx.coroutines.ExperimentalCoroutinesApi import net.lachlanmckee.timberjunit.TimberTestRule import org.junit.After import org.junit.Before @@ -30,6 +31,7 @@ class EditorSlashWidgetMarksTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -45,6 +47,8 @@ class EditorSlashWidgetMarksTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @After diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetObjectTypeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetObjectTypeTest.kt index 84f87da232..a43162295f 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetObjectTypeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetObjectTypeTest.kt @@ -18,6 +18,7 @@ import com.anytypeio.anytype.presentation.editor.editor.slash.SlashItem import com.anytypeio.anytype.presentation.objects.ObjectTypeView import com.anytypeio.anytype.presentation.objects.getProperName import com.anytypeio.anytype.presentation.util.CoroutinesTestRule +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.After import org.junit.Before import org.junit.Rule @@ -31,6 +32,7 @@ class EditorSlashWidgetObjectTypeTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -40,8 +42,12 @@ class EditorSlashWidgetObjectTypeTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager(space = space) + stubGetNetworkMode() + stubFileLimitEvents() + stubClosePage() } + @OptIn(ExperimentalCoroutinesApi::class) @After fun after() { coroutineTestRule.advanceTime(TEXT_CHANGES_DEBOUNCE_DURATION) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetRelationsTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetRelationsTest.kt index d6173e311d..d79507f893 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetRelationsTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetRelationsTest.kt @@ -22,6 +22,7 @@ import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import net.lachlanmckee.timberjunit.TimberTestRule import org.junit.After @@ -37,6 +38,7 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -52,6 +54,8 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @After @@ -391,6 +395,7 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() { stubUpdateText() stubCreateBlock(root = root) stubSearchObjects() + stubCopy() stubOpenDocument( document = doc, details = customDetails diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetShowHideTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetShowHideTest.kt index 372a4a83c3..fd590bf653 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetShowHideTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetShowHideTest.kt @@ -5,20 +5,22 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory import com.anytypeio.anytype.presentation.editor.editor.slash.SlashEvent import com.anytypeio.anytype.presentation.util.CoroutinesTestRule -import kotlin.test.assertFalse -import kotlin.test.assertNotNull -import kotlin.test.assertTrue import net.lachlanmckee.timberjunit.TimberTestRule import org.junit.Before import org.junit.Rule import org.junit.Test import org.mockito.MockitoAnnotations +import kotlin.test.assertFalse +import kotlin.test.assertNotNull +import kotlin.test.assertTrue +import kotlinx.coroutines.ExperimentalCoroutinesApi class EditorSlashWidgetShowHideTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -33,6 +35,9 @@ class EditorSlashWidgetShowHideTest : EditorPresentationTestSetup() { @Before fun setup() { MockitoAnnotations.openMocks(this) + stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetStyleTypeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetStyleTypeTest.kt index 2670d12235..0aea4eaedf 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetStyleTypeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSlashWidgetStyleTypeTest.kt @@ -14,6 +14,7 @@ import com.anytypeio.anytype.test_utils.MockDataFactory import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertNotNull +import kotlinx.coroutines.ExperimentalCoroutinesApi import net.lachlanmckee.timberjunit.TimberTestRule import org.junit.After import org.junit.Before @@ -28,6 +29,7 @@ class EditorSlashWidgetStyleTypeTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -42,8 +44,12 @@ class EditorSlashWidgetStyleTypeTest : EditorPresentationTestSetup() { @Before fun setup() { MockitoAnnotations.openMocks(this) + stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } + @OptIn(ExperimentalCoroutinesApi::class) @After fun after() { coroutineTestRule.advanceTime(TEXT_CHANGES_DEBOUNCE_DURATION) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSplitTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSplitTest.kt index d1974eb71f..f01980ff88 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSplitTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSplitTest.kt @@ -15,6 +15,7 @@ import com.anytypeio.anytype.presentation.editor.EditorViewModel import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import net.lachlanmckee.timberjunit.TimberTestRule import org.junit.After import org.junit.Before @@ -31,6 +32,7 @@ class EditorSplitTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -46,6 +48,8 @@ class EditorSplitTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @After diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorStartupTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorStartupTest.kt index 3292499a6d..fbe40da04a 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorStartupTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorStartupTest.kt @@ -4,6 +4,7 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.jraska.livedata.test +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -14,6 +15,7 @@ class EditorStartupTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -21,6 +23,8 @@ class EditorStartupTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @Test diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTableOfContentsBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTableOfContentsBlockTest.kt index 05b995894b..29a4bec06b 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTableOfContentsBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTableOfContentsBlockTest.kt @@ -13,6 +13,7 @@ import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import net.lachlanmckee.timberjunit.TimberTestRule import org.junit.After import org.junit.Before @@ -25,6 +26,7 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -40,8 +42,11 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } + @OptIn(ExperimentalCoroutinesApi::class) @After fun after() { coroutineTestRule.advanceTime(EditorViewModel.TEXT_CHANGES_DEBOUNCE_DURATION) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTextUpdateTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTextUpdateTest.kt index 363f71b4b9..18f0c00da2 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTextUpdateTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTextUpdateTest.kt @@ -9,6 +9,7 @@ import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runBlockingTest import org.junit.Before import org.junit.Rule @@ -24,6 +25,7 @@ class EditorTextUpdateTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -31,6 +33,8 @@ class EditorTextUpdateTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } val title = Block( diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTitleAddBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTitleAddBlockTest.kt index 273ffd178f..462ebfbefe 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTitleAddBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTitleAddBlockTest.kt @@ -9,6 +9,7 @@ import com.anytypeio.anytype.domain.block.interactor.CreateBlock import com.anytypeio.anytype.domain.event.interactor.InterceptEvents import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test @@ -23,6 +24,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -30,6 +32,9 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() + stubCreateBlock(root) } val title = Block( diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTitleTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTitleTest.kt index ff68d0507f..9e3baff04b 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTitleTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTitleTest.kt @@ -16,6 +16,7 @@ import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.flow.flow import kotlinx.coroutines.launch @@ -36,6 +37,7 @@ class EditorTitleTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -51,6 +53,12 @@ class EditorTitleTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubInterceptEvents() + stubFileLimitEvents() + stubCopy() + stubSplitBlock() + stubCreateBlock(root) } @After diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableBlockTest.kt index a2eea1083f..cc3d4decf4 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableBlockTest.kt @@ -21,6 +21,7 @@ import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import org.junit.Before import org.junit.Rule @@ -34,6 +35,7 @@ class EditorTableBlockTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -41,6 +43,8 @@ class EditorTableBlockTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } private var tableId = MockDataFactory.randomUuid() diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableMoveRowsColumnsTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableMoveRowsColumnsTest.kt index 9d80255427..ba9cf279ee 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableMoveRowsColumnsTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableMoveRowsColumnsTest.kt @@ -31,6 +31,7 @@ import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Rule @@ -47,6 +48,7 @@ class EditorTableMoveRowsColumnsTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -54,6 +56,8 @@ class EditorTableMoveRowsColumnsTest : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } private var tableId = MockDataFactory.randomUuid() diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableRowsColumnsDelete.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableRowsColumnsDeleteTest.kt similarity index 97% rename from presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableRowsColumnsDelete.kt rename to presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableRowsColumnsDeleteTest.kt index 8ad4275557..20de00dbd2 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableRowsColumnsDelete.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/EditorTableRowsColumnsDeleteTest.kt @@ -17,16 +17,18 @@ import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import kotlin.test.assertEquals +import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule import org.junit.Test import org.mockito.MockitoAnnotations -class EditorTableRowsColumnsDelete : EditorPresentationTestSetup() { +class EditorTableRowsColumnsDeleteTest : EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -34,6 +36,8 @@ class EditorTableRowsColumnsDelete : EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } private var tableId = MockDataFactory.randomUuid() diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/template/EditorTemplateTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/template/EditorTemplateTest.kt index cee08425f6..30ba506574 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/template/EditorTemplateTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/template/EditorTemplateTest.kt @@ -26,6 +26,7 @@ class EditorTemplateTest: EditorPresentationTestSetup() { @get:Rule val rule = InstantTaskExecutorRule() + @OptIn(ExperimentalCoroutinesApi::class) @get:Rule val coroutineTestRule = CoroutinesTestRule() @@ -33,6 +34,8 @@ class EditorTemplateTest: EditorPresentationTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) stubSpaceManager() + stubGetNetworkMode() + stubFileLimitEvents() } @OptIn(ExperimentalCoroutinesApi::class) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/home/HomeScreenViewModelTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/home/HomeScreenViewModelTest.kt index 0b8a5ea2c5..51c461bcfa 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/home/HomeScreenViewModelTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/home/HomeScreenViewModelTest.kt @@ -82,6 +82,7 @@ import com.anytypeio.anytype.presentation.widgets.WidgetView import com.anytypeio.anytype.test_utils.MockDataFactory import kotlin.test.assertEquals import kotlin.test.assertTrue +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.emptyFlow @@ -92,6 +93,7 @@ import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Rule import org.junit.Test +import org.mockito.BDDMockito.given import org.mockito.Mock import org.mockito.MockitoAnnotations import org.mockito.kotlin.any @@ -200,7 +202,6 @@ class HomeScreenViewModelTest { @Mock lateinit var getPinnedObjectTypes: GetPinnedObjectTypes - @Mock lateinit var userPermissionProvider: UserPermissionProvider private val objectPayloadDispatcher = Dispatcher.Default() @@ -210,6 +211,7 @@ class HomeScreenViewModelTest { lateinit var vm: HomeScreenViewModel + @OptIn(ExperimentalCoroutinesApi::class) private val appCoroutineDispatchers = AppCoroutineDispatchers( io = coroutineTestRule.dispatcher, main = coroutineTestRule.dispatcher, @@ -233,6 +235,8 @@ class HomeScreenViewModelTest { MockitoAnnotations.openMocks(this) urlBuilder = UrlBuilder(gateway) stubSpaceManager() + userPermissionProvider = UserPermissionProviderStub() + stubGetPinnedObjectTypes() } @Test @@ -1193,16 +1197,7 @@ class HomeScreenViewModelTest { ) ) - deleteWidget.stub { - onBlocking { - stream( - DeleteWidget.Params( - ctx = WIDGET_OBJECT_ID, - targets = listOf(widgetBlock.id) - ) - ) - } doReturn flowOf(Resultat.Success(givenPayload)) - } + stubDeleteWidget(widgetBlock, givenPayload) val vm = buildViewModel() @@ -1295,6 +1290,7 @@ class HomeScreenViewModelTest { stubGetWidgetSession() stubSpaceManager() stubSpaceWidgetContainer(defaultSpaceWidgetView) + stubDeleteWidget(widgetBlock, givenPayload) val vm = buildViewModel() @@ -1503,6 +1499,12 @@ class HomeScreenViewModelTest { stubWidgetActiveView(favoriteWidgetBlock) stubSpaceManager() stubSpaceWidgetContainer(defaultSpaceWidgetView) + given(objectWatcher.watch(any())).willReturn(flowOf()) + given(storelessSubscriptionContainer.subscribe(any())).willReturn(flowOf()) + given(storelessSubscriptionContainer.subscribe(any())).willReturn( + flowOf() + ) + stubCloseObject() val vm = buildViewModel() @@ -2490,7 +2492,8 @@ class HomeScreenViewModelTest { filters = buildList { addAll( ObjectSearchConstants.defaultDataViewFilters( - spaces = listOf(defaultSpaceConfig.space, defaultSpaceConfig.techSpace)) + spaces = listOf(defaultSpaceConfig.space, defaultSpaceConfig.techSpace) + ) ) add( DVFilter( @@ -2827,12 +2830,38 @@ class HomeScreenViewModelTest { } } + private fun stubGetPinnedObjectTypes() { + getPinnedObjectTypes.stub { + onBlocking { + flow(any()) + } doReturn flowOf() + } + } + + private fun stubDeleteWidget( + widgetBlock: Block, + givenPayload: Payload + ) { + deleteWidget.stub { + onBlocking { + stream( + DeleteWidget.Params( + ctx = WIDGET_OBJECT_ID, + targets = listOf(widgetBlock.id) + ) + ) + } doReturn flowOf(Resultat.Success(givenPayload)) + } + } + private fun stubUserPermission( permission: SpaceMemberPermissions = SpaceMemberPermissions.OWNER ) { - userPermissionProvider.stub { - on { observe(space = SpaceId(defaultSpaceConfig.space)) } doReturn flowOf(permission) - } + (userPermissionProvider as UserPermissionProviderStub).stubObserve( + SpaceId( + defaultSpaceConfig.space + ), permission + ) } private fun buildViewModel() = HomeScreenViewModel( diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/home/UserPermissionProviderStub.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/home/UserPermissionProviderStub.kt new file mode 100644 index 0000000000..bd489a18eb --- /dev/null +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/home/UserPermissionProviderStub.kt @@ -0,0 +1,24 @@ +package com.anytypeio.anytype.presentation.home + +import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions +import com.anytypeio.anytype.core_models.primitives.SpaceId +import com.anytypeio.anytype.domain.multiplayer.UserPermissionProvider +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOf + +class UserPermissionProviderStub : UserPermissionProvider { + private var permission: SpaceMemberPermissions? = null + private var spaceId: SpaceId? = null + + override fun start() {} + + override fun stop() {} + + override fun get(space: SpaceId): SpaceMemberPermissions? = null + + override fun observe(space: SpaceId): Flow = flowOf(permission) + fun stubObserve(spaceId: SpaceId, permission: SpaceMemberPermissions) { + this.spaceId = spaceId + this.permission = permission + } +} diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/linking/LinkToObjectOrWebViewModelTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/linking/LinkToObjectOrWebViewModelTest.kt index 6952164ad5..65ccf62421 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/linking/LinkToObjectOrWebViewModelTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/linking/LinkToObjectOrWebViewModelTest.kt @@ -135,6 +135,7 @@ open class LinkToObjectOrWebViewModelTest { @Test fun `should return selected range error state when selection range start is equal end`() = runTest { + spaceManager.set(spaceId) val target = MockDataFactory.randomString() @@ -146,6 +147,7 @@ open class LinkToObjectOrWebViewModelTest { runBlocking { store.document.update(listOf(block)) } val vm = givenViewModel() + stubSearchObjects(params = vm.getSearchObjectsParams(ctx)) vm.onStart( blockId = target, diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/ViewerDefaultObjectTypeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/ViewerDefaultObjectTypeTest.kt index c5f0513a73..802a9e1b15 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/ViewerDefaultObjectTypeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/ViewerDefaultObjectTypeTest.kt @@ -62,6 +62,7 @@ class ViewerDefaultObjectTypeTest : ObjectSetViewModelTestSetup() { fun setup() { closable = MockitoAnnotations.openMocks(this) viewModel = givenViewModel() + stubNetworkMode() } @After diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetCellTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetCellTest.kt index fdf8c7b861..dab2225df2 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetCellTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetCellTest.kt @@ -38,6 +38,7 @@ class ObjectSetCellTest : ObjectSetViewModelTestSetup() { // SETUP stubSpaceManager(mockObjectSet.spaceId) stubInterceptEvents() + stubNetworkMode() stubInterceptThreadStatus() stubOpenObject( doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetConvertToCollectionTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetConvertToCollectionTest.kt index 746b24bd6e..549a3b8a58 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetConvertToCollectionTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetConvertToCollectionTest.kt @@ -1,6 +1,7 @@ package com.anytypeio.anytype.presentation.sets.main import app.cash.turbine.testIn +import app.cash.turbine.turbineScope import com.anytypeio.anytype.core_models.Event import com.anytypeio.anytype.core_models.Payload import com.anytypeio.anytype.presentation.collections.MockSet @@ -42,9 +43,12 @@ class ObjectSetConvertToCollectionTest : ObjectSetViewModelTestSetup() { @Test fun `should start collection subscription after changing from set to collection`() = runTest { + turbineScope { // SETUP stubSpaceManager(defaultSpace) stubInterceptEvents() + stubNetworkMode() + stubObjectToCollection() stubInterceptThreadStatus() stubOpenObject( doc = listOf(mockObjectSet.header, mockObjectSet.title, mockObjectSet.dataView), @@ -60,57 +64,58 @@ class ObjectSetConvertToCollectionTest : ObjectSetViewModelTestSetup() { objects = listOf(mockObjectSet.obj1, mockObjectSet.obj2) ) - val stateFlow = stateReducer.state.testIn(backgroundScope) + val stateFlow = stateReducer.state.testIn(backgroundScope) - // TESTING + // TESTING proceedWithStartingViewModel() - val firstState = stateFlow.awaitItem() - assertIs(firstState) + val firstState = stateFlow.awaitItem() + assertIs(firstState) - val secondState = stateFlow.awaitItem() - assertIs(secondState) + val secondState = stateFlow.awaitItem() + assertIs(secondState) - viewModel.proceedWithConvertingToCollection() + viewModel.proceedWithConvertingToCollection() - val eventSetIsCollection = Event.Command.DataView.SetIsCollection( - context = root, - dv = mockObjectSet.dataView.id, - isCollection = true - ) - - dispatcher.send( - Payload( + val eventSetIsCollection = Event.Command.DataView.SetIsCollection( context = root, - events = listOf(eventSetIsCollection) + dv = mockObjectSet.dataView.id, + isCollection = true ) - ) - val thirdState = stateFlow.awaitItem() - assertIs(thirdState) - - advanceUntilIdle() - - verifyBlocking(repo, times(1)) { - searchObjectsWithSubscription( - eq(mockObjectSet.subscriptionId), - eq(listOf()), - eq( - mockObjectSet.filters + ObjectSearchConstants.defaultDataViewFilters( - listOf(spaceConfig.space, spaceConfig.techSpace) - ) - ), - eq(ObjectSearchConstants.defaultDataViewKeys + mockObjectSet.dvKeys), - eq(listOf()), - eq(0L), - eq(ObjectSetConfig.DEFAULT_LIMIT), - eq(null), - eq(null), - eq(null), - eq(null), - eq(mockObjectSet.root) + dispatcher.send( + Payload( + context = root, + events = listOf(eventSetIsCollection) + ) ) + + val thirdState = stateFlow.awaitItem() + assertIs(thirdState) + + advanceUntilIdle() + + verifyBlocking(repo, times(1)) { + searchObjectsWithSubscription( + eq(mockObjectSet.subscriptionId), + eq(listOf()), + eq( + mockObjectSet.filters + ObjectSearchConstants.defaultDataViewFilters( + listOf(spaceConfig.space, spaceConfig.techSpace) + ) + ), + eq(ObjectSearchConstants.defaultDataViewKeys + mockObjectSet.dvKeys), + eq(listOf()), + eq(0L), + eq(ObjectSetConfig.DEFAULT_LIMIT), + eq(null), + eq(null), + eq(null), + eq(null), + eq(mockObjectSet.root) + ) + } } } diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetDataViewObjectCreateTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetDataViewObjectCreateTest.kt index 79432e6411..38294b4cd7 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetDataViewObjectCreateTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetDataViewObjectCreateTest.kt @@ -8,6 +8,7 @@ import com.anytypeio.anytype.core_models.Relations import com.anytypeio.anytype.core_models.primitives.TypeKey import com.anytypeio.anytype.core_models.restrictions.DataViewRestriction import com.anytypeio.anytype.core_models.restrictions.DataViewRestrictions +import com.anytypeio.anytype.domain.base.Resultat import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewObject import com.anytypeio.anytype.presentation.collections.MockCollection import com.anytypeio.anytype.presentation.collections.MockSet @@ -25,6 +26,7 @@ import org.junit.Before import org.junit.Test import org.mockito.MockitoAnnotations import org.mockito.kotlin.doReturn +import org.mockito.kotlin.stub import org.mockito.kotlin.times import org.mockito.kotlin.verifyBlocking @@ -42,7 +44,8 @@ class ObjectSetDataViewObjectCreateTest : ObjectSetViewModelTestSetup() { fun setup() { MockitoAnnotations.openMocks(this) viewModel = givenViewModel() - mockObjectSet = MockSet(context = root, setOfValue = setOfId, setOfKey = setOfKey, space = defaultSpace) + mockObjectSet = + MockSet(context = root, setOfValue = setOfId, setOfKey = setOfKey, space = defaultSpace) mockObjectCollection = MockCollection(context = root, space = defaultSpace) stubNetworkMode() } @@ -71,14 +74,24 @@ class ObjectSetDataViewObjectCreateTest : ObjectSetViewModelTestSetup() { dvFilters = mockObjectSet.filters, objects = listOf(mockObjectSet.obj1, mockObjectSet.obj2) ) - doReturn(Unit).`when`(createDataViewObject).async( - CreateDataViewObject.Params.SetByType( - type = TypeKey(setOfKey), - filters = mockObjectSet.filters, - template = null, - prefilled = mapOf(), + createDataViewObject.stub { + onBlocking { + async( + CreateDataViewObject.Params.SetByType( + type = TypeKey(setOfKey), + filters = mockObjectSet.filters, + template = null, + prefilled = mapOf(), + ) + ) + } doReturn Resultat.success( + CreateDataViewObject.Result( + "", + TypeKey(""), + mapOf("spaceId" to "spaceId") + ) ) - ) + } // TESTING proceedWithStartingViewModel() diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetHeaderTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetHeaderTest.kt index 96f0f35853..6027613337 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetHeaderTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetHeaderTest.kt @@ -23,6 +23,7 @@ class ObjectSetHeaderTest : ObjectSetViewModelTestSetup() { MockitoAnnotations.openMocks(this) viewModel = givenViewModel() mockObjectSet = MockSet(context = root, space = defaultSpace) + stubNetworkMode() } @After diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetInitializationTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetInitializationTest.kt index a73d426472..2a5d125fd9 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetInitializationTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetInitializationTest.kt @@ -24,6 +24,7 @@ class ObjectSetInitializationTest : ObjectSetViewModelTestSetup() { MockitoAnnotations.openMocks(this) viewModel = givenViewModel() mockObjectSet = MockSet(context = root, space = defaultSpace) + stubNetworkMode() } @After diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetNavigationTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetNavigationTest.kt index 804542cbc7..e5e355232b 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetNavigationTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetNavigationTest.kt @@ -193,7 +193,7 @@ class ObjectSetNavigationTest : ObjectSetViewModelTestSetup() { dvFilters = mockObjectSet.filters ) - doReturn(Unit).`when`(closeBlock).async(mockObjectSet.root) + stubCloseBlock() // TESTING proceedWithStartingViewModel() diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetRestrictionsTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetRestrictionsTest.kt index e8985a86d3..f3b2958565 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetRestrictionsTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetRestrictionsTest.kt @@ -26,6 +26,7 @@ class ObjectSetRestrictionsTest : ObjectSetViewModelTestSetup() { MockitoAnnotations.openMocks(this) viewModel = givenViewModel() mockObjectSet = MockSet(context = root, space = defaultSpace) + givenNetworkNodeMocked() } @After diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetViewModelTestSetup.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetViewModelTestSetup.kt index d4ea5f039c..d01dc9fbf5 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetViewModelTestSetup.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetViewModelTestSetup.kt @@ -83,13 +83,18 @@ import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOf import net.bytebuddy.utility.RandomString +import org.junit.Before import org.junit.Rule import org.mockito.Mock +import org.mockito.MockitoAnnotations +import org.mockito.junit.MockitoJUnit import org.mockito.kotlin.any import org.mockito.kotlin.doReturn +import org.mockito.kotlin.given import org.mockito.kotlin.mock import org.mockito.kotlin.stub +@OptIn(ExperimentalCoroutinesApi::class) open class ObjectSetViewModelTestSetup { val root: Id = "context-${RandomString.make()}" @@ -328,6 +333,22 @@ open class ObjectSetViewModelTestSetup { } } + fun stubAddObjectToCollection() { + addObjectToCollection.stub { + onBlocking { + async(any()) + } doReturn Resultat.success(Payload("", emptyList())) + } + } + + fun stubCloseBlock() { + closeBlock.stub { + onBlocking { + async(any()) + } doReturn Resultat.success(Unit) + } + } + suspend fun stubSpaceManager(space: Id) { repo.stub { onBlocking { getSpaceConfig(space) } doReturn spaceConfig @@ -445,7 +466,7 @@ open class ObjectSetViewModelTestSetup { CreateDataViewObject.Result( objectId = objectId, objectType = TypeKey(objectType), - struct = null + struct = mapOf("spaceId" to "spaceId") ) ) ) @@ -457,4 +478,18 @@ open class ObjectSetViewModelTestSetup { onBlocking { run(Unit) } doReturn NetworkModeConfig() } } + + fun stubObjectToCollection() { + objectToCollection.stub { + onBlocking { async(any()) } doReturn Resultat.success(Unit) + } + } + + fun givenNetworkNodeMocked() { + getNetworkMode.stub { + onBlocking { + run(any()) + } doReturn NetworkModeConfig() + } + } } \ No newline at end of file diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/SetByRelationTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/SetByRelationTest.kt index 0cbc6959b0..5db2117c6c 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/SetByRelationTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/SetByRelationTest.kt @@ -1,6 +1,7 @@ package com.anytypeio.anytype.presentation.sets.main import app.cash.turbine.test +import app.cash.turbine.turbineScope import com.anytypeio.anytype.core_models.primitives.TypeKey import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewObject import com.anytypeio.anytype.presentation.collections.MockSet @@ -47,6 +48,7 @@ class SetByRelationTest : ObjectSetViewModelTestSetup() { // SETUP stubSpaceManager(mockObjectSet.spaceId) stubInterceptEvents() + stubCreateDataViewObject() stubInterceptThreadStatus() stubStoreOfRelations(mockObjectSet) stubOpenObject( diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/templates/CollectionViewerTypeAndTemplateTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/templates/CollectionViewerTypeAndTemplateTest.kt index 8048ecc69c..fd552e2dce 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/templates/CollectionViewerTypeAndTemplateTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/templates/CollectionViewerTypeAndTemplateTest.kt @@ -1,6 +1,7 @@ package com.anytypeio.anytype.presentation.templates import com.anytypeio.anytype.core_models.Block +import com.anytypeio.anytype.core_models.NetworkModeConfig import com.anytypeio.anytype.core_models.ObjectType import com.anytypeio.anytype.core_models.ObjectTypeIds import com.anytypeio.anytype.core_models.Relations @@ -29,6 +30,9 @@ import org.junit.After import org.junit.Before import org.junit.Test import org.mockito.MockitoAnnotations +import org.mockito.kotlin.any +import org.mockito.kotlin.doReturn +import org.mockito.kotlin.stub import org.mockito.kotlin.times import org.mockito.kotlin.verifyBlocking @@ -75,7 +79,9 @@ class CollectionViewerTypeAndTemplateTest: ObjectSetViewModelTestSetup() { @Before fun setup() { closable = MockitoAnnotations.openMocks(this) + givenNetworkNodeMocked() viewModel = givenViewModel() + stubAddObjectToCollection() } @After diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/templates/SetByTypeViewerTypeAndTemplateTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/templates/SetByTypeViewerTypeAndTemplateTest.kt index 58bf78e9a2..395a20828a 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/templates/SetByTypeViewerTypeAndTemplateTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/templates/SetByTypeViewerTypeAndTemplateTest.kt @@ -1,6 +1,7 @@ package com.anytypeio.anytype.presentation.templates import com.anytypeio.anytype.core_models.Block +import com.anytypeio.anytype.core_models.NetworkModeConfig import com.anytypeio.anytype.core_models.ObjectType import com.anytypeio.anytype.core_models.ObjectTypeIds import com.anytypeio.anytype.core_models.Relations @@ -24,8 +25,13 @@ import kotlinx.coroutines.test.runTest import net.bytebuddy.utility.RandomString import org.junit.After import org.junit.Before +import org.junit.Rule import org.junit.Test import org.mockito.MockitoAnnotations +import org.mockito.junit.MockitoJUnit +import org.mockito.kotlin.any +import org.mockito.kotlin.doReturn +import org.mockito.kotlin.stub import org.mockito.kotlin.times import org.mockito.kotlin.verifyBlocking @@ -59,6 +65,11 @@ class SetByTypeViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() { @Before fun setup() { closable = MockitoAnnotations.openMocks(this) + getNetworkMode.stub { + onBlocking { + run(any()) + } doReturn NetworkModeConfig() + } viewModel = givenViewModel() } diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/util/TestDispatchers.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/util/TestDispatchers.kt index 9eb5480234..c7c93b8ef1 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/util/TestDispatchers.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/util/TestDispatchers.kt @@ -4,7 +4,7 @@ import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.StandardTestDispatcher -@OptIn(ExperimentalCoroutinesApi::class) + val dispatchers = AppCoroutineDispatchers( io = StandardTestDispatcher(), main = StandardTestDispatcher(), diff --git a/protocol/build.gradle b/protocol/build.gradle index 22389b890c..69d1df09a7 100644 --- a/protocol/build.gradle +++ b/protocol/build.gradle @@ -14,12 +14,5 @@ wire { } android { - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - kotlin { - jvmToolchain(17) - } namespace 'com.anytypeio.anytype.protocol' } \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 7cb04b2f1f..3a4a8f1bce 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -29,15 +29,6 @@ android { } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - - kotlin { - jvmToolchain(17) - } - buildFeatures { viewBinding true compose true diff --git a/settings.gradle b/settings.gradle index dd2d9322e2..160a4225ab 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,6 +8,10 @@ pluginManagement { } } +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' +} + dependencyResolutionManagement { /** * Create github.properties in root project folder file diff --git a/test/android-utils/build.gradle b/test/android-utils/build.gradle index 204fa81d36..776e8c1f30 100644 --- a/test/android-utils/build.gradle +++ b/test/android-utils/build.gradle @@ -15,12 +15,5 @@ dependencies { } android { - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - kotlin { - jvmToolchain(17) - } namespace 'com.anytypeio.anytype.test_utils' } \ No newline at end of file diff --git a/ui-settings/build.gradle b/ui-settings/build.gradle index 8b74674ba6..e4e4a9b656 100644 --- a/ui-settings/build.gradle +++ b/ui-settings/build.gradle @@ -15,13 +15,6 @@ android { kotlinCompilerExtensionVersion libs.versions.composeKotlinCompilerVersion.get() } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - kotlin { - jvmToolchain(17) - } namespace 'com.anytypeio.anytype.ui_settings' }