Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.wordpress.android.ui.posts

import org.wordpress.android.util.UrlUtils
import org.wordpress.gutenberg.model.EditorConfiguration
import org.wordpress.gutenberg.model.PostTypeDetails

/**
* Utility object for building EditorConfiguration from settings maps.
Expand All @@ -13,7 +14,8 @@ object EditorConfigurationBuilder {
): EditorConfiguration {
val siteURL = settings.getSetting<String>("siteURL") ?: ""
val siteApiRoot = settings.getSetting<String>("siteApiRoot") ?: ""
val postType = settings.getSetting<String>("postType") ?: "post"
val postType = settings.getSetting<PostTypeDetails>("postType")
?: PostTypeDetails.post
val siteApiNamespace = settings.getStringArray("siteApiNamespace")

return EditorConfiguration.builder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.wordpress.android.fluxc.utils.extensions.getPasswordProcessed
import org.wordpress.android.fluxc.utils.extensions.getUserNameProcessed
import org.wordpress.android.util.AppLog
import org.wordpress.android.util.UrlUtils
import org.wordpress.gutenberg.model.PostTypeDetails

object GutenbergKitSettingsBuilder {
private const val AUTH_BEARER_PREFIX = "Bearer "
Expand Down Expand Up @@ -128,7 +129,11 @@ object GutenbergKitSettingsBuilder {

return mutableMapOf(
"postId" to postConfig.remotePostId?.toInt(),
"postType" to if (postConfig.isPage) "page" else "post",
"postType" to if (postConfig.isPage) {
PostTypeDetails.page
} else {
PostTypeDetails.post
},
"status" to postConfig.status,
"postTitle" to postConfig.title,
"postContent" to postConfig.content,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.junit.MockitoJUnitRunner
import org.wordpress.android.fluxc.network.UserAgent
import org.wordpress.gutenberg.model.PostTypeDetails

@RunWith(MockitoJUnitRunner::class)
@Suppress("LargeClass")
Expand Down Expand Up @@ -428,7 +429,7 @@ class GutenbergKitSettingsBuilderTest {

// Verify all settings are correctly configured
assertThat(settings["postId"]).isEqualTo(456)
assertThat(settings["postType"]).isEqualTo("post")
assertThat(settings["postType"]).isEqualTo(PostTypeDetails.post)
assertThat(settings["postTitle"]).isEqualTo("Test Post")
assertThat(settings["postContent"]).isEqualTo("Test Content")
assertThat(settings["siteURL"]).isEqualTo("https://example.wordpress.com")
Expand Down Expand Up @@ -476,7 +477,7 @@ class GutenbergKitSettingsBuilderTest {
featureConfig = createFeatureConfig(isPluginsFeatureEnabled = true)
)

assertThat(settings["postType"]).isEqualTo("page")
assertThat(settings["postType"]).isEqualTo(PostTypeDetails.page)
assertThat(settings["authHeader"] as String).startsWith("Basic ")
assertThat(settings["siteApiRoot"]).isEqualTo("https://jetpack-site.com/wp-json/")
assertThat(settings["siteApiNamespace"] as Array<*>).isEmpty()
Expand Down Expand Up @@ -598,7 +599,7 @@ class GutenbergKitSettingsBuilderTest {
assertThat(settings["postTitle"]).isNull()
assertThat(settings["postContent"]).isNull()
assertThat(settings["status"]).isNull()
assertThat(settings["postType"]).isEqualTo("post") // Still defaults to post
assertThat(settings["postType"]).isEqualTo(PostTypeDetails.post) // Still defaults to post
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ google-play-review = '2.0.2'
google-services = '4.4.4'
gravatar = '2.5.0'
greenrobot-eventbus = '3.3.1'
gutenberg-kit = 'v0.15.1'
gutenberg-kit = 'v0.15.2'
gutenberg-mobile = 'v1.121.0'
indexos-media-for-mobile = '43a9026f0973a2f0a74fa813132f6a16f7499c3a'
jackson-databind = '2.12.7.1'
Expand Down
Loading