diff --git a/web/src/BrowserList.jsx b/web/src/BrowserList.jsx
index 04024ea..0e8d58d 100644
--- a/web/src/BrowserList.jsx
+++ b/web/src/BrowserList.jsx
@@ -30,7 +30,7 @@ const statusLabels = {
}
function Status({ state }) {
- const label = statusLabels[state]
+ const label = Object.hasOwn(statusLabels, state) ? statusLabels[state] : undefined
const color = state === 'running' ? 'success.main' : state === 'exited' ? 'warning.main' : 'text.secondary'
return {label || '未知状态'}{label ? null : {state}}
}
diff --git a/web/src/BrowserList.test.jsx b/web/src/BrowserList.test.jsx
index abfafed..77f0bb8 100644
--- a/web/src/BrowserList.test.jsx
+++ b/web/src/BrowserList.test.jsx
@@ -46,6 +46,14 @@ describe('BrowserList', () => {
expect(rawStates[0].className).toContain('MuiTypography-caption')
})
+ it.each(['constructor', 'toString', '__proto__'])('treats prototype key %s as an unknown state', async (state) => {
+ const protoRuntime = { ...runtimes[0], state }
+ render()
+
+ expect(await screen.findAllByText('未知状态')).toHaveLength(2)
+ expect(screen.getAllByText(state)).toHaveLength(2)
+ })
+
it('disables invalid lifecycle actions and sends explicit domain actions', async () => {
const dataProvider = provider()
render()
diff --git a/web/tests/responsive.e2e.js b/web/tests/responsive.e2e.js
index 4035319..271437b 100644
--- a/web/tests/responsive.e2e.js
+++ b/web/tests/responsive.e2e.js
@@ -1,5 +1,14 @@
import { expect, test } from '@playwright/test'
+const runtime = {
+ id: 'container-a',
+ name: 'account-a',
+ state: 'running',
+ status: 'Up',
+ profile: 'creatorhub-profile-account-a',
+ endpoint: 'http://account-a:9222',
+}
+
test('keeps the create form inside a 900px viewport', async ({ page }) => {
await page.route('**/api/browsers', route => route.fulfill({ json: [] }))
await page.setViewportSize({ width: 900, height: 800 })
@@ -13,3 +22,17 @@ test('keeps the create form inside a 900px viewport', async ({ page }) => {
expect(box).not.toBeNull()
expect(box.x + box.width).toBeLessThanOrEqual(900)
})
+
+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] }))
+ const endpoint = page.getByText('http://account-a:9222')
+
+ await page.setViewportSize({ width: 900, height: 800 })
+ await page.goto('/')
+ await expect(page.getByRole('cell', { name: 'http://account-a:9222' })).toBeVisible()
+ await expect(endpoint.filter({ visible: true })).toHaveCount(1)
+
+ await page.setViewportSize({ width: 599, height: 800 })
+ await expect(page.getByRole('cell', { name: 'http://account-a:9222' })).toBeHidden()
+ await expect(endpoint.filter({ visible: true })).toHaveCount(1)
+})