11import { Disclosure } from '@headlessui/react'
22import { MinusCircleIcon , PlusCircleIcon } from '@heroicons/react/24/solid'
33import clsx from 'clsx'
4- import { type RefObject , Suspense , useCallback , useMemo } from 'react'
4+ import {
5+ type RefObject ,
6+ Suspense ,
7+ useCallback ,
8+ useMemo ,
9+ useEffect ,
10+ useState ,
11+ } from 'react'
512import { type ContextEnvironmentBackfill } from '~/api/client'
613import { useStoreContext } from '~/context/context'
714import {
@@ -23,12 +30,17 @@ import { EnumPlanChangeType, usePlan } from './context'
2330import { getBackfillStepHeadline , isModified } from './help'
2431import Plan from './Plan'
2532import PlanChangePreview from './PlanChangePreview'
33+ import { useChannelEvents } from '@api/channels'
34+ import { EnumVariant } from '~/types/enum'
35+ import Banner from '@components/banner/Banner'
2636
2737export default function PlanWizard ( {
2838 setRefTaskProgress,
2939} : {
3040 setRefTaskProgress : RefObject < HTMLDivElement >
3141} ) : JSX . Element {
42+ const [ subscribe ] = useChannelEvents ( )
43+
3244 const {
3345 backfills,
3446 hasChanges,
@@ -39,6 +51,7 @@ export default function PlanWizard({
3951 removed,
4052 virtualUpdateDescription,
4153 skip_backfill,
54+ skip_tests,
4255 change_categorization,
4356 hasVirtualUpdate,
4457 } = usePlan ( )
@@ -48,6 +61,12 @@ export default function PlanWizard({
4861 const planState = useStorePlan ( s => s . state )
4962 const planAction = useStorePlan ( s => s . action )
5063
64+ const [ testsReport , setTestsReport ] = useState < {
65+ ok : boolean
66+ time : number
67+ message : string
68+ } > ( )
69+
5170 const categories = useMemo (
5271 ( ) =>
5372 Array . from ( change_categorization . values ( ) ) . reduce <
@@ -123,6 +142,14 @@ export default function PlanWizard({
123142 [ backfills , change_categorization , activeBackfill ] ,
124143 )
125144
145+ useEffect ( ( ) => {
146+ const unsubscribeTasks = subscribe ( 'tests' , setTestsReport )
147+
148+ return ( ) => {
149+ unsubscribeTasks ?.( )
150+ }
151+ } , [ ] )
152+
126153 const isFinished = planState === EnumPlanState . Finished
127154 const hasNoChanges = [
128155 hasChanges ,
@@ -151,6 +178,28 @@ export default function PlanWizard({
151178 < Plan . StepOptions className = "w-full" />
152179 ) : (
153180 < >
181+ < PlanWizardStep
182+ headline = "Tests"
183+ description = "Report"
184+ disabled = { environment == null }
185+ >
186+ { planAction === EnumPlanAction . Running ? (
187+ < PlanWizardStepMessage hasSpinner >
188+ Running Tests ...
189+ </ PlanWizardStepMessage >
190+ ) : testsReport == null ? (
191+ < PlanWizardStepMessage >
192+ { skip_tests ? 'Tests Skipped' : 'No Tests' }
193+ </ PlanWizardStepMessage >
194+ ) : (
195+ < Banner
196+ variant = {
197+ testsReport . ok ? EnumVariant . Success : EnumVariant . Danger
198+ }
199+ description = { testsReport . message }
200+ />
201+ ) }
202+ </ PlanWizardStep >
154203 < PlanWizardStep
155204 headline = "Models"
156205 description = "Review Changes"
0 commit comments