fix(web): show paste box to any connected user, not only on an empty feed
hasConnected was computed only inside the buckets.empty() branch (it was added for the empty-state copy), so a connected user WITH videos got hasConnected=false and never saw the paste box (#2-regression of the v0.12.0 paste UI). Compute it on every list render. Test: connected user with a non-empty feed sees the box. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -111,3 +112,23 @@ func TestPasteDedupNoDuplicate(t *testing.T) {
|
||||
userID).Scan(&count))
|
||||
require.Equal(t, 1, count, "pasting the same video twice must not duplicate the row")
|
||||
}
|
||||
|
||||
func TestListShowsPasteFormForConnectedUserWithVideos(t *testing.T) {
|
||||
app := newApp(t)
|
||||
resetDB(t, rawPool(t))
|
||||
app.Fetcher = &fakeFetcher{title: "x"}
|
||||
p := rawPool(t)
|
||||
|
||||
// Connected user with a non-empty feed (the case the bug missed: hasConnected
|
||||
// was only computed for an empty feed).
|
||||
_, err := p.Exec(context.Background(),
|
||||
`INSERT INTO video_connections (user_id, provider, token_ref, status)
|
||||
VALUES ($1, 'youtube', 'youtube/x/refresh_token', 'active')`, userID)
|
||||
require.NoError(t, err)
|
||||
seedVideo(t, p, "11111111-1111-1111-1111-111111111111", "A talk", "https://youtu.be/aaaaaaaaaaa", time.Now())
|
||||
|
||||
rec := do(t, app, httptest.NewRequest(http.MethodGet, "/", nil))
|
||||
require.Equal(t, http.StatusOK, rec.Code)
|
||||
require.Contains(t, body(t, rec), `action="/paste"`,
|
||||
"a connected user must see the paste box even when the feed has videos")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user