File tree Expand file tree Collapse file tree 2 files changed +73
-4
lines changed Expand file tree Collapse file tree 2 files changed +73
-4
lines changed Original file line number Diff line number Diff line change 1+ import puppeteer from "puppeteer" ;
2+
3+ import {
4+ easyUid ,
5+ createHttpClient ,
6+ createTestTab ,
7+ setupBrowser ,
8+ typeAndRun ,
9+ waitForEditor ,
10+ waitForActiveTab ,
11+ waitForElement ,
12+ } from "./puppetHelpers" ;
13+
14+ let browser = null ;
15+
16+ beforeAll ( async ( ) => {
17+ browser = await setupBrowser ( ) ;
18+ } ) ;
19+
20+ afterAll ( async ( ) => browser && ( await browser . close ( ) ) ) ;
21+
22+ test ( "Should draw one to one nodes" , async ( ) => {
23+ const page = await createTestTab ( browser ) ;
24+
25+ await waitForEditor ( page ) ;
26+
27+ const testId = `testRun${ easyUid ( ) } ` ;
28+
29+ await createHttpClient ( ) . alter ( { schema : `${ testId } : uid .` } ) ;
30+ await createHttpClient ( )
31+ . newTxn ( )
32+ . mutate ( {
33+ setJson : {
34+ [ testId + "_name" ] : "Alice" ,
35+ [ testId ] : {
36+ [ testId + "_name" ] : "Bob" ,
37+ } ,
38+ } ,
39+ commitNow : true ,
40+ } ) ;
41+
42+ await typeAndRun (
43+ page ,
44+ `{
45+ query(func: has(${ testId } )) {
46+ uid
47+ ${ testId } { uid }
48+ ` ,
49+ ) ;
50+
51+ const summarySelector = ".graph-overlay .title" ;
52+ await waitForElement ( page , summarySelector ) ;
53+
54+ await expect (
55+ page . $eval ( summarySelector , el => el . textContent ) ,
56+ ) . resolves . toBe ( "Showing 2 nodes and 1 edges" ) ;
57+ } ) ;
Original file line number Diff line number Diff line change @@ -86,14 +86,13 @@ export class GraphParser {
8686 addResponseToQueue = ( response , expansionNode = "FromResponse" ) => {
8787 response = cloneDeep ( response ) ;
8888
89- Object . entries ( response ) . forEach ( ( [ key , block ] , index ) =>
89+ Object . entries ( response ) . forEach ( ( [ key , block ] ) =>
9090 block . forEach ( node =>
9191 this . queue . push ( {
9292 node,
9393 src : {
9494 id : "" ,
9595 pred : key ,
96- index,
9796 expansionNode,
9897 } ,
9998 } ) ,
@@ -163,17 +162,30 @@ export class GraphParser {
163162 typeof val [ 0 ] === "object"
164163 ) {
165164 // These are child nodes, lets add them to the queue.
166- val . map ( ( x , index ) =>
165+ val . map ( x =>
167166 this . queue . push ( {
168167 node : x ,
169168 src : {
170169 pred : prop ,
171170 id : uid ,
172- index,
173171 expansionNode : obj . src . expansionNode ,
174172 } ,
175173 } ) ,
176174 ) ;
175+ } else if (
176+ typeof val === "object" &&
177+ val &&
178+ typeof val . uid === "string"
179+ ) {
180+ // This is a one to one relationship in v1.1.
181+ this . queue . push ( {
182+ node : val ,
183+ src : {
184+ pred : prop ,
185+ id : uid ,
186+ expansionNode : obj . src . expansionNode ,
187+ } ,
188+ } ) ;
177189 } else {
178190 properties . attrs [ prop ] = val ;
179191 }
You can’t perform that action at this time.
0 commit comments