mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-11-16 04:46:46 +08:00
8e6558a83a
* Introduce file system abstraction and an S3 implementation * Support arbitrary absolute paths and delegate resolution to file system * Remove accidental notebook file * Apply suggestions from code review Co-authored-by: José Valim <jose.valim@dashbit.co> * Apply review comments * Add missing path assertions * Apply review comments * Fix test saving notebook in project root Co-authored-by: José Valim <jose.valim@dashbit.co>
40 lines
1.1 KiB
Elixir
40 lines
1.1 KiB
Elixir
defmodule LivebookWeb.FileSelectComponentTest do
|
|
use LivebookWeb.ConnCase, async: true
|
|
|
|
import Phoenix.LiveViewTest
|
|
|
|
alias Livebook.FileSystem
|
|
alias LivebookWeb.FileSelectComponent
|
|
|
|
test "when the path has a trailing slash, lists that directory" do
|
|
file = FileSystem.File.local(notebooks_path() <> "/")
|
|
assert render_component(FileSelectComponent, attrs(file: file)) =~ "basic.livemd"
|
|
assert render_component(FileSelectComponent, attrs(file: file)) =~ ".."
|
|
end
|
|
|
|
test "when the path has no trailing slash, lists the parent directory" do
|
|
file = FileSystem.File.local(notebooks_path())
|
|
assert render_component(FileSelectComponent, attrs(file: file)) =~ "notebooks"
|
|
end
|
|
|
|
test "does not show parent directory when in root" do
|
|
file = FileSystem.File.local("/")
|
|
refute render_component(FileSelectComponent, attrs(file: file)) =~ ".."
|
|
end
|
|
|
|
defp attrs(attrs) do
|
|
Keyword.merge(
|
|
[
|
|
id: 1,
|
|
file: FileSystem.File.local("/"),
|
|
extnames: [".livemd"],
|
|
running_files: []
|
|
],
|
|
attrs
|
|
)
|
|
end
|
|
|
|
defp notebooks_path() do
|
|
Path.expand("../../support/notebooks", __DIR__)
|
|
end
|
|
end
|