livebook/test/livebook_web/live/path_select_component_test.exs
Jonatan Kłosko 700987dc02
Add editor completion to Elixir cells (#208)
* Implement editor completion for Elixir cells

* Add completion tests

* Refactor completion

* Only extract Markdown docs for now

* Fix Elixir version-dependent test

* Fix docs matching

* Use upcoming Code.cursor_context/2

* Start temporary completion processes under a supervisor

* Show Erlang docs in completion items

* Update to latest Code.cursor_context

* Refactor completion

* Fix module completion when alias expands to Erlang module

* Remove tests-generated notebook

* Show variables and map fields differently

* Adjust signatures formatting
2021-04-20 19:34:17 +02:00

48 lines
1.3 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())
path = ""
assert render_component(PathSelectComponent, attrs(path: path)) =~ "basic.livemd"
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