Refactor type/format labels to enable translations

This commit is contained in:
Claudio Ortolina
2025-01-29 11:04:19 +00:00
parent 96bd453900
commit 9e1f00c9a8
16 changed files with 193 additions and 132 deletions
@@ -3,6 +3,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
import MusicLibrary.RecordsFixtures
import MusicLibrary.ReleaseGroupsFixtures
import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1]
import Mox
alias MusicLibrary.Records.{Cover, Record}
alias MusicBrainz.APIBehaviourMock
@@ -51,8 +52,8 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|> assert_has("#records-#{record.id}")
|> assert_has("#records-#{record.id} h2", text: escape(record.title))
|> 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} p", text: format_label(record.format))
|> assert_has("#records-#{record.id} p", text: type_label(record.type))
|> assert_has("#records-#{record.id} span",
text: Record.format_as_date(record.purchased_at)
)
@@ -136,8 +137,8 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|> assert_has("#records-#{record.id}")
|> assert_has("#records-#{record.id} h2", text: escape(record.title))
|> 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} p", text: format_label(record.format))
|> assert_has("#records-#{record.id} p", text: type_label(record.type))
|> assert_has("#records-#{record.id} span",
text: Record.format_as_date(record.purchased_at)
)
@@ -178,8 +179,8 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|> assert_has("#records-#{record.id}")
|> assert_has("#records-#{record.id} h2", text: escape(record.title))
|> 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} p", text: format_label(record.format))
|> assert_has("#records-#{record.id} p", text: type_label(record.type))
|> assert_has("#records-#{record.id} span",
text: Record.format_as_date(record.purchased_at)
)
@@ -2,6 +2,7 @@ defmodule MusicLibraryWeb.CollectionLive.ShowTest do
use MusicLibraryWeb.ConnCase
import MusicLibrary.RecordsFixtures
import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1]
alias MusicLibrary.Records.Record
describe "Edit record from show page" do
@@ -26,8 +27,8 @@ defmodule MusicLibraryWeb.CollectionLive.ShowTest do
|> visit(~p"/collection/#{record.id}")
|> assert_has("h2", text: escape(record.title))
|> 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("p", text: format_label(record.format))
|> assert_has("p", text: type_label(record.type))
|> assert_has("dd", text: Record.format_as_date(record.purchased_at))
|> assert_has("dd", text: record.id)
|> assert_has("a", text: record.musicbrainz_id)