feat: show generation prompts in previews and fix fluid page layout
This commit is contained in:
+20
-2
@@ -1,6 +1,7 @@
|
||||
"""真实浏览器 + 本地模拟上游的端到端验收,不访问付费服务。"""
|
||||
|
||||
import asyncio
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
@@ -107,7 +108,8 @@ class BrowserTests(unittest.TestCase):
|
||||
|
||||
page.goto(self.url + "/create.html")
|
||||
expect(page.locator("#model")).to_have_value("vendor/test-image")
|
||||
page.locator("#prompt").fill("a test image")
|
||||
prompt = "a test image\n<script>window.promptInjected = true</script>"
|
||||
page.locator("#prompt").fill(prompt)
|
||||
page.locator("#count").select_option("2")
|
||||
page.locator("#generateBtn").click()
|
||||
expect(page.locator("#resultStatus")).to_contain_text("生成成功 · 2 张")
|
||||
@@ -132,6 +134,9 @@ class BrowserTests(unittest.TestCase):
|
||||
page.locator(".folder-card").click()
|
||||
expect(page.locator("#galleryGrid img")).to_have_count(2)
|
||||
page.locator("#galleryGrid .gal-item").first.click()
|
||||
expect(page.locator("#lbPrompt")).to_be_visible()
|
||||
expect(page.locator("#lbPromptText")).to_have_text(prompt)
|
||||
self.assertFalse(page.evaluate("window.promptInjected === true"))
|
||||
page.on("dialog", lambda dialog: dialog.accept())
|
||||
page.locator("#lbDelete").click()
|
||||
expect(page.locator("#galleryGrid img")).to_have_count(1)
|
||||
@@ -141,7 +146,7 @@ class BrowserTests(unittest.TestCase):
|
||||
expect(page.locator("#mdView")).to_contain_text("调用流程")
|
||||
page.locator("#rawBtn").click()
|
||||
expect(page.locator("#rawView")).to_be_visible()
|
||||
for width in (1440, 390):
|
||||
for width in (2560, 1440, 390):
|
||||
page.set_viewport_size({"width": width, "height": 900})
|
||||
for name in ("index", "create", "providers", "models", "records", "skills"):
|
||||
page.goto(self.url + f"/{name}.html")
|
||||
@@ -149,12 +154,25 @@ class BrowserTests(unittest.TestCase):
|
||||
page.wait_for_load_state("networkidle")
|
||||
overflow = page.evaluate("document.documentElement.scrollWidth > innerWidth")
|
||||
self.assertFalse(overflow, f"{name} 页面在 {width}px 出现横向溢出")
|
||||
content = page.locator(".app-content").bounding_box()
|
||||
body = page.locator(".page-body").bounding_box()
|
||||
self.assertAlmostEqual(body["width"], content["width"], delta=1,
|
||||
msg=f"{name} 页面在 {width}px 未铺满内容区域")
|
||||
|
||||
page.goto(self.url + "/providers.html")
|
||||
page.locator('[data-act="del"]').click()
|
||||
page.locator("#confirmDeleteBtn").click()
|
||||
expect(page.locator("#providerList")).not_to_contain_text("浏览器测试供应商")
|
||||
self.assertEqual(errors, [])
|
||||
legacy = Path(self.runtime.name) / "output" / "legacy-preview"
|
||||
legacy.mkdir(exist_ok=True)
|
||||
(legacy / "legacy.png").write_bytes(base64.b64decode(PNG))
|
||||
page.goto(self.url + "/index.html")
|
||||
page.locator(".folder-card").filter(has_text="legacy-preview").click()
|
||||
page.locator("#galleryGrid .gal-item").first.click()
|
||||
expect(page.locator("#lightbox")).to_have_class("lightbox open")
|
||||
expect(page.locator("#lbPrompt")).to_be_hidden()
|
||||
expect(page.locator("#lbPromptText")).to_be_empty()
|
||||
browser.close()
|
||||
|
||||
def test_provider_state_and_default(self):
|
||||
|
||||
Reference in New Issue
Block a user