mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-11-16 12:57:32 +08:00
663ec3283e
* Prototype standalone mode with mix * Move runtime initialization into separate LiveViews * Make standalone node initialization async * Refactor async node initialization * Automatically scroll to the bottom of output * Refactor streaming output * Move MessageEmitter under Utils * Add path selector to the mix runtime picker * Update runtime descriptions * Add successful or error message at the end of output * Run formatter * Rename Standalone to ElixirStandalone for consistency * Show only directories when looking for a mix project * Update docs * Extract shared standalone logic * Make the remote primary process monitor Manager instead of session * Further refactoring and docs * Add tests for collectable Callback * Add missing macro doc * Apply review suggestions * Decouple sending asynchronous notifications from the runtime initialization * Apply suggestions
51 lines
1.7 KiB
Elixir
51 lines
1.7 KiB
Elixir
defmodule LiveBookWeb.PathSelectComponentTest do
|
|
use LiveBookWeb.ConnCase
|
|
|
|
import Phoenix.LiveViewTest
|
|
|
|
alias LiveBookWeb.PathSelectComponent
|
|
|
|
test "when the path has a trailing slash, lists that directory" do
|
|
path = notebooks_path() <> "/"
|
|
assert render_component(PathSelectComponent, attrs(path: path)) =~ "basic.livemd"
|
|
assert render_component(PathSelectComponent, attrs(path: path)) =~ ".."
|
|
end
|
|
|
|
test "when the path has no trailing slash, lists the parent directory" do
|
|
path = notebooks_path()
|
|
assert render_component(PathSelectComponent, attrs(path: path)) =~ "notebooks"
|
|
end
|
|
|
|
test "lists only files with matching name" do
|
|
path = notebooks_path() |> Path.join("with_two_sectio")
|
|
assert render_component(PathSelectComponent, attrs(path: path)) =~ "with_two_sections.livemd"
|
|
refute render_component(PathSelectComponent, attrs(path: path)) =~ "basic.livemd"
|
|
end
|
|
|
|
test "does not show parent directory when in root" do
|
|
path = "/"
|
|
refute render_component(PathSelectComponent, attrs(path: path)) =~ ".."
|
|
end
|
|
|
|
test "does not show parent directory when there is a basename typed" do
|
|
path = notebooks_path() |> Path.join("a")
|
|
refute render_component(PathSelectComponent, attrs(path: path)) =~ ".."
|
|
end
|
|
|
|
test "relative paths are expanded from the current working directory" do
|
|
File.cd!(notebooks_path())
|
|
path = ""
|
|
assert render_component(PathSelectComponent, attrs(path: path)) =~ "basic.livemd"
|
|
end
|
|
|
|
defp attrs(attrs) do
|
|
Keyword.merge(
|
|
[id: 1, path: "/", extnames: [".livemd"], running_paths: [], target: nil],
|
|
attrs
|
|
)
|
|
end
|
|
|
|
defp notebooks_path() do
|
|
Path.expand("../../support/notebooks", __DIR__)
|
|
end
|
|
end
|