@@ -118,7 +118,7 @@ describe("Image v3 editor remote asset Dynamic Media", function() {
118118 } ) ;
119119
120120 describe ( "processPolarisSmartCropMetadataResponse" , function ( ) {
121- it ( "shows smart crop and image modifiers when smartcrops metadata is present" , function ( ) {
121+ it ( "shows preset type, smart crop radio, smart crop dropdown, and image modifiers when smartcrops metadata is present" , function ( ) {
122122 const responseText = JSON . stringify ( {
123123 repositoryMetadata : {
124124 smartcrops : {
@@ -131,12 +131,37 @@ describe("Image v3 editor remote asset Dynamic Media", function() {
131131
132132 const smartCrop = fixtureRoot . querySelector ( ".cmp-image__editor-dynamicmedia-smartcroprendition" ) ;
133133 const modifiers = fixtureRoot . querySelector ( "input[name='./imageModifiers']" ) ;
134+ const presetType = fixtureRoot . querySelector ( ".cmp-image__editor-dynamicmedia-presettype" ) ;
135+ const smartCropRadio = fixtureRoot . querySelector (
136+ ".cmp-image__editor-dynamicmedia-presettype input[value='smartCrop']"
137+ ) ;
134138 expect ( isGroupVisible ( fixtureRoot ) ) . toBe ( true ) ;
139+ expect ( isParentVisible ( presetType ) ) . toBe ( true ) ;
140+ expect ( smartCropRadio . checked ) . toBe ( true ) ;
135141 expect ( isParentVisible ( smartCrop ) ) . toBe ( true ) ;
136142 expect ( isParentVisible ( modifiers ) ) . toBe ( true ) ;
137143 } ) ;
138144
139- it ( "shows image modifiers but hides smart crop and preset type when smartcrops metadata is absent" , function ( ) {
145+ it ( "re-shows preset type after a previous no-smartcrops response had hidden it" , function ( ) {
146+ const noSmartCrops = JSON . stringify ( {
147+ repositoryMetadata : { }
148+ } ) ;
149+ const withSmartCrops = JSON . stringify ( {
150+ repositoryMetadata : {
151+ smartcrops : {
152+ Landscape : { width : 16 , height : 9 }
153+ }
154+ }
155+ } ) ;
156+
157+ api . processPolarisSmartCropMetadataResponse ( 200 , noSmartCrops ) ;
158+ api . processPolarisSmartCropMetadataResponse ( 200 , withSmartCrops ) ;
159+
160+ const presetType = fixtureRoot . querySelector ( ".cmp-image__editor-dynamicmedia-presettype" ) ;
161+ expect ( isParentVisible ( presetType ) ) . toBe ( true ) ;
162+ } ) ;
163+
164+ it ( "shows image modifiers but hides smart crop, image preset, and preset type when smartcrops metadata is absent" , function ( ) {
140165 const responseText = JSON . stringify ( {
141166 repositoryMetadata : { }
142167 } ) ;
@@ -146,10 +171,12 @@ describe("Image v3 editor remote asset Dynamic Media", function() {
146171 const smartCrop = fixtureRoot . querySelector ( ".cmp-image__editor-dynamicmedia-smartcroprendition" ) ;
147172 const modifiers = fixtureRoot . querySelector ( "input[name='./imageModifiers']" ) ;
148173 const presetType = fixtureRoot . querySelector ( ".cmp-image__editor-dynamicmedia-presettype" ) ;
174+ const imagePreset = fixtureRoot . querySelector ( ".cmp-image__editor-dynamicmedia-imagepreset" ) ;
149175 expect ( isGroupVisible ( fixtureRoot ) ) . toBe ( true ) ;
150176 expect ( isParentVisible ( modifiers ) ) . toBe ( true ) ;
151177 expect ( isParentVisible ( smartCrop ) ) . toBe ( false ) ;
152178 expect ( isParentVisible ( presetType ) ) . toBe ( false ) ;
179+ expect ( isParentVisible ( imagePreset ) ) . toBe ( false ) ;
153180 } ) ;
154181
155182 it ( "keeps original preset behaviour by hiding image preset radio parent" , function ( ) {
0 commit comments