fix: add anime details link to continue watching card
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<a href="/anime/{{.AnimeID}}/watch{{if .CurrentEpisode.Valid}}?ep={{.CurrentEpisode.Int64}}{{end}}" class="block outline-none focus-visible:ring-1 focus-visible:ring-accent">
|
<a href="/anime/{{.AnimeID}}" class="block outline-none focus-visible:ring-1 focus-visible:ring-accent">
|
||||||
<h3 class="text-foreground truncate text-sm font-normal">
|
<h3 class="text-foreground truncate text-sm font-normal">
|
||||||
{{$title}}
|
{{$title}}
|
||||||
</h3>
|
</h3>
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package templates
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"mal/integrations/jikan"
|
"mal/integrations/jikan"
|
||||||
|
"mal/internal/db"
|
||||||
"mal/internal/domain"
|
"mal/internal/domain"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -254,3 +256,32 @@ func TestExecuteFragmentInvalidTemplate(t *testing.T) {
|
|||||||
t.Fatal("expected error for missing template")
|
t.Fatal("expected error for missing template")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestContinueWatchingTemplateIncludesAnimeDetailsLink(t *testing.T) {
|
||||||
|
r, err := ProvideRenderer()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err = r.ExecuteFragment(&buf, "index.gohtml", "continue_watching", []db.GetContinueWatchingEntriesRow{
|
||||||
|
{
|
||||||
|
AnimeID: 321,
|
||||||
|
TitleOriginal: "Original Title",
|
||||||
|
TitleEnglish: sql.NullString{String: "English Title", Valid: true},
|
||||||
|
ImageUrl: "https://example.com/poster.webp",
|
||||||
|
CurrentEpisode: sql.NullInt64{Int64: 7, Valid: true},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ExecuteFragment error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
body := buf.String()
|
||||||
|
if !strings.Contains(body, `href="/anime/321"`) {
|
||||||
|
t.Fatalf("continue watching card should include anime details link:\n%s", body)
|
||||||
|
}
|
||||||
|
if !strings.Contains(body, `href="/anime/321/watch?ep=7"`) {
|
||||||
|
t.Fatalf("continue watching card should keep watch link:\n%s", body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user