Skip to content

Commit 26b93d5

Browse files
committed
Probe the direct host for Jetpack capability detection, not the proxy
The route-support probe only sent Atomic sites to the direct host; Jetpack WPCom-REST sites fell through to the WP.com proxy. Since the proxy and the direct host advertise different route lists (the #22879 premise), Jetpack sites got the wrong answer. Broaden the predicate to isUsingWpComRestApi && !isWPComSimpleSite (Atomic + Jetpack); the proxy is only for minting the application password.
1 parent 5591795 commit 26b93d5

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

WordPress/src/main/java/org/wordpress/android/repositories/EditorSettingsRepository.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,12 @@ class EditorSettingsRepository @Inject constructor(
108108
private suspend fun fetchRouteSupport(
109109
site: SiteModel
110110
): Boolean = try {
111-
// For Atomic sites the editor fetches `wp-block-editor/v1/settings`
112-
// from the direct host — proxy and direct host can advertise
113-
// different route lists, so detection has to probe the direct host
114-
// too. See #22879.
115-
if (site.isWPComAtomic) {
111+
// Atomic and Jetpack-WPCom-REST sites have their own REST host that the editor talks to
112+
// directly — the WP.com proxy and the direct host advertise different route lists, so
113+
// detection has to probe the direct host too. The proxy is only for minting the application
114+
// password. WP.com Simple sites have no direct host (the WP.com REST API *is* their API),
115+
// and self-hosted sites are already direct via the configured client. See #22879.
116+
if (site.isUsingWpComRestApi && !site.isWPComSimpleSite) {
116117
fetchRouteSupportViaDirectHostDiscovery(site)
117118
} else {
118119
fetchRouteSupportViaConfiguredClient(site)

WordPress/src/test/java/org/wordpress/android/repositories/EditorSettingsRepositoryTest.kt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,36 @@ class EditorSettingsRepositoryTest : BaseUnitTest() {
229229
verify(wpApiClientProvider, never()).getWpApiClient(atomicSite)
230230
}
231231

232+
@Test
233+
fun `jetpack site probes the direct host, not the WP_com proxy`() =
234+
runTest {
235+
val jetpackSite = SiteModel().apply {
236+
id = 7
237+
url = "https://jetpack.example.com"
238+
// isUsingWpComRestApi via Jetpack, but not Atomic and not WP.com Simple → direct host.
239+
setIsJetpackConnected(true)
240+
setOrigin(SiteModel.ORIGIN_WPCOM_REST)
241+
}
242+
mockDiscoverySuccess(
243+
siteUrl = jetpackSite.url,
244+
hasEditorSettings = true,
245+
hasEditorAssets = true
246+
)
247+
whenever(themeRepository.fetchCurrentTheme(jetpackSite))
248+
.thenReturn(buildTheme(isBlockTheme = false))
249+
250+
val result =
251+
repository.fetchEditorCapabilitiesForSite(jetpackSite)
252+
253+
assertThat(result).isTrue()
254+
verify(appPrefsWrapper)
255+
.setSiteSupportsEditorSettings(jetpackSite, true)
256+
verify(appPrefsWrapper)
257+
.setSiteSupportsEditorAssets(jetpackSite, true)
258+
// The proxy is only for minting — capability detection goes direct.
259+
verify(wpApiClientProvider, never()).getWpApiClient(jetpackSite)
260+
}
261+
232262
@Test
233263
fun `atomic site returns false when discovery fails`() =
234264
runTest {

0 commit comments

Comments
 (0)