Files
ueblueprint/tests/linking.spec.js
barsdeveloper 23ee628e28 Refactoring entities (#23)
* Still WIP

* WIP

* ArrayEntity parsing fixed

* Fix format text entity

* Tests for various entity classes and update entity class implementations

* More tests and fixed

* More entities fixed

* Simple entities serialization fixed

* Entities tests fixed

* Remove serialization bits

* Fix Function reference

* CustomProperties creating fixed

* WIP

* Better typing for grammars

* Decoding code fixes

* Fixing still

* Several fixes

* rename toString to serialize

* Several fixes

* More fixes

* Moving more stuff out of Utility

* Several fixes

* Fixing Linear color entity print

* Serialization fixes

* Fix serialization

* Method to compute grammar

* Renaming fix

* Fix array grammar and equality check

* Fix inlined keys

* Fix type

* Several serialization fixes

* Fix undefined dereference

* Several fixes

* More fixes and cleanup

* Fix keys quoting mechanism

* Fix natural number assignment

* Fix Int64 toString()

* Fix quoted keys for inlined arrays

* Fix PG pins

* Fix several test cases

* Types fixes

* New pin default value empty

* Fix non existing DefaultValue for variadic nodes

* Smaller fixes for crashes

* Fix link color when attached to knot

* Linking test and more reliability operations for adding pins

* Improve issue 18 test

* More tests and fixes

* Fix enum pin entity

* Remove failing test
2024-09-08 11:46:36 +02:00

158 lines
13 KiB
JavaScript

import BlueprintFixture from "./fixtures/BlueprintFixture.js"
import { expect, test } from "./fixtures/test.js"
test.describe("Linking", () => {
test.beforeEach(async ({ blueprintPage }) => {
await blueprintPage.removeNodes()
await blueprintPage.paste(String.raw`
Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_29" ExportPath="/Script/BlueprintGraph.K2Node_CallFunction'/Engine/Maps/Templates/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_CallFunction_29'"
bIsPureFunc=True
FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/Engine.KismetMathLibrary'",MemberName="MakeRotator")
NodePosX=-3152
NodePosY=-608
NodeGuid=4340FF7A779C4CD6A214350F6B196A20
CustomProperties Pin (PinId=01CEDBCB4492ACD233830FBBB7583895,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nKismet Math Library Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/Engine.KismetMathLibrary'",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__KismetMathLibrary",PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=9EF49AF4439604F146626C942630AE7F,PinName="Roll",PinFriendlyName="X (Roll)",PinToolTip="X (Roll)\nFloat (single-precision)",PinType.PinCategory="real",PinType.PinSubCategory="float",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,DefaultValue="0.0",AutogeneratedDefaultValue="0.0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=C7D2429C4EC24C0D8AE6ADA672BE7C6F,PinName="Pitch",PinFriendlyName="Y (Pitch)",PinToolTip="Y (Pitch)\nFloat (single-precision)",PinType.PinCategory="real",PinType.PinSubCategory="float",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,DefaultValue="0.0",AutogeneratedDefaultValue="0.0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=291C0FB3400FBFE88817D7BF71DC1FF7,PinName="Yaw",PinFriendlyName="Z (Yaw)",PinToolTip="Z (Yaw)\nFloat (single-precision)",PinType.PinCategory="real",PinType.PinSubCategory="float",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,DefaultValue="0.0",AutogeneratedDefaultValue="0.0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=5BADBCF34ED86925DAA81983B5BE12B2,PinName="ReturnValue",PinToolTip="Return Value\nRotator\n\nMakes a rotator {Roll, Pitch, Yaw} from rotation values supplied in degrees",Direction="EGPD_Output",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/CoreUObject.Rotator'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0, 0, 0",AutogeneratedDefaultValue="0, 0, 0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_5" ExportPath="/Script/BlueprintGraph.K2Node_CallFunction'/Engine/Maps/Templates/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_CallFunction_5'"
bIsPureFunc=True
FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/Engine.KismetMathLibrary'",MemberName="GetForwardVector")
NodePosX=-2704
NodePosY=-576
NodeGuid=9BFBB662CF9642FBB9003050B5A1D394
CustomProperties Pin (PinId=E8BB6375453E11DF80EEBDBEEE1FFA23,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nKismet Math Library Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/Engine.KismetMathLibrary'",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__KismetMathLibrary",PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=EBD734BF4537F7BFDA921F932A1E67D9,PinName="InRot",PinToolTip="In Rot\nRotator",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/CoreUObject.Rotator'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0, 0, 0",AutogeneratedDefaultValue="0, 0, 0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=C0EC34304B3A9CCCDFFE71BEE1A30949,PinName="ReturnValue",PinToolTip="Return Value\nVector\n\nRotate the world forward vector by the given rotation",Direction="EGPD_Output",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/CoreUObject.Vector'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0, 0, 0",AutogeneratedDefaultValue="0, 0, 0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
`)
})
/** @param {BlueprintFixture} blueprintPage */
const getElements = blueprintPage => {
/** @type {Locator<PinElement>} */
const aPin = blueprintPage.blueprintLocator.locator('ueb-node:has-text("Make Rotator") ueb-pin:has-text("Return Value")')
/** @type {Locator<PinElement>} */
const bPin = blueprintPage.blueprintLocator.locator('ueb-node:has-text("Get Forward Vector") ueb-pin:has-text("In Rot")')
return { aPin, bPin }
}
test("Can connect pins", async ({ blueprintPage }) => {
const { aPin, bPin } = getElements(blueprintPage)
const aRect = await aPin.evaluate(pin => pin.getBoundingClientRect())
const bRect = await bPin.evaluate(pin => pin.getBoundingClientRect())
const mouse = blueprintPage.page.mouse
const color = await aPin.evaluate(pin => pin.entity.pinColor().toString())
expect(color).toMatch(/\d+\,\s*\d+\,\s*\d+/)
expect(await aPin.evaluate(pin => pin.entity.pinColor().toString())).toEqual(color)
expect(await aPin.evaluate(pin => pin.entity.isLinked())).toBeFalsy()
expect(await bPin.evaluate(pin => pin.entity.isLinked())).toBeFalsy()
await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(0)
await aPin.hover({
position: {
x: Math.floor(aRect.width / 2),
y: Math.floor(aRect.height / 2),
}
})
await mouse.down()
await mouse.move(aRect.left + aRect.width + 100, aRect.top + aRect.height + 100, { steps: 4 })
// There is one link element ...
expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(1)
// ... but no pins are linked yet
expect(await aPin.evaluate(pin => pin.entity.isLinked())).toBeFalsy()
expect(await bPin.evaluate(pin => pin.entity.isLinked())).toBeFalsy()
await bPin.hover({
position: {
x: Math.floor(bRect.width / 2),
y: Math.floor(bRect.height / 2),
}
})
await mouse.up()
await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(1)
expect(await blueprintPage.blueprintLocator.locator("ueb-link").evaluate(
link => link.style.getPropertyValue("--ueb-link-color-rgb"))
)
.toEqual(color)
expect(await aPin.evaluate(pin => pin.entity.isLinked())).toBeTruthy()
expect(await bPin.evaluate(pin => pin.entity.isLinked())).toBeTruthy()
})
test("Can connect only once", async ({ blueprintPage }) => {
{
const { aPin, bPin } = getElements(blueprintPage)
const aRect = await aPin.evaluate(pin => pin.getBoundingClientRect())
const bRect = await bPin.evaluate(pin => pin.getBoundingClientRect())
const mouse = blueprintPage.page.mouse
await aPin.hover({
position: {
x: Math.floor(aRect.width / 2),
y: Math.floor(aRect.height / 2),
}
})
await mouse.down()
await mouse.move(aRect.left + aRect.width + 100, aRect.top + aRect.height + 100, { steps: 4 })
await bPin.hover({
position: {
x: Math.floor(bRect.width / 2),
y: Math.floor(bRect.height / 2),
}
})
await mouse.up()
await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(1)
}
{
const { aPin, bPin } = getElements(blueprintPage)
const aRect = await aPin.evaluate(pin => pin.getBoundingClientRect())
const bRect = await bPin.evaluate(pin => pin.getBoundingClientRect())
const mouse = blueprintPage.page.mouse
await aPin.hover({
position: {
x: Math.floor(aRect.width / 2),
y: Math.floor(aRect.height / 2),
}
})
await mouse.down()
await mouse.move(aRect.left + aRect.width + 100, aRect.top + aRect.height + 100, { steps: 4 })
await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(2)
await bPin.hover({
position: {
x: Math.floor(bRect.width / 2),
y: Math.floor(bRect.height / 2),
}
})
await expect(blueprintPage.blueprintLocator.locator('ueb-link[data-dragging="true"] .ueb-link-message-text'))
.toContainText("Replace existing input connections")
await mouse.up()
await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(1)
}
{
const { aPin, bPin } = getElements(blueprintPage)
const aRect = await aPin.evaluate(pin => pin.getBoundingClientRect())
const bRect = await bPin.evaluate(pin => pin.getBoundingClientRect())
const mouse = blueprintPage.page.mouse
await bPin.hover({
position: {
x: Math.floor(bRect.width / 2),
y: Math.floor(bRect.height / 2),
}
})
await mouse.down()
await mouse.move(bRect.left + bRect.width + 100, bRect.top + bRect.height + 100, { steps: 4 })
await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(2)
await aPin.hover({
position: {
x: Math.floor(aRect.width / 2),
y: Math.floor(aRect.height / 2),
}
})
await mouse.up()
await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(1)
}
})
})