Still WIP

This commit is contained in:
barsdeveloper
2024-05-28 16:44:39 +02:00
parent 70b4cabb97
commit 1c2778fbf8
62 changed files with 2480 additions and 2853 deletions

View File

@@ -1,5 +1,6 @@
// @ts-nocheck
import NumberEntity from "../js/entity/NumberEntity.js"
import UnknownKeysEntity from "../js/entity/UnknownKeysEntity.js"
import Grammar from "../js/serialization/Grammar.js"
import ObjectSerializer from "../js/serialization/ObjectSerializer.js"
@@ -104,8 +105,8 @@ test("Entity3", () => {
)
expect(Object.keys(entity)).toHaveLength(keys.length)
expect(Object.keys(entity)).toStrictEqual(keys)
expect(entity.alpha).toBe(32)
expect(entity.bravo).toBe(78)
expect(entity.alpha).toEqual(new NumberEntity(32))
expect(entity.bravo).toBe(new NumberEntity(78))
expect(entity.charlie).toBe("Charlie")
expect(entity.delta).toBeNull()
expect(entity.echo).toBe("echo")
@@ -116,28 +117,10 @@ test("Entity3", () => {
expect(entity.juliett).toStrictEqual(["a", "b", "c", "d", "e"])
expect(entity.kilo).toStrictEqual([true, false, false, true, true])
expect(entity.mike).toBe("Bar")
expect(entity.november).toBe(0)
expect(entity.november).toBe(new NumberEntity())
expect(entity.oscar).toStrictEqual(new Entity1({ a: 8, b: 9 }))
expect(entity.papa).toStrictEqual(new Entity1({ a: 12, b: 13 }))
expect(entity.quebec).toBeUndefined()
entity = new Entity3()
entity.quebec = 2
expect(entity.quebec).toBe(2)
entity["quebec"] = 7
expect(entity.quebec).toBe(7)
entity.quebec = 1
expect(entity.quebec).toBe(1)
entity["quebec"] = 10
expect(entity.quebec).toBe(10)
entity.quebec = 0
expect(entity.quebec).toBe(10)
entity["quebec"] = 11
expect(entity.quebec).toBe(10)
entity.quebec = -1
expect(entity.quebec).toBe(10)
entity.quebec = 6
expect(entity.quebec).toBe(6)
expect(SerializerFactory.getSerializer(Entity3).write(entity)).toBe(entity3Value)
expect(Grammar.getAttribute(Entity3, ["romeo", "b"]).type).toBe(Number)

View File

@@ -478,7 +478,7 @@ test("UnknownKeysValue", () => {
expect(parser.parse("(1,2,3,4,5,6,7,8,9)")).toStrictEqual([1, 2, 3, 4, 5, 6, 7, 8, 9])
expect(parser.parse(`( "Hello", "World", )`)).toStrictEqual(["Hello", "World"])
expect(parser.parse(`( "Alpha", 123, Beta, "Gamma", "Delta", 99 )`))
.toStrictEqual(["Alpha", 123, new SymbolEntity({ value: "Beta" }), "Gamma", "Delta", 99])
.toStrictEqual(["Alpha", 123, new SymbolEntity("Beta"), "Gamma", "Delta", 99])
})
test("UnknownKeysEntity", () => {

View File

@@ -1,17 +1,11 @@
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 attributes = {
a: new AttributeInfo({
type: Number,
default: 8,
}),
b: new AttributeInfo({
type: Number,
default: 9,
}),
a: NumberEntity.withDefault(type => new type(8)),
b: NumberEntity.withDefault(type => new type(9)),
}
constructor(values = {}) {

View File

@@ -1,21 +1,33 @@
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 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()
}),
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),
])).flagInlined(),
someEntity: Entity1.withDefault(),
}
}

View File

@@ -1,74 +1,45 @@
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 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 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,
}),
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 => null),
echo: StringEntity.withDefault(type => new type("echo")),
foxtrot: BooleanEntity.withDefault(),
golf: ArrayEntity.of(StringEntity).withDefault(),
hotel: ArrayEntity.of(NumberEntity).withDefault(() => null),
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(() => new Entity1()),
papa: Entity1.withDefault(() => new Entity1({ a: 12, b: 13 })),
quebec: NumberEntity.withDefault(), // will assign undefined because it does not satisfy the predicate,
romeo: Entity1.withDefault().flagInlined(),
sierra: Entity2.withDefault().flagInlined(),
}
}

View File

@@ -44,7 +44,93 @@ export default class IssuesNodes1 extends NodeTests {
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" })
}
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 )")
const resultSerialization = await blueprintPage.blueprintLocator.evaluate(blueprint => {
blueprint.selectAll()
return blueprint.template.getCopyInputObject().getSerializedText()
})
const expectedSerialization = String.raw`
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_37" ExportPath="/Script/UnrealEd.MaterialGraphNode'/Engine/Transient.NewMaterial:MaterialGraph_0.MaterialGraphNode_37'"
Begin Object Class=/Script/Engine.MaterialExpressionComponentMask Name="MaterialExpressionComponentMask_0" ExportPath="/Script/Engine.MaterialExpressionComponentMask'/Engine/Transient.NewMaterial:MaterialGraph_0.MaterialGraphNode_37.MaterialExpressionComponentMask_0'"
End Object
Begin Object Name="MaterialExpressionComponentMask_0" ExportPath="/Script/Engine.MaterialExpressionComponentMask'/Engine/Transient.NewMaterial:MaterialGraph_0.MaterialGraphNode_37.MaterialExpressionComponentMask_0'"
B=True
A=True
MaterialExpressionEditorX=-544
MaterialExpressionEditorY=32
MaterialExpressionGuid=8EFA535CAE3A4DAF9DAE27B200E06EDC
Material="/Script/UnrealEd.PreviewMaterial'/Engine/Transient.NewMaterial'"
End Object
MaterialExpression="/Script/Engine.MaterialExpressionComponentMask'MaterialExpressionComponentMask_0'"
NodePosX=-544
NodePosY=32
AdvancedPinDisplay=Shown
NodeGuid=54A40610EEC646A0954F310727D1B888
CustomProperties Pin (PinId=DC3859AB4C8C12645EEA1AA4E500A637,PinName="Input",PinFriendlyName=NSLOCTEXT("MaterialGraphNode", "Space", " "),PinType.PinCategory="required",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,)
CustomProperties Pin (PinId=D5C8F4DF4AFE5EEB605ED382CD5744DE,PinName="R",PinType.PinCategory="optional",PinType.PinSubCategory="bool",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="false",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=True,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=True,bOrphanedPin=False,)
CustomProperties Pin (PinId=7E43455B4D2232C4E99BB098631CAFCE,PinName="G",PinType.PinCategory="optional",PinType.PinSubCategory="bool",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="false",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=True,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=True,bOrphanedPin=False,)
CustomProperties Pin (PinId=46CEC6754365CB39F9FC39944B40D5C6,PinName="B",PinType.PinCategory="optional",PinType.PinSubCategory="bool",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="true",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=True,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=True,bOrphanedPin=False,)
CustomProperties Pin (PinId=F658E76C400B0AF242DFE292C92702C8,PinName="A",PinType.PinCategory="optional",PinType.PinSubCategory="bool",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="true",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=True,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=True,bOrphanedPin=False,)
CustomProperties Pin (PinId=2EC8C8234D570AB2A03DB59A1FF65987,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,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
`
const words = expectedSerialization
.split("\n")
.map(row => row.match(/\s*("?\w+(\s+\w+)*).+/)?.[1])
.filter(v => v?.length > 0)
expect(resultSerialization).toMatch(Utility.getFirstWordOrder(words))
}
},
{
name: "Issue 21",
title: "Mask ( R )",
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: [7, 14.5],
color: Configuration.nodeColors.green,
icon: null,
pins: 6,
pinNames: Configuration.rgba,
delegate: false,
development: false,
additionalTest: async (node, pins, blueprintPage) => {
const relevantPins = (await Promise.all(
pins.map(async p => {
const innerText = await p.innerText()
return [Configuration.rgba.includes(innerText), p]
})
))