refactor: migrate browser gateway to native xvfb

This commit is contained in:
2026-09-18 16:50:18 +08:00
parent 7e3808cf4c
commit e8f2c192ba
86 changed files with 6104 additions and 5323 deletions
+6 -6
View File
@@ -6,7 +6,7 @@ const runtime = {
name: 'account-a',
state: 'running',
status: 'Up',
image_version: '148.0.0.1',
browser_version: '148.0.0.1',
fingerprint: { seed: 1000 },
profile: 'creatorhub-profile-account-a',
endpoint: 'http://account-a:9222',
@@ -22,7 +22,7 @@ test.beforeEach(async ({ page }) => {
test('opens social-account and network-exit configuration from the main menu', async ({ page }) => {
await page.route('**/api/browsers', route => route.fulfill({ json: [] }))
await page.route('**/api/gateways', route => route.fulfill({ json: [] }))
await page.route('**/api/browser-images', route => route.fulfill({ json: [] }))
await page.route('**/api/browser-versions', route => route.fulfill({ json: [] }))
await page.route('**/api/phase-a/accounts', route => route.fulfill({ json: [] }))
await page.route('**/api/network-exits', route => route.fulfill({ json: [] }))
await page.setViewportSize({ width: 599, height: 800 })
@@ -42,7 +42,7 @@ test('opens social-account and network-exit configuration from the main menu', a
test('keeps the create form inside a 900px viewport', async ({ page }) => {
await page.route('**/api/browsers', route => route.fulfill({ json: [] }))
await page.route('**/api/gateways', route => route.fulfill({ json: [] }))
await page.route('**/api/browser-images', route => route.fulfill({ json: [] }))
await page.route('**/api/browser-versions', route => route.fulfill({ json: [] }))
await page.route('**/api/phase-a/accounts', route => route.fulfill({ json: [] }))
await page.route('**/api/network-exits', route => route.fulfill({ json: [] }))
await page.setViewportSize({ width: 900, height: 800 })
@@ -60,7 +60,7 @@ test('keeps the create form inside a 900px viewport', async ({ page }) => {
test('shows the CDP endpoint only in the active branch at 900px and 599px', async ({ page }) => {
await page.route('**/api/browsers', route => route.fulfill({ json: [runtime] }))
await page.route('**/api/gateways', route => route.fulfill({ json: [] }))
await page.route('**/api/browser-images', route => route.fulfill({ json: [] }))
await page.route('**/api/browser-versions', route => route.fulfill({ json: [] }))
await page.route('**/api/phase-a/accounts', route => route.fulfill({ json: [] }))
await page.route('**/api/network-exits', route => route.fulfill({ json: [] }))
const endpoint = page.getByText('http://account-a:9222')
@@ -84,7 +84,7 @@ test('enforces browser readiness before starting at 900px', async ({ page }) =>
]
await page.route('**/api/browsers', route => route.fulfill({ json: environments }))
await page.route('**/api/gateways', route => route.fulfill({ json: [] }))
await page.route('**/api/browser-images', route => route.fulfill({ json: [] }))
await page.route('**/api/browser-versions', route => route.fulfill({ json: [] }))
await page.route('**/api/phase-a/accounts', route => route.fulfill({ json: [] }))
await page.route('**/api/network-exits', route => route.fulfill({ json: [] }))
await page.route('**/api/browsers/*/start', route => route.fulfill({ status: 204 }))
@@ -227,7 +227,7 @@ test('keeps task recovery and audit traceable without blind retry at 599px, 900p
return route.fulfill({ json: [listTask] })
})
await page.route('**/api/phase-a/attempts/attempt-a', route => route.fulfill({ json: { ...baseTask.attempts[0], task_id: 'task-a', browser_env_alias: 'env-a', network_exit_id: 'exit-a', binding_version: 4 } }))
await page.route('**/api/browsers/env-a', route => route.fulfill({ json: { alias: 'env-a', name: '店铺环境', account_id: 'account-a', image_version: '148', binding_version: 4, runtime_instance_id: 'runtime-a', network_exit: { id: 'exit-a', health_status: 'healthy' } } }))
await page.route('**/api/browsers/env-a', route => route.fulfill({ json: { alias: 'env-a', name: '店铺环境', account_id: 'account-a', browser_version: '148', binding_version: 4, runtime_instance_id: 'runtime-a', network_exit: { id: 'exit-a', health_status: 'healthy' } } }))
await page.route('**/api/network-exits/exit-a', route => route.fulfill({ json: { id: 'exit-a', protocol: 'socks5', host: 'proxy.example', port: 1080, health_status: 'healthy', version: 2 } }))
await page.route('**/api/phase-a/audit*', route => {
const currentPage = Number(new URL(route.request().url()).searchParams.get('page') || 1)