Skip to content

Commit b5615d4

Browse files
authored
Feat: Display Tests Report when running plan (#666)
1 parent 1cd49da commit b5615d4

4 files changed

Lines changed: 92 additions & 41 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import clsx from 'clsx'
2+
import { EnumVariant, type Variant } from '~/types/enum'
3+
4+
export default function Banner({
5+
variant,
6+
headline,
7+
description,
8+
}: {
9+
variant: Variant
10+
description?: string
11+
headline?: string
12+
}): JSX.Element {
13+
return (
14+
<div className="mt-4 mb-2 flex items-center w-full text-sm">
15+
<div
16+
className={clsx(
17+
'p-4 w-full h-full border-2 rounded-lg',
18+
variant === EnumVariant.Primary &&
19+
'bg-primary-10 border-primary-400 text-primary-600',
20+
variant === EnumVariant.Secondary &&
21+
'bg-secondary-10 border-secondary-400 text-secondary-600',
22+
variant === EnumVariant.Success &&
23+
'bg-success-10 border-success-400 text-success-600',
24+
variant === EnumVariant.Warning &&
25+
'bg-warning-10 border-warning-400 text-warning-600',
26+
variant === EnumVariant.Danger &&
27+
'bg-danger-10 border-danger-400 text-danger-600',
28+
variant === EnumVariant.Info &&
29+
'bg-neutral-10 border-neutral-400 text-neutral-400',
30+
)}
31+
>
32+
{headline != null && (
33+
<h4 className="mb-2 font-bold text-lg">{headline}</h4>
34+
)}
35+
{description != null && <p className="text-prose">{description}</p>}
36+
</div>
37+
</div>
38+
)
39+
}
Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import clsx from 'clsx'
1+
import Banner from '@components/banner/Banner'
22
import { useStoreContext } from '~/context/context'
3-
import { EnumVariant, type Variant } from '~/types/enum'
3+
import { EnumVariant } from '~/types/enum'
44

55
export default function Plan({ error }: { error?: Error }): JSX.Element {
66
const environment = useStoreContext(s => s.environment)
@@ -32,40 +32,3 @@ export default function Plan({ error }: { error?: Error }): JSX.Element {
3232
</div>
3333
)
3434
}
35-
36-
function Banner({
37-
variant,
38-
headline,
39-
description,
40-
}: {
41-
variant: Variant
42-
description?: string
43-
headline?: string
44-
}): JSX.Element {
45-
return (
46-
<div className="mt-4 mb-2 flex items-center w-full text-sm">
47-
<div
48-
className={clsx(
49-
'p-4 w-full h-full border-2 rounded-lg',
50-
variant === EnumVariant.Primary &&
51-
'bg-primary-10 border-primary-400 text-primary-600',
52-
variant === EnumVariant.Secondary &&
53-
'bg-secondary-10 border-secondary-400 text-secondary-600',
54-
variant === EnumVariant.Success &&
55-
'bg-success-10 border-success-400 text-success-600',
56-
variant === EnumVariant.Warning &&
57-
'bg-warning-10 border-warning-400 text-warning-600',
58-
variant === EnumVariant.Danger &&
59-
'bg-danger-10 border-danger-400 text-danger-600',
60-
variant === EnumVariant.Info &&
61-
'bg-neutral-10 border-neutral-400 text-neutral-400',
62-
)}
63-
>
64-
{headline != null && (
65-
<h4 className="mb-2 font-bold text-lg">{headline}</h4>
66-
)}
67-
{description != null && <p className="text-prose">{description}</p>}
68-
</div>
69-
</div>
70-
)
71-
}

web/client/src/library/components/plan/PlanWizard.tsx

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import { Disclosure } from '@headlessui/react'
22
import { MinusCircleIcon, PlusCircleIcon } from '@heroicons/react/24/solid'
33
import 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'
512
import { type ContextEnvironmentBackfill } from '~/api/client'
613
import { useStoreContext } from '~/context/context'
714
import {
@@ -23,12 +30,17 @@ import { EnumPlanChangeType, usePlan } from './context'
2330
import { getBackfillStepHeadline, isModified } from './help'
2431
import Plan from './Plan'
2532
import PlanChangePreview from './PlanChangePreview'
33+
import { useChannelEvents } from '@api/channels'
34+
import { EnumVariant } from '~/types/enum'
35+
import Banner from '@components/banner/Banner'
2636

2737
export 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"

web/client/src/library/components/plan/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function usePlanPayload({
4040
}, [environment, start, end, isInitialPlanRun, restate_models])
4141

4242
const planOptions = useMemo(() => {
43-
if (environment.isInitial) return { skip_tests: true }
43+
if (environment.isInitial) return { skip_tests: false }
4444
if (environment.isDefault) return { skip_tests }
4545

4646
return {

0 commit comments

Comments
 (0)