AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(flows): Test Trigger stays clickable while a test runs and reopens the test panel (#15475)
Bartosz Majewskib49bbe0cfcb2
diff --git a/packages/web/src/app/builder/test-step/test-step-cta-button.tsx b/packages/web/src/app/builder/test-step/test-step-cta-button.tsxindex 7e41ff9759d..747aeca60c1 100644--- a/packages/web/src/app/builder/test-step/test-step-cta-button.tsx+++ b/packages/web/src/app/builder/test-step/test-step-cta-button.tsx@@ -12,6 +12,7 @@ import { useContext, useEffect } from 'react';import { toast } from 'sonner';import { useBuilderStateContext } from '@/app/builder/builder-hooks';+import { LoadingSpinner } from '@/components/custom/spinner';import { Button } from '@/components/ui/button';import { pieceSelectorUtils } from '@/features/pieces';@@ -27,21 +28,14 @@ const SOFT_PRIMARY_CTA_CLASSES ='w-full justify-center bg-accent-3 enabled:hover:bg-accent-4 enabled:hover:text-accent-11 text-accent-11 border-accent-6';const TestStepCTAButton = () => {- const [- selectedStep,- flowVersion,- isStepBeingTested,- setStepDataPanelOpen,- run,- saving,- ] = useBuilderStateContext((state) => [- state.selectedStep,- state.flowVersion,- state.isStepBeingTested,- state.setStepDataPanelOpen,- state.run,- state.saving,- ]);+ const [selectedStep, flowVersion, setStepDataPanelOpen, run, saving] =+ useBuilderStateContext((state) => [+ state.selectedStep,+ state.flowVersion,+ state.setStepDataPanelOpen,+ state.run,+ state.saving,+ ]);const currentStep = selectedStep? flowStructureUtil.getStep(selectedStep, flowVersion.trigger)@@ -54,7 +48,6 @@ const TestStepCTAButton = () => {const sampleDataExists = !isNil(currentStep.settings?.sampleData?.lastTestDate,);- const stepIsRunning = isStepBeingTested(currentStep.name);const onOpenPanel = () => setStepDataPanelOpen(true);if (isFlowAction(currentStep)) {@@ -81,7 +74,6 @@ const TestStepCTAButton = () => {return (<TriggerCTAButtonsampleDataExists={sampleDataExists}- stepIsRunning={stepIsRunning}stepIsValid={currentStep.valid !== false}onOpenPanel={onOpenPanel}saving={saving}@@ -119,7 +111,8 @@ const ActionCTAButton = ({const stepIsValid = currentStep.valid !== false;const { isLoadingDynamicProperties } = useContext(DynamicPropertiesContext);const runner = useActionTestRunner();- useConfigureStepShortcutToast(stepIsValid);+ const runnerBusy = runner?.isTesting ?? false;+ useConfigureStepShortcutToast(stepIsValid || runnerBusy);const fireTest = () => {onOpenPanel();@@ -144,10 +137,10 @@ const ActionCTAButton = ({);}- if (sampleDataExists) {- const retestDisabled = saving || !stepIsValid || isLoadingDynamicProperties;- return (- <CTAShell>+ const testDisabled = saving || !stepIsValid || isLoadingDynamicProperties;+ return (+ <CTAShell>+ {sampleDataExists && (<Buttonvariant="outline"onClick={onOpenPanel}@@ -157,48 +150,36 @@ const ActionCTAButton = ({>{t('Show Data')}</Button>+ )}+ {runnerBusy ? (+ <TestInProgressButton+ label={t('Testing...')}+ onOpenPanel={onOpenPanel}+ testId="test-step-button"+ />+ ) : (<TestButtonTooltip saving={saving} invalid={!stepIsValid}><Buttonvariant="outline"onClick={fireTest}- disabled={retestDisabled}+ disabled={testDisabled}keyboardShortcut="G"onKeyboardShortcut={fireTest}className={SOFT_PRIMARY_CTA_CLASSES}size="sm"+ data-testid="test-step-button"><Play className="size-4 fill-current" />- {t('Retest Step')}+ {sampleDataExists ? t('Retest Step') : t('Test Step')}</Button></TestButtonTooltip>- </CTAShell>- );- }-- const testDisabled = !stepIsValid || saving || isLoadingDynamicProperties;- return (- <CTAShell>- <TestButtonTooltip saving={saving} invalid={!stepIsValid}>- <Button- variant="outline"- onClick={fireTest}- disabled={testDisabled}- keyboardShortcut="G"- onKeyboardShortcut={fireTest}- className={SOFT_PRIMARY_CTA_CLASSES}- size="sm"- >- <Play className="size-4 fill-current" />- {t('Test Step')}- </Button>- </TestButtonTooltip>+ )}</CTAShell>);};type TriggerCTAButtonProps = {sampleDataExists: boolean;- stepIsRunning: boolean;stepIsValid: boolean;onOpenPanel: () => void;saving: boolean;@@ -207,31 +188,20 @@ type TriggerCTAButtonProps = {const TriggerCTAButton = ({sampleDataExists,- stepIsRunning,stepIsValid,onOpenPanel,saving,hasRun,}: TriggerCTAButtonProps) => {- const { isLoadingDynamicProperties } = useContext(DynamicPropertiesContext);const runner = useTriggerTestRunner();- useConfigureStepShortcutToast(stepIsValid);+ const runnerBusy = runner?.isTesting ?? false;+ useConfigureStepShortcutToast(stepIsValid || runnerBusy);const fireTest = () => {onOpenPanel();runner?.fireTest();};- const runnerBusy = runner?.isTesting ?? false;- const runnerReady = runner?.canFireTest ?? false;- const testDisabled =- !stepIsValid ||- saving ||- isLoadingDynamicProperties ||- stepIsRunning ||- runnerBusy ||- !runnerReady;-if (hasRun) {return (<CTAShell>@@ -248,9 +218,11 @@ const TriggerCTAButton = ({);}- if (sampleDataExists) {- return (- <CTAShell>+ const runnerReady = runner?.canFireTest ?? false;+ const testDisabled = saving || !runnerReady;+ return (+ <CTAShell>+ {sampleDataExists && (<Buttonvariant="outline"onClick={onOpenPanel}@@ -260,6 +232,14 @@ const TriggerCTAButton = ({>{t('Show Data')}</Button>+ )}+ {runnerBusy ? (+ <TestInProgressButton+ label={t('Testing Trigger')}+ onOpenPanel={onOpenPanel}+ testId="test-trigger-button"+ />+ ) : (<TestButtonTooltip saving={saving} invalid={!stepIsValid}><Buttonvariant="outline"@@ -269,32 +249,13 @@ const TriggerCTAButton = ({onKeyboardShortcut={fireTest}className={SOFT_PRIMARY_CTA_CLASSES}size="sm"+ data-testid="test-trigger-button"><Play className="size-4 fill-current" />- {t('Retest Trigger')}+ {sampleDataExists ? t('Retest Trigger') : t('Test Trigger')}</Button></TestButtonTooltip>- </CTAShell>- );- }-- return (- <CTAShell>- <TestButtonTooltip saving={saving} invalid={!stepIsValid}>- <Button- variant="outline"- onClick={fireTest}- disabled={testDisabled}- keyboardShortcut="G"- onKeyboardShortcut={fireTest}- className={SOFT_PRIMARY_CTA_CLASSES}- size="sm"- data-testid="test-trigger-button"- >- <Play className="size-4 fill-current" />- {t('Test Trigger')}- </Button>- </TestButtonTooltip>+ )}</CTAShell>);};@@ -314,6 +275,31 @@ const useConfigureStepShortcutToast = (stepIsValid: boolean) => {}, [stepIsValid]);};+type TestInProgressButtonProps = {+ label: string;+ onOpenPanel: () => void;+ testId: string;+};++const TestInProgressButton = ({+ label,+ onOpenPanel,+ testId,+}: TestInProgressButtonProps) => (+ <Button+ variant="outline"+ onClick={onOpenPanel}+ keyboardShortcut="G"+ onKeyboardShortcut={onOpenPanel}+ className={SOFT_PRIMARY_CTA_CLASSES}+ size="sm"+ data-testid={testId}+ >+ <LoadingSpinner className="size-4 stroke-current" />+ {label}+ </Button>+);+const CTAShell = ({ children }: { children: React.ReactNode }) => (<divdata-test-panel-trigger