mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-18 19:16:22 +00:00
fix: address review feedback for PR #610
This commit is contained in:
@@ -1,12 +1,8 @@
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { defineWebExtConfig } from 'wxt'
|
||||
|
||||
// biome-ignore lint/style/noProcessEnv: config file needs env access
|
||||
const env = process.env
|
||||
|
||||
const _MONOREPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), '../..')
|
||||
|
||||
const chromiumArgs = [
|
||||
'--use-mock-keychain',
|
||||
'--show-component-extension-options',
|
||||
|
||||
@@ -12,13 +12,12 @@ interface StatusDeps {
|
||||
}
|
||||
|
||||
export function createStatusRoute(deps: StatusDeps = {}) {
|
||||
const cdpConnected = deps.browser?.isCdpConnected()
|
||||
|
||||
return new Hono().get('/', (c) =>
|
||||
c.json(
|
||||
return new Hono().get('/', (c) => {
|
||||
const cdpConnected = deps.browser?.isCdpConnected()
|
||||
return c.json(
|
||||
cdpConnected === undefined
|
||||
? { status: 'ok' }
|
||||
: { status: 'ok', cdpConnected },
|
||||
),
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -161,6 +161,10 @@ function parseCliArgs(argv: string[]): ConfigResult<ParsedCliArgs> {
|
||||
)
|
||||
}
|
||||
|
||||
if (opts.extensionPort !== undefined) {
|
||||
console.warn('Warning: --extension-port is deprecated and has no effect.')
|
||||
}
|
||||
|
||||
const cwd = process.cwd()
|
||||
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 BrowserOS
|
||||
*/
|
||||
|
||||
import { describe, it } from 'bun:test'
|
||||
import assert from 'node:assert'
|
||||
|
||||
import { createStatusRoute } from '../../../src/api/routes/status'
|
||||
|
||||
describe('createStatusRoute', () => {
|
||||
it('returns status ok when no browser is provided', async () => {
|
||||
const route = createStatusRoute()
|
||||
const response = await route.request('/')
|
||||
|
||||
assert.strictEqual(response.status, 200)
|
||||
const body = await response.json()
|
||||
assert.deepStrictEqual(body, { status: 'ok' })
|
||||
})
|
||||
|
||||
it('reads CDP connectivity on each request', async () => {
|
||||
let connected = false
|
||||
const route = createStatusRoute({
|
||||
browser: {
|
||||
isCdpConnected: () => connected,
|
||||
} as never,
|
||||
})
|
||||
|
||||
const firstResponse = await route.request('/')
|
||||
assert.deepStrictEqual(await firstResponse.json(), {
|
||||
status: 'ok',
|
||||
cdpConnected: false,
|
||||
})
|
||||
|
||||
connected = true
|
||||
|
||||
const secondResponse = await route.request('/')
|
||||
assert.deepStrictEqual(await secondResponse.json(), {
|
||||
status: 'ok',
|
||||
cdpConnected: true,
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -80,6 +80,30 @@ describe('loadServerConfig', () => {
|
||||
assert.strictEqual(result.value.cdpPort, null)
|
||||
assert.strictEqual(result.value.extensionPort, null)
|
||||
})
|
||||
|
||||
it('warns when --extension-port is provided', () => {
|
||||
const warnings: string[] = []
|
||||
const originalWarn = console.warn
|
||||
console.warn = (message?: unknown) => {
|
||||
warnings.push(String(message))
|
||||
}
|
||||
|
||||
try {
|
||||
const result = loadServerConfig([
|
||||
'bun',
|
||||
'src/index.ts',
|
||||
'--server-port=9223',
|
||||
'--extension-port=9224',
|
||||
])
|
||||
|
||||
assert.strictEqual(result.ok, true)
|
||||
assert.deepStrictEqual(warnings, [
|
||||
'Warning: --extension-port is deprecated and has no effect.',
|
||||
])
|
||||
} finally {
|
||||
console.warn = originalWarn
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('environment variables', () => {
|
||||
|
||||
Reference in New Issue
Block a user