Some minor fixes and refactoring

This commit is contained in:
barsdeveloper
2025-01-31 00:22:11 +02:00
parent 1073691794
commit 0e2ecdf93e
26 changed files with 290 additions and 87 deletions

View File

@@ -32,6 +32,12 @@ export default class BlueprintFixture {
}
}
async clone() {
const result = new BlueprintFixture(await this.page.context().newPage())
await result.setup()
return result
}
/**
* @param {Locator<HTMLElement>} draggable
* @param {Coordinates} offset
@@ -144,6 +150,7 @@ export default class BlueprintFixture {
}
async cleanup() {
await this.page.close()
}
blur() {

View File

@@ -63,12 +63,12 @@ test("Issue 30", async ({ blueprintPage }) => {
`)
await expect(blueprintPage.blueprintLocator.locator("ueb-node")).toHaveCount(5)
await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(4)
expect(blueprintPage.blueprintLocator.evaluate(blueprint =>
expect(await blueprintPage.blueprintLocator.evaluate(blueprint =>
/** @type {KnotNodeTemplate} */(
/** @type {NodeElement} */(blueprint.querySelectorAll("ueb-node")[3]).template
).switchDirectionsVisually
)).toBeTruthy()
expect(blueprintPage.blueprintLocator.evaluate(blueprint =>
expect(await blueprintPage.blueprintLocator.evaluate(blueprint =>
/** @type {KnotNodeTemplate} */(
/** @type {NodeElement} */(blueprint.querySelectorAll("ueb-node")[4]).template
).switchDirectionsVisually

83
tests/linking2.spec.js Executable file
View File

@@ -0,0 +1,83 @@
import { expect, test } from "./fixtures/test.js"
test("Linking 2", async ({ blueprintPage }) => {
const source = String.raw`
Begin Object Class=/Script/BlueprintGraph.K2Node_Knot Name="K2Node_Knot_6" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/Examples/Tag/Blueprints/DirectionDistanceObserver.DirectionDistanceObserver:GetObservationSpace.K2Node_Knot_6'"
NodePosX=816
NodePosY=256
NodeGuid=E8BC1D254BC44CC5E7076388BC697D41
CustomProperties Pin (PinId=47E4D9AF4CD414564F484A96E876E80B,PinName="InputPin",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=009095D54E2C15EBBB57DC9098EC7D8B,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/BlueprintGraph.K2Node_Knot Name="K2Node_Knot_7" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/Examples/Tag/Blueprints/DirectionDistanceObserver.DirectionDistanceObserver:GetObservationSpace.K2Node_Knot_7'"
NodePosX=1088
NodePosY=256
NodeGuid=E8BC1D254BC44CC5E7076388BC697D41
CustomProperties Pin (PinId=47E4D9AF4CD414564F484A96E876E80B,PinName="InputPin",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=009095D54E2C15EBBB57DC9098EC7D8B,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/BlueprintGraph.K2Node_Knot Name="K2Node_Knot_8" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/Examples/Tag/Blueprints/DirectionDistanceObserver.DirectionDistanceObserver:GetObservationSpace.K2Node_Knot_8'"
NodePosX=832
NodePosY=448
NodeGuid=E8BC1D254BC44CC5E7076388BC697D41
CustomProperties Pin (PinId=47E4D9AF4CD414564F484A96E876E80B,PinName="InputPin",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=009095D54E2C15EBBB57DC9098EC7D8B,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/BlueprintGraph.K2Node_Knot Name="K2Node_Knot_5" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/Examples/Tag/Blueprints/DirectionDistanceObserver.DirectionDistanceObserver:GetObservationSpace.K2Node_Knot_5'"
NodePosX=1088
NodePosY=464
NodeGuid=E8BC1D254BC44CC5E7076388BC697D41
CustomProperties Pin (PinId=47E4D9AF4CD414564F484A96E876E80B,PinName="InputPin",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=009095D54E2C15EBBB57DC9098EC7D8B,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
`
await blueprintPage.paste(source)
/** @type {(i: Number) => Locator<NodeElement>} */
const getKnot = i => blueprintPage.blueprintLocator.locator("ueb-node").nth(i)
const getRect = async i => await getKnot(i).evaluate(pin => pin.getBoundingClientRect())
let rect = await getRect(0)
const knotSize = [rect.width / 2, rect.height / 2]
await blueprintPage.blueprintLocator.evaluate(b => b.template.centerContentInViewport(false))
const mouse = blueprintPage.page.mouse
const link = async (origin, target) => {
await origin.hover()
await mouse.down()
await mouse.move(100, 100, { steps: 4 })
await target.hover()
await mouse.up()
}
await expect(blueprintPage.blueprintLocator.locator("ueb-node")).toHaveCount(4)
await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(0)
let a = getKnot(0)
let b = getKnot(1)
await link(a, b)
await expect(blueprintPage.blueprintLocator.locator("ueb-node")).toHaveCount(4)
await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(1)
expect((await a.evaluate(n => /** @type {KnotNodeTemplate} */(n.template).inputPin.isLinked))).toBeFalsy()
expect((await a.evaluate(n => /** @type {KnotNodeTemplate} */(n.template).outputPin.isLinked))).toBeTruthy()
expect((await b.evaluate(n => /** @type {KnotNodeTemplate} */(n.template).inputPin.isLinked))).toBeTruthy()
expect((await b.evaluate(n => /** @type {KnotNodeTemplate} */(n.template).outputPin.isLinked))).toBeFalsy()
a = getKnot(3)
b = getKnot(2)
await link(a, b)
await expect(blueprintPage.blueprintLocator.locator("ueb-node")).toHaveCount(4)
await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(2)
expect((await a.evaluate(n => /** @type {KnotNodeTemplate} */(n.template).inputPin.isLinked))).toBeTruthy()
expect((await a.evaluate(n => /** @type {KnotNodeTemplate} */(n.template).outputPin.isLinked))).toBeFalsy()
expect((await b.evaluate(n => /** @type {KnotNodeTemplate} */(n.template).inputPin.isLinked))).toBeFalsy()
expect((await b.evaluate(n => /** @type {KnotNodeTemplate} */(n.template).outputPin.isLinked))).toBeTruthy()
a = getKnot(3)
b = getKnot(0)
await link(a, b)
await expect(blueprintPage.blueprintLocator.locator("ueb-node")).toHaveCount(4)
await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(2)
expect((await a.evaluate(n => /** @type {KnotNodeTemplate} */(n.template).inputPin.isLinked))).toBeTruthy()
expect((await a.evaluate(n => /** @type {KnotNodeTemplate} */(n.template).outputPin.isLinked))).toBeFalsy()
expect((await b.evaluate(n => /** @type {KnotNodeTemplate} */(n.template).inputPin.isLinked))).toBeFalsy()
expect((await b.evaluate(n => /** @type {KnotNodeTemplate} */(n.template).outputPin.isLinked))).toBeTruthy()
})

View File

@@ -3,6 +3,7 @@ import { expect, test } from "./fixtures/test.js"
const firstRowOnly = v => v.replaceAll(/^\s+|\n.+/gs, "")
test("Inner renaming", async ({ blueprintPage }) => {
blueprintPage = await blueprintPage.clone()
let source = String.raw`
Begin Object Class=/Script/PCGEditor.PCGEditorGraphNode Name="PCGEditorGraphNode_2" ExportPath=/Script/PCGEditor.PCGEditorGraphNode'"/Game/NewPCGGraph.NewPCGGraph:PCGEditorGraph_1.PCGEditorGraphNode_2"'
Begin Object Class=/Script/PCG.PCGNode Name="ExecuteBlueprint_7" ExportPath=/Script/PCG.PCGNode'"/Game/NewPCGGraph.NewPCGGraph:PCGEditorGraph_1.PCGEditorGraphNode_2.ExecuteBlueprint_7"'
@@ -169,4 +170,5 @@ test("Inner renaming", async ({ blueprintPage }) => {
))).toEqual(
`Begin Object Name="PCGBlueprintSettings_0" ExportPath=/Script/PCG.PCGBlueprintSettings'"/Game/NewPCGGraph.NewPCGGraph:PCGEditorGraph_1..ExecuteBlueprint_7.PCGBlueprintSettings_0"'`
)
blueprintPage.cleanup()
})

View File

@@ -3,6 +3,7 @@ import { expect, test } from "./fixtures/test.js"
const firstRowOnly = v => v.replaceAll(/^\s+|\n.+/gs, "")
test("Renaming", async ({ blueprintPage }) => {
blueprintPage = await blueprintPage.clone()
let source = String.raw`
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_40" ExportPath=/Script/UnrealEd.MaterialGraphNode'"/Engine/Transient.M_Brick_Cut_Stone:MaterialGraph_0.MaterialGraphNode_40"'
End Object
@@ -27,4 +28,5 @@ test("Renaming", async ({ blueprintPage }) => {
expect(firstRowOnly(await blueprintPage.getSerializedNodes())).toEqual(
`Begin Object Class=/Script/UnrealEd.MaterialGraphNode ExportPath=/Script/UnrealEd.MaterialGraphNode'"/Engine/Transient.M_Brick_Cut_Stone:MaterialGraph_0."'`
)
await blueprintPage.cleanup()
})

View File

@@ -36,9 +36,8 @@ test.describe("Niagara ScriptVariables", () => {
await blueprintPage.removeNodes()
})
test.describe.configure({ mode: "parallel" })
test("Deserialization", async ({ blueprintPage }) => {
blueprintPage = await blueprintPage.clone()
expect(await blueprintPage.blueprintLocator.evaluate(blueprint => blueprint.entity.serialize()))
.toEqual('Begin Object Name="Blueprint"\nEnd Object\n')
const source = String.raw`
@@ -83,9 +82,11 @@ test.describe("Niagara ScriptVariables", () => {
return entity.serialize()
}))
.toEqual(serialized(source, "###########"))
blueprintPage.cleanup()
})
test("Merging", async ({ blueprintPage }) => {
blueprintPage = await blueprintPage.clone()
// Var: Local.Module.Input, Local.Module.Input001, Local.Module.NewOutput
let source = String.raw`
Begin Object Class=/Script/NiagaraEditor.NiagaraClipboardContent Name="NiagaraClipboardContent_6" ExportPath="/Script/NiagaraEditor.NiagaraClipboardContent'/Engine/Transient.NiagaraClipboardContent_6'"
@@ -357,5 +358,6 @@ test.describe("Niagara ScriptVariables", () => {
.filter(v => v?.length > 0)
source = await blueprintPage.getSerializedNodes()
expect(source).toMatch(Utility.getFirstWordOrder(expectedWords))
blueprintPage.cleanup()
})
})

View File

@@ -0,0 +1,32 @@
import { testNode, expect } from "./fixtures/test.js"
testNode({
name: "Conv Transform To String",
title: "",
value: String.raw`
Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_3" ExportPath="/Script/BlueprintGraph.K2Node_CallFunction'/Game/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_CallFunction_3'"
bDefaultsToPureFunc=True
FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/Engine.KismetStringLibrary'",MemberName="Conv_TransformToString")
NodePosX=2640
NodePosY=-1152
NodeGuid=5DE5CD9FB3DD44ADA7C373D59EA63D23
CustomProperties Pin (PinId=A1DEA5655C524429A83F3447B2DB6A42,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nKismet String Library Riferimento Oggetto",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/Engine.KismetStringLibrary'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultObject="/Script/Engine.Default__KismetStringLibrary",PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=50F38A250A1944A4A2AFF41A4AE5092C,PinName="InTrans",PinToolTip="In Trans\nTrasformazione (by ref)",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/CoreUObject.Transform'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=True,PinType.bIsConst=True,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_Knot_5 009095D54E2C15EBBB57DC9098EC7D8B,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=0A7DB6976935430EAF08AEA50D0C6278,PinName="ReturnValue",PinToolTip="Return Value\nStringa\n\nConverte un valore di trasformazione in una stringa, nel formato \'Translazione: X= Y= Z= Rotazione: P= Y= R= Scala: X= Y= Z=\'",Direction="EGPD_Output",PinType.PinCategory="string",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_CallFunction_0 06ED5D76ADEE42119EC0A4761E2689CE,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
`,
pins: 2,
delegate: false,
development: false,
additionalTest: async node => {
expect(await node.evaluate(node => node.classList.contains("ueb-node-style-glass"))).toBeTruthy()
expect(await node.evaluate(node => node.classList.contains("ueb-node-style-conversion"))).toBeTruthy()
expect(await node.evaluate(node => node.classList.contains("ueb-node-style-default"))).toBeFalsy()
expect(await node.locator("ueb-pin").nth(0).evaluate(pin =>
/** @type {PinElement} */(pin).entity.pinColor().toString()
)).toEqual("227, 103, 0")
expect(await node.locator("ueb-pin").nth(1).evaluate(pin =>
/** @type {PinElement} */(pin).entity.pinColor().toString()
)).toEqual("251, 0, 208")
},
})

26
tests/nodeGetTransform.spec.js Executable file
View File

@@ -0,0 +1,26 @@
import Configuration from "../js/Configuration.js"
import SVGIcon from "../js/SVGIcon.js"
import { testNode } from "./fixtures/test.js"
testNode({
name: "Get Transform",
subtitle: "Target is Actor",
value: String.raw`
Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_1" ExportPath="/Script/BlueprintGraph.K2Node_CallFunction'/Game/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_CallFunction_1'"
bDefaultsToPureFunc=True
FunctionReference=(MemberName="GetTransform",bSelfContext=True)
NodePosX=2416
NodePosY=-720
NodeGuid=CFB627D77A3A4419AFF2A5539B872404
CustomProperties Pin (PinId=2BC8CE91A0424570A4CCEBCC33E102C4,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nActor Riferimento Oggetto",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/Engine.Actor'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=BDF15274D22541DA9E33F342F6341F11,PinName="ReturnValue",PinToolTip="Return Value\nTrasformazione (by ref)\n\nLa trasformazione che trasforma lo spazio dell\'attore in quello del mondo.",Direction="EGPD_Output",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/CoreUObject.Transform'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=True,PinType.bIsConst=True,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_Knot_8 47E4D9AF4CD414564F484A96E876E80B,K2Node_Knot_5 47E4D9AF4CD414564F484A96E876E80B,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
End Object
`,
size: [15, 5],
color: Configuration.nodeColors.green,
icon: SVGIcon.functionSymbol,
pins: 2,
pinNames: ["Target", "Return Value"],
delegate: false,
development: false,
})