@@ -49,7 +49,7 @@ def dummy_method1(self):
49
49
50
50
51
51
# mock helpers
52
- def mock_healthcheck (fail = False , fail_how = 'error' , session_type = None , widths = None ):
52
+ def mock_healthcheck (fail = False , fail_how = 'error' , session_type = None , widths = None , config = None ):
53
53
health_body = { "success" : True }
54
54
health_headers = { 'X-Percy-Core-Version' : '1.0.0' }
55
55
health_status = 200
@@ -66,6 +66,7 @@ def mock_healthcheck(fail=False, fail_how='error', session_type=None, widths = N
66
66
health_body ["type" ] = session_type
67
67
68
68
if widths : health_body ['widths' ] = widths
69
+ if config : health_body ['config' ] = config
69
70
health_body = json .dumps (health_body )
70
71
httpretty .register_uri (
71
72
httpretty .GET , 'http://localhost:5338/percy/healthcheck' ,
@@ -272,6 +273,23 @@ def test_posts_snapshots_to_the_local_percy_server_for_responsive_snapshot_captu
272
273
{ 'html' : dom_string , 'cookies' : expected_cookies , 'width' : 390 }
273
274
])
274
275
276
+ def test_posts_snapshots_to_the_local_percy_server_with_defer_and_responsive (self ):
277
+ mock_logger ()
278
+ mock_healthcheck (widths = { "config" : [375 , 1280 ], "mobile" : [390 ]}, config = { 'percy' : { 'deferUploads' : True }})
279
+ mock_snapshot ()
280
+ dom_string = '<html><head></head><body>Snapshot Me</body></html>'
281
+ expected_dom_snapshot = { 'html' : dom_string , 'cookies' : [] }
282
+
283
+ percy_snapshot (self .driver , 'Snapshot 1' , responsiveSnapshotCapture = True )
284
+
285
+ self .assertEqual (httpretty .last_request ().path , '/percy/snapshot' )
286
+
287
+ s1 = httpretty .latest_requests ()[2 ].parsed_body
288
+ self .assertEqual (s1 ['name' ], 'Snapshot 1' )
289
+ self .assertEqual (s1 ['url' ], 'http://localhost:8000/' )
290
+ self .assertEqual (s1 ['dom_snapshot' ], expected_dom_snapshot )
291
+
292
+
275
293
@patch ('selenium.webdriver.Chrome' )
276
294
def test_posts_snapshots_to_the_local_percy_server_for_responsive_dom_chrome (self , MockChrome ):
277
295
os .environ ['RESONSIVE_CAPTURE_SLEEP_TIME' ] = '1'
@@ -282,7 +300,7 @@ def test_posts_snapshots_to_the_local_percy_server_for_responsive_dom_chrome(sel
282
300
driver .get_cookies .return_value = ''
283
301
driver .execute_cdp_cmd .return_value = ''
284
302
driver .get_window_size .return_value = { 'height' : 400 , 'width' : 800 }
285
- mock_healthcheck (widths = { "config" : [375 ], "mobile" : [390 ]})
303
+ mock_healthcheck (widths = { "config" : [375 ], "mobile" : [390 ] })
286
304
mock_snapshot ()
287
305
expected_dom_snapshot = [
288
306
{ 'cookies' : '' , 'html' : 'some_dom' , 'width' : 600 },
0 commit comments