@@ -36,6 +36,7 @@ extension BlockEditorSettingsServiceRemoteTests {
3636 XCTAssertFalse ( result!. checksum. isEmpty)
3737 XCTAssertGreaterThan ( result!. themeSupport!. colors!. count, 0 )
3838 XCTAssertGreaterThan ( result!. themeSupport!. gradients!. count, 0 )
39+ XCTAssertTrue ( result!. themeSupport!. blockTemplates)
3940 case . failure:
4041 XCTFail ( " This payload should parse successfully " )
4142 }
@@ -84,7 +85,10 @@ extension BlockEditorSettingsServiceRemoteTests {
8485 var theme = mockedResponse [ 0 ]
8586 var themeSupport = theme [ RemoteEditorTheme . CodingKeys. themeSupport. stringValue] as! [ String : Any ]
8687 themeSupport [ RemoteEditorThemeSupport . CodingKeys. colors. stringValue] = " false "
88+
89+ themeSupport [ RemoteEditorThemeSupport . CodingKeys. blockTemplates. stringValue] = " false "
8790 theme [ RemoteEditorTheme . CodingKeys. themeSupport. stringValue] = themeSupport
91+
8892 mockedResponse [ 0 ] = theme
8993
9094 service. fetchTheme ( forSiteID: siteID) { ( response) in
@@ -94,6 +98,32 @@ extension BlockEditorSettingsServiceRemoteTests {
9498 XCTAssertFalse ( result!. checksum. isEmpty)
9599 XCTAssertNil ( result!. themeSupport!. colors)
96100 XCTAssertGreaterThan ( result!. themeSupport!. gradients!. count, 0 )
101+ XCTAssertFalse ( result!. themeSupport!. blockTemplates)
102+ case . failure:
103+ XCTFail ( " This payload should parse successfully " )
104+ }
105+ waitExpectation. fulfill ( )
106+ }
107+ mockRemoteApi. successBlockPassedIn!( mockedResponse as AnyObject , HTTPURLResponse ( ) )
108+
109+ waitForExpectations ( timeout: 0.1 )
110+ validateEditorThemeRequest ( )
111+ }
112+
113+ func testFetchThemeNoThemeSupport( ) {
114+ let waitExpectation = expectation ( description: " Theme should be successfully fetched " )
115+ var mockedResponse = mockedData ( withFilename: twentytwentyoneResponseFilename) as! [ [ String : Any ] ]
116+ var theme = mockedResponse [ 0 ]
117+ var themeSupport = theme [ RemoteEditorTheme . CodingKeys. themeSupport. stringValue] as! [ String : Any ]
118+
119+ themeSupport. removeValue ( forKey: RemoteEditorThemeSupport . CodingKeys. blockTemplates. stringValue)
120+ theme [ RemoteEditorTheme . CodingKeys. themeSupport. stringValue] = themeSupport
121+ mockedResponse [ 0 ] = theme
122+
123+ service. fetchTheme ( forSiteID: siteID) { ( response) in
124+ switch response {
125+ case . success( let result) :
126+ XCTAssertFalse ( result!. themeSupport!. blockTemplates)
97127 case . failure:
98128 XCTFail ( " This payload should parse successfully " )
99129 }
@@ -139,6 +169,7 @@ extension BlockEditorSettingsServiceRemoteTests {
139169 case . success( let result) :
140170 self . validateFetchBlockEditorSettingsResults ( result)
141171 XCTAssertNil ( result!. rawStyles)
172+ XCTAssertFalse ( result!. isFSETheme)
142173 case . failure:
143174 XCTFail ( " This payload should parse successfully " )
144175 }
@@ -160,6 +191,7 @@ extension BlockEditorSettingsServiceRemoteTests {
160191 self . validateFetchBlockEditorSettingsResults ( result)
161192
162193 XCTAssertNotNil ( result!. rawStyles)
194+ XCTAssertTrue ( result!. isFSETheme)
163195 let gssRawJson = result!. rawStyles!. data ( using: . utf8) !
164196 let vaildJson = try ? JSONSerialization . jsonObject ( with: gssRawJson, options: [ ] )
165197 XCTAssertNotNil ( vaildJson)
@@ -174,6 +206,27 @@ extension BlockEditorSettingsServiceRemoteTests {
174206 validateFetchBlockEditorSettingsRequest ( )
175207 }
176208
209+ func testFetchBlockEditorSettingsNoFSETheme( ) {
210+ let waitExpectation = expectation ( description: " Block Settings should be successfully fetched " )
211+ var mockedResponse = mockedData ( withFilename: blockSettingsThemeJSONResponseFilename) as! [ String : Any ]
212+ mockedResponse. removeValue ( forKey: RemoteBlockEditorSettings . CodingKeys. isFSETheme. stringValue)
213+
214+ service. fetchBlockEditorSettings ( forSiteID: siteID) { ( response) in
215+ switch response {
216+ case . success( let result) :
217+ self . validateFetchBlockEditorSettingsResults ( result)
218+ XCTAssertFalse ( result!. isFSETheme)
219+ case . failure:
220+ XCTFail ( " This payload should parse successfully " )
221+ }
222+ waitExpectation. fulfill ( )
223+ }
224+ mockRemoteApi. successBlockPassedIn!( mockedResponse as AnyObject , HTTPURLResponse ( ) )
225+
226+ waitForExpectations ( timeout: 0.1 )
227+ validateFetchBlockEditorSettingsRequest ( )
228+ }
229+
177230 func testFetchBlockEditorSettingsThemeJSON_ConsistentChecksum( ) {
178231 let json = Bundle ( for: BlockEditorSettingsServiceRemoteTests . self) . url ( forResource: blockSettingsThemeJSONResponseFilename, withExtension: " json " ) !
179232 let data = try ! Data ( contentsOf: json)
0 commit comments