From 0a5a9fd15e625e6137ecac671fa5c34f9b19e25c Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 11 Apr 2024 10:43:38 -0400 Subject: [PATCH 01/16] chore(sequencer): new RenameModal --- .../components/modals/RenameModal.tsx | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/renderer/routes/test_sequencer_panel/components/modals/RenameModal.tsx diff --git a/src/renderer/routes/test_sequencer_panel/components/modals/RenameModal.tsx b/src/renderer/routes/test_sequencer_panel/components/modals/RenameModal.tsx new file mode 100644 index 000000000..6b8149089 --- /dev/null +++ b/src/renderer/routes/test_sequencer_panel/components/modals/RenameModal.tsx @@ -0,0 +1,44 @@ +import { Button } from "@/renderer/components/ui/button"; +import { Dialog, DialogContent } from "@/renderer/components/ui/dialog"; +import { Input } from "@/renderer/components/ui/input"; +import { useState } from "react"; + + +export const RenameModal = ({ + isModalOpen, + setModalOpen, + initialName, + handleSubmit, + target, +}: { + isModalOpen: boolean; + setModalOpen: (value: boolean) => void; + initialName: string; + handleSubmit: (newName: string) => void; + target: string | undefined; +}) => { + const [newName, setNewName] = useState(initialName); + + + return ( + + +

Rename

+ { target && +
+

{target}

+
+ } + setNewName(e.target.value)} + /> + +
+
+ ); +}; From a8b626a76527bbc51d149a44f1c54db5f155e424 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 11 Apr 2024 12:57:47 -0400 Subject: [PATCH 02/16] chore(sequencer): rename modal - Sequence Name and Sequence Description --- .../components/data-table/SequenceTable.tsx | 94 ++++++++++++++++++- .../components/dnd/DraggableRowSequence.tsx | 2 + .../components/modals/RenameModal.tsx | 20 ++-- 3 files changed, 106 insertions(+), 10 deletions(-) diff --git a/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx b/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx index 7a89bd261..6e96daa6a 100644 --- a/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx +++ b/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx @@ -2,6 +2,7 @@ import { ContextMenu, ContextMenuContent, ContextMenuItem, + ContextMenuSeparator, ContextMenuTrigger, } from "@/renderer/components/ui/context-menu"; import { @@ -40,7 +41,7 @@ import { import { parseInt, map } from "lodash"; import { ChevronDownIcon, ChevronUpIcon, TrashIcon } from "lucide-react"; import LockableButton from "@/renderer/routes/test_sequencer_panel/components/lockable/LockedButtons"; -import { useState } from "react"; +import { useRef, useState } from "react"; import { DraggableRowSequence } from "@/renderer/routes/test_sequencer_panel/components/dnd/DraggableRowSequence"; import { getCompletionTime, getSuccessRate, mapStatusToDisplay } from "./utils"; import useWithPermission from "@/renderer/hooks/useWithPermission"; @@ -48,6 +49,8 @@ import { useImportSequences } from "@/renderer/hooks/useTestSequencerProject"; import { useSequencerModalStore } from "@/renderer/stores/modal"; import { useSequencerStore } from "@/renderer/stores/sequencer"; import { useShallow } from "zustand/react/shallow"; +import { RenameModal } from "../modals/RenameModal"; +import { toast } from "sonner"; export function SequenceTable() { const { project, isLocked } = useDisplayedSequenceState(); @@ -255,8 +258,82 @@ export function SequenceTable() { ); }; + const onRenameSequence = (idx: number) => { + const sequence = sequences[idx]; + renameForIdx.current = idx; + setRenameTarget(sequence.project.name); + setInitialName(sequence.project.name); + setIsRenameNameModalOpen(true); + }; + + const handleRenameSequence = (newName: string) => { + // make sure the new name is unique + if (sequences.some((seq) => seq.project.name === newName)) { + toast.error("Sequence name must be unique"); + return; + } + setSequences( + [...sequences].map((seq, idx) => { + if (idx === renameForIdx.current) { + return { + ...seq, + project: { ...seq.project, name: newName }, + testSequenceUnsaved: true, + }; + } + return seq; + }), + ); + setIsRenameNameModalOpen(false); + } + const [isRenameNameModalOpen, setIsRenameNameModalOpen] = useState(false); + const [isRenameDescModalOpen, setIsRenameDescModalOpen] = useState(false); + const [renameTarget, setRenameTarget] = useState(""); + const [initialName, setInitialName] = useState(""); + const renameForIdx = useRef(-1); + + const onRenameDescription = (idx: number) => { + const sequence = sequences[idx]; + renameForIdx.current = idx; + setRenameTarget(sequence.project.name); + setInitialName(sequence.project.description); + setIsRenameDescModalOpen(true); + }; + + const handleRenameDescription = (newDescription: string) => { + setSequences( + [...sequences].map((seq, idx) => { + if (idx === renameForIdx.current) { + return { + ...seq, + project: { ...seq.project, description: newDescription }, + testSequenceUnsaved: true, + }; + } + return seq; + }), + ); + setIsRenameDescModalOpen(false); + } + return (
+ +
{isAdmin() ? ( + { + onRenameSequence(row.index); + }} + > + Rename sequence + + { + onRenameDescription(row.index); + }} + > + Edit description + + { onRemoveSequence([row.index]); diff --git a/src/renderer/routes/test_sequencer_panel/components/dnd/DraggableRowSequence.tsx b/src/renderer/routes/test_sequencer_panel/components/dnd/DraggableRowSequence.tsx index 875ff230c..3691de93d 100644 --- a/src/renderer/routes/test_sequencer_panel/components/dnd/DraggableRowSequence.tsx +++ b/src/renderer/routes/test_sequencer_panel/components/dnd/DraggableRowSequence.tsx @@ -13,6 +13,7 @@ import { TestSequenceContainer } from "@/renderer/types/test-sequencer"; export const DraggableRowSequence = ({ isSelected, row, + ...props }: { isSelected: boolean; row: Row; @@ -80,6 +81,7 @@ export const DraggableRowSequence = ({ className={"relative" + (isSelected ? " bg-primary-foreground" : "")} onClick={() => handleDisplaySequence(row.index)} ref={drag} + {...props} > {/* capture drag on above */}
diff --git a/src/renderer/routes/test_sequencer_panel/components/modals/RenameModal.tsx b/src/renderer/routes/test_sequencer_panel/components/modals/RenameModal.tsx index 6b8149089..4de77f175 100644 --- a/src/renderer/routes/test_sequencer_panel/components/modals/RenameModal.tsx +++ b/src/renderer/routes/test_sequencer_panel/components/modals/RenameModal.tsx @@ -1,24 +1,28 @@ import { Button } from "@/renderer/components/ui/button"; import { Dialog, DialogContent } from "@/renderer/components/ui/dialog"; import { Input } from "@/renderer/components/ui/input"; -import { useState } from "react"; +import { useEffect, useState } from "react"; export const RenameModal = ({ + title, isModalOpen, setModalOpen, initialName, handleSubmit, target, }: { + title: string; isModalOpen: boolean; setModalOpen: (value: boolean) => void; initialName: string; handleSubmit: (newName: string) => void; - target: string | undefined; + target: string; }) => { const [newName, setNewName] = useState(initialName); - + useEffect(() => { + setNewName(initialName); + }, [initialName]); return ( -

Rename

- { target && -
-

{target}

-
- } +

{title}

+
+

{target}

+
Date: Thu, 11 Apr 2024 13:09:58 -0400 Subject: [PATCH 03/16] chore(sequencer): better dropdown menu for test table --- .../components/data-table/TestTable.tsx | 58 ++++++++++--------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/renderer/routes/test_sequencer_panel/components/data-table/TestTable.tsx b/src/renderer/routes/test_sequencer_panel/components/data-table/TestTable.tsx index 4d2ee95c6..9650e3d91 100644 --- a/src/renderer/routes/test_sequencer_panel/components/data-table/TestTable.tsx +++ b/src/renderer/routes/test_sequencer_panel/components/data-table/TestTable.tsx @@ -2,6 +2,7 @@ import { ContextMenu, ContextMenuContent, ContextMenuItem, + ContextMenuSeparator, ContextMenuTrigger, } from "@/renderer/components/ui/context-menu"; import { @@ -454,14 +455,36 @@ export function TestTable() { Add Conditional {row.original.type === "test" && ( - { - openRenameTestModal(row.original.id); - }} - > - Rename Test - + <> + + { + setOpenPyTestFileModal(true); + setTestToDisplay(row.original as Test); + }} + > + Consult Code + + + { + openRenameTestModal(row.original.id); + }} + > + Rename Test + + { + toggleExportToCloud(row.original.id); + }} + > + {row.original.exportToCloud + ? "Disable export to Cloud" + : "Enable export to Cloud"} + + )} + onRemoveTest([parseInt(row.id)])} > @@ -469,27 +492,6 @@ export function TestTable() { ? "Remove Test" : "Remove Conditional"} - {row.original.type === "test" && ( - { - setOpenPyTestFileModal(true); - setTestToDisplay(row.original as Test); - }} - > - Consult Code - - )} - {row.original.type === "test" && ( - { - toggleExportToCloud(row.original.id); - }} - > - {row.original.exportToCloud - ? "Disable export to Cloud" - : "Enable export to Cloud"} - - )} )) From 00a0febf52c3b48a88e92e8341870dba5b825356 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 11 Apr 2024 13:32:37 -0400 Subject: [PATCH 04/16] chore(sequencer): formatting --- .../components/data-table/SequenceTable.tsx | 42 +++++++++---------- .../components/modals/RenameModal.tsx | 8 +--- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx b/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx index 6e96daa6a..ac9e9b1b9 100644 --- a/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx +++ b/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx @@ -274,24 +274,24 @@ export function SequenceTable() { } setSequences( [...sequences].map((seq, idx) => { - if (idx === renameForIdx.current) { - return { - ...seq, - project: { ...seq.project, name: newName }, - testSequenceUnsaved: true, - }; - } - return seq; + if (idx === renameForIdx.current) { + return { + ...seq, + project: { ...seq.project, name: newName }, + testSequenceUnsaved: true, + }; + } + return seq; }), ); setIsRenameNameModalOpen(false); - } + }; const [isRenameNameModalOpen, setIsRenameNameModalOpen] = useState(false); const [isRenameDescModalOpen, setIsRenameDescModalOpen] = useState(false); const [renameTarget, setRenameTarget] = useState(""); const [initialName, setInitialName] = useState(""); const renameForIdx = useRef(-1); - + const onRenameDescription = (idx: number) => { const sequence = sequences[idx]; renameForIdx.current = idx; @@ -303,22 +303,22 @@ export function SequenceTable() { const handleRenameDescription = (newDescription: string) => { setSequences( [...sequences].map((seq, idx) => { - if (idx === renameForIdx.current) { - return { - ...seq, - project: { ...seq.project, description: newDescription }, - testSequenceUnsaved: true, - }; - } - return seq; + if (idx === renameForIdx.current) { + return { + ...seq, + project: { ...seq.project, description: newDescription }, + testSequenceUnsaved: true, + }; + } + return seq; }), ); setIsRenameDescModalOpen(false); - } + }; return (
- - +

{title}

From 5506e286a5306b1c48c0ffd59c90572ee60642b7 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 11 Apr 2024 13:31:48 -0400 Subject: [PATCH 05/16] chore(sequencer): patch the 'not save' when it's actually save. tmp --- src/renderer/hooks/useTestSequencerProject.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/renderer/hooks/useTestSequencerProject.ts b/src/renderer/hooks/useTestSequencerProject.ts index 3ce2a3bcc..0e640cfdf 100644 --- a/src/renderer/hooks/useTestSequencerProject.ts +++ b/src/renderer/hooks/useTestSequencerProject.ts @@ -37,11 +37,16 @@ export function useSaveSequence() { export function useSaveAllSequences() { const { withPermissionCheck } = useWithPermission(); + const { setSequences, sequences } = useSequencerState(); const manager = usePrepareStateManager(); const handle = async () => { toastResultPromise(saveSequences(manager), { loading: "Saving sequences...", - success: () => "Sequences saved", + success: () => { + // Update the sequences in the state to set them as saved + setSequences([...sequences].map((seq) => ({ ...seq, testSequenceUnsaved: false }))); + return "Sequences saved"; + }, error: (e) => `${e}`, }); }; From 2a335b8ea516edc35719874133914afec6a0f103 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 11 Apr 2024 13:54:19 -0400 Subject: [PATCH 06/16] chore(sequencer): handle set unsaved false in the save function --- src/renderer/hooks/useTestSequencerProject.ts | 11 +++-------- .../test_sequencer_panel/utils/SequenceHandler.ts | 9 +++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/renderer/hooks/useTestSequencerProject.ts b/src/renderer/hooks/useTestSequencerProject.ts index 0e640cfdf..8fc663bd1 100644 --- a/src/renderer/hooks/useTestSequencerProject.ts +++ b/src/renderer/hooks/useTestSequencerProject.ts @@ -17,8 +17,8 @@ import { toastResultPromise } from "../utils/report-error"; function usePrepareStateManager(): StateManager { const { elems, project } = useDisplayedSequenceState(); - const { addNewSequence, removeSequence, sequences } = useSequencerState(); - return { elems, project, addNewSequence, removeSequence, sequences }; + const { addNewSequence, removeSequence, sequences, setSequences } = useSequencerState(); + return { elems, project, addNewSequence, removeSequence, sequences, setSequences }; } export function useSaveSequence() { @@ -37,16 +37,11 @@ export function useSaveSequence() { export function useSaveAllSequences() { const { withPermissionCheck } = useWithPermission(); - const { setSequences, sequences } = useSequencerState(); const manager = usePrepareStateManager(); const handle = async () => { toastResultPromise(saveSequences(manager), { loading: "Saving sequences...", - success: () => { - // Update the sequences in the state to set them as saved - setSequences([...sequences].map((seq) => ({ ...seq, testSequenceUnsaved: false }))); - return "Sequences saved"; - }, + success: () => "Sequences saved", error: (e) => `${e}`, }); }; diff --git a/src/renderer/routes/test_sequencer_panel/utils/SequenceHandler.ts b/src/renderer/routes/test_sequencer_panel/utils/SequenceHandler.ts index fdfefffc6..52c92ec86 100644 --- a/src/renderer/routes/test_sequencer_panel/utils/SequenceHandler.ts +++ b/src/renderer/routes/test_sequencer_panel/utils/SequenceHandler.ts @@ -28,6 +28,7 @@ export type StateManager = { removeSequence: (name: string) => void; project: TestSequencerProject | null; sequences: TestSequenceContainer[]; + setSequences: (sequences: TestSequenceContainer[]) => void; }; export async function createSequence( @@ -82,6 +83,13 @@ export async function saveSequence( if (isSync.isErr()) { return isSync; } + // Set the sequence as saved + stateManager.setSequences([...stateManager.sequences].map((seq) => { + if (seq.project.name === sequence.name) { + return { ...seq, testSequenceUnsaved: false } + } + return seq; + })); return ok(undefined); } @@ -110,6 +118,7 @@ export async function saveSequences( if (res.isErr()) { return err(res.error); } + stateManager.setSequences([...stateManager.sequences].map((seq) => ({ ...seq, testSequenceUnsaved: false }))); }); return ok(undefined); } From 206bee44b00840777d00c4ee2dbfe33c33081efd Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 11 Apr 2024 13:55:13 -0400 Subject: [PATCH 07/16] chore(sequencer): formatting --- src/renderer/hooks/useTestSequencerProject.ts | 12 +++++++++-- .../utils/SequenceHandler.ts | 21 ++++++++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/renderer/hooks/useTestSequencerProject.ts b/src/renderer/hooks/useTestSequencerProject.ts index 8fc663bd1..e33605743 100644 --- a/src/renderer/hooks/useTestSequencerProject.ts +++ b/src/renderer/hooks/useTestSequencerProject.ts @@ -17,8 +17,16 @@ import { toastResultPromise } from "../utils/report-error"; function usePrepareStateManager(): StateManager { const { elems, project } = useDisplayedSequenceState(); - const { addNewSequence, removeSequence, sequences, setSequences } = useSequencerState(); - return { elems, project, addNewSequence, removeSequence, sequences, setSequences }; + const { addNewSequence, removeSequence, sequences, setSequences } = + useSequencerState(); + return { + elems, + project, + addNewSequence, + removeSequence, + sequences, + setSequences, + }; } export function useSaveSequence() { diff --git a/src/renderer/routes/test_sequencer_panel/utils/SequenceHandler.ts b/src/renderer/routes/test_sequencer_panel/utils/SequenceHandler.ts index 52c92ec86..4ef127e07 100644 --- a/src/renderer/routes/test_sequencer_panel/utils/SequenceHandler.ts +++ b/src/renderer/routes/test_sequencer_panel/utils/SequenceHandler.ts @@ -84,12 +84,14 @@ export async function saveSequence( return isSync; } // Set the sequence as saved - stateManager.setSequences([...stateManager.sequences].map((seq) => { - if (seq.project.name === sequence.name) { - return { ...seq, testSequenceUnsaved: false } - } - return seq; - })); + stateManager.setSequences( + [...stateManager.sequences].map((seq) => { + if (seq.project.name === sequence.name) { + return { ...seq, testSequenceUnsaved: false }; + } + return seq; + }), + ); return ok(undefined); } @@ -118,7 +120,12 @@ export async function saveSequences( if (res.isErr()) { return err(res.error); } - stateManager.setSequences([...stateManager.sequences].map((seq) => ({ ...seq, testSequenceUnsaved: false }))); + stateManager.setSequences( + [...stateManager.sequences].map((seq) => ({ + ...seq, + testSequenceUnsaved: false, + })), + ); }); return ok(undefined); } From 0b5e84a602cbc2cdc5299cc0b0f120da00d38df8 Mon Sep 17 00:00:00 2001 From: Guillaume Thibault Date: Mon, 15 Apr 2024 16:42:55 -0400 Subject: [PATCH 08/16] [stu-343-edit-sequence-name-descriotion] refactor: setSequences, using immer --- .../components/data-table/SequenceTable.tsx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx b/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx index ac9e9b1b9..c44b2e972 100644 --- a/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx +++ b/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx @@ -51,6 +51,7 @@ import { useSequencerStore } from "@/renderer/stores/sequencer"; import { useShallow } from "zustand/react/shallow"; import { RenameModal } from "../modals/RenameModal"; import { toast } from "sonner"; +import { produce } from "immer"; export function SequenceTable() { const { project, isLocked } = useDisplayedSequenceState(); @@ -301,18 +302,11 @@ export function SequenceTable() { }; const handleRenameDescription = (newDescription: string) => { - setSequences( - [...sequences].map((seq, idx) => { - if (idx === renameForIdx.current) { - return { - ...seq, - project: { ...seq.project, description: newDescription }, - testSequenceUnsaved: true, - }; - } - return seq; - }), - ); + setSequences(produce(sequences, (draft) => { + const seq = draft[renameForIdx.current]; + seq.project.description = newDescription; + seq.testSequenceUnsaved = true; + })) setIsRenameDescModalOpen(false); }; From ff39d3ee259aa33ac3e8a3a056cac7f255335efe Mon Sep 17 00:00:00 2001 From: Guillaume Thibault Date: Mon, 15 Apr 2024 17:03:47 -0400 Subject: [PATCH 09/16] [stu-343-edit-sequence-name-descriotion] chore: using Immer + remove useless spread operation --- .../components/data-table/SequenceTable.tsx | 23 +++++++++---------- .../utils/SequenceHandler.ts | 4 ++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx b/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx index c44b2e972..9273ad247 100644 --- a/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx +++ b/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx @@ -273,18 +273,17 @@ export function SequenceTable() { toast.error("Sequence name must be unique"); return; } - setSequences( - [...sequences].map((seq, idx) => { - if (idx === renameForIdx.current) { - return { - ...seq, - project: { ...seq.project, name: newName }, - testSequenceUnsaved: true, - }; - } - return seq; - }), - ); + if (newName === "") { + toast.error("Sequence name cannot be empty"); + return; + } + setSequences(produce(sequences, (draft) => { + const seq = draft[renameForIdx.current]; + seq.project.name = newName; + seq.testSequenceUnsaved = true; + })) + setIsRenameDescModalOpen(false); + setIsRenameNameModalOpen(false); }; const [isRenameNameModalOpen, setIsRenameNameModalOpen] = useState(false); diff --git a/src/renderer/routes/test_sequencer_panel/utils/SequenceHandler.ts b/src/renderer/routes/test_sequencer_panel/utils/SequenceHandler.ts index 4ef127e07..a123bf72f 100644 --- a/src/renderer/routes/test_sequencer_panel/utils/SequenceHandler.ts +++ b/src/renderer/routes/test_sequencer_panel/utils/SequenceHandler.ts @@ -85,7 +85,7 @@ export async function saveSequence( } // Set the sequence as saved stateManager.setSequences( - [...stateManager.sequences].map((seq) => { + stateManager.sequences.map((seq) => { if (seq.project.name === sequence.name) { return { ...seq, testSequenceUnsaved: false }; } @@ -121,7 +121,7 @@ export async function saveSequences( return err(res.error); } stateManager.setSequences( - [...stateManager.sequences].map((seq) => ({ + stateManager.sequences.map((seq) => ({ ...seq, testSequenceUnsaved: false, })), From 0b2ee85418fc59b14520a242a65a2bdea6bab274 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Mon, 15 Apr 2024 17:05:36 -0400 Subject: [PATCH 10/16] chore: format --- .../components/data-table/SequenceTable.tsx | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx b/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx index 9273ad247..83a7f9771 100644 --- a/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx +++ b/src/renderer/routes/test_sequencer_panel/components/data-table/SequenceTable.tsx @@ -277,11 +277,13 @@ export function SequenceTable() { toast.error("Sequence name cannot be empty"); return; } - setSequences(produce(sequences, (draft) => { - const seq = draft[renameForIdx.current]; - seq.project.name = newName; - seq.testSequenceUnsaved = true; - })) + setSequences( + produce(sequences, (draft) => { + const seq = draft[renameForIdx.current]; + seq.project.name = newName; + seq.testSequenceUnsaved = true; + }), + ); setIsRenameDescModalOpen(false); setIsRenameNameModalOpen(false); @@ -301,11 +303,13 @@ export function SequenceTable() { }; const handleRenameDescription = (newDescription: string) => { - setSequences(produce(sequences, (draft) => { - const seq = draft[renameForIdx.current]; - seq.project.description = newDescription; - seq.testSequenceUnsaved = true; - })) + setSequences( + produce(sequences, (draft) => { + const seq = draft[renameForIdx.current]; + seq.project.description = newDescription; + seq.testSequenceUnsaved = true; + }), + ); setIsRenameDescModalOpen(false); }; From 1bc41ad2d43b26b4cd01923533565e36afc446f8 Mon Sep 17 00:00:00 2001 From: Guillaume Thibault Date: Mon, 15 Apr 2024 19:22:47 -0400 Subject: [PATCH 11/16] [stu-343-edit-sequence-name-descriotion] tmp: disable edit menu due to colision in ubuntu CI test --- playwright-test/07_block_context_menu.spec.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/playwright-test/07_block_context_menu.spec.ts b/playwright-test/07_block_context_menu.spec.ts index c2c3b85a5..3a2566c8d 100644 --- a/playwright-test/07_block_context_menu.spec.ts +++ b/playwright-test/07_block_context_menu.spec.ts @@ -46,21 +46,21 @@ test.describe("Block context menu", () => { ).toBeVisible(); }); - test("Should open block edit menu upon clicking Edit block", async () => { - // Click on Edit block button from context menu - await window.getByTestId(Selectors.contextEditBlockBtn).click(); - - // Select all param div - const params = await window.$$( - `[data-testid="${Selectors.blockEditParam}"]`, - ); - - // Expect 5 parameters for SINE block - expect(params).toHaveLength(5); - - // Close the block edit menu - await window.getByTestId(Selectors.blockEditMenuCloseBtn).click(); - }); + // test("Should open block edit menu upon clicking Edit block", async () => { + // // Click on Edit block button from context menu + // await window.getByTestId(Selectors.contextEditBlockBtn).click(); + // + // // Select all param div + // const params = await window.$$( + // `[data-testid="${Selectors.blockEditParam}"]`, + // ); + // + // // Expect 5 parameters for SINE block + // expect(params).toHaveLength(5); + // + // // Close the block edit menu + // await window.getByTestId(Selectors.blockEditMenuCloseBtn).click(); + // }); test("Should open block info modal", async () => { // Right click on `SINE` block From 768bcc91a187a239a0dff83495c22562aaf035bb Mon Sep 17 00:00:00 2001 From: Guillaume Thibault Date: Mon, 15 Apr 2024 20:21:59 -0400 Subject: [PATCH 12/16] Revert "tmp: disable edit menu due to colision in ubuntu CI test" This reverts commit 1bc41ad2d43b26b4cd01923533565e36afc446f8. --- playwright-test/07_block_context_menu.spec.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/playwright-test/07_block_context_menu.spec.ts b/playwright-test/07_block_context_menu.spec.ts index 3a2566c8d..c2c3b85a5 100644 --- a/playwright-test/07_block_context_menu.spec.ts +++ b/playwright-test/07_block_context_menu.spec.ts @@ -46,21 +46,21 @@ test.describe("Block context menu", () => { ).toBeVisible(); }); - // test("Should open block edit menu upon clicking Edit block", async () => { - // // Click on Edit block button from context menu - // await window.getByTestId(Selectors.contextEditBlockBtn).click(); - // - // // Select all param div - // const params = await window.$$( - // `[data-testid="${Selectors.blockEditParam}"]`, - // ); - // - // // Expect 5 parameters for SINE block - // expect(params).toHaveLength(5); - // - // // Close the block edit menu - // await window.getByTestId(Selectors.blockEditMenuCloseBtn).click(); - // }); + test("Should open block edit menu upon clicking Edit block", async () => { + // Click on Edit block button from context menu + await window.getByTestId(Selectors.contextEditBlockBtn).click(); + + // Select all param div + const params = await window.$$( + `[data-testid="${Selectors.blockEditParam}"]`, + ); + + // Expect 5 parameters for SINE block + expect(params).toHaveLength(5); + + // Close the block edit menu + await window.getByTestId(Selectors.blockEditMenuCloseBtn).click(); + }); test("Should open block info modal", async () => { // Right click on `SINE` block From d420cf9abe391564eb5503fac8438c42507d9251 Mon Sep 17 00:00:00 2001 From: Guillaume Thibault Date: Mon, 15 Apr 2024 20:54:05 -0400 Subject: [PATCH 13/16] [stu-343-edit-sequence-name-descriotion] ci: adding screenshot to understand test layout in CI --- playwright-test/07_block_context_menu.spec.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/playwright-test/07_block_context_menu.spec.ts b/playwright-test/07_block_context_menu.spec.ts index c2c3b85a5..e209f8ea3 100644 --- a/playwright-test/07_block_context_menu.spec.ts +++ b/playwright-test/07_block_context_menu.spec.ts @@ -47,6 +47,12 @@ test.describe("Block context menu", () => { }); test("Should open block edit menu upon clicking Edit block", async () => { + // Take a screenshot + await window.screenshot({ + fullPage: true, + path: "test-results/before-right-click-block.jpeg", + }); + // Click on Edit block button from context menu await window.getByTestId(Selectors.contextEditBlockBtn).click(); From 173836b4e99f66b0e427d53306bbc7a6948e2ccb Mon Sep 17 00:00:00 2001 From: Guillaume Date: Mon, 15 Apr 2024 22:07:06 -0400 Subject: [PATCH 14/16] fix(test_007): limit on the number of zoom out --- playwright-test/07_block_context_menu.spec.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/playwright-test/07_block_context_menu.spec.ts b/playwright-test/07_block_context_menu.spec.ts index de501495b..fdf29598f 100644 --- a/playwright-test/07_block_context_menu.spec.ts +++ b/playwright-test/07_block_context_menu.spec.ts @@ -56,9 +56,7 @@ test.describe("Block context menu", () => { // CI problem if not center due to multi-layered context menu await window.locator("button[title='zoom out']").click(); await window.locator("button[title='zoom out']").click(); - await window.locator("button[title='zoom out']").click(); - await window.locator("button[title='fit view']").click(); - // + // Take a screenshot await window.screenshot({ fullPage: true, From 9768abdf170bfa7f212a33a296c2e374fa544d34 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Mon, 15 Apr 2024 22:26:37 -0400 Subject: [PATCH 15/16] ci: fix zoom out already max --- playwright-test/07_block_context_menu.spec.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/playwright-test/07_block_context_menu.spec.ts b/playwright-test/07_block_context_menu.spec.ts index fdf29598f..0fafa83e5 100644 --- a/playwright-test/07_block_context_menu.spec.ts +++ b/playwright-test/07_block_context_menu.spec.ts @@ -54,16 +54,14 @@ test.describe("Block context menu", () => { }); // CI problem if not center due to multi-layered context menu - await window.locator("button[title='zoom out']").click(); - await window.locator("button[title='zoom out']").click(); - + await window.locator("button[title='fit view']").click(); + // Take a screenshot await window.screenshot({ fullPage: true, path: "test-results/before-right-click-block-After-Zoom.jpeg", }); - // Click on Edit block button from context menu await window.getByTestId(Selectors.contextEditBlockBtn).click(); From d2866b997804292ead05c6a573e6f1155b515552 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 16 Apr 2024 09:23:36 -0400 Subject: [PATCH 16/16] test(07): using RAND instead of SINE for CI problem --- playwright-test/07_block_context_menu.spec.ts | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/playwright-test/07_block_context_menu.spec.ts b/playwright-test/07_block_context_menu.spec.ts index 0fafa83e5..ea7a32f0b 100644 --- a/playwright-test/07_block_context_menu.spec.ts +++ b/playwright-test/07_block_context_menu.spec.ts @@ -35,8 +35,8 @@ test.describe("Block context menu", () => { timeout: 20000, }); - // Right click on `SINE` block - await window.locator("h2", { hasText: "SINE" }).click({ + // Right click on `RAND` block + await window.locator("h2", { hasText: "RAND" }).click({ button: "right", }); @@ -56,12 +56,6 @@ test.describe("Block context menu", () => { // CI problem if not center due to multi-layered context menu await window.locator("button[title='fit view']").click(); - // Take a screenshot - await window.screenshot({ - fullPage: true, - path: "test-results/before-right-click-block-After-Zoom.jpeg", - }); - // Click on Edit block button from context menu await window.getByTestId(Selectors.contextEditBlockBtn).click(); @@ -70,16 +64,16 @@ test.describe("Block context menu", () => { `[data-testid="${Selectors.blockEditParam}"]`, ); - // Expect 5 parameters for SINE block - expect(params).toHaveLength(5); + // Expect 5 parameters for RAND block + expect(params).toHaveLength(4); // Close the block edit menu await window.getByTestId(Selectors.blockEditMenuCloseBtn).click(); }); test("Should open block info modal", async () => { - // Right click on `SINE` block - await window.locator("h2", { hasText: "SINE" }).click({ + // Right click on `RAND` block + await window.locator("h2", { hasText: "RAND" }).click({ button: "right", }); @@ -102,16 +96,16 @@ test.describe("Block context menu", () => { }); test("Should delete a block", async () => { - // Right click on `SINE` block - await window.locator("h2", { hasText: "SINE" }).click({ + // Right click on `RAND` block + await window.locator("h2", { hasText: "RAND" }).click({ button: "right", }); // Click on Delete block button from context menu await window.getByTestId(Selectors.contextDeleteBlockBtn).click(); - // Expect SINE block to disappear from DOM - await expect(window.locator("h2", { hasText: "SINE" })).toBeHidden(); + // Expect RAND block to disappear from DOM + await expect(window.locator("h2", { hasText: "RAND" })).toBeHidden(); }); test("Should duplicate a block", async () => {