Skip to content

Commit

Permalink
WIP: Adds wp-block-editor/v1/settings call
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonis Lilis committed May 3, 2021
1 parent 8ac01f9 commit 4a0fdab
Show file tree
Hide file tree
Showing 7 changed files with 1,548 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class MockedStack_EditorThemeStoreTest : MockedStack_Base() {
private lateinit var countDownLatch: CountDownLatch
private lateinit var site: SiteModel
private lateinit var payload: FetchEditorThemePayload
private lateinit var payloadWithGSS: FetchEditorThemePayload
private var editorTheme: EditorTheme? = null

override fun setUp() {
Expand All @@ -39,6 +40,7 @@ class MockedStack_EditorThemeStoreTest : MockedStack_Base() {
site = SiteModel()
site.setIsWPCom(true)
payload = FetchEditorThemePayload(site)
payloadWithGSS = FetchEditorThemePayload(site, true)
countDownLatch = CountDownLatch(1)
}

Expand Down Expand Up @@ -134,6 +136,46 @@ class MockedStack_EditorThemeStoreTest : MockedStack_Base() {
assertEmpty(themeBundle)
}

@Test
fun testGlobalStylesSettingsOffSuccess() { // TODO: Fix
interceptor.respondWith("global-styles-off-success.json")
dispatcher.dispatch(EditorThemeActionBuilder.newFetchEditorThemeAction(payloadWithGSS))

// See onEditorThemeChanged for the latch's countdown to fire.
Assert.assertTrue(countDownLatch.await(TestUtils.DEFAULT_TIMEOUT_MS.toLong(), MILLISECONDS))

// Validate Callback
assertEmpty(editorTheme)

// Validate Cache
val cachedTheme = editorThemeStore.getEditorThemeForSite(site)
assertEmpty(cachedTheme)

// Validate Bundle
val themeBundle = editorTheme!!.themeSupport.toBundle()
assertEmpty(themeBundle)
}

@Test
fun testGlobalStylesSettingsFullSuccess() { // TODO: Fix
interceptor.respondWith("global-styles-full-success.json")
dispatcher.dispatch(EditorThemeActionBuilder.newFetchEditorThemeAction(payloadWithGSS))

// See onEditorThemeChanged for the latch's countdown to fire.
Assert.assertTrue(countDownLatch.await(TestUtils.DEFAULT_TIMEOUT_MS.toLong(), MILLISECONDS))

// Validate Callback
assertEmpty(editorTheme)

// Validate Cache
val cachedTheme = editorThemeStore.getEditorThemeForSite(site)
assertEmpty(cachedTheme)

// Validate Bundle
val themeBundle = editorTheme!!.themeSupport.toBundle()
assertEmpty(themeBundle)
}

private fun assertNotEmpty(theme: EditorTheme?) {
Assert.assertFalse(theme?.themeSupport?.colors.isNullOrEmpty())
Assert.assertFalse(theme?.themeSupport?.gradients.isNullOrEmpty())
Expand Down

This file was deleted.

Loading

0 comments on commit 4a0fdab

Please sign in to comment.