From c9a80a6fd116f45c7b101c3fcc89c339e23bd8fb Mon Sep 17 00:00:00 2001 From: Christian Toney Date: Sun, 29 Jun 2025 16:53:13 -0400 Subject: [PATCH] Add test: DynamicContentCheckbox automatically refreshes if "IsDisabled" attribute is toggled --- .../DynamicContentCheckbox.test.luau | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/DialogueEditor/components/Explorer/components/Preview/components/DynamicContentCheckbox/DynamicContentCheckbox.test.luau b/src/DialogueEditor/components/Explorer/components/Preview/components/DynamicContentCheckbox/DynamicContentCheckbox.test.luau index 4ba3a26..a03363b 100644 --- a/src/DialogueEditor/components/Explorer/components/Preview/components/DynamicContentCheckbox/DynamicContentCheckbox.test.luau +++ b/src/DialogueEditor/components/Explorer/components/Preview/components/DynamicContentCheckbox/DynamicContentCheckbox.test.luau @@ -158,6 +158,39 @@ return { end).toFinishBeforeSeconds(1); end); + + it(`automatically refreshes if "IsDisabled" attribute is toggled`, function() + + expect(function() + + local selectedScript = render("Message"); + + assert(screenGui, "ScreenGui should be initialized before running tests."); + local dynamicContentCheckbox = screenGui:FindFirstChildOfClass("Frame"); + assert(dynamicContentCheckbox, "DynamicContentCheckbox should be rendered."); + + local checkbox = dynamicContentCheckbox:FindFirstChild("Checkbox"); + assert(checkbox and checkbox:IsA("TextButton"), "Checkbox should be rendered inside DynamicContentCheckbox."); + + -- Create the ContentScript + VirtualService.events.GuiButton.Activated:fireEvent(checkbox); + local contentScript = selectedScript:WaitForChild("ContentScript"); + verifyReactStatus(); + + -- Initially, the ContentScript should not be disabled, so let's disable it. + checkbox:GetAttributeChangedSignal("IsChecked"):Wait(); + contentScript:SetAttribute("IsDisabled", true); + checkbox:GetAttributeChangedSignal("IsChecked"):Wait(); + expect(checkbox:GetAttribute("IsChecked")).toBe(false); + + -- Now, let's enable it again. + contentScript:SetAttribute("IsDisabled", false); + checkbox:GetAttributeChangedSignal("IsChecked"):Wait(); + expect(checkbox:GetAttribute("IsChecked")).toBe(true); + + end).toFinishBeforeSeconds(1); + + end); }