|
382 | 382 |
|
383 | 383 | end
|
384 | 384 |
|
385 |
| -@testset "pattern-match ALL" begin |
| 385 | +@testset "pattern-match ALL single out" begin |
386 | 386 | app = dash()
|
387 | 387 | app.layout = html_div() do
|
388 | 388 | dcc_input(id = (type="test", index = 1), value="initial value", type = "text"),
|
|
412 | 412 | request = (
|
413 | 413 | output = string(out_key),
|
414 | 414 | outputs = [
|
415 |
| - [ |
416 | 415 | (id = (index=1, type="test-out"), property = "children"),
|
417 | 416 | (id = (index=2, type="test-out"), property = "children")
|
418 |
| - ] |
419 | 417 | ],
|
420 | 418 | changedPropIds = [changed_key],
|
421 | 419 | inputs = [
|
|
435 | 433 | @test resp_obj.response.var"{\"index\":1,\"type\":\"test-out\"}".children =="test 1"
|
436 | 434 | @test resp_obj.response.var"{\"index\":2,\"type\":\"test-out\"}".children =="test"
|
437 | 435 |
|
| 436 | +end |
| 437 | +@testset "pattern-match ALL multi out" begin |
| 438 | + app = dash() |
| 439 | + app.layout = html_div() do |
| 440 | + dcc_input(id = (type="test", index = 1), value="initial value", type = "text"), |
| 441 | + dcc_input(id = (type="test", index = 2), value="initial value", type = "text"), |
| 442 | + html_div(id = (type = "test-out", index = 1)), |
| 443 | + html_div(id = (type = "test-out", index = 2)) |
| 444 | + end |
| 445 | + |
| 446 | + first_key = """{"index":1,"type":"test"}.value""" |
| 447 | + changed_key = """{"index":2,"type":"test"}.value""" |
| 448 | + callback!(app, [Output((type = "test-out", index = ALL), "children")], Input((type="test", index = ALL), "value")) do value |
| 449 | + context = callback_context() |
| 450 | + @test haskey(context.inputs, first_key) |
| 451 | + @test context.inputs[first_key] == "test 1" |
| 452 | + @test haskey(context.inputs, changed_key) |
| 453 | + @test context.inputs[changed_key] == "test" |
| 454 | + @test length(context.triggered) == 1 |
| 455 | + @test context.triggered[1].prop_id == changed_key |
| 456 | + @test context.triggered[1].value == "test" |
| 457 | + return [value] |
| 458 | + end |
| 459 | + @test length(app.callbacks) == 1 |
| 460 | + out_key = Symbol("""..{"index":["ALL"],"type":"test-out"}.children..""") |
| 461 | + @test haskey(app.callbacks, out_key) |
| 462 | + |
| 463 | + handler = Dash.make_handler(app) |
| 464 | + request = ( |
| 465 | + output = string(out_key), |
| 466 | + outputs = [[ |
| 467 | + (id = (index=1, type="test-out"), property = "children"), |
| 468 | + (id = (index=2, type="test-out"), property = "children") |
| 469 | + ]], |
| 470 | + changedPropIds = [changed_key], |
| 471 | + inputs = [ |
| 472 | + [ |
| 473 | + (id = (index=1, type="test"), property = "value", value = "test 1"), |
| 474 | + (id = (index=2, type="test"), property = "value", value = "test") |
| 475 | + ] |
| 476 | + ] |
| 477 | + ) |
| 478 | + test_json = JSON2.write(request) |
| 479 | + request = HTTP.Request("POST", "/_dash-update-component", [], Vector{UInt8}(test_json)) |
| 480 | + response = HTTP.handle(handler, request) |
| 481 | + @test response.status == 200 |
| 482 | + resp_obj = JSON2.read(String(response.body)) |
| 483 | + @test in(:multi, keys(resp_obj)) |
| 484 | + |
| 485 | + @test resp_obj.response.var"{\"index\":1,\"type\":\"test-out\"}".children =="test 1" |
| 486 | + @test resp_obj.response.var"{\"index\":2,\"type\":\"test-out\"}".children =="test" |
| 487 | + |
438 | 488 | end
|
439 | 489 |
|
440 | 490 | @testset "invalid multi out" begin
|
|
0 commit comments