fix(web): normalize server addresses before connecting
This commit is contained in:
@@ -280,6 +280,9 @@ const collectMetrics = async () => page.evaluate(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await page.goto(`http://127.0.0.1:${port}/`, { waitUntil: 'networkidle' })
|
await page.goto(`http://127.0.0.1:${port}/`, { waitUntil: 'networkidle' })
|
||||||
|
await page.locator('.login-form input').first().fill('localhost:9150')
|
||||||
|
await page.waitForSelector('.connection-card.online')
|
||||||
|
const loginConnectionStatus = await page.locator('.connection-card').textContent()
|
||||||
await page.screenshot({ path: 'test-results/login-react-acro.png', fullPage: true })
|
await page.screenshot({ path: 'test-results/login-react-acro.png', fullPage: true })
|
||||||
await page.locator('.login-form-panel .arco-btn-primary').click()
|
await page.locator('.login-form-panel .arco-btn-primary').click()
|
||||||
await page.waitForSelector('.workbench-shell')
|
await page.waitForSelector('.workbench-shell')
|
||||||
@@ -415,6 +418,7 @@ console.log(JSON.stringify({
|
|||||||
|
|
||||||
const failures = []
|
const failures = []
|
||||||
const metrics = workspaceMetrics
|
const metrics = workspaceMetrics
|
||||||
|
if (!loginConnectionStatus?.includes('连接正常')) failures.push(`scheme-less server address must connect, got ${JSON.stringify(loginConnectionStatus)}`)
|
||||||
if (errors.length) failures.push(`console errors: ${errors.join('; ')}`)
|
if (errors.length) failures.push(`console errors: ${errors.join('; ')}`)
|
||||||
if (metrics.statusbarHeight !== 32) failures.push(`expected statusbar height 32, got ${metrics.statusbarHeight}`)
|
if (metrics.statusbarHeight !== 32) failures.push(`expected statusbar height 32, got ${metrics.statusbarHeight}`)
|
||||||
if (!metrics.statusName) failures.push('expected authenticated status label')
|
if (!metrics.statusName) failures.push('expected authenticated status label')
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ function fallbackErrorMessage(status: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function normalizeBaseUrl(value: string) {
|
export function normalizeBaseUrl(value: string) {
|
||||||
const trimmed = value.trim()
|
const normalized = value.trim().replace(/\/+$/, '')
|
||||||
return trimmed.replace(/\/+$/, '')
|
if (!normalized || /^https?:\/\//i.test(normalized)) return normalized
|
||||||
|
return `http://${normalized}`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user