🐛 If a user tries to graft the user tree of an emptyquid quiddity with the 'connections' path and an object data, user_tree.grafted returns null for a value
Summary
When trying to create a new scene in Scenic
, we have noticed that the creation of the scene is blocked by an error stating that the returned data from user_tree.grafted
is not an object and therefore not valid to create a new scene.
How to reproduce ?
There are two ways to reproduce the bug:
- Launch scenic with sw3 and try to create a new scene.
- Use an integration test to examine the returned value like below:
TEST:
it('should be triggered when a quiddity\'s user tree is grafted with a complex value', (done) => {
userTreeAPI.onGrafted(
(quidId, path, value) => {
expect(quidId).toEqual(quidId)
expect(path).toEqual('connections')
expect(value).toEqual({ id: 'scene1', name: 'Scene 1', active: false, connections: [] })
done()
}
)
userTreeAPI.graft(emptyquid.id, 'connections', { id: 'scene1', name: 'Scene 1', active: false, connections: [] })
})
RESULT
test/integration/tree/UserTreeAPI.test.js (7.544 s)
UserTreeAPI
get
✓ should get the empty user tree of a created quiddity (13 ms)
✓ should get the user tree of a quiddity (12 ms)
✓ should query the user tree of a quiddity (10 ms)
✓ should not query the tree if the path doesn't exist (8 ms)
graft
✓ should set a new value to the user tree (10 ms)
✓ should set a new value to the user tree (11 ms)
onGrafted
✓ should be triggered when a quiddity's user tree is grafted with a simple value (1015 ms)
✕ should be triggered when a quiddity's user tree is grafted with a complex value (6009 ms)
● UserTreeAPI › onGrafted › should be triggered when a quiddity's user tree is grafted with a complex value
expect(received).toEqual(expected) // deep equality
Expected: {"active": false, "connections": [], "id": "scene1", "name": "Scene 1"}
Received: null
109 | expect(quidId).toEqual(quidId)
110 | expect(path).toEqual('connections')
> 111 | expect(value).toEqual({ id: 'scene1', name: 'Scene 1', active: false, connections: [] })
| ^
112 | done()
113 | }
114 | )
at toEqual (test/integration/tree/UserTreeAPI.test.js:111:25)
at Socket.onGraftAction (lib/tree/UserTreeAPI.js:53:9)
at Socket.Object.<anonymous>.Emitter.emit (node_modules/@socket.io/component-emitter/index.js:143:20)
at Socket.emitEvent (node_modules/socket.io-client/build/cjs/socket.js:294:20)
at Socket.onevent (node_modules/socket.io-client/build/cjs/socket.js:281:18)
at Socket.onpacket (node_modules/socket.io-client/build/cjs/socket.js:249:22)
at Manager.Object.<anonymous>.Emitter.emit (node_modules/@socket.io/component-emitter/index.js:143:20)
at Manager.ondecoded (node_modules/socket.io-client/build/cjs/manager.js:233:14)
at Decoder.Object.<anonymous>.Emitter.emit (node_modules/@socket.io/component-emitter/index.js:143:20)
at Decoder.add (node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/index.js:135:23)
● UserTreeAPI › onGrafted › should be triggered when a quiddity's user tree is grafted with a complex value
thrown: "Exceeded timeout of 5000 ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
104 | // })
105 |
> 106 | it('should be triggered when a quiddity\'s user tree is grafted with a complex value', (done) => {
| ^
107 | userTreeAPI.onGrafted(
108 | (quidId, path, value) => {
109 | expect(quidId).toEqual(quidId)
at it (test/integration/tree/UserTreeAPI.test.js:106:5)
at describe (test/integration/tree/UserTreeAPI.test.js:68:3)
at Object.describe (test/integration/tree/UserTreeAPI.test.js:10:1)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 7 passed, 8 total
Snapshots: 0 total
Time: 7.577 s, estimated 8 s
Ran all test suites matching /test\/integration\/tree\/UserTreeAPI/i.
Expected behavior
The data should be well grafted and user_tree.grafted
should return the grafted object which is in this case { id: 'scene1', name: 'Scene 1', active: false, connections: [] }
What is the frequency of occurrence of this behavior ?
100%
Other comment
For more details see #263 in scenic-web
Edited by Pascale Stark