From 346d174d3174c672eb5a9da6201546277f86fbe6 Mon Sep 17 00:00:00 2001 From: yyh Date: Sat, 9 May 2026 12:33:52 +0800 Subject: [PATCH] test(web): align popover tooltip assertions --- .../billing/cloud-plan-payment-flow.test.tsx | 22 ++++++++++--------- .../__tests__/param-config-content.spec.tsx | 3 +-- .../form/components/__tests__/label.spec.tsx | 4 ++-- .../cloud-plan-item/__tests__/index.spec.tsx | 2 +- .../list/__tests__/index.spec.tsx | 7 ++++-- .../list/item/__tests__/index.spec.tsx | 7 ++++-- ...itch-credential-in-load-balancing.spec.tsx | 8 ++++--- .../__tests__/status-indicators.spec.tsx | 18 +++++++-------- .../__tests__/integration.spec.tsx | 4 ++-- 9 files changed, 42 insertions(+), 33 deletions(-) diff --git a/web/__tests__/billing/cloud-plan-payment-flow.test.tsx b/web/__tests__/billing/cloud-plan-payment-flow.test.tsx index de145a73e6..7682de5f88 100644 --- a/web/__tests__/billing/cloud-plan-payment-flow.test.tsx +++ b/web/__tests__/billing/cloud-plan-payment-flow.test.tsx @@ -90,6 +90,8 @@ const renderCloudPlanItem = ({ ) } +const getPlanButton = (name: string) => screen.getByRole('button', { name }) + // ═══════════════════════════════════════════════════════════════════════════════ describe('Cloud Plan Payment Flow', () => { beforeEach(() => { @@ -180,30 +182,30 @@ describe('Cloud Plan Payment Flow', () => { it('should disable sandbox button when user is on professional plan (downgrade)', () => { renderCloudPlanItem({ currentPlan: Plan.professional, plan: Plan.sandbox }) - const button = screen.getByRole('button') + const button = getPlanButton('billing.plansCommon.startForFree') expect(button).toBeDisabled() }) it('should disable sandbox and professional buttons when user is on team plan', () => { const { unmount } = renderCloudPlanItem({ currentPlan: Plan.team, plan: Plan.sandbox }) - expect(screen.getByRole('button')).toBeDisabled() + expect(getPlanButton('billing.plansCommon.startForFree')).toBeDisabled() unmount() renderCloudPlanItem({ currentPlan: Plan.team, plan: Plan.professional }) - expect(screen.getByRole('button')).toBeDisabled() + expect(getPlanButton('billing.plansCommon.startBuilding')).toBeDisabled() }) it('should not disable current paid plan button (for invoice management)', () => { renderCloudPlanItem({ currentPlan: Plan.professional, plan: Plan.professional }) - const button = screen.getByRole('button') + const button = getPlanButton('billing.plansCommon.currentPlan') expect(button).not.toBeDisabled() }) it('should enable higher-tier plan buttons for upgrade', () => { renderCloudPlanItem({ currentPlan: Plan.sandbox, plan: Plan.team }) - const button = screen.getByRole('button') + const button = getPlanButton('billing.plansCommon.getStarted') expect(button).not.toBeDisabled() }) }) @@ -219,7 +221,7 @@ describe('Cloud Plan Payment Flow', () => { planRange: PlanRange.monthly, }) - const button = screen.getByRole('button') + const button = getPlanButton('billing.plansCommon.startBuilding') await user.click(button) await waitFor(() => { @@ -235,7 +237,7 @@ describe('Cloud Plan Payment Flow', () => { planRange: PlanRange.yearly, }) - const button = screen.getByRole('button') + const button = getPlanButton('billing.plansCommon.getStarted') await user.click(button) await waitFor(() => { @@ -247,7 +249,7 @@ describe('Cloud Plan Payment Flow', () => { const user = userEvent.setup() renderCloudPlanItem({ currentPlan: Plan.professional, plan: Plan.professional }) - const button = screen.getByRole('button') + const button = getPlanButton('billing.plansCommon.currentPlan') await user.click(button) await waitFor(() => { @@ -261,7 +263,7 @@ describe('Cloud Plan Payment Flow', () => { const user = userEvent.setup() renderCloudPlanItem({ currentPlan: Plan.sandbox, plan: Plan.sandbox }) - const button = screen.getByRole('button') + const button = getPlanButton('billing.plansCommon.currentPlan') await user.click(button) // Wait a tick and verify no actions were taken @@ -279,7 +281,7 @@ describe('Cloud Plan Payment Flow', () => { const user = userEvent.setup() renderCloudPlanItem({ currentPlan: Plan.sandbox, plan: Plan.professional }) - const button = screen.getByRole('button') + const button = getPlanButton('billing.plansCommon.startBuilding') await user.click(button) await waitFor(() => { diff --git a/web/app/components/base/features/new-feature-panel/text-to-speech/__tests__/param-config-content.spec.tsx b/web/app/components/base/features/new-feature-panel/text-to-speech/__tests__/param-config-content.spec.tsx index 754bde98a6..b4d5beefa6 100644 --- a/web/app/components/base/features/new-feature-panel/text-to-speech/__tests__/param-config-content.spec.tsx +++ b/web/app/components/base/features/new-feature-panel/text-to-speech/__tests__/param-config-content.spec.tsx @@ -110,8 +110,7 @@ describe('ParamConfigContent', () => { const languageLabel = screen.getByText(/voice\.voiceSettings\.language/) expect(languageLabel)!.toBeInTheDocument() - const tooltip = languageLabel.parentElement as HTMLElement - expect(tooltip.querySelector('svg'))!.toBeInTheDocument() + expect(screen.getByRole('button', { name: /voice\.voiceSettings\.resolutionTooltip/ }))!.toBeInTheDocument() }) it('should display language listbox button', () => { diff --git a/web/app/components/base/form/components/__tests__/label.spec.tsx b/web/app/components/base/form/components/__tests__/label.spec.tsx index a3f564dafe..99471e5171 100644 --- a/web/app/components/base/form/components/__tests__/label.spec.tsx +++ b/web/app/components/base/form/components/__tests__/label.spec.tsx @@ -41,8 +41,8 @@ describe('Label', () => { const tooltipText = 'Test Tooltip' render(