cytoscape / cyjShiny

An R/shiny widget for cytoscape.js
Other
92 stars 28 forks source link

cyjs instrospective testing #46

Closed paul-shannon closed 3 years ago

paul-shannon commented 3 years ago

@Dharna5599

cytoscape.js can tell us quite a bit about the current graph, and the current view.

Imagine an automated test which:

  1. creates a 3-node, 3-edge network
  2. from R, we use the cyjShiny API, asking "what is the current network?"
  3. then in R, we check the expected network structure against the reported one
  4. then in R, programmatically select one node
  5. in R, query for the selected nodes: should be only the one you just selected
  6. the next level of tests would be on the view, but let's defer that for now

Please give this a try, in (as we have discussed) a tiny program, just as simple as possible. If I am unclear, just say so, and I will give you a small demo test program.

I am sad about the apparent need to abandon shinytest, but it looks like all indications point that way.

Dharna5599 commented 3 years ago

Hey @paul-shannon, I am sorry but I'm not sure I get your viewpoint. Could you please be more specific and, if possible, can you please provide an example test programme so that I may better comprehend your point or else you can brief about it.

Thank you

paul-shannon commented 3 years ago

@Dharna5599 - sorry for my delay in answering. I have a report to the NIH due Monday which is keeping me busy.

Perhaps the best way for you to get started on our new approach to cyjShiny testing is to install and learn to use my companion package RCyjs: https://bioconductor.org/packages/release/bioc/html/RCyjs.html

This package also connects R to cytoscape.js running in the browser. It is more fully developed than cyjShiny, permitting, for instance, this sequence of calls:

   g <- testerGraph()
   addGraph(rcy, g)
   checkEquals(getNodeCount(rcy), 3)
   checkEquals(getEdgeCount(rcy), 3)

This demonstrates introspection: we send a network of 3 nodes and 3 edges to cytoscape.js. Then we ask cytoscape.js how many nodes it has, and how many edges.

I apologize for the change in direction - I had more faith in shinytest than is warranted. Still, you have learned a lot, we have learned a lot, and now we have a new strategy.

I am busy until late Monday (early Tuesday for you). Please install RCyjs, run through the vignette, try writing some simple tests.

Also, and very important, study the API (application programmers interface) for cytoscape.js. Keep in mind that in both cyjShiny, and RCyjs, all that we really do is provide R commands that get translated to javascript commands that cytoscape.js can execute.

Dharna5599 commented 3 years ago

Ok @paul-shannon, Thanks, I will go through it.

paul-shannon commented 3 years ago

this strategy is sound, now demonstrated in unitTests/test_selection.R the first of many such bash-callable + interactive shiny apps in R6 classes.