mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-12-28 18:50:48 +08:00
e755ff8122
* Force menu items into a single line * Add shortcut for saving the notebook * Make the disk icon always show file dialog * Split runtime and file settings into separate modals * Add ctrl+s to the shortcuts list * Add togglable menu to the session page * Make sure newly saved file appears in the file selector * Fix path seletor force reloading * Remove notebook generated in tests * Add test for file list refresh after save
49 lines
1.4 KiB
Elixir
49 lines
1.4 KiB
Elixir
defmodule LivebookWeb.PathSelectComponentTest do
|
|
# Note: we cannot run asynchronously, because we use `File.cd!`
|
|
use LivebookWeb.ConnCase, async: false
|
|
|
|
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 "does not show parent directory when in root" do
|
|
path = "/"
|
|
refute render_component(PathSelectComponent, attrs(path: path)) =~ ".."
|
|
end
|
|
|
|
test "relative paths are expanded from the current working directory" do
|
|
File.cd!(notebooks_path(), fn ->
|
|
path = ""
|
|
assert render_component(PathSelectComponent, attrs(path: path)) =~ "basic.livemd"
|
|
end)
|
|
end
|
|
|
|
defp attrs(attrs) do
|
|
Keyword.merge(
|
|
[
|
|
id: 1,
|
|
path: "/",
|
|
extnames: [".livemd"],
|
|
running_paths: [],
|
|
phx_target: nil,
|
|
phx_submit: nil
|
|
],
|
|
attrs
|
|
)
|
|
end
|
|
|
|
defp notebooks_path() do
|
|
Path.expand("../../support/notebooks", __DIR__)
|
|
end
|
|
end
|