Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/DialogueEditor/components/DropdownOption/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
local root = script.Parent.Parent.Parent;
local React = require(root.roblox_packages.react);
local useStudioColors = require(root.DialogueEditor.hooks.useStudioColors);
local VirtualService = require(root.VirtualService);

export type DropdownOptionProperties = {
layoutOrder: number;
Expand All @@ -14,15 +15,34 @@ export type DropdownOptionProperties = {
local function DropdownOption(props: DropdownOptionProperties)

local colors = useStudioColors();
local buttonRef = React.useRef(nil);

React.useEffect(function()
local button = buttonRef.current;
assert(button and button:IsA("TextButton"), "Button reference is not a TextButton");

local connection = VirtualService.events.GuiButton.Activated:getSignal(button):Connect(function()

props.onClick();

end);

return function()

connection:Disconnect();

end;
end, {props.onClick});

return React.createElement("TextButton", {
LayoutOrder = props.layoutOrder;
Size = UDim2.new(1, 0, 0, 25);
BackgroundColor3 = colors.backgroundTableRow;
Text = "";
[React.Event.Activated] = function()
ref = buttonRef;
[React.Event.Activated] = function(self)

props.onClick();
VirtualService.events.GuiButton.Activated:fireEvent(self);

end;
BorderSizePixel = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,35 @@ return {
end).toFinishBeforeSeconds(1);

end);

it("can initialize action scripts", function()

expect(function()

local selectedScript = render("Message");

assert(screenGui, "ScreenGui should be initialized before running tests.");
local dialogueOptions = screenGui:FindFirstChildOfClass("Frame");
assert(dialogueOptions, "DialogueOptions should be rendered.");

local actionsDropdown = dialogueOptions:FindFirstChild("ActionsDropdown");
assert(actionsDropdown, "Actions dropdown should be present in the DialogueOptions.");

local toggleButton = actionsDropdown:FindFirstChild("ToggleButton");
assert(toggleButton and toggleButton:IsA("TextButton"), "Toggle button should be present in the ActionsDropdown.");

VirtualService.events.GuiButton.Activated:fireEvent(toggleButton);

local optionsFrame = actionsDropdown:WaitForChild("OptionsFrame");
local initializationButton = optionsFrame:FindFirstChild("InitializationButton");
assert(initializationButton and initializationButton:IsA("TextButton"), "Initialization button should be present in the ActionsDropdown options.");

VirtualService.events.GuiButton.Activated:fireEvent(initializationButton);
selectedScript:WaitForChild("InitializationActionScript");

end).toFinishBeforeSeconds(1);

end);

}

Expand Down
3 changes: 3 additions & 0 deletions test.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"roblox_packages": {
"$path": "roblox_packages"
}
},
"runTests": {
"$path": "runTests.luau"
}
}
}
Expand Down