Consolidate datetime as date formatting

This commit is contained in:
Claudio Ortolina
2025-01-05 15:48:56 +00:00
parent 75154df3cf
commit 9428828064
8 changed files with 20 additions and 30 deletions
@@ -28,10 +28,6 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|> Phoenix.HTML.safe_to_string()
end
defp human_datetime(dt) do
"#{dt.day}/#{dt.month}/#{dt.year}"
end
describe "Collection" do
setup [:fill_collection, :fill_wishlist]
@@ -61,7 +57,9 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|> assert_has("#records-#{record.id} p", text: record.release)
|> assert_has("#records-#{record.id} p", text: Record.format_long_label(record.format))
|> assert_has("#records-#{record.id} p", text: Record.type_long_label(record.type))
|> assert_has("#records-#{record.id} span", text: human_datetime(record.purchased_at))
|> assert_has("#records-#{record.id} span",
text: Record.format_as_date(record.purchased_at)
)
for artist <- record.artists do
assert_has(session, "#records-#{record.id} a", text: escape(artist.name))
@@ -152,7 +150,9 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|> assert_has("#records-#{record.id} p", text: record.release)
|> assert_has("#records-#{record.id} p", text: Record.format_long_label(record.format))
|> assert_has("#records-#{record.id} p", text: Record.type_long_label(record.type))
|> assert_has("#records-#{record.id} span", text: human_datetime(record.purchased_at))
|> assert_has("#records-#{record.id} span",
text: Record.format_as_date(record.purchased_at)
)
|> unwrap(fn collection_view ->
html = render(collection_view)
assert html =~ ~p"/covers/#{record.id}?vsn=#{record.cover_hash}"
@@ -194,7 +194,9 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|> assert_has("#records-#{record.id} p", text: record.release)
|> assert_has("#records-#{record.id} p", text: Record.format_long_label(record.format))
|> assert_has("#records-#{record.id} p", text: Record.type_long_label(record.type))
|> assert_has("#records-#{record.id} span", text: human_datetime(record.purchased_at))
|> assert_has("#records-#{record.id} span",
text: Record.format_as_date(record.purchased_at)
)
|> unwrap(fn collection_view ->
html = render(collection_view)
assert html =~ ~p"/covers/#{record.id}?vsn=#{record.cover_hash}"
@@ -10,10 +10,6 @@ defmodule MusicLibraryWeb.CollectionLive.ShowTest do
|> Phoenix.HTML.safe_to_string()
end
defp human_datetime(dt) do
"#{dt.day}/#{dt.month}/#{dt.year}"
end
describe "Edit record from show page" do
test "can navigate to the record edit form", %{conn: conn} do
record = record_fixture()
@@ -37,9 +33,9 @@ defmodule MusicLibraryWeb.CollectionLive.ShowTest do
|> assert_has("p", text: record.release)
|> assert_has("p", text: Record.format_long_label(record.format))
|> assert_has("p", text: Record.type_long_label(record.type))
|> assert_has("dd", text: human_datetime(record.purchased_at))
|> assert_has("dd", text: human_datetime(record.inserted_at))
|> assert_has("dd", text: human_datetime(record.updated_at))
|> assert_has("dd", text: Record.format_as_date(record.purchased_at))
|> assert_has("dd", text: Record.format_as_date(record.inserted_at))
|> assert_has("dd", text: Record.format_as_date(record.updated_at))
|> unwrap(fn show_view ->
html = render(show_view)
assert html =~ ~p"/covers/#{record.id}?vsn=#{record.cover_hash}"