Skip to content

Commit 99ec972

Browse files
Add test: DialogueOptions shows condition and action buttons for dialogue (#173)
1 parent b6ce22a commit 99ec972

File tree

1 file changed

+41
-6
lines changed

1 file changed

+41
-6
lines changed

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

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,34 @@ return {
5757

5858
end;
5959

60-
local function createDialogueScript(name: string)
60+
local function createDialogueScript(name: string, type: "Conversation" | "Dialogue")
6161

6262
local dialogueScript = Instance.new("ModuleScript");
63-
dialogueScript:AddTag("DialogueMakerConversationScript");
63+
64+
if type == "Conversation" then
65+
66+
dialogueScript:AddTag("DialogueMakerConversationScript");
67+
68+
elseif type == "Dialogue" then
69+
70+
dialogueScript:AddTag("DialogueMakerDialogueScript");
71+
dialogueScript:SetAttribute("DialogueType", "Message");
72+
73+
else
74+
75+
error("Invalid dialogue script type: " .. tostring(type));
76+
77+
end;
78+
6479
return dialogueScript;
6580

6681
end;
6782

68-
local function render(): ModuleScript
83+
local function render(type: "Conversation" | "Dialogue"): ModuleScript
6984

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

72-
local selectedScript = createDialogueScript("TestDialogueScript");
87+
local selectedScript = createDialogueScript("TestDialogueScript", type);
7388
local didRender = false;
7489
local element = React.createElement(MockComponent, {
7590
selectedScript = selectedScript;
@@ -99,7 +114,7 @@ return {
99114

100115
expect(function()
101116

102-
local selectedScript = render();
117+
local selectedScript = render("Conversation");
103118
local testFolder = Instance.new("Folder");
104119
selectedScript.Parent = testFolder;
105120

@@ -129,7 +144,7 @@ return {
129144

130145
expect(function()
131146

132-
render();
147+
render("Conversation");
133148

134149
assert(screenGui, "ScreenGui should be initialized before running tests.");
135150
local dialogueOptions = screenGui:FindFirstChildOfClass("Frame");
@@ -144,6 +159,26 @@ return {
144159
end).toFinishBeforeSeconds(1);
145160

146161
end);
162+
163+
it("shows condition and action buttons for dialogue", function()
164+
165+
expect(function()
166+
167+
render("Dialogue");
168+
169+
assert(screenGui, "ScreenGui should be initialized before running tests.");
170+
local dialogueOptions = screenGui:FindFirstChildOfClass("Frame");
171+
assert(dialogueOptions, "DialogueOptions should be rendered.");
172+
173+
local conditionButton = dialogueOptions:FindFirstChild("ConditionButton");
174+
expect(conditionButton).toNotBe(nil);
175+
176+
local actionsDropdown = dialogueOptions:FindFirstChild("ActionsDropdown");
177+
expect(actionsDropdown).toNotBe(nil);
178+
179+
end).toFinishBeforeSeconds(1);
180+
181+
end);
147182

148183
}
149184

0 commit comments

Comments
 (0)