diff --git a/src/renderer/hooks/useTestImport.ts b/src/renderer/hooks/useTestImport.ts index 9fc5cabd3..bf13d96c6 100644 --- a/src/renderer/hooks/useTestImport.ts +++ b/src/renderer/hooks/useTestImport.ts @@ -169,9 +169,5 @@ export const useDiscoverPytestElements = () => { return ok(newElems); } - // Return a function that takes the file path as an argument - return async (filePath: string) => { - const result = await getTests(filePath); - return result; - }; + return getTests }; diff --git a/src/renderer/hooks/useTestSequencerState.ts b/src/renderer/hooks/useTestSequencerState.ts index 4f5fc39f6..cc91fc329 100644 --- a/src/renderer/hooks/useTestSequencerState.ts +++ b/src/renderer/hooks/useTestSequencerState.ts @@ -126,7 +126,7 @@ export function createNewTest(test: NewTest): Test { completionTime: undefined, error: null, isSavedToCloud: false, - exportToCloud: test.exportToCloud || true, + exportToCloud: test.exportToCloud === undefined ? true : test.exportToCloud, createdAt: new Date().toISOString(), minValue: test.minValue, maxValue: test.maxValue, diff --git a/src/renderer/routes/test_sequencer_panel/components/modals/ChangeLinkedTest.tsx b/src/renderer/routes/test_sequencer_panel/components/modals/ChangeLinkedTest.tsx index 23ffda692..a39362c0b 100644 --- a/src/renderer/routes/test_sequencer_panel/components/modals/ChangeLinkedTest.tsx +++ b/src/renderer/routes/test_sequencer_panel/components/modals/ChangeLinkedTest.tsx @@ -42,41 +42,22 @@ export const ChangeLinkedTestModal = ({ const discoverPytestElement = useDiscoverPytestElements(); const handleDiscoverPytestElements = async (filePath: string) => { - try { - const result = await discoverPytestElement(filePath); - if (result.isOk()) { - setAvailableTests(result.value); - if (result.value.length > 0) { - setSelectedPath(result.value[0].path); - } - } else { - console.error(result.error); + const result = await discoverPytestElement(filePath); + if (result.isOk()) { + setAvailableTests(result.value); + if (result.value.length > 0) { + setSelectedPath(result.value[0].path); } - } catch (error) { - console.error(error); + } else { + console.error(result.error); } }; - const openFilePicker = async () => { - return new Promise((resolve, reject) => { - window.api.openTestPicker().then((result) => { - if (!result) { - reject(new Error("No file selected.")); - } else { - resolve(result.filePath); - } - }); - }); - }; - const handleFilePicker = async () => { - try { - const filePath = await openFilePicker(); - if (filePath) { - await handleDiscoverPytestElements(filePath); - } - } catch (error) { - console.error(error); + const res = await window.api.openTestPicker(); + if (!res) return; + if (res.filePath) { + await handleDiscoverPytestElements(res.filePath); } };