From 20daecc9cf2b5f6a58057626570c9974c4b98051 Mon Sep 17 00:00:00 2001 From: huanghuoguoguo <60681390+huanghuoguoguo@users.noreply.github.com> Date: Sat, 17 Oct 2026 15:00:41 +0800 Subject: [PATCH] test(web): replace self-confirming progress checks and remove duplicates --- web/tests/e2e/crud-smoke.spec.ts | 36 ---------- web/tests/unit/install-progress.test.mjs | 70 ++++++++++---------- web/tests/unit/oss-cloud-ui-privacy.test.mjs | 12 ---- 3 files changed, 35 insertions(+), 83 deletions(-) diff --git a/web/tests/e2e/crud-smoke.spec.ts b/web/tests/e2e/crud-smoke.spec.ts index ba0d3b176..004b8cc12 100644 --- a/web/tests/e2e/crud-smoke.spec.ts +++ b/web/tests/e2e/crud-smoke.spec.ts @@ -1464,39 +1464,3 @@ test.describe('cross-resource flows', () => { ).toBeVisible(); }); }); - -test.describe('empty states', () => { - test('shows empty state when no bots exist', async ({ page }) => { - await installLangBotApiMocks(page, { authenticated: true }); - - await page.goto('/home/bots'); - await expect(page.getByText('Select a bot from the sidebar')).toBeVisible(); - }); - - test('shows empty state when no processors exist', async ({ page }) => { - await installLangBotApiMocks(page, { authenticated: true }); - - await page.goto('/home/agents'); - await expect( - page.getByText('Select a processor from the sidebar'), - ).toBeVisible(); - }); - - test('shows empty state when no knowledge bases exist', async ({ page }) => { - await installLangBotApiMocks(page, { authenticated: true }); - - await page.goto('/home/knowledge'); - await expect( - page.getByText('Select a knowledge base from the sidebar'), - ).toBeVisible(); - }); - - test('shows empty state when no MCP servers exist', async ({ page }) => { - await installLangBotApiMocks(page, { authenticated: true }); - - await page.goto('/home/mcp'); - await expect( - page.getByText('Select an MCP server from the sidebar'), - ).toBeVisible(); - }); -}); diff --git a/web/tests/unit/install-progress.test.mjs b/web/tests/unit/install-progress.test.mjs index 84f176ed6..1bc5bdeee 100644 --- a/web/tests/unit/install-progress.test.mjs +++ b/web/tests/unit/install-progress.test.mjs @@ -25,7 +25,6 @@ new Function('require', 'module', 'exports', compiled)( const { InstallStage, - INSTALL_PROGRESS_CAP, STAGE_PROGRESS_RANGE, computeStageProgress, mapActionToStage, @@ -92,27 +91,22 @@ test('measured byte counts stay inside the download stage range', () => { ); }); -test('fallback drift never spills into the next stage range', () => { - for (const stage of [ - InstallStage.DOWNLOADING, - InstallStage.INSTALLING_DEPS, - InstallStage.INITIALIZING, - InstallStage.LAUNCHING, - ]) { - const [start, end] = STAGE_PROGRESS_RANGE[stage]; - const progress = computeStageProgress({ - stage, - stageElapsedSeconds: 100000, - }); +test('fallback drift advances within fixed stage boundaries', () => { + const stages = [ + [InstallStage.DOWNLOADING, 5, 25, 44], + [InstallStage.INSTALLING_DEPS, 45, 65, 84], + [InstallStage.INITIALIZING, 85, 87, 87], + [InstallStage.LAUNCHING, 88, 92, 96], + ]; - assert.ok( - progress >= start && progress <= end, - `stage ${stage} produced ${progress}, outside [${start}, ${end}]`, - ); - assert.ok( - progress < INSTALL_PROGRESS_CAP, - `stage ${stage} must not reach the completion cap on drift alone`, - ); + for (const [stage, start, midpoint, ceiling] of stages) { + const progressAt = (stageElapsedSeconds) => + computeStageProgress({ stage, stageElapsedSeconds }); + assert.equal(progressAt(0), start); + assert.equal(progressAt(1), start); + assert.equal(progressAt(4), start + 2); + assert.equal(progressAt((midpoint - start) * 2), midpoint); + assert.equal(progressAt(100000), ceiling); } }); @@ -173,18 +167,24 @@ test('measured bytes override Host coarse progress and fallback stays bounded', } }); -test('a missing or zero download total falls back to bounded drift', () => { - const [start, end] = STAGE_PROGRESS_RANGE[InstallStage.DOWNLOADING]; - - const progress = computeStageProgress({ - stage: InstallStage.DOWNLOADING, - downloadCurrent: 10, - downloadTotal: 0, - stageElapsedSeconds: 100000, - }); - - assert.ok( - progress >= start && progress <= end, - `expected progress within [${start}, ${end}], received ${progress}`, - ); +test('a missing or zero download total advances using fallback drift', () => { + for (const downloadTotal of [undefined, 0]) { + for (const [stageElapsedSeconds, expected] of [ + [0, 5], + [4, 7], + [20, 15], + [100000, 44], + ]) { + assert.equal( + computeStageProgress({ + stage: InstallStage.DOWNLOADING, + downloadCurrent: 10, + downloadTotal, + stageElapsedSeconds, + }), + expected, + `download total ${downloadTotal}, elapsed ${stageElapsedSeconds}s`, + ); + } + } }); diff --git a/web/tests/unit/oss-cloud-ui-privacy.test.mjs b/web/tests/unit/oss-cloud-ui-privacy.test.mjs index 41a81e375..4fd65d326 100644 --- a/web/tests/unit/oss-cloud-ui-privacy.test.mjs +++ b/web/tests/unit/oss-cloud-ui-privacy.test.mjs @@ -31,18 +31,6 @@ const authenticatedPluginResourceSource = readSource( 'src/hooks/useAuthenticatedPluginResource.ts', ); -test('hides the entire workspace switcher slot for a singleton local workspace', () => { - assert.match(homeSidebarSource, /useWorkspaceBootstrap/); - assert.match( - homeSidebarSource, - /const showWorkspaceSwitcher\s*=\s*workspaces\.length\s*>\s*1\s*\|\|\s*currentWorkspace\?\.workspace\.source\s*===\s*'cloud_projection'/, - ); - assert.match( - homeSidebarSource, - /\{showWorkspaceSwitcher\s*&&\s*\(\s*