Skip to content

Commit 12463de

Browse files
Add test: DialogueTypeDropdown can create dialogue folder if it doesn't exist (#186)
1 parent d7d2767 commit 12463de

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/DialogueEditor/components/Explorer/components/Preview/components/DialogueTypeDropdown/DialogueTypeDropdown.test.luau

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,49 @@ return {
182182
end).toFinishBeforeSeconds(1);
183183

184184
end);
185+
186+
it("can create dialogue folder if it doesn't exist", function()
187+
188+
expect(function()
189+
190+
local selectedScript = render("Message");
191+
local messagesFolder = Instance.new("Folder");
192+
messagesFolder.Name = "Messages";
193+
selectedScript.Parent = messagesFolder;
194+
195+
local parentDialogueScript = Instance.new("ModuleScript");
196+
messagesFolder.Parent = parentDialogueScript;
197+
198+
assert(screenGui, "ScreenGui should be initialized before running tests.");
199+
local dialogueTypeDropdown = screenGui:FindFirstChildOfClass("Frame");
200+
assert(dialogueTypeDropdown, "DialogueTypeDropdown should be rendered.");
201+
202+
local toggleButton = dialogueTypeDropdown:FindFirstChild("ToggleButton");
203+
assert(toggleButton and toggleButton:IsA("TextButton"), "ToggleButton should be present in DialogueTypeDropdown.");
204+
205+
VirtualService.events.GuiButton.Activated:fireEvent(toggleButton);
206+
207+
local optionsFrame = dialogueTypeDropdown:WaitForChild("OptionsFrame");
208+
assert(optionsFrame, "OptionsFrame should be present in DialogueTypeDropdown.");
209+
210+
local responseButton = optionsFrame:FindFirstChild("ResponseButton");
211+
assert(responseButton and responseButton:IsA("TextButton"), "ResponseButton should be present in OptionsFrame.");
212+
213+
local didDialogueTypeChange = false;
214+
eventConnection = selectedScript:GetAttributeChangedSignal("DialogueType"):Once(function()
215+
216+
didDialogueTypeChange = true;
217+
218+
end);
219+
VirtualService.events.GuiButton.Activated:fireEvent(responseButton);
220+
repeat task.wait() until didDialogueTypeChange or propagatedErrorMessage;
221+
verifyReactStatus();
222+
assert(selectedScript.Parent, "Selected script parent should not be nil after changing dialogue type.");
223+
expect(selectedScript.Parent.Name).toBe("Responses");
224+
225+
end).toFinishBeforeSeconds(1);
226+
227+
end);
185228

186229
}
187230

0 commit comments

Comments
 (0)