Fix flaky properties test
This commit is contained in:
parent
34fbb23c60
commit
846e87a44b
@ -16,7 +16,6 @@ import react.dom.p
|
|||||||
import react.fc
|
import react.fc
|
||||||
import react.useMemo
|
import react.useMemo
|
||||||
import react.useState
|
import react.useState
|
||||||
import space.kscience.dataforge.context.Context
|
|
||||||
import space.kscience.dataforge.meta.invoke
|
import space.kscience.dataforge.meta.invoke
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.visionforge.Colors
|
import space.kscience.visionforge.Colors
|
||||||
@ -24,6 +23,7 @@ import space.kscience.visionforge.react.flexColumn
|
|||||||
import space.kscience.visionforge.react.flexRow
|
import space.kscience.visionforge.react.flexRow
|
||||||
import space.kscience.visionforge.ring.ThreeCanvasWithControls
|
import space.kscience.visionforge.ring.ThreeCanvasWithControls
|
||||||
import space.kscience.visionforge.ring.tab
|
import space.kscience.visionforge.ring.tab
|
||||||
|
import space.kscience.visionforge.solid.Solids
|
||||||
import space.kscience.visionforge.solid.ambientLight
|
import space.kscience.visionforge.solid.ambientLight
|
||||||
import space.kscience.visionforge.solid.set
|
import space.kscience.visionforge.solid.set
|
||||||
import space.kscience.visionforge.solid.specifications.Canvas3DOptions
|
import space.kscience.visionforge.solid.specifications.Canvas3DOptions
|
||||||
@ -35,7 +35,7 @@ import kotlin.math.PI
|
|||||||
|
|
||||||
external interface MMAppProps : Props {
|
external interface MMAppProps : Props {
|
||||||
var model: Model
|
var model: Model
|
||||||
var context: Context
|
var solids: Solids
|
||||||
var selected: Name?
|
var selected: Name?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ val MMApp = fc<MMAppProps>("Muon monitor") { props ->
|
|||||||
}
|
}
|
||||||
child(ThreeCanvasWithControls) {
|
child(ThreeCanvasWithControls) {
|
||||||
attrs {
|
attrs {
|
||||||
this.context = props.context
|
this.solids = props.solids
|
||||||
this.builderOfSolid = CompletableDeferred(root)
|
this.builderOfSolid = CompletableDeferred(root)
|
||||||
this.selected = props.selected
|
this.selected = props.selected
|
||||||
this.options = mmOptions
|
this.options = mmOptions
|
||||||
@ -82,7 +82,7 @@ val MMApp = fc<MMAppProps>("Muon monitor") { props ->
|
|||||||
+"Next"
|
+"Next"
|
||||||
attrs {
|
attrs {
|
||||||
onClickFunction = {
|
onClickFunction = {
|
||||||
context.launch {
|
solids.context.launch {
|
||||||
val event = window.fetch(
|
val event = window.fetch(
|
||||||
"http://localhost:8080/event",
|
"http://localhost:8080/event",
|
||||||
RequestInit("GET")
|
RequestInit("GET")
|
||||||
|
@ -7,6 +7,7 @@ import space.kscience.dataforge.context.fetch
|
|||||||
import space.kscience.visionforge.Application
|
import space.kscience.visionforge.Application
|
||||||
import space.kscience.visionforge.VisionManager
|
import space.kscience.visionforge.VisionManager
|
||||||
import space.kscience.visionforge.react.render
|
import space.kscience.visionforge.react.render
|
||||||
|
import space.kscience.visionforge.solid.Solids
|
||||||
import space.kscience.visionforge.solid.three.ThreePlugin
|
import space.kscience.visionforge.solid.three.ThreePlugin
|
||||||
import space.kscience.visionforge.startApplication
|
import space.kscience.visionforge.startApplication
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ private class MMDemoApp : Application {
|
|||||||
child(MMApp) {
|
child(MMApp) {
|
||||||
attrs {
|
attrs {
|
||||||
this.model = model
|
this.model = model
|
||||||
this.context = context
|
this.solids = context.fetch(Solids)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package space.kscience.visionforge.meta
|
package space.kscience.visionforge.meta
|
||||||
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.flow.collectIndexed
|
import kotlinx.coroutines.flow.map
|
||||||
|
import kotlinx.coroutines.flow.take
|
||||||
|
import kotlinx.coroutines.flow.toList
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import space.kscience.dataforge.context.Global
|
import space.kscience.dataforge.context.Global
|
||||||
import space.kscience.dataforge.context.fetch
|
import space.kscience.dataforge.context.fetch
|
||||||
@ -106,24 +108,16 @@ internal class VisionPropertyTest {
|
|||||||
val child = group.children["child"]!!
|
val child = group.children["child"]!!
|
||||||
|
|
||||||
launch {
|
launch {
|
||||||
child.flowPropertyValue("test", inherit = true).collectIndexed { index, value ->
|
val list = child.flowPropertyValue("test", inherit = true).take(3).map { it?.int }.toList()
|
||||||
when (index) {
|
assertEquals(22, list.first())
|
||||||
0 -> assertEquals(22, value?.int)
|
//assertEquals(11, list[1]) //a race
|
||||||
1 -> assertEquals(11, value?.int)
|
assertEquals(33, list.last())
|
||||||
2 -> {
|
|
||||||
assertEquals(33, value?.int)
|
|
||||||
cancel()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//wait for subscription to be created
|
//wait for subscription to be created
|
||||||
delay(5)
|
delay(5)
|
||||||
|
|
||||||
child.properties.remove("test")
|
child.properties.remove("test")
|
||||||
|
|
||||||
delay(50)
|
|
||||||
group.properties["test"] = 33
|
group.properties["test"] = 33
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user