Skip to content

Commit 0d9aba7

Browse files
committed
Move wsl_distro
1 parent c38effa commit 0d9aba7

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

lib/tidewave.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ def config_data(request)
236236
"team" => @options[:team] || {},
237237
"tidewave_version" => VERSION,
238238
"local_port" => local_port(request),
239-
"tmp_dir" => TMP_DIR,
240-
"wsl_distro" => ENV["WSL_DISTRO_NAME"]
239+
"tmp_dir" => TMP_DIR
241240
}
242241
end
243242

@@ -291,7 +290,9 @@ def toolbar_html(request)
291290
client_url = @options[:client_url].to_s.sub(%r{/\z}, "")
292291
payload = {
293292
"tidewave" => config_data(request),
294-
"root" => @root.to_s
293+
"root" => @root.to_s,
294+
"wsl_distro" => ENV["WSL_DISTRO_NAME"],
295+
"framework" => {}
295296
}
296297

297298
<<~HTML

test/tidewave_test.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,20 @@ def test_injects_toolbar_into_html_responses
9595
assert_equal "demo-app", payload.dig("tidewave", "project_name")
9696
assert_equal 5000, payload.dig("tidewave", "local_port")
9797
assert_equal @tmpdir, payload["root"]
98+
assert_equal({}, payload["framework"])
9899
end
99100

100-
def test_config_includes_the_wsl_distribution
101+
def test_toolbar_config_includes_the_wsl_distribution_at_the_top_level
101102
previous_wsl_distro = ENV["WSL_DISTRO_NAME"]
102103
ENV["WSL_DISTRO_NAME"] = "Ubuntu-24.04"
103-
app = Tidewave.new(@downstream_app, allow_remote_access: true, project_name: "demo-app")
104+
downstream = ->(_env) { [ 200, { "content-type" => "text/html" }, [ "<head></head>" ] ] }
105+
app = Tidewave.new(downstream, allow_remote_access: true, project_name: "demo-app")
104106

105-
_status, _headers, body = perform_request(app, path: "/tidewave/config")
106-
assert_equal "Ubuntu-24.04", JSON.parse(body)["wsl_distro"]
107+
_status, _headers, body = perform_request(app, path: "/")
108+
payload = JSON.parse(CGI.unescapeHTML(body[/name="tidewave:config" content="([^"]+)"/, 1]))
109+
110+
assert_equal "Ubuntu-24.04", payload["wsl_distro"]
111+
refute payload["tidewave"].key?("wsl_distro")
107112
ensure
108113
ENV["WSL_DISTRO_NAME"] = previous_wsl_distro
109114
end

0 commit comments

Comments
 (0)