adding api unit tests

This commit is contained in:
2026-03-01 16:46:27 -06:00
parent b7e74242b8
commit 6700c83692
35 changed files with 1607 additions and 177 deletions

View File

@@ -33,7 +33,7 @@ const LogForm = () => {
`api/logs/${logbookContext.state.selectedLogId}`
);
const log = response.data;
console.log(log)
reset(log);
} catch (error) {
const axiosError = error as AxiosError;
@@ -53,11 +53,16 @@ const LogForm = () => {
if (pilots && FormMode.ADD) {
const newPilotsOptions = pilots.map((pilot) => {
return {
key: pilot.id,
label: pilot.name,
value: pilot.id,
};
});
newPilotsOptions.unshift({
label: '',
value: '',
})
dispatch({ type: 'SET_PILOT_OPTIONS', payload: newPilotsOptions });
}
}, [pilots]);
@@ -80,9 +85,9 @@ const LogForm = () => {
onChange={onChange}
value={[value]}
>
{state.pilotOptions?.map((pilotOption: { key: string; label: string, }) => {
{state.pilotOptions?.map((pilotOption: { label: string, value: string; }) => {
return (
<option key={pilotOption.key}>{pilotOption.label}</option>
<option value={pilotOption.value}>{pilotOption.label}</option>
)
})}
</select>

View File

@@ -4,6 +4,6 @@ export interface LogFormState {
alert: Alert | undefined;
isDisabled: boolean;
isLoading: boolean;
pilotOptions: { key: string; label: string; }[];
pilotOptions: { label: string; value: string; }[];
selectedPilotName: string;
}

View File

@@ -5,7 +5,7 @@ type Action =
| { type: 'SET_ALERT'; payload: Alert | undefined }
| { type: 'SET_IS_DISABLED'; payload: boolean }
| { type: 'SET_IS_LOADING'; payload: boolean }
| { type: 'SET_PILOT_OPTIONS'; payload: { key: string, label: string; }[] }
| { type: 'SET_PILOT_OPTIONS'; payload: { label: string; value: string }[] }
| { type: 'SET_SELECTED_PILOT_NAME'; payload: string };
export const initialState: LogFormState = {