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
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,48 @@ return {
expect(#getDialogueItems(screenGui)).toBe(#dialogueFolder:GetChildren());

-- Delete a new dialogue script and verify that it is not rendered.
assert(dialogueGroup);

local dialogueItem = getDialogueItems(screenGui)[1]
dialogueFolder:GetChildren()[1]:Destroy();
dialogueGroup.ChildRemoved:Wait();
dialogueItem.Destroying:Wait();
verifyReactStatus();
expect(#getDialogueItems(screenGui)).toBe(#dialogueFolder:GetChildren());

end).toFinishBeforeSeconds(1);

end);

it("refreshes the selected dialogue group if a dialogue script's static content is changed", function()

expect(function()

-- Render the component and wait for it to finish rendering.
assert(screenGui, "ScreenGui should be initialized before running tests.");
local dialogueFolder, selectedScript = initializeDialogueFolder(4);
VirtualService.mocks.services.Selection:Set({selectedScript});
render();
verifyReactStatus();

local dialogueItem = getDialogueItems(screenGui)[1];
local viewButton = dialogueItem:FindFirstChild("ViewButton");
assert(viewButton, "ViewButton should be present in the dialogue item.");

local informationFrame = viewButton:FindFirstChild("InformationFrame");
assert(informationFrame, "InformationFrame should be present in the ViewButton.");

local descriptionLabel = informationFrame:FindFirstChild("DescriptionLabel");
assert(descriptionLabel and descriptionLabel:IsA("TextLabel"), "DescriptionLabel should be present in the InformationFrame.");

-- Verify that there are no dialogue items rendered.
local messageContent = "New content";
dialogueFolder:GetChildren()[1]:SetAttribute("DialogueContent", messageContent);
verifyReactStatus();
descriptionLabel:GetPropertyChangedSignal("Text"):Wait();
expect(descriptionLabel.Text).toBe(messageContent);

end).toFinishBeforeSeconds(1);

end);

it("refreshes the conversation group if a conversation is added", function()

expect(function()
Expand Down Expand Up @@ -266,13 +297,12 @@ return {
assert(screenGui, "ScreenGui should be initialized before running tests.");
render();
verifyReactStatus();
expect(#getDialogueItems(screenGui)).toBe(#conversationsFolder:GetChildren());
local dialogueItem = getDialogueItems(screenGui)[1];

-- Delete the conversation script and verify that it is not rendered.
assert(dialogueGroup);
conversationScript:Destroy();
dialogueItem.Destroying:Wait();
verifyReactStatus();
dialogueGroup.ChildRemoved:Wait();
expect(#getDialogueItems(screenGui)).toBe(#conversationsFolder:GetChildren());

end).toFinishBeforeSeconds(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ local function DialogueItem(props: DialogueItemProperties)
local colors = useStudioColors();
local beginHistoryRecording, finishHistoryRecording = useChangeHistory();

local dialogueContent = dialogueScript:GetAttribute("DialogueContent");
local dialogueContent, setDialogueContent = React.useState(dialogueScript:GetAttribute("DialogueContent"));

local incrementPriority = React.useCallback(function(increment: number)

Expand Down Expand Up @@ -150,6 +150,22 @@ local function DialogueItem(props: DialogueItemProperties)

end, {increasePriority, decreasePriority, viewDialogue});

React.useEffect(function()

local dialogueContentChangedConnection = dialogueScript:GetAttributeChangedSignal("DialogueContent"):Connect(function()

setDialogueContent(dialogueScript:GetAttribute("DialogueContent"));

end);

return function()

dialogueContentChangedConnection:Disconnect();

end;

end, {dialogueScript});

return React.createElement("Frame", {
AutomaticSize = Enum.AutomaticSize.Y;
BackgroundTransparency = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,16 @@ local function DialogueGroupContainer(props: DialogueTableBodyProperties)
errorBoundary.showBoundary(errorMessage);

end;

table.insert(contentScriptConnections, Selection.SelectionChanged:Connect(refreshTable))

end;

local selectionChangedConnection = Selection.SelectionChanged:Connect(refreshTable);

task.spawn(refreshTable);

return function()

cleanupConnections();
selectionChangedConnection:Disconnect();

end;

Expand Down