From 7b9bd3781867ffb3d07392f0729a32889ed680c5 Mon Sep 17 00:00:00 2001 From: Christian Toney Date: Thu, 26 Jun 2025 13:02:41 -0400 Subject: [PATCH 1/2] Add test: DialogueGroupContainer refreshes the selected dialogue group if a dialogue script is removed from a dialogue folder --- .../DialogueGroupContainer.test.luau | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/src/DialogueEditor/components/Explorer/components/DialogueGroupContainer/DialogueGroupContainer.test.luau b/src/DialogueEditor/components/Explorer/components/DialogueGroupContainer/DialogueGroupContainer.test.luau index 1efd013..b8b1926 100644 --- a/src/DialogueEditor/components/Explorer/components/DialogueGroupContainer/DialogueGroupContainer.test.luau +++ b/src/DialogueEditor/components/Explorer/components/DialogueGroupContainer/DialogueGroupContainer.test.luau @@ -140,6 +140,95 @@ return { end).toFinishBeforeSeconds(1); end); + + it("refreshes the selected dialogue group if a dialogue script is removed from a dialogue folder", function() + + expect(function() + + -- Render the component and wait for it to finish rendering. + assert(screenGui, "ScreenGui should be initialized before running tests."); + assert(reactRoot, "React root should be initialized before running tests."); + + local messageCount = 4; + local dialogueFolder = Instance.new("Folder"); + dialogueFolder.Name = "Messages"; + + local scriptToDestroy; + + for i = 1, messageCount do + + local dialogueScript = Instance.new("ModuleScript"); + dialogueScript.Name = tostring(i); + dialogueScript:SetAttribute("DialogueType", "Message"); + dialogueScript:AddTag("DialogueMakerDialogueScript"); + dialogueScript.Parent = dialogueFolder; + scriptToDestroy = dialogueScript; + + end; + + local selectedScript = Instance.new("ModuleScript"); + selectedScript:SetAttribute("DialogueType", "Message"); + selectedScript:AddTag("DialogueMakerDialogueScript"); + dialogueFolder.Parent = selectedScript; + + local propagatedErrorMessage; + local didRender = false; + local element = React.createElement(MockComponent, { + selectedScript = selectedScript; + onErrored = function(errorMessage) + + propagatedErrorMessage = errorMessage; + + end; + onRendered = function() + + didRender = true; + + end; + }); + + reactRoot:render(element); + repeat task.wait() until didRender or propagatedErrorMessage; + if propagatedErrorMessage then + + error(propagatedErrorMessage); + + end; + + -- Verify that there are four dialogue items rendered. + local dialogueGroupContainer = screenGui:FindFirstChildOfClass("Frame"); + assert(dialogueGroupContainer, "DialogueGroupContainer should be rendered in the ScreenGui."); + + local dialogueGroup = dialogueGroupContainer:FindFirstChild("DialogueGroup"); + assert(dialogueGroup, "DialogueGroup should be rendered in the DialogueGroupContainer."); + + local function getDialogueItems() + + local dialogueItems = {}; + for _, child in dialogueGroup:GetChildren() do + + if child:IsA("Frame") then + + table.insert(dialogueItems, child); + + end; + + end; + + return dialogueItems; + + end; + + expect(#getDialogueItems()).toBe(4); + + -- Add a new dialogue script to the folder and verify that the component refreshes. + scriptToDestroy:Destroy(); + dialogueGroup.ChildRemoved:Wait(); + expect(#getDialogueItems()).toBe(3); + + end).toFinishBeforeSeconds(1); + + end); } From ad10187b52a1c887feacb6f7d931b373399b6369 Mon Sep 17 00:00:00 2001 From: Christian Toney Date: Thu, 26 Jun 2025 13:03:11 -0400 Subject: [PATCH 2/2] Make comment more specific --- .../DialogueGroupContainer/DialogueGroupContainer.test.luau | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DialogueEditor/components/Explorer/components/DialogueGroupContainer/DialogueGroupContainer.test.luau b/src/DialogueEditor/components/Explorer/components/DialogueGroupContainer/DialogueGroupContainer.test.luau index b8b1926..e9762e7 100644 --- a/src/DialogueEditor/components/Explorer/components/DialogueGroupContainer/DialogueGroupContainer.test.luau +++ b/src/DialogueEditor/components/Explorer/components/DialogueGroupContainer/DialogueGroupContainer.test.luau @@ -221,7 +221,7 @@ return { expect(#getDialogueItems()).toBe(4); - -- Add a new dialogue script to the folder and verify that the component refreshes. + -- Remove a dialogue script to the folder and verify that the component refreshes. scriptToDestroy:Destroy(); dialogueGroup.ChildRemoved:Wait(); expect(#getDialogueItems()).toBe(3);