fixed day time testing
This commit is contained in:
+35
-2
@@ -245,6 +245,9 @@ function sanitizeSettings(saved = {}) {
|
||||
export default function App() {
|
||||
const [settingsOpen, setSettingsOpen] = useState(false)
|
||||
const [settings, setSettings] = useState(DEFAULT_SETTINGS)
|
||||
const [daytimeTestingToday, setDaytimeTestingToday] = useState(false)
|
||||
const [daytimeTestingHours, setDaytimeTestingHours] = useState('8')
|
||||
const [daytimeTestingDevice, setDaytimeTestingDevice] = useState('CGW453')
|
||||
const [dualDeviceWeekendWeekSelections, setDualDeviceWeekendWeekSelections] = useState({})
|
||||
const [topPriorityDut, setTopPriorityDut] = useState('')
|
||||
const [topPriorityRef, setTopPriorityRef] = useState('')
|
||||
@@ -291,6 +294,10 @@ export default function App() {
|
||||
if (!dualDeviceWeekendWeekEnabled) return []
|
||||
return getWeekendStartDatesForWeek(weekStart, holidaySet)
|
||||
}, [dualDeviceWeekendWeekEnabled, weekStart, holidaySet])
|
||||
const daytimeDateKey = useMemo(
|
||||
() => (daytimeTestingToday ? toKey(new Date()) : null),
|
||||
[daytimeTestingToday],
|
||||
)
|
||||
|
||||
// Fetch schedule for the given weekStart (Monday)
|
||||
const fetchSchedule = useCallback(async (start) => {
|
||||
@@ -413,6 +420,9 @@ export default function App() {
|
||||
setTopPriorityRef('')
|
||||
setLowestPriority('')
|
||||
setStartDateOverride('')
|
||||
setDaytimeTestingToday(false)
|
||||
setDaytimeTestingHours('8')
|
||||
setDaytimeTestingDevice('CGW453')
|
||||
setFailedTests([])
|
||||
setScheduleData({})
|
||||
setPreviousScheduleData({})
|
||||
@@ -435,9 +445,16 @@ export default function App() {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
try {
|
||||
const parsedDaytimeHours = Number.parseInt(String(daytimeTestingHours).trim(), 10)
|
||||
const safeDaytimeHours = Number.isFinite(parsedDaytimeHours)
|
||||
? Math.max(0, Math.min(8, parsedDaytimeHours))
|
||||
: 8
|
||||
const effectiveStartDate = startDateOverride.trim()
|
||||
const result = await api.compileSchedule({
|
||||
start_date: effectiveStartDate || null,
|
||||
daytime_testing_today: daytimeTestingToday,
|
||||
daytime_testing_hours: safeDaytimeHours,
|
||||
daytime_testing_device: daytimeTestingDevice,
|
||||
dual_device_weekend_start_dates: dualDeviceWindowStartDates,
|
||||
top_priority_tests_dut: topPriorityDut.split(',').map(s => s.trim()).filter(Boolean),
|
||||
top_priority_tests_ref: topPriorityRef.split(',').map(s => s.trim()).filter(Boolean),
|
||||
@@ -467,7 +484,7 @@ export default function App() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleRerunDecision(_rerunDuringDay) {
|
||||
function handleRerunDecision(rerunDuringDay) {
|
||||
const appendUnique = (currentValue, incomingValues) => {
|
||||
const existing = currentValue.split(',').map(s => s.trim()).filter(Boolean)
|
||||
const merged = [...new Set([...existing, ...incomingValues])]
|
||||
@@ -488,6 +505,15 @@ export default function App() {
|
||||
setTopPriorityRef(prev => appendUnique(prev, refIncoming))
|
||||
}
|
||||
|
||||
if (rerunDuringDay) {
|
||||
setDaytimeTestingToday(true)
|
||||
if (dutIncoming.length > 0 && refIncoming.length === 0) {
|
||||
setDaytimeTestingDevice('CGW453')
|
||||
} else if (refIncoming.length > 0 && dutIncoming.length === 0) {
|
||||
setDaytimeTestingDevice('CGW452')
|
||||
}
|
||||
}
|
||||
|
||||
setFailedTests([])
|
||||
}
|
||||
|
||||
@@ -521,13 +547,14 @@ export default function App() {
|
||||
<FailedBanner
|
||||
rerunTests={failedTests}
|
||||
onDecision={handleRerunDecision}
|
||||
onClose={() => setFailedTests([])}
|
||||
/>
|
||||
|
||||
<main className="relative flex flex-1 gap-4 p-4 overflow-hidden">
|
||||
<div className="flex-1 min-w-0 flex flex-col">
|
||||
<Calendar
|
||||
scheduleData={calendarScheduleData}
|
||||
daytimeDateKey={null}
|
||||
daytimeDateKey={daytimeDateKey}
|
||||
weekStart={weekStart}
|
||||
onWeekChange={setWeekStart}
|
||||
dualDeviceWeekendWeekEnabled={dualDeviceWeekendWeekEnabled}
|
||||
@@ -545,6 +572,12 @@ export default function App() {
|
||||
|
||||
<RightPanel
|
||||
completionDate={completionDate}
|
||||
daytimeTestingToday={daytimeTestingToday}
|
||||
onDaytimeTestingTodayChange={setDaytimeTestingToday}
|
||||
daytimeTestingHours={daytimeTestingHours}
|
||||
onDaytimeTestingHoursChange={setDaytimeTestingHours}
|
||||
daytimeTestingDevice={daytimeTestingDevice}
|
||||
onDaytimeTestingDeviceChange={setDaytimeTestingDevice}
|
||||
startDateOverride={startDateOverride}
|
||||
onStartDateOverrideChange={setStartDateOverride}
|
||||
topPriorityDut={topPriorityDut}
|
||||
|
||||
@@ -18,10 +18,10 @@ export default function FailedBanner({ rerunTests, onDecision }) {
|
||||
.map(([device, ids]) => `${device}: ${ids.join(', ')}`)
|
||||
|
||||
return (
|
||||
<div className="flex items-start gap-4 px-6 py-3 bg-red-900/70 border-b border-red-700 text-red-100">
|
||||
<div className="flex items-start gap-4 px-6 py-3 bg-yellow-900/35 border-b border-yellow-700/55 text-yellow-100/85">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="w-5 h-5 mt-0.5 shrink-0 text-red-300"
|
||||
className="w-5 h-5 mt-0.5 shrink-0 text-yellow-300/80"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
@@ -39,28 +39,10 @@ export default function FailedBanner({ rerunTests, onDecision }) {
|
||||
{' '}require a rerun — not completed in last overnight window:
|
||||
</p>
|
||||
{deviceSummaries.map((summary) => (
|
||||
<p key={summary} className="text-sm font-mono text-red-200 mt-0.5 truncate">
|
||||
<p key={summary} className="text-sm font-mono text-yellow-200/80 mt-0.5 truncate">
|
||||
{summary}
|
||||
</p>
|
||||
))}
|
||||
<p className="text-sm text-red-300 mt-0.5">
|
||||
Estimated rerun time: <span className="font-semibold text-red-100">{timeStr}</span>
|
||||
{' '}— Schedule rerun during daytime today?
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex gap-2 shrink-0">
|
||||
<button
|
||||
onClick={() => onDecision(true)}
|
||||
className="px-3 py-1 text-sm font-medium bg-red-700 hover:bg-red-600 text-white rounded-md border border-red-500 transition-colors"
|
||||
>
|
||||
Yes
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onDecision(false)}
|
||||
className="px-3 py-1 text-sm font-medium bg-gray-700 hover:bg-gray-600 text-gray-100 rounded-md border border-gray-500 transition-colors"
|
||||
>
|
||||
No
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useState } from 'react'
|
||||
import cgw453Image from '../assets/CGW453.PNG'
|
||||
|
||||
function formatCompletionDate(value) {
|
||||
@@ -16,6 +17,12 @@ function formatCompletionDate(value) {
|
||||
|
||||
export default function RightPanel({
|
||||
completionDate,
|
||||
daytimeTestingToday,
|
||||
onDaytimeTestingTodayChange,
|
||||
daytimeTestingHours,
|
||||
onDaytimeTestingHoursChange,
|
||||
daytimeTestingDevice,
|
||||
onDaytimeTestingDeviceChange,
|
||||
startDateOverride,
|
||||
onStartDateOverrideChange,
|
||||
topPriorityDut,
|
||||
@@ -29,6 +36,7 @@ export default function RightPanel({
|
||||
loading = false,
|
||||
}) {
|
||||
const formattedCompletionDate = formatCompletionDate(completionDate)
|
||||
const [topPriorityOpen, setTopPriorityOpen] = useState(false)
|
||||
|
||||
return (
|
||||
<aside className="flex flex-col gap-4 w-60 shrink-0 pt-8">
|
||||
@@ -47,31 +55,124 @@ export default function RightPanel({
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Top priority */}
|
||||
<div>
|
||||
<label className="block text-[11px] font-semibold uppercase tracking-wider text-gray-500 mb-1.5">
|
||||
Top Priority Tests (DUT - CGW453)
|
||||
</label>
|
||||
<textarea
|
||||
rows={3}
|
||||
value={topPriorityDut}
|
||||
onChange={(e) => onTopPriorityDutChange(e.target.value)}
|
||||
placeholder="P2PRXAX001, COERXBE002…"
|
||||
className="w-full bg-gray-900 border border-gray-600 rounded-md px-2.5 py-1.5 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-blue-500 resize-none font-mono"
|
||||
/>
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<span className="text-[11px] font-semibold uppercase tracking-wider text-gray-400">
|
||||
Day Time Testing Today
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
aria-checked={daytimeTestingToday}
|
||||
onClick={() => onDaytimeTestingTodayChange(!daytimeTestingToday)}
|
||||
className={`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500/70 ${
|
||||
daytimeTestingToday ? 'bg-blue-600' : 'bg-gray-600'
|
||||
}`}
|
||||
title="Toggle daytime testing for today's compile"
|
||||
>
|
||||
<span
|
||||
className={`pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow transform transition-transform ${
|
||||
daytimeTestingToday ? 'translate-x-4' : 'translate-x-0'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={`overflow-hidden transition-all duration-300 ease-out ${
|
||||
daytimeTestingToday
|
||||
? 'max-h-56 opacity-100 translate-y-0 mt-3'
|
||||
: 'max-h-0 opacity-0 -translate-y-1 mt-0 pointer-events-none'
|
||||
}`}
|
||||
>
|
||||
<div>
|
||||
<label className="block text-[11px] font-semibold uppercase tracking-wider text-gray-500 mb-1.5">
|
||||
Day Time Hours (Max 8)
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
max="8"
|
||||
step="1"
|
||||
value={daytimeTestingHours}
|
||||
onChange={(e) => onDaytimeTestingHoursChange(e.target.value)}
|
||||
className="w-full bg-gray-900 border border-gray-600 rounded-md px-2.5 py-1.5 text-xs text-gray-200 focus:outline-none focus:border-blue-500 font-mono"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="mt-3">
|
||||
<label className="block text-[11px] font-semibold uppercase tracking-wider text-gray-500 mb-1.5">
|
||||
Day Time Device
|
||||
</label>
|
||||
<select
|
||||
value={daytimeTestingDevice}
|
||||
onChange={(e) => onDaytimeTestingDeviceChange(e.target.value)}
|
||||
className="w-full bg-gray-900 border border-gray-600 rounded-md px-2.5 py-1.5 text-xs text-gray-200 focus:outline-none focus:border-blue-500 font-mono"
|
||||
>
|
||||
<option value="CGW453">DUT (CGW453)</option>
|
||||
<option value="CGW452">REF (CGW452)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Top priority */}
|
||||
<div>
|
||||
<label className="block text-[11px] font-semibold uppercase tracking-wider text-gray-500 mb-1.5">
|
||||
Top Priority Tests (REF - CGW452)
|
||||
</label>
|
||||
<textarea
|
||||
rows={3}
|
||||
value={topPriorityRef}
|
||||
onChange={(e) => onTopPriorityRefChange(e.target.value)}
|
||||
placeholder="P2PRXAX001, COERXBE002…"
|
||||
className="w-full bg-gray-900 border border-gray-600 rounded-md px-2.5 py-1.5 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-blue-500 resize-none font-mono"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setTopPriorityOpen((open) => !open)}
|
||||
className="w-full flex items-center justify-between text-[11px] font-semibold uppercase tracking-wider text-gray-500 hover:text-gray-300 transition-colors"
|
||||
aria-expanded={topPriorityOpen}
|
||||
aria-controls="top-priority-section"
|
||||
>
|
||||
<span>Top Priority Tests</span>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className={`w-4 h-4 transition-transform duration-300 ${topPriorityOpen ? 'rotate-180' : 'rotate-0'}`}
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
strokeWidth={2}
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M19 9l-7 7-7-7" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div
|
||||
id="top-priority-section"
|
||||
className={`overflow-hidden transition-all duration-300 ease-out ${
|
||||
topPriorityOpen
|
||||
? 'max-h-96 opacity-100 translate-y-0 mt-2'
|
||||
: 'max-h-0 opacity-0 -translate-y-1 mt-0 pointer-events-none'
|
||||
}`}
|
||||
>
|
||||
<div>
|
||||
<label className="block text-[11px] font-semibold uppercase tracking-wider text-gray-500 mb-1.5">
|
||||
Top Priority DUT Tests
|
||||
</label>
|
||||
<textarea
|
||||
rows={3}
|
||||
value={topPriorityDut}
|
||||
onChange={(e) => onTopPriorityDutChange(e.target.value)}
|
||||
placeholder="P2PRXAX001, COERXBE002…"
|
||||
className="w-full bg-gray-900 border border-gray-600 rounded-md px-2.5 py-1.5 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-blue-500 resize-none font-mono"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="mt-3">
|
||||
<label className="block text-[11px] font-semibold uppercase tracking-wider text-gray-500 mb-1.5">
|
||||
Top Priority REF Tests
|
||||
</label>
|
||||
<textarea
|
||||
rows={3}
|
||||
value={topPriorityRef}
|
||||
onChange={(e) => onTopPriorityRefChange(e.target.value)}
|
||||
placeholder="P2PRXAX001, COERXBE002…"
|
||||
className="w-full bg-gray-900 border border-gray-600 rounded-md px-2.5 py-1.5 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-blue-500 resize-none font-mono"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user