From dc4deb17701e817f9ab64dcb11e4c504f86caed3 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenko Date: Sun, 23 Aug 2020 16:07:14 +0300 Subject: [PATCH 1/8] reverse dependency --- Project.toml | 4 + src/Components.jl | 48 +-------- src/Dash.jl | 80 ++++++++++++-- src/Front.jl | 17 +-- src/handler/processors/callback.jl | 2 +- test/Project.toml | 12 --- test/TestComponents.jl | 164 +++++------------------------ test/core.jl | 99 ++++++----------- 8 files changed, 144 insertions(+), 282 deletions(-) delete mode 100644 test/Project.toml diff --git a/Project.toml b/Project.toml index 1b5d969..4eb96db 100644 --- a/Project.toml +++ b/Project.toml @@ -16,6 +16,10 @@ PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5" Sockets = "6462fe0b-24de-5631-8697-dd941f90decc" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +DashBase = "03207cf0-e2b3-4b91-9ca8-690cf0fb507e" +DashCoreComponents = "1b08a953-4be3-4667-9a23-03c9473d1193" +DashHtmlComponents = "1b08a953-4be3-4667-9a23-341813c6f7a5" +DashTable = "1b08a953-4be3-4667-9a23-d3c7dd0aada8" [compat] DataStructures = "0.17.5" diff --git a/src/Components.jl b/src/Components.jl index cca15f2..ebb3103 100644 --- a/src/Components.jl +++ b/src/Components.jl @@ -1,41 +1,3 @@ -module Components -import JSON2 -export Component, <|, hasproperty, is_prop_available, validate - -abstract type AbstractComponent end - - -struct Component <: AbstractComponent - type ::String - namespace ::String - props ::Dict{Symbol, Any} - available_props ::Set{Symbol} - wildcard_props ::Set{Symbol} -end - -JSON2.@format Component begin - available_props => (exclude = true,) - wildcard_props => (exclude = true,) -end - -function <|(comp::Component, value::Any) - comp.props["children"] = value - return comp -end - -hasproperty(c::Component, prop::Symbol) = haskey(c.props, prop) -function is_prop_available(c::Component, prop::Symbol) - if length(c.wildcard_props) > 0 - wild_regs = Regex("^(?$(join(c.wildcard_props, "|")))") - if !isnothing(match(wild_regs, string(prop))) - return true - end - end - - return prop in c.available_props -end - - function _validate_children(children::Union{Vector, Tuple}, ids::Set{Symbol}) for child in children _validate(child, ids) @@ -48,17 +10,15 @@ function _validate_children(children, ids::Set{Symbol}) end function _validate(comp::Component, ids::Set{Symbol}) - if haskey(comp.props, :id) - id = Symbol(comp.props[:id]) + if hasproperty(comp, :id) && !isnothing(comp.id) + id = Symbol(comp.id) id in ids && error("Duplicate component id found in the initial layout: $(id)") push!(ids, id) end - _validate_children(get(comp.props, :children, nothing), ids) + hasproperty(comp, :children) && _validate_children(comp.children, ids) end function _validate(non_comp, ids::Set{Symbol}) end function validate(comp::Component) _validate(comp, Set{Symbol}()) -end - -end +end \ No newline at end of file diff --git a/src/Dash.jl b/src/Dash.jl index c5fe31c..1a8316e 100644 --- a/src/Dash.jl +++ b/src/Dash.jl @@ -1,13 +1,14 @@ module Dash +using DashBase import HTTP, JSON2, CodecZlib, MD5 using Sockets const ROOT_PATH = realpath(joinpath(@__DIR__, "..")) +const RESOURCE_PATH = realpath(joinpath(ROOT_PATH, "resources")) include("exceptions.jl") include("Components.jl") include("Front.jl") include("HttpHelpers/HttpHelpers.jl") -import .Front -using .Components + using .HttpHelpers export dash, Component, Front, callback!, @@ -20,7 +21,6 @@ include("Contexts/Contexts.jl") include("env.jl") include("utils.jl") include("app.jl") -include("resources/registry.jl") include("resources/application.jl") include("handlers.jl") include("server.jl") @@ -39,14 +39,14 @@ using DashCoreComponents app = dash(external_stylesheets=["https://codepen.io/chriddyp/pen/bWLwgP.css"]) do html_div() do dcc_input(id="graphTitle", value="Let's Dance!", type = "text"), - html_div(id="outputID"), + html_div(id="outputID"), dcc_graph(id="graph", figure = ( data = [(x = [1,2,3], y = [3,2,8], type="bar")], layout = Dict(:title => "Graph") ) ) - + end end callback!(app, Output("outputID", "children"), Input("graphTitle","value"), State("graphTitle","type")) do value, type @@ -56,7 +56,7 @@ callback!(app, Output("graph", "figure"), Input("graphTitle", "value")) do value ( data = [ (x = [1,2,3], y = abs.(randn(3)), type="bar"), - (x = [1,2,3], y = abs.(randn(3)), type="scatter", mode = "lines+markers", line = (width = 4,)) + (x = [1,2,3], y = abs.(randn(3)), type="scatter", mode = "lines+markers", line = (width = 4,)) ], layout = (title = value,) ) @@ -67,5 +67,73 @@ run_server(app, HTTP.Sockets.localhost, 8050) """ Dash +function __init__() + DashBase.main_registry().dash_dependency = ( + dev = ResourcePkg( + "dash_renderer", + RESOURCE_PATH, version = "1.5.0", + [ + Resource( + relative_package_path = "react@16.13.0.js", + external_url = "https://unpkg.com/react@16.13.0/umd/react.development.js" + ), + Resource( + relative_package_path = "react-dom@16.13.0.js", + external_url = "https://unpkg.com/react-dom@16.13.0/umd/react-dom.development.js" + ), + Resource( + relative_package_path = "polyfill@7.8.7.min.js", + external_url = "https://unpkg.com/@babel/polyfill@7.8.7/dist/polyfill.min.js" + ), + Resource( + relative_package_path = "prop-types@15.7.2.js", + external_url = "https://unpkg.com/prop-types@15.7.2/prop-types.js", + ), + ] + ), + prod = ResourcePkg( + "dash_renderer", + RESOURCE_PATH, version = "1.2.2", + [ + Resource( + relative_package_path = "react@16.13.0.min.js", + external_url = "https://unpkg.com/react@16.13.0/umd/react.production.min.js" + ), + Resource( + relative_package_path = "react-dom@16.13.0.min.js", + external_url = "https://unpkg.com/react-dom@16.13.0/umd/react-dom.production.min.js" + ), + Resource( + relative_package_path = "polyfill@7.8.7.min.js", + external_url = "https://unpkg.com/@babel/polyfill@7.8.7/dist/polyfill.min.js" + ), + Resource( + relative_package_path = "prop-types@15.7.2.min.js", + external_url = "https://unpkg.com/prop-types@15.7.2/prop-types.min.js" + ), + ] + ) + ) + + DashBase.main_registry().dash_renderer = ResourcePkg( + "dash_renderer", + RESOURCE_PATH, version = "1.5.0", + [ + Resource( + relative_package_path = "dash_renderer.min.js", + dev_package_path = "dash_renderer.dev.js", + external_url = "https://unpkg.com/dash-renderer@1.5.0/dash_renderer/dash_renderer.min.js" + ), + Resource( + relative_package_path = "dash_renderer.min.js.map", + dev_package_path = "dash_renderer.dev.js.map", + dynamic = true, + ), + ] + ) + + +end + end # module diff --git a/src/Front.jl b/src/Front.jl index eff4f13..9d5895b 100644 --- a/src/Front.jl +++ b/src/Front.jl @@ -1,17 +1,4 @@ -module Front import JSON, JSON2, PlotlyBase - -to_dash(t::Any) = t -from_dash(::Type{Any}, t::Any) = t - - -function from_dash(::Type{PlotlyBase.Plot}, t) - data = PlotlyBase.GenericTrace[PlotlyBase.GenericTrace(tr) for tr in t.data] - layout = PlotlyBase.Layout(t.layout) - PlotlyBase.Plot(data, layout) -end - -#FIXME It's not elegant, but I didn't find elegant solution -JSON2.write(io::IO, p::PlotlyBase.Plot; kwargs...) = write(io, JSON.json(p)) -end +#FIXME It's not elegant, but I didn't find elegant soluiton +JSON2.write(io::IO, p::PlotlyBase.Plot; kwargs...) = write(io, JSON.json(p)) \ No newline at end of file diff --git a/src/handler/processors/callback.jl b/src/handler/processors/callback.jl index a57db82..9a3d308 100644 --- a/src/handler/processors/callback.jl +++ b/src/handler/processors/callback.jl @@ -22,7 +22,7 @@ end function _push_to_res!(res, value, out) !(value isa NoUpdate) && push!(res, dep_id_string(out.id) => Dict( - Symbol(out.property) => Front.to_dash(value) + Symbol(out.property) => DashBase.to_dash(value) ) ) end diff --git a/test/Project.toml b/test/Project.toml deleted file mode 100644 index 3b0804b..0000000 --- a/test/Project.toml +++ /dev/null @@ -1,12 +0,0 @@ -[deps] -CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" -DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" -HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" -Inflate = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9" -JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3" -MD5 = "6ac74813-4b46-53a4-afec-0b5dc9d7885c" -LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" -PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -SnoopCompile = "aa65fe97-06da-5843-b5b1-d5d13cad87d2" diff --git a/test/TestComponents.jl b/test/TestComponents.jl index 4716506..593e392 100644 --- a/test/TestComponents.jl +++ b/test/TestComponents.jl @@ -3,167 +3,51 @@ using Dash export html_div, html_a, dcc_input, dcc_graph, html_h1, html_img function html_div(; kwargs...) - available_props = Set(Symbol[:children, :id, :n_clicks, :n_clicks_timestamp, :key, :role, :accessKey, :className, :contentEditable, :contextMenu, :dir, :draggable, :hidden, :lang, :spellCheck, :style, :tabIndex, :title, :loading_state]) - wild_props = Set(Symbol[Symbol("data-"), Symbol("aria-")]) - wild_regs = r"^(?data-|aria-)" - - result = Component("Div", "dash_html_components", Dict{Symbol, Any}(), available_props, Set(Symbol[Symbol("data-"), Symbol("aria-")])) - - for (prop, value) = pairs(kwargs) - m = match(wild_regs, string(prop)) - if (length(wild_props) == 0 || isnothing(m)) && !(prop in available_props) - throw(ArgumentError("Invalid property $(string(prop)) for component " * "html_div")) - end - - push!(result.props, prop => Front.to_dash(value)) - end - -return result -end - -function html_div(children::Any; kwargs...) -result = html_div(;kwargs...) -push!(result.props, :children => Front.to_dash(children)) -return result + available_props = Symbol[:children, :id, :n_clicks, :n_clicks_timestamp, :key, :role, :accessKey, :className, :contentEditable, :contextMenu, :dir, :draggable, :hidden, :lang, :spellCheck, :style, :tabIndex, :title, :loading_state] + wild_props = Symbol[Symbol("data-"), Symbol("aria-")] + return Component("html_div", "Div", "dash_html_components", available_props, wild_props; kwargs...) end +html_div(children::Any; kwargs...) = html_div(;kwargs..., children = children) html_div(children_maker::Function; kwargs...) = html_div(children_maker(); kwargs...) -function html_h1(; kwargs...) - available_props = Set(Symbol[:children, :id, :n_clicks, :n_clicks_timestamp, :key, :role, :accessKey, :className, :contentEditable, :contextMenu, :dir, :draggable, :hidden, :lang, :spellCheck, :style, :tabIndex, :title, :loading_state]) - wild_props = Set(Symbol[Symbol("data-"), Symbol("aria-")]) - wild_regs = r"^(?data-|aria-)" - - result = Component("H1", "dash_html_components", Dict{Symbol, Any}(), available_props, Set(Symbol[Symbol("data-"), Symbol("aria-")])) - - for (prop, value) = pairs(kwargs) - m = match(wild_regs, string(prop)) - if (length(wild_props) == 0 || isnothing(m)) && !(prop in available_props) - throw(ArgumentError("Invalid property $(string(prop)) for component " * "html_h1")) - end - - push!(result.props, prop => Front.to_dash(value)) - end - -return result -end -function html_h1(children::Any; kwargs...) -result = html_h1(;kwargs...) -push!(result.props, :children => Front.to_dash(children)) -return result +function html_h1(; kwargs...) + available_props = Symbol[:children, :id, :n_clicks, :n_clicks_timestamp, :key, :role, :accessKey, :className, :contentEditable, :contextMenu, :dir, :draggable, :hidden, :lang, :spellCheck, :style, :tabIndex, :title, :loading_state] + wild_props = Symbol[Symbol("data-"), Symbol("aria-")] + return Component("html_h1", "H1", "dash_html_components", available_props, wild_props; kwargs...) end +html_h1(children::Any; kwargs...) = html_h1(;kwargs..., children = children) html_h1(children_maker::Function; kwargs...) = html_h1(children_maker(); kwargs...) function html_img(; kwargs...) - available_props = Set(Symbol[:children, :id, :n_clicks, :n_clicks_timestamp, :key, :role, :alt, :crossOrigin, :height, :sizes, :src, :srcSet, :useMap, :width, :accessKey, :className, :contentEditable, :contextMenu, :dir, :draggable, :hidden, :lang, :spellCheck, :style, :tabIndex, :title, :loading_state]) - wild_props = Set(Symbol[Symbol("data-"), Symbol("aria-")]) - wild_regs = r"^(?data-|aria-)" - - result = Component("Img", "dash_html_components", Dict{Symbol, Any}(), available_props, Set(Symbol[Symbol("data-"), Symbol("aria-")])) - - for (prop, value) = pairs(kwargs) - m = match(wild_regs, string(prop)) - if (length(wild_props) == 0 || isnothing(m)) && !(prop in available_props) - throw(ArgumentError("Invalid property $(string(prop)) for component " * "html_img")) - end - - push!(result.props, prop => Front.to_dash(value)) - end - -return result -end - -function html_img(children::Any; kwargs...) -result = html_img(;kwargs...) -push!(result.props, :children => Front.to_dash(children)) -return result + available_props = Symbol[:children, :id, :n_clicks, :n_clicks_timestamp, :key, :role, :alt, :crossOrigin, :height, :sizes, :src, :srcSet, :useMap, :width, :accessKey, :className, :contentEditable, :contextMenu, :dir, :draggable, :hidden, :lang, :spellCheck, :style, :tabIndex, :title, :loading_state] + wild_props = Symbol[Symbol("data-"), Symbol("aria-")] + return Component("html_img", "Img", "dash_html_components", available_props, wild_props; kwargs...) end +html_img(children::Any; kwargs...) = html_img(;kwargs..., children = children) html_img(children_maker::Function; kwargs...) = html_img(children_maker(); kwargs...) function html_a(; kwargs...) - available_props = Set(Symbol[:children, :id, :n_clicks, :n_clicks_timestamp, :key, :role, :download, :href, :hrefLang, :media, :rel, :shape, :target, :accessKey, :className, :contentEditable, :contextMenu, :dir, :draggable, :hidden, :lang, :spellCheck, :style, :tabIndex, :title, :loading_state]) - wild_props = Set(Symbol[Symbol("data-"), Symbol("aria-")]) - wild_regs = r"^(?data-|aria-)" - - result = Component("A", "dash_html_components", Dict{Symbol, Any}(), available_props, Set(Symbol[Symbol("data-"), Symbol("aria-")])) - - for (prop, value) = pairs(kwargs) - m = match(wild_regs, string(prop)) - if (length(wild_props) == 0 || isnothing(m)) && !(prop in available_props) - throw(ArgumentError("Invalid property $(string(prop)) for component " * "html_a")) - end - - push!(result.props, prop => Front.to_dash(value)) - end - -return result -end - -function html_a(children::Any; kwargs...) -result = html_a(;kwargs...) -push!(result.props, :children => Front.to_dash(children)) -return result + available_props = Symbol[:children, :id, :n_clicks, :n_clicks_timestamp, :key, :role, :download, :href, :hrefLang, :media, :rel, :shape, :target, :accessKey, :className, :contentEditable, :contextMenu, :dir, :draggable, :hidden, :lang, :spellCheck, :style, :tabIndex, :title, :loading_state] + wild_props = Symbol[Symbol("data-"), Symbol("aria-")] + return Component("html_a", "A", "dash_html_components", available_props, wild_props; kwargs...) end +html_a(children::Any; kwargs...) = html_a(;kwargs..., children = children) html_a(children_maker::Function; kwargs...) = html_a(children_maker(); kwargs...) - - function dcc_input(; kwargs...) - available_props = Set(Symbol[:id, :value, :style, :className, :debounce, :type, :autoComplete, :autoFocus, :disabled, :inputMode, :list, :max, :maxLength, :min, :minLength, :multiple, :name, :pattern, :placeholder, :readOnly, :required, :selectionDirection, :selectionEnd, :selectionStart, :size, :spellCheck, :step, :n_submit, :n_submit_timestamp, :n_blur, :n_blur_timestamp, :loading_state, :persistence, :persisted_props, :persistence_type]) - wild_props = Set(Symbol[]) - wild_regs = r"^(?)" - - result = Component("Input", "dash_core_components", Dict{Symbol, Any}(), available_props, Set(Symbol[])) - - for (prop, value) = pairs(kwargs) - m = match(wild_regs, string(prop)) - if (length(wild_props) == 0 || isnothing(m)) && !(prop in available_props) - throw(ArgumentError("Invalid property $(string(prop)) for component " * "dcc_input")) - end - - push!(result.props, prop => Front.to_dash(value)) - end - -return result -end - -function dcc_input(children::Any; kwargs...) -result = dcc_input(;kwargs...) -push!(result.props, :children => Front.to_dash(children)) -return result + available_props = Symbol[:id, :value, :style, :className, :debounce, :type, :autoComplete, :autoFocus, :disabled, :inputMode, :list, :max, :maxLength, :min, :minLength, :multiple, :name, :pattern, :placeholder, :readOnly, :required, :selectionDirection, :selectionEnd, :selectionStart, :size, :spellCheck, :step, :n_submit, :n_submit_timestamp, :n_blur, :n_blur_timestamp, :loading_state, :persistence, :persisted_props, :persistence_type] + wild_props = Symbol[] + return Component("dcc_input", "Input", "dash_core_components", available_props, wild_props; kwargs...) end -dcc_input(children_maker::Function; kwargs...) = dcc_input(children_maker(); kwargs...) - function dcc_graph(; kwargs...) - available_props = Set(Symbol[:id, :responsive, :clickData, :clickAnnotationData, :hoverData, :clear_on_unhover, :selectedData, :relayoutData, :extendData, :restyleData, :figure, :style, :className, :animate, :animation_options, :config, :loading_state]) - wild_props = Set(Symbol[]) - wild_regs = r"^(?)" - - result = Component("Graph", "dash_core_components", Dict{Symbol, Any}(), available_props, Set(Symbol[])) - - for (prop, value) = pairs(kwargs) - m = match(wild_regs, string(prop)) - if (length(wild_props) == 0 || isnothing(m)) && !(prop in available_props) - throw(ArgumentError("Invalid property $(string(prop)) for component " * "dcc_graph")) - end - - push!(result.props, prop => Front.to_dash(value)) - end - -return result -end - -function dcc_graph(children::Any; kwargs...) -result = dcc_graph(;kwargs...) -push!(result.props, :children => Front.to_dash(children)) -return result -end - -dcc_graph(children_maker::Function; kwargs...) = dcc_graph(children_maker(); kwargs...) - + available_props = Symbol[:id, :responsive, :clickData, :clickAnnotationData, :hoverData, :clear_on_unhover, :selectedData, :relayoutData, :extendData, :restyleData, :figure, :style, :className, :animate, :animation_options, :config, :loading_state] + wild_props = Symbol[] + return Component("dcc_graph", "Graph", "dash_core_components", available_props, wild_props; kwargs...) end +end \ No newline at end of file diff --git a/test/core.jl b/test/core.jl index ea6c47d..d6d4d9a 100644 --- a/test/core.jl +++ b/test/core.jl @@ -1,33 +1,31 @@ import HTTP, JSON2 using Test +using DashBase using Dash -using Inflate + @testset "Components" begin - + a_comp = html_a("test", id = "test-a") - @test a_comp.type == "A" - @test a_comp.namespace == "dash_html_components" - @test a_comp.props[:id] == "test-a" - @test a_comp.props[:children] == "test" - + + @test a_comp.id == "test-a" + @test a_comp.children == "test" + input_comp = dcc_input(id = "test-input", type="text") - @test input_comp.type == "Input" - @test input_comp.namespace == "dash_core_components" - @test input_comp.props[:id] == "test-input" - @test input_comp.props[:type] == "text" - - @test_throws ArgumentError html_a(undefined_prop = "rrrr") - - component_with_children = html_div() do + @test input_comp.id == "test-input" + @test input_comp.type == "text" + @test_throws ErrorException html_a(undefined_prop = "rrrr") + + component_with_children = html_div() do html_a("fffff"), html_h1("fffff") end - @test haskey(component_with_children.props, :children) - @test component_with_children.props[:children] isa Tuple{Component, Component} - @test length(component_with_children.props[:children]) == 2 - @test component_with_children.props[:children][1].type == "A" - @test component_with_children.props[:children][2].type == "H1" + @test !isnothing(component_with_children.children) + @test component_with_children.children isa Tuple{Component, Component} + @test length(component_with_children.children) == 2 + @test DashBase.get_type(component_with_children.children[1]) == "A" + @test DashBase.get_type(component_with_children.children[2]) == "H1" + end @@ -37,7 +35,7 @@ end app.layout = html_div() do dcc_input(id = "my-id", value="initial value", type = "text"), html_div(id = "my-div"), - html_div(id = "my-div2") + html_div(id = "my-div2") end callback!(app, Output("my-div","children"), Input("my-id","value")) do value return value @@ -52,7 +50,7 @@ end response = HTTP.handle(handler, request) @test response.status == 200 body_str = String(response.body) - + request = HTTP.Request("GET", "/_dash-layout") response = HTTP.handle(handler, request) @test response.status == 200 @@ -64,7 +62,7 @@ end @test response.status == 200 body_str = String(response.body) resp_json = JSON2.read(body_str) - + @test resp_json isa Vector @test length(resp_json) == 2 @test haskey(resp_json[1], :inputs) @@ -81,7 +79,7 @@ end response = HTTP.handle(handler, request) @test response.status == 200 body_str = String(response.body) - + @test body_str == """{"response":{"my-div":{"children":"initial value3333"}},"multi":true}""" end @@ -92,9 +90,9 @@ end html_div() do dcc_input(id = "my-id", value="initial value", type = "text"), html_div(id = "my-div"), - html_div(id = global_id) + html_div(id = global_id) end - end + end app.layout = layout_func handler = Dash.make_handler(app) request = HTTP.Request("GET", "/_dash-layout") @@ -116,8 +114,8 @@ end @testset "assets" begin app = dash(assets_folder = "assets") - app.layout = html_div() do - html_img(src = "assets/test.png") + app.layout = html_div() do + html_img(src = "assets/test.png") end @test Dash.get_assets_path(app) == joinpath(pwd(),"assets") handler = Dash.make_handler(app) @@ -125,12 +123,12 @@ end response = HTTP.handle(handler, request) @test response.status == 200 body_str = String(response.body) - + request = HTTP.Request("GET", "/assets/wrong.png") response = HTTP.handle(handler, request) @test response.status == 404 body_str = String(response.body) - + end @testset "PreventUpdate and no_update" begin @@ -138,7 +136,7 @@ end app.layout = html_div() do html_div(10, id = "my-id"), - html_div(id = "my-div") + html_div(id = "my-div") end callback!(app, Output("my-div","children"), Input("my-id","children")) do value throw(PreventUpdate()) @@ -147,7 +145,7 @@ end handler = Dash.make_handler(app) test_json = """{"output":"my-div.children","changedPropIds":["my-id.children"],"inputs":[{"id":"my-id","property":"children","value":10}]}""" - + request = HTTP.Request("POST", "/_dash-update-component", [], Vector{UInt8}(test_json)) response = HTTP.handle(handler, request) @test response.status == 204 @@ -157,7 +155,7 @@ end app.layout = html_div() do html_div(10, id = "my-id"), html_div(id = "my-div"), - html_div(id = "my-div2") + html_div(id = "my-div2") end callback!(app, [Output("my-div","children"), Output("my-div2","children")], Input("my-id","children")) do value no_update(), "test" @@ -168,10 +166,10 @@ end request = HTTP.Request("POST", "/_dash-update-component", [], Vector{UInt8}(test_json)) response = HTTP.handle(handler, request) - + @test response.status == 200 result = JSON2.read(String(response.body)) - + @test length(result[:response]) == 1 @test haskey(result[:response], Symbol("my-div2")) @test !haskey(result[:response], Symbol("my-div")) @@ -179,33 +177,6 @@ end end -@testset "HTTP Compression" begin - # test compression of assets - app = dash(assets_folder = "assets_compressed", compress = true) - app.layout = html_div() - handler = Dash.make_handler(app) - - # ensure no compression of assets when Accept-Encoding not passed - request = HTTP.Request("GET", "/assets/bootstrap.css") - body = read("assets_compressed/bootstrap.css", String) - response = HTTP.handle(handler, request) - @test String(response.body) == body - @test !in("Content-Encoding"=>"gzip", response.headers) - - # ensure compression when Accept-Encoding = "gzip" - request = HTTP.Request("GET", "/assets/bootstrap.css", ["Accept-Encoding"=>"gzip"]) - response = HTTP.handle(handler, request) - @test String(inflate_gzip(response.body)) == body - @test String(response.body) != body - @test in("Content-Encoding"=>"gzip", response.headers) - - # test cases for compress = false - app = dash(assets_folder = "assets", compress=false) - app.layout = html_div() do - html_div("test") - end -end - @testset "layout validation" begin app = dash(assets_folder = "assets_compressed", compress = true) @test_throws ErrorException make_handler(app) @@ -216,7 +187,7 @@ end html_div(id = "third") do html_div("dsfsd", id = "inner2") end - end + end make_handler(app) app.layout = html_div(id="top") do @@ -226,6 +197,6 @@ end html_div(id = "second") do html_div("dsfsd", id = "inner2") end - end + end @test_throws ErrorException make_handler(app) end From c976cb6662b37aac5d1e4bdb05893fd6c8c0db30 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenko Date: Mon, 24 Aug 2020 10:40:20 +0300 Subject: [PATCH 2/8] ci+readme changes --- Project.toml | 16 ++++++++++------ README.md | 6 +++--- test/ci_prepare.jl | 5 +++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Project.toml b/Project.toml index 4eb96db..4821589 100644 --- a/Project.toml +++ b/Project.toml @@ -5,23 +5,27 @@ version = "0.1.0" [deps] CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" +DashBase = "03207cf0-e2b3-4b91-9ca8-690cf0fb507e" +DashCoreComponents = "1b08a953-4be3-4667-9a23-9da06441d987" +DashHtmlComponents = "1b08a953-4be3-4667-9a23-24100242a84a" +DashTable = "1b08a953-4be3-4667-9a23-f0e2ba4deb9a" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3" -LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" MD5 = "6ac74813-4b46-53a4-afec-0b5dc9d7885c" MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5" Sockets = "6462fe0b-24de-5631-8697-dd941f90decc" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" -DashBase = "03207cf0-e2b3-4b91-9ca8-690cf0fb507e" -DashCoreComponents = "1b08a953-4be3-4667-9a23-03c9473d1193" -DashHtmlComponents = "1b08a953-4be3-4667-9a23-341813c6f7a5" -DashTable = "1b08a953-4be3-4667-9a23-d3c7dd0aada8" [compat] +CodecZlib = "1.2.11" +DashBase = "0.1.0" +DashCoreComponents = "1.10.2" +DashHtmlComponents = "1.0.3" +DashTable = "4.9.0" DataStructures = "0.17.5" HTTP = "0.8.10" JSON = "0.21.0" @@ -34,4 +38,4 @@ julia = "1.1" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test"] \ No newline at end of file +test = ["Test"] diff --git a/README.md b/README.md index af1f4a5..c12f91e 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,10 @@ To install the latest (stable) development version instead: ```julia using Pkg +Pkg.add(PackageSpec(url="https://github.com/waralex/dash-html-components.git", rev="jl_generated")) +Pkg.add(PackageSpec(url="https://github.com/waralex/dash-core-components.git", rev="jl_generated")) +Pkg.add(PackageSpec(url="https://github.com/waralex/dash-table.git", rev="jl_generated")) Pkg.add(PackageSpec(url="https://github.com/plotly/Dash.jl.git", rev="dev")) -Pkg.add(PackageSpec(url="https://github.com/plotly/dash-html-components.git", rev="jl")) -Pkg.add(PackageSpec(url="https://github.com/plotly/dash-core-components.git", rev="jl")) -Pkg.add(PackageSpec(url="https://github.com/plotly/dash-table.git", rev="jl")) ``` ## Usage diff --git a/test/ci_prepare.jl b/test/ci_prepare.jl index 4636418..dcbaa3f 100644 --- a/test/ci_prepare.jl +++ b/test/ci_prepare.jl @@ -1,8 +1,9 @@ using Pkg Pkg.update() +Pkg.add(PackageSpec(url="https://github.com/waralex/dash-html-components.git", rev="jl_generated")) +Pkg.add(PackageSpec(url="https://github.com/waralex/dash-core-components.git", rev="jl_generated")) +Pkg.add(PackageSpec(url="https://github.com/waralex/dash-table.git", rev="jl_generated")) Pkg.add(PackageSpec(url="https://github.com/plotly/Dash.jl.git", rev=ENV["CIRCLE_BRANCH"])) -Pkg.add(PackageSpec(url="https://github.com/waralex/dash-html-components.git", rev="jl_generator_test")) -Pkg.add(PackageSpec(url="https://github.com/waralex/dash-core-components.git", rev="jl_generator_test")) Pkg.add("HTTP") Pkg.build("Dash") Pkg.build("DashHtmlComponents") From c5fd55417c4df424c7d027d712531ab76620525c Mon Sep 17 00:00:00 2001 From: Alexandr Romanenko Date: Mon, 24 Aug 2020 10:43:04 +0300 Subject: [PATCH 3/8] compat --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4821589..21fa7df 100644 --- a/Project.toml +++ b/Project.toml @@ -21,7 +21,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [compat] -CodecZlib = "1.2.11" +CodecZlib = "0.7.0" DashBase = "0.1.0" DashCoreComponents = "1.10.2" DashHtmlComponents = "1.0.3" From d7f0e2e7f710498d91b724ba567277c20fa12c8e Mon Sep 17 00:00:00 2001 From: Alexandr Romanenko Date: Mon, 24 Aug 2020 10:51:38 +0300 Subject: [PATCH 4/8] add DashBase to ci and readme --- README.md | 1 + test/ci_prepare.jl | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index c12f91e..5978b72 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ To install the latest (stable) development version instead: ```julia using Pkg +Pkg.add(PackageSpec(url="https://github.com/plotly/DashBase.jl.git")) Pkg.add(PackageSpec(url="https://github.com/waralex/dash-html-components.git", rev="jl_generated")) Pkg.add(PackageSpec(url="https://github.com/waralex/dash-core-components.git", rev="jl_generated")) Pkg.add(PackageSpec(url="https://github.com/waralex/dash-table.git", rev="jl_generated")) diff --git a/test/ci_prepare.jl b/test/ci_prepare.jl index dcbaa3f..bd4738c 100644 --- a/test/ci_prepare.jl +++ b/test/ci_prepare.jl @@ -1,5 +1,6 @@ using Pkg Pkg.update() +Pkg.add(PackageSpec(url="https://github.com/plotly/DashBase.jl.git")) Pkg.add(PackageSpec(url="https://github.com/waralex/dash-html-components.git", rev="jl_generated")) Pkg.add(PackageSpec(url="https://github.com/waralex/dash-core-components.git", rev="jl_generated")) Pkg.add(PackageSpec(url="https://github.com/waralex/dash-table.git", rev="jl_generated")) From 767637ef2d04a24abbb70d56fd60c988bc7106e9 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenko Date: Mon, 24 Aug 2020 11:47:51 +0300 Subject: [PATCH 5/8] increase timeout --- .../callbacks/test_basic_callback.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/integration/callbacks/test_basic_callback.py b/test/integration/callbacks/test_basic_callback.py index 2ee94f0..210ca14 100644 --- a/test/integration/callbacks/test_basic_callback.py +++ b/test/integration/callbacks/test_basic_callback.py @@ -8,12 +8,12 @@ def jl_test_file_path(filename): return os.path.join(curr_path, "jl_basic_callback", filename) def test_jlcbsc001_simple_callback(dashjl): - fp = jl_test_file_path("jlcbsc001_simple_callback.jl") + fp = jl_test_file_path("jlcbsc001_simple_callback.jl") dashjl.start_server(fp) dashjl.wait_for_element_by_css_selector( "#input", timeout=2 - ) + ) dashjl.wait_for_text_to_equal( "#output", "initial value", timeout=3 @@ -27,11 +27,11 @@ def test_jlcbsc001_simple_callback(dashjl): ) def test_jlcbsc002_callbacks_generating_children(dashjl): - fp = jl_test_file_path("jlcbsc002_callbacks_generating_children.jl") + fp = jl_test_file_path("jlcbsc002_callbacks_generating_children.jl") dashjl.start_server(fp) dashjl.wait_for_element_by_css_selector( "#input", timeout=3 - ) + ) dashjl.wait_for_text_to_equal( "#sub-output-1", "sub input initial value", timeout=3 @@ -59,7 +59,7 @@ def test_jlcbsc002_callbacks_generating_children(dashjl): def test_jlcbsc003_callback_with_unloaded_async_component(dashjl): - fp = jl_test_file_path("jlcbsc003_callback_with_unloaded_async_component.jl") + fp = jl_test_file_path("jlcbsc003_callback_with_unloaded_async_component.jl") dashjl.start_server(fp) dashjl.wait_for_text_to_equal("#output", "Hello", timeout=3) dashjl.find_element("#btn").click() @@ -67,7 +67,7 @@ def test_jlcbsc003_callback_with_unloaded_async_component(dashjl): def test_jlcbsc005_children_types(dashjl): - fp = jl_test_file_path("jlcbsc005_children_types.jl") + fp = jl_test_file_path("jlcbsc005_children_types.jl") dashjl.start_server(fp) outputs = [ @@ -87,12 +87,12 @@ def test_jlcbsc005_children_types(dashjl): dashjl.wait_for_text_to_equal("#out", text, timeout=3) def test_jlcbsc006_multiple_outputs(dashjl): - fp = jl_test_file_path("jlcbsc006_multiple_outputs.jl") + fp = jl_test_file_path("jlcbsc006_multiple_outputs.jl") dashjl.start_server(fp) dashjl.wait_for_element_by_css_selector( "#input", timeout=2 - ) + ) dashjl.wait_for_text_to_equal( "#output1", "initial value first", timeout=3 @@ -113,12 +113,12 @@ def test_jlcbsc006_multiple_outputs(dashjl): ) def test_jlcbsc007_prevent_update(dashjl): - fp = jl_test_file_path("jlcbsc007_prevent_update.jl") + fp = jl_test_file_path("jlcbsc007_prevent_update.jl") dashjl.start_server(fp) dashjl.wait_for_element_by_css_selector( - "#input", timeout=2 - ) + "#input", timeout=4 + ) dashjl.find_element("#input").click() dashjl.find_elements("div.VirtualizedSelectOption")[0].click() @@ -150,12 +150,12 @@ def test_jlcbsc007_prevent_update(dashjl): ) def test_jlcbsc008_prevent_update(dashjl): - fp = jl_test_file_path("jlcbsc008_prevent_update_multiple.jl") + fp = jl_test_file_path("jlcbsc008_prevent_update_multiple.jl") dashjl.start_server(fp) dashjl.wait_for_element_by_css_selector( "#input", timeout=2 - ) + ) dashjl.find_element("#input").click() dashjl.find_elements("div.VirtualizedSelectOption")[0].click() #regular @@ -213,12 +213,12 @@ def test_jlcbsc008_prevent_update(dashjl): ) def test_jlcbsc009_single_element_array_output(dashjl): - fp = jl_test_file_path("jlcbsc009_single_element_array_output.jl") + fp = jl_test_file_path("jlcbsc009_single_element_array_output.jl") dashjl.start_server(fp) dashjl.wait_for_element_by_css_selector( "#input", timeout=3 - ) + ) dashjl.wait_for_text_to_equal( "#output", "initial value", timeout=2 From 93a2f49f11c86607d5046e0030e32becfed4a64a Mon Sep 17 00:00:00 2001 From: Alexandr Romanenko Date: Mon, 24 Aug 2020 13:03:13 +0300 Subject: [PATCH 6/8] increase test timeouts --- test/integration/base/test_render.py | 6 +++--- .../callbacks/test_basic_callback.py | 6 +++--- .../callbacks/test_callback_context.py | 6 +++--- .../integration/clientside/test_clientside.py | 20 +++++++++---------- .../components/test_default_children.py | 6 +++--- .../dash_assets/test_dash_assets.py | 8 ++++---- test/integration/devtools/test_devtools_ui.py | 8 ++++---- test/integration/devtools/test_hot_reload.py | 12 +++++------ test/integration/devtools/test_props_check.py | 4 ++-- 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/test/integration/base/test_render.py b/test/integration/base/test_render.py index 9b46e8c..13eda6d 100644 --- a/test/integration/base/test_render.py +++ b/test/integration/base/test_render.py @@ -23,11 +23,11 @@ def click_redo(self): def test_jltr001r_undo_redo(dashjl): - fp = jl_test_file_path("jltr001r_undo_redo.jl") + fp = jl_test_file_path("jltr001r_undo_redo.jl") dashjl.start_server(fp) dashjl.wait_for_element_by_css_selector( - "#a" - ) + "#a", timeout=4 + ) input1 = dashjl.find_element("#a") input1.send_keys("xyz") dashjl.wait_for_text_to_equal( diff --git a/test/integration/callbacks/test_basic_callback.py b/test/integration/callbacks/test_basic_callback.py index 210ca14..e380523 100644 --- a/test/integration/callbacks/test_basic_callback.py +++ b/test/integration/callbacks/test_basic_callback.py @@ -12,7 +12,7 @@ def test_jlcbsc001_simple_callback(dashjl): dashjl.start_server(fp) dashjl.wait_for_element_by_css_selector( - "#input", timeout=2 + "#input", timeout=4 ) dashjl.wait_for_text_to_equal( @@ -91,7 +91,7 @@ def test_jlcbsc006_multiple_outputs(dashjl): dashjl.start_server(fp) dashjl.wait_for_element_by_css_selector( - "#input", timeout=2 + "#input", timeout=4 ) dashjl.wait_for_text_to_equal( @@ -154,7 +154,7 @@ def test_jlcbsc008_prevent_update(dashjl): dashjl.start_server(fp) dashjl.wait_for_element_by_css_selector( - "#input", timeout=2 + "#input", timeout=4 ) dashjl.find_element("#input").click() dashjl.find_elements("div.VirtualizedSelectOption")[0].click() #regular diff --git a/test/integration/callbacks/test_callback_context.py b/test/integration/callbacks/test_callback_context.py index d4ef61e..0fccc18 100644 --- a/test/integration/callbacks/test_callback_context.py +++ b/test/integration/callbacks/test_callback_context.py @@ -9,10 +9,10 @@ def jl_test_file_path(filename): return os.path.join(curr_path, "jl_callback_context", filename) def test_jlcbcx001_modified_response(dashjl): - fp = jl_test_file_path("jlcbcx001_modified_response.jl") + fp = jl_test_file_path("jlcbcx001_modified_response.jl") dashjl.start_server(fp) - dashjl.wait_for_text_to_equal("#output", "ab - output", timeout=3) + dashjl.wait_for_text_to_equal("#output", "ab - output", timeout=4) input1 = dashjl.find_element("#input") input1.send_keys("cd") @@ -25,7 +25,7 @@ def test_jlcbcx001_modified_response(dashjl): assert not dashjl.get_logs() def test_jlcbcx002_triggered(dashjl): - fp = jl_test_file_path("jlcbcx002_triggered.jl") + fp = jl_test_file_path("jlcbcx002_triggered.jl") dashjl.start_server(fp) btns = ["btn-{}".format(x) for x in range(1, 6)] dashjl.wait_for_element_by_css_selector("#output", timeout=3) diff --git a/test/integration/clientside/test_clientside.py b/test/integration/clientside/test_clientside.py index 77ae144..a598b24 100644 --- a/test/integration/clientside/test_clientside.py +++ b/test/integration/clientside/test_clientside.py @@ -9,7 +9,7 @@ def jl_test_file_path(filename): return os.path.join(curr_path, "jl_clientside", filename) def test_jlclsd001_simple_clientside_serverside_callback(dashjl): - fp = jl_test_file_path("jlclsd001_simple_clientside_serverside_callback.jl") + fp = jl_test_file_path("jlclsd001_simple_clientside_serverside_callback.jl") dashjl.start_server(fp) dashjl.wait_for_text_to_equal("#output-serverside", 'Server says "nothing"', timeout=3) @@ -20,7 +20,7 @@ def test_jlclsd001_simple_clientside_serverside_callback(dashjl): dashjl.wait_for_text_to_equal("#output-clientside", 'Client says "hello world"', timeout=2) def test_jlclsd002_chained_serverside_clientside_callbacks(dashjl): - fp = jl_test_file_path("jlclsd002_chained_serverside_clientside_callbacks.jl") + fp = jl_test_file_path("jlclsd002_chained_serverside_clientside_callbacks.jl") dashjl.start_server(fp) test_cases = [ @@ -49,7 +49,7 @@ def test_jlclsd002_chained_serverside_clientside_callbacks(dashjl): dashjl.wait_for_text_to_equal(selector, expected, timeout=2) def test_jlclsd003_clientside_exceptions_halt_subsequent_updates(dashjl): - fp = jl_test_file_path("jlclsd003_clientside_exceptions_halt_subsequent_updates.jl") + fp = jl_test_file_path("jlclsd003_clientside_exceptions_halt_subsequent_updates.jl") dashjl.start_server(fp) test_cases = [["#first", "1"], ["#second", "2"], ["#third", "3"]] @@ -72,7 +72,7 @@ def test_jlclsd003_clientside_exceptions_halt_subsequent_updates(dashjl): dashjl.wait_for_text_to_equal(selector, expected, timeout=2) def test_jlclsd004_clientside_multiple_outputs(dashjl): - fp = jl_test_file_path("jlclsd004_clientside_multiple_outputs.jl") + fp = jl_test_file_path("jlclsd004_clientside_multiple_outputs.jl") dashjl.start_server(fp) for selector, expected in [ @@ -96,7 +96,7 @@ def test_jlclsd004_clientside_multiple_outputs(dashjl): dashjl.wait_for_text_to_equal(selector, expected, timeout=2) def test_jlclsd005_clientside_fails_when_returning_a_promise(dashjl): - fp = jl_test_file_path("jlclsd005_clientside_fails_when_returning_a_promise.jl") + fp = jl_test_file_path("jlclsd005_clientside_fails_when_returning_a_promise.jl") dashjl.start_server(fp) dashjl.wait_for_text_to_equal("#input", "hello", timeout=2) @@ -104,10 +104,10 @@ def test_jlclsd005_clientside_fails_when_returning_a_promise(dashjl): dashjl.wait_for_text_to_equal("#output", "output") def test_jlclsd006_PreventUpdate(dashjl): - fp = jl_test_file_path("jlclsd006_PreventUpdate.jl") + fp = jl_test_file_path("jlclsd006_PreventUpdate.jl") dashjl.start_server(fp) - dashjl.wait_for_text_to_equal("#first", "1", timeout=2) + dashjl.wait_for_text_to_equal("#first", "1", timeout=4) dashjl.wait_for_text_to_equal("#second", "2") dashjl.wait_for_text_to_equal("#third", "2") @@ -124,7 +124,7 @@ def test_jlclsd006_PreventUpdate(dashjl): dashjl.wait_for_text_to_equal("#third", "3") def test_jlclsd007_no_update(dashjl): - fp = jl_test_file_path("jlclsd007_no_update.jl") + fp = jl_test_file_path("jlclsd007_no_update.jl") dashjl.start_server(fp) dashjl.wait_for_text_to_equal("#first", "1") dashjl.wait_for_text_to_equal("#second", "2") @@ -143,10 +143,10 @@ def test_jlclsd007_no_update(dashjl): dashjl.wait_for_text_to_equal("#third", "4") def test_jlclsd008_clientside_inline_source(dashjl): - fp = jl_test_file_path("jlclsd008_clientside_inline_source.jl") + fp = jl_test_file_path("jlclsd008_clientside_inline_source.jl") dashjl.start_server(fp) - dashjl.wait_for_text_to_equal("#output-serverside", 'Server says "nothing"', timeout=3) + dashjl.wait_for_text_to_equal("#output-serverside", 'Server says "nothing"', timeout=4) dashjl.wait_for_text_to_equal("#output-clientside", 'Client says "undefined"') dashjl.find_element("#input").send_keys("hello world") diff --git a/test/integration/components/test_default_children.py b/test/integration/components/test_default_children.py index 3952fb3..14e6672 100644 --- a/test/integration/components/test_default_children.py +++ b/test/integration/components/test_default_children.py @@ -8,8 +8,8 @@ def jl_test_file_path(filename): return os.path.join(curr_path, "jl_default_children", filename) def test_jlcmdc001_default_children(dashjl): - fp = jl_test_file_path("jlcmdc001_default_children.jl") + fp = jl_test_file_path("jlcmdc001_default_children.jl") dashjl.start_server(fp) dashjl.wait_for_element_by_css_selector( - "#first-inner-div", timeout=2 - ) \ No newline at end of file + "#first-inner-div", timeout=4 + ) \ No newline at end of file diff --git a/test/integration/dash_assets/test_dash_assets.py b/test/integration/dash_assets/test_dash_assets.py index e7dfe74..f76bba7 100644 --- a/test/integration/dash_assets/test_dash_assets.py +++ b/test/integration/dash_assets/test_dash_assets.py @@ -11,10 +11,10 @@ def jl_test_file_path(filename): def test_jldada001_assets(dashjl): - fp = jl_test_file_path("jldada001_assets.jl") + fp = jl_test_file_path("jldada001_assets.jl") dashjl.start_server(fp) - dashjl.wait_for_element("body", timeout=2) + dashjl.wait_for_element("body", timeout=4) assert ( dashjl.find_element("body").value_of_css_property("margin") == "0px" @@ -40,7 +40,7 @@ def test_jldada001_assets(dashjl): assert order == tested, "the content and order is expected" def test_jldada002_external_files_init(dashjl): - fp = jl_test_file_path("jldada002_external_files_init.jl") + fp = jl_test_file_path("jldada002_external_files_init.jl") js_files = [ "https://www.google-analytics.com/analytics.js", {"src": "https://cdn.polyfill.io/v2/polyfill.min.js"}, @@ -67,7 +67,7 @@ def test_jldada002_external_files_init(dashjl): ] dashjl.start_server(fp) - dashjl.wait_for_element("body", timeout=2) + dashjl.wait_for_element("body", timeout=4) js_urls = [x["src"] if isinstance(x, dict) else x for x in js_files] css_urls = [x["href"] if isinstance(x, dict) else x for x in css_files] diff --git a/test/integration/devtools/test_devtools_ui.py b/test/integration/devtools/test_devtools_ui.py index e60da88..46827eb 100644 --- a/test/integration/devtools/test_devtools_ui.py +++ b/test/integration/devtools/test_devtools_ui.py @@ -9,10 +9,10 @@ def jl_test_file_path(filename): return os.path.join(curr_path, "jl_devtools_ui", filename) def test_jldvui001_disable_props_check_config(dashjl): - fp = jl_test_file_path("jldvui001_disable_props_check_config.jl") + fp = jl_test_file_path("jldvui001_disable_props_check_config.jl") dashjl.start_server(fp) - dashjl.wait_for_text_to_equal("#tcid", "Hello Props Check", timeout = 2) + dashjl.wait_for_text_to_equal("#tcid", "Hello Props Check", timeout = 4) assert dashjl.find_elements("#broken svg.main-svg"), "graph should be rendered" assert dashjl.find_elements( @@ -20,10 +20,10 @@ def test_jldvui001_disable_props_check_config(dashjl): ), "the debug menu icon should show up" def test_jldvui002_disable_ui_config(dashjl): - fp = jl_test_file_path("jldvui002_disable_ui_config.jl") + fp = jl_test_file_path("jldvui002_disable_ui_config.jl") dashjl.start_server(fp) - dashjl.wait_for_text_to_equal("#tcid", "Hello Disable UI", timeout = 2) + dashjl.wait_for_text_to_equal("#tcid", "Hello Disable UI", timeout = 4) logs = str(wait.until(dashjl.get_logs, timeout=2)) assert ( "Invalid argument `animate` passed into Graph" in logs diff --git a/test/integration/devtools/test_hot_reload.py b/test/integration/devtools/test_hot_reload.py index cbe3533..904fdda 100644 --- a/test/integration/devtools/test_hot_reload.py +++ b/test/integration/devtools/test_hot_reload.py @@ -44,11 +44,11 @@ def jl_test_file_path(filename): def test_jldvhr001_hot_reload(dashjl): - fp = jl_test_file_path("jldvhr001_hot_reload.jl") + fp = jl_test_file_path("jldvhr001_hot_reload.jl") dashjl.start_server(fp) dashjl.wait_for_text_to_equal( - "#tested", "Initial", timeout = 2 + "#tested", "Initial", timeout = 4 ) # default overload color is blue @@ -109,12 +109,12 @@ def test_jldvhr001_hot_reload(dashjl): "#tested", "Initial" ) def test_jldvhr002_hot_restart(dashjl): - app_file = jl_test_file_path("jldvhr002_hot_restart.jl") + app_file = jl_test_file_path("jldvhr002_hot_restart.jl") dashjl.start_server(app_file) dashjl.wait_for_element_by_css_selector( - "#before-reload-content", timeout=2 - ) + "#before-reload-content", timeout=4 + ) dashjl.wait_for_text_to_equal( "#output", "before reload initial", timeout=2 @@ -138,7 +138,7 @@ def test_jldvhr002_hot_restart(dashjl): try: dashjl.wait_for_element_by_css_selector( "#after-reload-content", timeout=30 - ) + ) dashjl.wait_for_text_to_equal( "#output", "after reload init", timeout=1 diff --git a/test/integration/devtools/test_props_check.py b/test/integration/devtools/test_props_check.py index d1a3151..fc18fb5 100644 --- a/test/integration/devtools/test_props_check.py +++ b/test/integration/devtools/test_props_check.py @@ -91,14 +91,14 @@ def jl_test_file_path(filename): } def test_jldvpc001_prop_check_errors_with_path(dashjl): - fp = jl_test_file_path("jldvpc001_prop_check_errors_with_path.jl") + fp = jl_test_file_path("jldvpc001_prop_check_errors_with_path.jl") dashjl.start_server(fp) for tc in test_cases: route_url = "{}/{}".format(dashjl.server_url, tc) dashjl.wait_for_page(url=route_url) if test_cases[tc]["fail"]: - dashjl.wait_for_element(".test-devtools-error-toggle", timeout=2).click() + dashjl.wait_for_element(".test-devtools-error-toggle", timeout=4).click() dashjl.wait_for_element(".dash-error-card") else: dashjl.wait_for_element("#new-component", timeout=2) \ No newline at end of file From e01ee4960caaeb4a6e650ca6cba9d149bcb7040b Mon Sep 17 00:00:00 2001 From: Alexandr Romanenko Date: Wed, 26 Aug 2020 17:52:19 +0300 Subject: [PATCH 7/8] Update src/Front.jl Co-authored-by: Alex Johnson --- src/Front.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Front.jl b/src/Front.jl index 9d5895b..0cd5726 100644 --- a/src/Front.jl +++ b/src/Front.jl @@ -1,4 +1,4 @@ import JSON, JSON2, PlotlyBase -#FIXME It's not elegant, but I didn't find elegant soluiton -JSON2.write(io::IO, p::PlotlyBase.Plot; kwargs...) = write(io, JSON.json(p)) \ No newline at end of file +#FIXME It's not elegant, but I didn't find elegant solution +JSON2.write(io::IO, p::PlotlyBase.Plot; kwargs...) = write(io, JSON.json(p)) From 1cfaf4a9d3b42d314a908932ca825cbee0a5c1e2 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenko Date: Thu, 27 Aug 2020 12:12:05 +0300 Subject: [PATCH 8/8] change components repos to plotly --- README.md | 6 +++--- test/ci_prepare.jl | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5978b72..3e0390c 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ To install the latest (stable) development version instead: ```julia using Pkg Pkg.add(PackageSpec(url="https://github.com/plotly/DashBase.jl.git")) -Pkg.add(PackageSpec(url="https://github.com/waralex/dash-html-components.git", rev="jl_generated")) -Pkg.add(PackageSpec(url="https://github.com/waralex/dash-core-components.git", rev="jl_generated")) -Pkg.add(PackageSpec(url="https://github.com/waralex/dash-table.git", rev="jl_generated")) +Pkg.add(PackageSpec(url="https://github.com/plotly/dash-html-components.git", rev="master")) +Pkg.add(PackageSpec(url="https://github.com/plotly/dash-core-components.git", rev="master")) +Pkg.add(PackageSpec(url="https://github.com/plotly/dash-table.git", rev="master")) Pkg.add(PackageSpec(url="https://github.com/plotly/Dash.jl.git", rev="dev")) ``` diff --git a/test/ci_prepare.jl b/test/ci_prepare.jl index bd4738c..3d6c88e 100644 --- a/test/ci_prepare.jl +++ b/test/ci_prepare.jl @@ -1,9 +1,9 @@ using Pkg Pkg.update() Pkg.add(PackageSpec(url="https://github.com/plotly/DashBase.jl.git")) -Pkg.add(PackageSpec(url="https://github.com/waralex/dash-html-components.git", rev="jl_generated")) -Pkg.add(PackageSpec(url="https://github.com/waralex/dash-core-components.git", rev="jl_generated")) -Pkg.add(PackageSpec(url="https://github.com/waralex/dash-table.git", rev="jl_generated")) +Pkg.add(PackageSpec(url="https://github.com/plotly/dash-html-components.git", rev="master")) +Pkg.add(PackageSpec(url="https://github.com/plotly/dash-core-components.git", rev="master")) +Pkg.add(PackageSpec(url="https://github.com/plotly/dash-table.git", rev="master")) Pkg.add(PackageSpec(url="https://github.com/plotly/Dash.jl.git", rev=ENV["CIRCLE_BRANCH"])) Pkg.add("HTTP") Pkg.build("Dash")