From 4968086abb3249f8b1c5bcfca9755e6d578d51ec Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 8 Oct 2025 17:05:53 -0400 Subject: [PATCH 1/4] Address parsing issues for post_types & templates --- wp_api/src/post_types.rs | 12 +++++++++++- wp_api/src/templates.rs | 1 + .../tests/test_post_types_immut.rs | 2 +- wp_api_integration_tests/tests/test_templates_mut.rs | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/wp_api/src/post_types.rs b/wp_api/src/post_types.rs index 54181d930..b905d5c50 100644 --- a/wp_api/src/post_types.rs +++ b/wp_api/src/post_types.rs @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::str::FromStr; use wp_contextual::WpContextual; +use wp_serde_helper::deserialize_empty_array_or_hashmap; #[derive( Debug, @@ -74,7 +75,7 @@ pub struct SparsePostTypeDetails { #[WpContext(edit, embed, view)] pub slug: Option, #[WpContext(edit)] - pub supports: Option>, + pub supports: Option, #[WpContext(edit, view)] pub has_archive: Option, #[WpContext(edit, view)] @@ -90,6 +91,15 @@ pub struct SparsePostTypeDetails { pub icon: Option, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, uniffi::Record)] +#[serde(transparent)] +pub struct PostTypeSupportsMap { + #[serde(deserialize_with = "deserialize_empty_array_or_hashmap")] + #[serde(flatten)] + #[serde(rename = "supports")] + pub map: HashMap, +} + #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, uniffi::Record)] pub struct PostTypeLabels { pub name: String, diff --git a/wp_api/src/templates.rs b/wp_api/src/templates.rs index 77800abf7..08610a9ea 100644 --- a/wp_api/src/templates.rs +++ b/wp_api/src/templates.rs @@ -94,6 +94,7 @@ pub struct SparseTemplate { #[WpContext(edit, embed, view)] pub slug: Option, #[WpContext(edit, embed, view)] + #[WpContextualOption] pub theme: Option, #[serde(rename = "type")] #[WpContext(edit, embed, view)] diff --git a/wp_api_integration_tests/tests/test_post_types_immut.rs b/wp_api_integration_tests/tests/test_post_types_immut.rs index aa2248fea..140cba347 100644 --- a/wp_api_integration_tests/tests/test_post_types_immut.rs +++ b/wp_api_integration_tests/tests/test_post_types_immut.rs @@ -93,7 +93,7 @@ async fn retrieve_post_types_with_edit_context( // post types might not support `Title` in which case it's perfectly fine to completely // remove this assertion. assert_eq!( - post_type.supports.get(&PostTypeSupports::Title), + post_type.supports.map.get(&PostTypeSupports::Title), Some(true).as_ref() ); // All post types in our current testing sites have `EditPost` capability, so we use this diff --git a/wp_api_integration_tests/tests/test_templates_mut.rs b/wp_api_integration_tests/tests/test_templates_mut.rs index d0008228f..fe69429a5 100644 --- a/wp_api_integration_tests/tests/test_templates_mut.rs +++ b/wp_api_integration_tests/tests/test_templates_mut.rs @@ -52,7 +52,7 @@ async fn create_template_with_slug_title_and_theme() { test_create_template(¶ms, |created_template| { assert_slug(&created_template); assert_title(&created_template); - assert_eq!(created_template.theme, theme); + assert_eq!(created_template.theme, Some(theme.to_string())); }) .await; } From e5ba092e257340bfb95cda7d2c359dccb40e74e8 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 8 Oct 2025 17:45:00 -0400 Subject: [PATCH 2/4] Update Kotlin integration tests for PostTypeSupports changes --- .../src/integrationTest/kotlin/PostTypesEndpointTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native/kotlin/api/kotlin/src/integrationTest/kotlin/PostTypesEndpointTest.kt b/native/kotlin/api/kotlin/src/integrationTest/kotlin/PostTypesEndpointTest.kt index b1a5f31ca..f954e8037 100644 --- a/native/kotlin/api/kotlin/src/integrationTest/kotlin/PostTypesEndpointTest.kt +++ b/native/kotlin/api/kotlin/src/integrationTest/kotlin/PostTypesEndpointTest.kt @@ -26,7 +26,7 @@ class PostTypesEndpointTest { val postTypesPost = client.request { requestBuilder -> requestBuilder.postTypes().retrieveWithEditContext(PostType.Post) }.assertSuccessAndRetrieveData().data - assert(postTypesPost.supports[PostTypeSupports.Title]!!) + assert(postTypesPost.supports.map[PostTypeSupports.Title]!!) assertFalse(postTypesPost.capabilities[PostTypeCapabilities.EditPosts]!!.isEmpty()) } @@ -35,7 +35,7 @@ class PostTypesEndpointTest { val postTypesPost = client.request { requestBuilder -> requestBuilder.postTypes().retrieveWithEditContext(PostType.WpFontFace) }.assertSuccessAndRetrieveData().data - assertNull(postTypesPost.supports[PostTypeSupports.Author]) + assertNull(postTypesPost.supports.map[PostTypeSupports.Author]) } @Test From eb0f61746f236e546328471a0d205386397dc7dc Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 8 Oct 2025 17:46:28 -0400 Subject: [PATCH 3/4] Update Swift example app for PostTypeSupports changes --- native/swift/Example/Example/ExampleApp.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/swift/Example/Example/ExampleApp.swift b/native/swift/Example/Example/ExampleApp.swift index 3d4b372bd..fc98e3bde 100644 --- a/native/swift/Example/Example/ExampleApp.swift +++ b/native/swift/Example/Example/ExampleApp.swift @@ -128,7 +128,7 @@ struct ExampleApp: App { .postTypes .map(\.value) .filter { $0.visibility.showInNavMenus } - .filter { $0.supports.keys.contains(allOf: [.title, .author, .customFields]) } + .filter { $0.supports.map.keys.contains(allOf: [.title, .author, .customFields]) } for type in postTypes { baseData.append(RootListData(name: type.name, sequence: { From d37bb54c5dfe4a2dbdfde2442101a5bb6b936089 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Thu, 9 Oct 2025 17:29:23 -0400 Subject: [PATCH 4/4] Pin Gutenberg plugin version for test server to 21.7.0 --- scripts/setup-test-site.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/setup-test-site.sh b/scripts/setup-test-site.sh index b5950b451..90252b1b0 100755 --- a/scripts/setup-test-site.sh +++ b/scripts/setup-test-site.sh @@ -71,7 +71,9 @@ wp import /tmp/testdata.xml --authors=create wp plugin deactivate wordpress-importer wp plugin delete wordpress-importer -wp plugin install gutenberg --activate +curl -sSL https://downloads.wordpress.org/plugin/gutenberg.21.7.0.zip -o /tmp/gutenberg.zip +unzip -q /tmp/gutenberg.zip -d wp-content/plugins/ +wp plugin activate gutenberg # Install custom must-use plugins for integration tests mkdir -p wp-content/mu-plugins