feat(ai-studio): read shopee source image urls
This commit is contained in:
@@ -39,10 +39,11 @@ class FakeCDP:
|
||||
|
||||
|
||||
class FakeProductCDP:
|
||||
def __init__(self, ws, ready=True, toasts=None):
|
||||
def __init__(self, ws, ready=True, toasts=None, rects=None):
|
||||
self.ws = ws
|
||||
self.ready = ready
|
||||
self.toasts = list(toasts or [])
|
||||
self.rects = list(rects or [])
|
||||
self.closed = False
|
||||
self.sent = []
|
||||
self.toast_observer_installed = False
|
||||
@@ -55,6 +56,8 @@ class FakeProductCDP:
|
||||
return True
|
||||
if expr == editor.JS_PAGE_TOASTS:
|
||||
return json.dumps(self.toasts)
|
||||
if expr == editor.JS_RECTS:
|
||||
return json.dumps(self.rects)
|
||||
return None
|
||||
|
||||
def send(self, method, params=None):
|
||||
@@ -655,6 +658,20 @@ class EditorLoginTests(unittest.TestCase):
|
||||
self.assertTrue(cdp.closed)
|
||||
close_tab.assert_not_called()
|
||||
|
||||
def test_read_product_image_urls_returns_all_images_in_page_order(self):
|
||||
cdp = FakeProductCDP("ws-existing", rects=cover_rects(3, prefix="main"))
|
||||
|
||||
images = editor.read_product_image_urls(cdp)
|
||||
|
||||
self.assertEqual(
|
||||
[
|
||||
{"index": 1, "src": "https://susercontent.com/main-0.jpg"},
|
||||
{"index": 2, "src": "https://susercontent.com/main-1.jpg"},
|
||||
{"index": 3, "src": "https://susercontent.com/main-2.jpg"},
|
||||
],
|
||||
images,
|
||||
)
|
||||
|
||||
def test_click_update_confirms_shopee_update_modal(self):
|
||||
cdp = FakeUpdateCDP(confirm_present=True, confirm_click=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user