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
5 changes: 3 additions & 2 deletions src/DialogueEditor/components/DropdownOption/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local function DropdownOption(props: DropdownOptionProperties)

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

React.useEffect(function()

Expand All @@ -24,7 +25,7 @@ local function DropdownOption(props: DropdownOptionProperties)

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

props.onClick();
onClick();

end);

Expand All @@ -34,7 +35,7 @@ local function DropdownOption(props: DropdownOptionProperties)

end;

end, {props.onClick});
end, {onClick});

return React.createElement("TextButton", {
LayoutOrder = props.layoutOrder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ return {

end;

local function createDialogueScript(name: string, type: "Conversation" | "Message" | "Redirect")
local function createDialogueScript(type: "Conversation" | "Message" | "Redirect")

local dialogueScript = Instance.new("ModuleScript");

Expand All @@ -81,7 +81,7 @@ return {

assert(reactRoot, "React root should be initialized before running tests.");

local selectedScript = createDialogueScript("TestDialogueScript", type);
local selectedScript = createDialogueScript(type);
local didRender = false;
local element = React.createElement(MockComponent, {
selectedScript = selectedScript;
Expand Down Expand Up @@ -111,8 +111,7 @@ return {

expect(function()

local dialogueType = "Conversation";
render(dialogueType :: any);
local selectedScript = render("Message");

assert(screenGui, "ScreenGui should be initialized before running tests.");
local dialogueTypeDropdown = screenGui:FindFirstChildOfClass("Frame");
Expand All @@ -126,7 +125,7 @@ return {

local textLabel = selectionFrame:FindFirstChild("TextLabel");
assert(textLabel and textLabel:IsA("TextLabel"), "TextLabel should be present in SelectionFrame.");
expect(textLabel.Text).toBe(dialogueType);
expect(textLabel.Text).toBe(selectedScript:GetAttribute("DialogueType"));

end).toFinishBeforeSeconds(1);

Expand All @@ -136,8 +135,7 @@ return {

expect(function()

local dialogueType = "Conversation";
render(dialogueType :: any);
render("Conversation");

assert(screenGui, "ScreenGui should be initialized before running tests.");
local dialogueTypeDropdown = screenGui:FindFirstChildOfClass("Frame");
Expand All @@ -149,6 +147,41 @@ return {
end).toFinishBeforeSeconds(1);

end);

it("can set the DialogueType attribute of the selected script", function()

expect(function()

local selectedScript = render("Message");

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

local toggleButton = dialogueTypeDropdown:FindFirstChild("ToggleButton");
assert(toggleButton and toggleButton:IsA("TextButton"), "ToggleButton should be present in DialogueTypeDropdown.");

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

local optionsFrame = dialogueTypeDropdown:WaitForChild("OptionsFrame");
assert(optionsFrame, "OptionsFrame should be present in DialogueTypeDropdown.");

local responseButton = optionsFrame:FindFirstChild("ResponseButton");
assert(responseButton and responseButton:IsA("TextButton"), "ResponseButton should be present in OptionsFrame.");

local didDialogueTypeChange = false;
eventConnection = selectedScript:GetAttributeChangedSignal("DialogueType"):Once(function()

didDialogueTypeChange = true;

end);
VirtualService.events.GuiButton.Activated:fireEvent(responseButton);
repeat task.wait() until didDialogueTypeChange or propagatedErrorMessage;
verifyReactStatus();

end).toFinishBeforeSeconds(1);

end);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ local function DialogueTypeDropdown(properties: DialogueTypeDropdownProperties)
for index, dialogueType in dialogueTypes do

local option = React.createElement(DropdownOption, {
key = dialogueType;
key = `{dialogueType}Button`;
text = dialogueType;
layoutOrder = index;
iconImage = icons[`{dialogueType:sub(1, 1):upper()}{dialogueType:sub(2)}`];
Expand Down