-
Notifications
You must be signed in to change notification settings - Fork 10
Handle escaped quotes; Fix Vector return type color #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dave-artificial-agency
wants to merge
28
commits into
Joined-Forces:main
Choose a base branch
from
ai-startup:parse-escaped-quotes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
7195288
install jest for unit tests
dave-artificial-agency d39ef4a
add test class to test nodes
dave-artificial-agency 91e6709
add jest config file
dave-artificial-agency 01a40ce
add github action file to run the tests in PRs
dave-artificial-agency 2ea898a
tests - add tests for PinPropertyParser.bSerializeAsSinglePrecisionFloat
dave-artificial-agency a46ac14
tests - add tests for PinPropertyParser SubPins
dave-artificial-agency 654d9c7
tests - add tests for PinPropertyParser ParentPin
dave-artificial-agency 84dad2e
tests - add tests for PinPropertyParser DesiredPinDirection
dave-artificial-agency eb80ee5
tests - add test for GenericNodeParser UserDefinedPin
dave-artificial-agency e7b4697
tests - add null check tests for PinPropertyParser null subCategoryOb…
dave-artificial-agency 1103eae
tests - add test for ColorUtils getPinColor() handles null subCategor…
dave-artificial-agency bce2bc3
tests - add test for ColorUtil real type
dave-artificial-agency 8745b31
tests - add tests for PinPropertyParser INVTEXT
dave-artificial-agency d3e3496
tests - add test for CallFunctionNodeParser bDefaultsToPureFunc
dave-artificial-agency da200a8
fix error: Label.textAlign on load
dave-artificial-agency ad6125a
exclude tests from build
dave-artificial-agency 223e047
add parser for INVTEXT in PinFriendlyName
dave-artificial-agency 8feecc7
move repeated mock to global test setup
dave-artificial-agency ba612ca
add test config for better imports
dave-artificial-agency 8f405f6
remove unneeded mock
dave-artificial-agency cf66358
readme - note how to run the tests
dave-artificial-agency 04aed10
Merge branch 'main' of https://github.com/ai-startup/klee into add-tests
dave-artificial-agency 6a2acbc
update tests to use new merged registry syntax
dave-artificial-agency a8514e7
add tests for PinPropertyParser regex cases
dave-artificial-agency ab63b1e
add tests for parsing escaped quotes in DefaultValue
dave-artificial-agency 2c12ecb
improve regex to parse escaped quotes
dave-artificial-agency 13d550f
add friendly name for Get Actor Location
dave-artificial-agency f8ab440
correctly render vector type Return Value as yellow
dave-artificial-agency File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| name: Tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ main] | ||
| push: | ||
| branches: [ main] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| node-version: [20.x] | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run Jest | ||
| run: npx jest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,8 @@ npm install | |
| npm run dev | ||
| ``` | ||
|
|
||
| ### Run the tests | ||
|
|
||
| ```bash | ||
| npx jest | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| module.exports = { | ||
| preset: 'ts-jest', | ||
| testEnvironment: 'node', | ||
| moduleFileExtensions: ['ts', 'js'], | ||
| testMatch: ['**/*.test.ts'], | ||
| transform: { | ||
| '^.+\\.ts$': 'ts-jest', | ||
| }, | ||
| collectCoverageFrom: [ | ||
| 'src/**/*.ts', | ||
| '!src/**/*.test.ts' | ||
| ], | ||
| clearMocks: true, | ||
| setupFiles: ['<rootDir>/src/jest.setup.ts'], | ||
| }; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /// <reference types="jest" /> | ||
|
|
||
| import { Label } from '../label'; | ||
|
|
||
| describe('Label', () => { | ||
| test('constructor sets default values', () => { | ||
| const label = new Label('Test Text'); | ||
|
|
||
| expect(label.text).toBe('Test Text'); | ||
| expect(label.textAlign).toBeDefined(); | ||
| expect(label.font).toBeDefined(); | ||
| expect(label.color).toBeDefined(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /// <reference types="jest" /> | ||
|
|
||
| import { ColorUtils } from '../color-utils'; | ||
| import { PinProperty } from '../../../data/pin/pin-property'; | ||
| import { PinCategory } from '../../../data/pin/pin-category'; | ||
|
|
||
| describe('ColorUtils', () => { | ||
| test('getPinColor handles null subCategoryObject', () => { | ||
| const pin = new PinProperty('TestNode'); | ||
| pin.category = PinCategory.object; | ||
| pin.subCategoryObject = undefined; | ||
|
|
||
| const color = ColorUtils.getPinColor(pin); | ||
|
|
||
| expect(color).toBeDefined(); | ||
| expect(typeof color).toBe('string'); | ||
| }); | ||
|
|
||
| test('getPinColor returns correct color for real category', () => { | ||
| const realPin = new PinProperty('RealPin'); | ||
| realPin.category = PinCategory.real; | ||
| const realColor = ColorUtils.getPinColor(realPin); | ||
|
|
||
| const floatPin = new PinProperty('FloatPin'); | ||
| floatPin.category = PinCategory.float; | ||
| const floatColor = ColorUtils.getPinColor(floatPin); | ||
|
|
||
| expect(realColor).toBeDefined(); | ||
| expect(typeof realColor).toBe('string'); | ||
| expect(realColor).toBe(floatColor); | ||
| }); | ||
| }); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| /// <reference types="jest" /> | ||
|
|
||
| // Mock browser APIs that aren't available in Node.js | ||
| global.Path2D = jest.fn().mockImplementation((path) => ({ path })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/parser/node-parsers/tests/call-function-node-parser.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /// <reference types="jest" /> | ||
|
|
||
| import { CallFunctionNodeParser } from '../call-function-node.parser'; | ||
| import { ParsingNodeData } from '../../parsing-node-data'; | ||
| import { CallFunctionNode } from '../../../data/nodes/call-function.node'; | ||
| import { Vector2 } from '../../../math/vector2'; | ||
|
|
||
| describe('CallFunctionNodeParser', () => { | ||
| test('bDefaultsToPureFunc=True sets isPureFunc to true', () => { | ||
| const parser = new CallFunctionNodeParser(); | ||
|
|
||
| const node: CallFunctionNode = { | ||
| pos: new Vector2(0, 0), | ||
| title: 'Test', | ||
| subTitles: [], | ||
| customProperties: [], | ||
| isPureFunc: false, | ||
| isConstFunc: false, | ||
| functionReference: null | ||
| } as CallFunctionNode; | ||
|
|
||
| const parsingData = new ParsingNodeData([ | ||
| 'Begin Object', | ||
| 'bDefaultsToPureFunc=True', | ||
| 'End Object' | ||
| ]); | ||
|
|
||
| parsingData.node = node; | ||
| parser.parse(parsingData); | ||
| expect(node.isPureFunc).toBe(true); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /// <reference types="jest" /> | ||
|
|
||
| import { GenericNodeParser } from '../generic-node.parser'; | ||
| import { NodeParserRegistry } from "../../node-parser-registry"; | ||
| import { ParsingNodeData } from '../../parsing-node-data'; | ||
| import { PinDirection } from '../../../data/pin/pin-direction'; | ||
| import { TestableNodeControl } from '../../../tests/testable-node-control'; | ||
|
|
||
|
|
||
| // Mock UnrealNodeClass to reduce expensive constructor loop | ||
| jest.mock('../../../data/classes/unreal-node-class', () => ({ | ||
| UnrealNodeClass: { | ||
| CUSTOM_EVENT: '/Script/BlueprintGraph.K2Node_CustomEvent' | ||
| } | ||
| })); | ||
|
|
||
| describe('GenericNodeParser', () => { | ||
| let parser: GenericNodeParser; | ||
|
|
||
| beforeEach(() => { | ||
| let nodeParserRegistry = new NodeParserRegistry(); | ||
| parser = new GenericNodeParser(nodeParserRegistry); | ||
| }); | ||
|
|
||
| test('Can parse CustomProperties UserDefinedPin', () => { | ||
| const lines = [ | ||
| 'Begin Object Class=/Script/BlueprintGraph.K2Node_CustomEvent Name="K2Node_CustomEvent_4"', | ||
| ' NodeGuid=7E57DA7A000000000000000000000000', | ||
| 'CustomProperties UserDefinedPin (PinName="Context",PinType=(PinCategory="object"),DesiredPinDirection=EGPD_Output)', | ||
| 'End Object' | ||
| ]; | ||
|
|
||
| const parsingData = new ParsingNodeData(lines); | ||
| const nodeControl = parser.parse(parsingData); | ||
| const result = new TestableNodeControl(nodeControl); | ||
|
|
||
| expect(result).toBeDefined(); | ||
| expect(result.node).toBeDefined(); | ||
| expect(result.node.customProperties).toBeDefined(); | ||
|
|
||
| const userDefinedPin = result.node.customProperties.find((prop: any) => | ||
| prop.constructor.name === 'PinProperty' && prop.name === 'Context' | ||
| ) as any; | ||
|
|
||
| expect(userDefinedPin).toBeDefined(); | ||
| expect(userDefinedPin.name).toBe('Context'); | ||
| expect(userDefinedPin.category).toBe('object'); | ||
| expect(userDefinedPin.direction).toBe(PinDirection.EGPD_Output); | ||
| }); | ||
|
|
||
| }); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this regex change , several of these regex comments are no longer accurate. I can update them, or delete them so we don't have to maintain anything if that's better.