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
This commit is contained in:
barsdeveloper
2024-09-08 11:46:36 +02:00
committed by GitHub
parent 31a07b992d
commit 23ee628e28
129 changed files with 8888 additions and 8584 deletions

View File

@@ -1,20 +1,13 @@
import AttributeInfo from "../../js/entity/AttributeInfo.js"
import IEntity from "../../js/entity/IEntity.js"
import NumberEntity from "../../js/entity/NumberEntity.js"
export default class Entity1 extends IEntity {
static attributeSeparator = ", "
static wrap = (entity, v) => `Entity1(${v})`
static attributes = {
a: new AttributeInfo({
type: Number,
default: 8,
}),
b: new AttributeInfo({
type: Number,
default: 9,
}),
}
constructor(values = {}) {
super(values)
...super.attributes,
a: NumberEntity.withDefault(type => new type(8)),
b: NumberEntity.withDefault(type => new type(9)),
}
}

View File

@@ -1,21 +1,38 @@
import AttributeInfo from "../../js/entity/AttributeInfo.js"
import ArrayEntity from "../../js/entity/ArrayEntity.js"
import BooleanEntity from "../../js/entity/BooleanEntity.js"
import IEntity from "../../js/entity/IEntity.js"
import NumberEntity from "../../js/entity/NumberEntity.js"
import StringEntity from "../../js/entity/StringEntity.js"
import Entity1 from "./Entity1.js"
export default class Entity2 extends IEntity {
static attributeSeparator = "\n"
static keySeparator = ": "
static printKey = k => ` ${k}`
static wrap = (entity, v) => `{\n${v}\n}`
static attributes = {
someNumber: AttributeInfo.createValue(567),
someString: AttributeInfo.createValue("alpha"),
someString2: AttributeInfo.createValue("beta"),
someBoolean: AttributeInfo.createValue(true),
someBoolean2: AttributeInfo.createValue(false),
someObjectString: AttributeInfo.createValue("gamma"),
someArray: AttributeInfo.createValue([400, 500, 600, 700, 800]),
someArray2: AttributeInfo.createValue(() => [400, 500, 600, 700, 800]),
someEntity: new AttributeInfo({
type: Entity1,
default: new Entity1()
}),
...super.attributes,
someNumber: NumberEntity.withDefault(type => new type(567)),
someString: StringEntity.withDefault(type => new type("alpha")),
someString2: StringEntity.withDefault(type => new type("beta")),
someBoolean: BooleanEntity.withDefault(type => new type(true)),
someBoolean2: BooleanEntity.withDefault(),
someObjectString: StringEntity.withDefault(type => new type("gamma")),
someArray: ArrayEntity.of(NumberEntity).withDefault(type => new type([
new NumberEntity(400),
new NumberEntity(500),
new NumberEntity(600),
new NumberEntity(700),
new NumberEntity(800),
])),
someArray2: ArrayEntity.of(NumberEntity).withDefault(type => new type([
new NumberEntity(-400),
new NumberEntity(-500),
new NumberEntity(-600),
new NumberEntity(-700),
new NumberEntity(-800),
])),
someEntity: Entity1.withDefault(),
}
}

View File

@@ -1,74 +1,58 @@
import AttributeInfo from "../../js/entity/AttributeInfo.js"
import AlternativesEntity from "../../js/entity/AlternativesEntity.js"
import ArrayEntity from "../../js/entity/ArrayEntity.js"
import BooleanEntity from "../../js/entity/BooleanEntity.js"
import IEntity from "../../js/entity/IEntity.js"
import Union from "../../js/entity/Union.js"
import NullEntity from "../../js/entity/NullEntity.js"
import NumberEntity from "../../js/entity/NumberEntity.js"
import StringEntity from "../../js/entity/StringEntity.js"
import Entity1 from "./Entity1.js"
import Entity2 from "./Entity2.js"
export default class Entity3 extends IEntity {
static attributeSeparator = "\n"
static keySeparator = ": "
static printKey = k => ` ${k}`
static wrap = (entity, v) => `[[\n${v}\n]]`
static attributes = {
alpha: AttributeInfo.createValue(32),
bravo: new AttributeInfo({
type: Number,
default: 78,
}),
charlie: new AttributeInfo({
type: String,
default: "Charlie",
}),
delta: new AttributeInfo({
type: String,
default: null,
}),
echo: AttributeInfo.createValue("echo"),
foxtrot: AttributeInfo.createValue(false),
golf: AttributeInfo.createValue([]),
hotel: new AttributeInfo({
type: Array,
default: null,
}),
india: new AttributeInfo({
type: [Number],
default: () => [],
}),
juliett: new AttributeInfo({
type: [String],
default: ["a", "b", "c", "d", "e"],
}),
kilo: new AttributeInfo({
type: [Boolean],
default: () => [true, false, false, true, true],
}),
lima: AttributeInfo.createType(String),
mike: new AttributeInfo({
type: new Union(Number, String, Array),
default: "Bar",
}),
november: new AttributeInfo({
type: new Union(Number, String, Array),
default: 0,
}),
oscar: new AttributeInfo({
type: Entity1,
default: () => new Entity1()
}),
papa: new AttributeInfo({
type: Entity1,
default: () => new Entity1({ a: 12, b: 13 }),
}),
quebec: new AttributeInfo({
default: 0, // will assign undefined because it does not satisfy the predicate
predicate: v => v >= 1 && v <= 10,
}),
romeo: new AttributeInfo({
type: Entity1,
default: new Entity1(),
inlined: true,
}),
sierra: new AttributeInfo({
type: Entity2,
default: new Entity2(),
inlined: true,
}),
...super.attributes,
alpha: NumberEntity.withDefault(type => new type(32)),
bravo: NumberEntity.withDefault(type => new type(78)),
charlie: StringEntity.withDefault(type => new type("Charlie")),
delta: StringEntity.withDefault(type => new NullEntity()),
echo: StringEntity.withDefault(type => new type("echo")),
foxtrot: BooleanEntity.withDefault(),
golf: ArrayEntity.of(StringEntity).withDefault(),
hotel: ArrayEntity.of(NumberEntity).withDefault(() => new NullEntity()),
india: ArrayEntity.of(NumberEntity).withDefault(),
juliett: ArrayEntity.of(StringEntity).withDefault(type => new type([
new StringEntity("a"),
new StringEntity("b"),
new StringEntity("c"),
new StringEntity("d"),
new StringEntity("e"),
])),
kilo: ArrayEntity.of(BooleanEntity).withDefault(type => new type([
new BooleanEntity(true),
new BooleanEntity(),
new BooleanEntity(),
new BooleanEntity(true),
new BooleanEntity(true),
])),
lima: StringEntity,
mike: AlternativesEntity
.accepting(NumberEntity, StringEntity, ArrayEntity)
.withDefault(type => new StringEntity("Bar")),
november: AlternativesEntity
.accepting(NumberEntity, StringEntity, ArrayEntity)
.withDefault(type => new NumberEntity(0)),
oscar: Entity1.withDefault(),
papa: Entity1.withDefault(type => new type({
a: new NumberEntity(12),
b: new NumberEntity(13),
})),
quebec: NumberEntity,
romeo: Entity1.withDefault().flagInlined(),
sierra: Entity2.withDefault().flagInlined(),
}
}

View File

@@ -1,33 +1,23 @@
import AttributeInfo from "../../js/entity/AttributeInfo.js"
import ArrayEntity from "../../js/entity/ArrayEntity.js"
import IEntity from "../../js/entity/IEntity.js"
import NullEntity from "../../js/entity/NullEntity.js"
import NumberEntity from "../../js/entity/NumberEntity.js"
import Entity1 from "./Entity1.js"
import Entity3 from "./Entity3.js"
export default class Entity4 extends IEntity {
static attributeSeparator = "\n"
static keySeparator = " => "
static printKey = k => ` \${${k}}`
static wrap = (entity, v) => `Begin\n${v}\nEnd`
static attributes = {
first: new AttributeInfo({
type: Entity3,
default: new Entity3(),
inlined: true,
}),
second: new AttributeInfo({
default: [new Entity1({ a: 1, b: 2 }), new Entity1({ a: 11, b: 22 })],
inlined: true,
}),
third: new AttributeInfo({
type: Array,
default: null,
})
}
constructor() {
super()
/** @type {Entity1} */ this.second
IEntity.defineAttributes(this.second, {
0: {
inlined: true,
},
})
...super.attributes,
first: Entity3.withDefault().flagInlined(),
second: ArrayEntity.of(Entity1).withDefault(type => new type([
new (Entity1.flagInlined())({ a: new NumberEntity(1), b: new NumberEntity(2) }),
new Entity1({ a: new NumberEntity(11), b: new NumberEntity(22) }),
])).flagInlined(),
third: ArrayEntity.withDefault(() => new NullEntity()),
}
}

View File

@@ -1,19 +0,0 @@
import AttributeInfo from "../../js/entity/AttributeInfo.js"
import IntegerEntity from "../../js/entity/IntegerEntity.js"
import ObjectEntity from "../../js/entity/ObjectEntity.js"
import EntityF from "./EntityF.js"
// @ts-expect-error
export default class Entity5 extends ObjectEntity {
static attributes = {
key1: AttributeInfo.createType(String),
key2: AttributeInfo.createType(EntityF),
key3: new AttributeInfo({
type: IntegerEntity,
default: new IntegerEntity(5),
silent: true,
}),
}
static grammar = this.createGrammar()
}

View File

@@ -1,27 +0,0 @@
import AttributeInfo from "../../js/entity/AttributeInfo.js"
import IEntity from "../../js/entity/IEntity.js"
import Union from "../../js/entity/Union.js"
import Grammar from "../../js/serialization/Grammar.js"
export default class EntityF extends IEntity {
static attributes = {
...super.attributes,
arg1: AttributeInfo.createType(Number),
arg2: AttributeInfo.createType(String),
lookbehind: new AttributeInfo({
...super.attributes.lookbehind,
default: new Union("Foo", "Bar"),
})
}
static grammar = this.createGrammar()
static createGrammar() {
return Grammar.createEntityGrammar(this, false)
}
constructor(values = {}) {
super(values)
}
}

View File

@@ -538,6 +538,32 @@ export default class FlowControlNodes extends NodeTests {
delegate: false,
development: false,
},
{
name: "Sequence",
value: String.raw`
Begin Object Class=/Script/BlueprintGraph.K2Node_ExecutionSequence Name="K2Node_ExecutionSequence_4" ExportPath="/Script/BlueprintGraph.K2Node_ExecutionSequence'/Engine/Maps/Templates/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_ExecutionSequence_4'"
NodePosX=496
NodePosY=192
NodeGuid=7E38FFEB6B474D4E80CDA4B4720C9E24
CustomProperties Pin (PinId=2612016B4EAAC152FA9ABB9E23572EE1,PinName="execute",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,LinkedTo=(K2Node_CallFunction_26 2658362A4F2BA6A3BE7398A8604FAC6D,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=D665418E47B39BB80A8F02B3951BF0DB,PinName="then_0",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,LinkedTo=(K2Node_Timeline_1 ABA55A2B4F3689076D856F921255888F,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=A3D98FA145671788536EA1AD2CF5DA61,PinName="then_1",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,LinkedTo=(K2Node_Timeline_1 4069CE0043C4948BDE9D17A2FEE8DE0A,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=47D0C212ACF74C57873C7C16B66E0EC6,PinName="then_2",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
`,
size: [8.5, 10],
color: Configuration.nodeColors.gray,
icon: SVGIcon.sequence,
pins: 4,
pinNames: [
"Then 0",
"Then 1",
"Then 2",
],
delegate: false,
development: false,
variadic: true,
},
])
}
}

View File

@@ -41,26 +41,24 @@ export default class IssuesNodes1 extends NodeTests {
delegate: false,
development: false,
additionalTest: async (node, pins, blueprintPage) => {
const relevantPins = (await Promise.all(
pins.map(async p => {
const innerText = await p.innerText()
// @ts-expect-error
return [Configuration.rgba.includes(innerText), p]
})
))
.filter(([flag, value]) => flag)
.map(([flag, value]) => /** @type {Locator<PinElement>} */(value))
expect(await Promise.all(relevantPins.map(async pin => await pin.innerText()))).toStrictEqual(Configuration.rgba)
for (const p of relevantPins) {
const pinName = await p.innerText()
expect(p.locator('input[type="checkbox"]')).toBeChecked({ checked: pinName === "R" })
const relevantPins = []
for (const pin of pins) {
const innerText = await pin.innerText()
if (Configuration.rgba.includes(innerText)) {
relevantPins.push(pin)
}
}
for (const pin of relevantPins) {
const pinName = await pin.innerText()
// Only pin R is checked
await expect(pin.locator('input[type="checkbox"]')).toBeChecked({ checked: pinName === "R" })
}
await relevantPins[0].locator('input[type="checkbox"]').uncheck() // Uncheck "R"
await relevantPins[2].locator('input[type="checkbox"]').check() // Check "B"
await relevantPins[3].locator('input[type="checkbox"]').check() // Check "A"
await relevantPins[2].locator('input[type="checkbox"]').uncheck() // Uncheck "B"
await relevantPins[2].locator('input[type="checkbox"]').check() // Check "B"
expect(node.locator(".ueb-node-name")).toHaveText("Mask ( B A )")
await expect(node.locator(".ueb-node-name")).toHaveText("Mask ( B A )")
const resultSerialization = await blueprintPage.blueprintLocator.evaluate(blueprint => {
blueprint.selectAll()
return blueprint.template.getCopyInputObject().getSerializedText()
@@ -97,6 +95,49 @@ export default class IssuesNodes1 extends NodeTests {
expect(resultSerialization).toMatch(Utility.getFirstWordOrder(words))
}
},
{
name: "Issue 21",
title: "Subtract(1,1)",
value: String.raw`
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_202" ExportPath=/Script/UnrealEd.MaterialGraphNode'/Engine/Transient.卡通:MaterialGraph_0.MaterialGraphNode_202'
Begin Object Class=/Script/Engine.MaterialExpressionSubtract Name="MaterialExpressionSubtract_10" ExportPath=/Script/Engine.MaterialExpressionSubtract'/Engine/Transient.卡通:MaterialGraph_0.MaterialGraphNode_202.MaterialExpressionSubtract_10'
End Object
Begin Object Name="MaterialExpressionSubtract_10" ExportPath=/Script/Engine.MaterialExpressionSubtract'/Engine/Transient.卡通:MaterialGraph_0.MaterialGraphNode_202.MaterialExpressionSubtract_10'
A=(Expression="/Script/Engine.MaterialExpressionSaturate'MaterialGraphNode_237.MaterialExpressionSaturate_3'")
B=(Expression="/Script/Engine.MaterialExpressionSaturate'MaterialGraphNode_201.MaterialExpressionSaturate_7'")
MaterialExpressionEditorX=0
MaterialExpressionEditorY=0
MaterialExpressionGuid=7202C13642DA1225C118CF867599387C
Material="/Script/UnrealEd.PreviewMaterial'/Engine/Transient.卡通'"
End Object
MaterialExpression=/Script/Engine.MaterialExpressionSubtract'MaterialExpressionSubtract_10'
NodePosX=0
NodePosY=0
NodeGuid=7008F5AC49E8F5BFD4C707819A58C021
CustomProperties Pin (PinId=86D4DE5E48C71A576ED0519B982907B3,PinName="A",PinType.PinCategory="optional",PinType.PinSubCategory="red",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="1",LinkedTo=(),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=5C75E1374E1E7436C72B9FA072875C04,PinName="B",PinType.PinCategory="optional",PinType.PinSubCategory="red",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="1",LinkedTo=(),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=528D346A49976B0854764CA755AF2F93,PinName="Output",PinFriendlyName=NSLOCTEXT("MaterialGraphNode", "Space", " "),Direction="EGPD_Output",PinType.PinCategory="",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=(),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
`,
size: [8, 6],
color: Configuration.nodeColors.green,
icon: null,
pins: 3,
pinNames: ["A", "B"],
delegate: false,
development: false,
additionalTest: async (node, pins, blueprintPage) => {
await expect(pins[0].locator("ueb-input")).toHaveText("1.0")
await expect(pins[1].locator("ueb-input")).toHaveText("1.0")
let inputs = await node.locator("ueb-input").all()
await inputs[0].fill("-8")
await blueprintPage.blur()
expect(await node.evaluate(n => n.nodeDisplayName)).toEqual("Subtract(-8,1)")
await inputs[1].fill("9.2")
await blueprintPage.blur()
expect(await node.evaluate(n => n.nodeDisplayName)).toEqual("Subtract(-8,9.2)")
}
},
])
}
}

View File

@@ -1,7 +1,7 @@
import Configuration from "../../js/Configuration.js"
import Utility from "../../js/Utility.js"
import PinElement from "../../js/element/PinElement.js"
import IntegerEntity from "../../js/entity/IntegerEntity.js"
import NumberEntity from "../../js/entity/NumberEntity.js"
import RBSerializationVector2DEntity from "../../js/entity/RBSerializationVector2DEntity.js"
import VectorEntity from "../../js/entity/VectorEntity.js"
import { expect } from "../fixtures/test.js"
@@ -70,10 +70,10 @@ export default class MaterialNodes extends NodeTests {
development: false,
additionalTest: async node => {
const value = 10000.0
/** @type {Locator<PinElement<Number>>} */
/** @type {Locator<PinElement<NumberEntity>>} */
const pin = node.locator("ueb-pin").first()
expect(await pin.evaluate(pin => pin.getDefaultValue())).toBeCloseTo(value)
await expect(node.locator("ueb-input")).toHaveText([Utility.printNumber(value)])
expect(await pin.evaluate(pin => pin.getDefaultValue().valueOf())).toBeCloseTo(value)
await expect(node.locator("ueb-input")).toHaveText([NumberEntity.printNumber(value)])
}
},
{
@@ -111,13 +111,13 @@ export default class MaterialNodes extends NodeTests {
additionalTest: async node => {
const x = 0.1
const y = 23.88888
/** @type {Locator<PinElement<Number>>} */
/** @type {Locator<PinElement<NumberEntity>>} */
const xPin = node.locator("ueb-pin").nth(0)
/** @type {Locator<PinElement<Number>>} */
/** @type {Locator<PinElement<NumberEntity>>} */
const yPin = node.locator("ueb-pin").nth(1)
expect(await xPin.evaluate(pin => pin.getDefaultValue())).toBeCloseTo(x)
expect(await yPin.evaluate(pin => pin.getDefaultValue())).toBeCloseTo(y)
await expect(node.locator("ueb-input")).toHaveText([Utility.printNumber(x), Utility.printNumber(y)])
expect(await xPin.evaluate(pin => pin.getDefaultValue().valueOf())).toBeCloseTo(x)
expect(await yPin.evaluate(pin => pin.getDefaultValue().valueOf())).toBeCloseTo(y)
await expect(node.locator("ueb-input")).toHaveText([NumberEntity.printNumber(x), NumberEntity.printNumber(y)])
}
},
{
@@ -157,7 +157,7 @@ export default class MaterialNodes extends NodeTests {
const values = await input.evaluate(pin => pin.getDefaultValue().toArray())
const expected = [0.00432, 123.199997, 7657650176.0]
expected.forEach((v, i) => expect(v).toBeCloseTo(values[i]))
await expect(input.locator("ueb-input")).toHaveText(expected.map(v => Utility.printNumber(v)))
await expect(input.locator("ueb-input")).toHaveText(expected.map(v => NumberEntity.printNumber(v)))
}
},
{
@@ -490,9 +490,7 @@ export default class MaterialNodes extends NodeTests {
color: Configuration.nodeColors.red,
icon: null,
pins: 2,
pinNames: [
"Preview",
],
pinNames: ["Preview"],
delegate: false,
development: false,
},
@@ -520,9 +518,7 @@ export default class MaterialNodes extends NodeTests {
color: Configuration.nodeColors.red,
icon: null,
pins: 2,
pinNames: [
"Preview",
],
pinNames: ["Preview"],
delegate: false,
development: false,
},

View File

@@ -193,11 +193,24 @@ export default class OperationsNodes extends NodeTests {
delegate: false,
development: false,
variadic: true,
additionalTest: async (node, pins) => {
additionalTest: async (node, pins, blueprintPage) => {
for (const pin of pins) {
expect(await pin.evaluate(pin => pin.template.renderIcon().strings.join("")))
.toStrictEqual(SVGIcon.operationPin.strings.join(""))
}
let inputs = await node.locator(".ueb-pin-input").all()
for (const input of inputs) {
expect(await input.isChecked()).toBeFalsy()
}
await inputs[inputs.length - 1].check()
expect(await inputs[inputs.length - 1].isChecked()).toBeTruthy()
const variadic = blueprintPage.node.getByText("Add pin")
await variadic.click()
inputs = await node.locator(".ueb-pin-input").all()
await inputs[inputs.length - 2].uncheck()
for (const input of inputs) {
expect(await input.isChecked()).toBeFalsy()
}
}
},
{
@@ -276,11 +289,21 @@ export default class OperationsNodes extends NodeTests {
delegate: false,
development: false,
variadic: true,
additionalTest: async (node, pins) => {
additionalTest: async (node, pins, blueprintPage) => {
for (const pin of pins) {
expect(await pin.evaluate(pin => pin.template.renderIcon().strings.join("")))
.toStrictEqual(SVGIcon.operationPin.strings.join(""))
}
expect(await pins[0].evaluate(pin => pin.entity.DefaultValue.constructor.serialized)).toBeTruthy()
expect(await pins[1].evaluate(pin => pin.entity.DefaultValue.constructor.serialized)).toBeTruthy()
await pins[0].locator("ueb-input").fill("54")
await blueprintPage.blur()
expect(await pins[0].evaluate(pin => pin.entity.DefaultValue.constructor.serialized)).toBeTruthy()
expect(await pins[0].evaluate(pin => pin.entity.DefaultValue.serialize())).toEqual('"54"')
await pins[1].locator("ueb-input").fill("771")
await blueprintPage.blur()
expect(await pins[1].evaluate(pin => pin.entity.DefaultValue.constructor.serialized)).toBeTruthy()
expect(await pins[1].evaluate(pin => pin.entity.DefaultValue.serialize())).toEqual('"771"')
}
},
{

View File

@@ -570,7 +570,7 @@ export default class OtherNodes extends NodeTests {
await inputs[1].fill("-22.22")
await inputs[2].fill("-33.33")
await blueprintPage.blur()
expect(await pins[2].evaluate(pin => pin.entity.DefaultValue.constructor.name))
expect(await pins[2].evaluate(pin => pin.entity.DefaultValue.constructor.className()))
.toBe("SimpleSerializationVectorEntity")
await expect(pins[2].locator("ueb-input")).toHaveText(["-11.11", "-22.22", "-33.33"])
inputs = await pins[3].locator("ueb-input").all()
@@ -578,18 +578,18 @@ export default class OtherNodes extends NodeTests {
await inputs[1].fill("77")
await inputs[2].fill("66")
await blueprintPage.blur()
expect(await pins[3].evaluate(pin => pin.entity.DefaultValue.constructor.name))
expect(await pins[3].evaluate(pin => pin.entity.DefaultValue.constructor.className()))
.toBe("SimpleSerializationRotatorEntity")
await expect(pins[3].locator("ueb-input")).toHaveText(["88.0", "77.0", "66.0"])
await pins[4].locator("ueb-input").fill("35.814")
await blueprintPage.blur()
expect(await pins[4].evaluate(pin => pin.entity.DefaultValue.constructor.name))
expect(await pins[4].evaluate(pin => pin.entity.DefaultValue.constructor.className()))
.toBe("IntegerEntity")
await expect(pins[4].locator("ueb-input")).toHaveText("35")
await pins[6].locator("input").check()
await expect(pins[6].locator("input")).toBeChecked()
expect(await pins[6].evaluate(pin => pin.entity.DefaultValue.constructor.name))
.toBe("Boolean")
expect(await pins[6].evaluate(pin => pin.entity.DefaultValue.constructor.className()))
.toBe("BooleanEntity")
const serialization = await blueprintPage.getSerializedNodes()
await blueprintPage.removeNodes()
await blueprintPage.paste(serialization)

View File

@@ -0,0 +1,12 @@
export default `{
someNumber: 567
someString: "alpha"
someString2: "beta"
someBoolean: True
someBoolean2: False
someObjectString: "gamma"
someArray: (400,500,600,700,800)
someArray2: (-400,-500,-600,-700,-800)
someEntity.a: 8
someEntity.b: 9
}`

View File

@@ -6,6 +6,6 @@ export default `{
someBoolean2: False
someObjectString: "gamma"
someArray: (400,500,600,700,800)
someArray2: (400,500,600,700,800)
someArray2: (-400,-500,-600,-700,-800)
someEntity: Entity1(a=8, b=9)
}`

View File

@@ -14,7 +14,6 @@ export default `[[
november: 0
oscar: Entity1(a=8, b=9)
papa: Entity1(a=12, b=13)
quebec: 6
romeo.a: 8
romeo.b: 9
sierra.someNumber: 567
@@ -24,6 +23,6 @@ export default `[[
sierra.someBoolean2: False
sierra.someObjectString: "gamma"
sierra.someArray: (400,500,600,700,800)
sierra.someArray2: (400,500,600,700,800)
sierra.someArray2: (-400,-500,-600,-700,-800)
sierra.someEntity: Entity1(a=8, b=9)
]]`

View File

@@ -23,7 +23,7 @@ export default `Begin
\${first.sierra.someBoolean2} => False
\${first.sierra.someObjectString} => "gamma"
\${first.sierra.someArray} => (400,500,600,700,800)
\${first.sierra.someArray2} => (400,500,600,700,800)
\${first.sierra.someArray2} => (-400,-500,-600,-700,-800)
\${first.sierra.someEntity} => E1[A:8 - B:9]
\${second(0).a} => 1
\${second(0).b} => 2

View File

@@ -1,5 +0,0 @@
export default `Begin Object
key1="Value 1"
key2=Foo(arg1=55,arg2="Argument 2")
End Object
`