Il selettore lingua funziona sul web e sulle app native; su Android la preferenza è persistita e applicata al riavvio. Incluse anche eliminazione replay a scope e campi pagina pubblica squadra. Co-authored-by: Cursor <cursoragent@cursor.com>
85 lines
3.0 KiB
Ruby
85 lines
3.0 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe Teams::PublicDirectory do
|
|
let(:user) { User.create!(email: "dir-#{SecureRandom.hex(4)}@test.com", name: "Dir", password: "password123", role: "coach") }
|
|
let(:club) { Club.create!(name: "ASD Directory #{SecureRandom.hex(3)}", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff") }
|
|
let!(:team_live) { club.teams.create!(name: "Live Team", sport_key: "pallavolo") }
|
|
let!(:team_replay) { club.teams.create!(name: "Replay Team", sport_key: "basket") }
|
|
let!(:team_upcoming) { club.teams.create!(name: "Future Team", sport_key: "pallavolo") }
|
|
let!(:team_empty) { club.teams.create!(name: "Empty Team", sport_key: "pallavolo") }
|
|
|
|
before do
|
|
club.club_memberships.create!(user: user, role: "owner")
|
|
Billing::AssignPlan.call(club: club, plan_slug: "premium_full")
|
|
|
|
live_match = team_live.matches.create!(opponent_name: "Rival A", sport_key: "pallavolo", scheduled_at: 1.hour.from_now)
|
|
StreamSession.create!(
|
|
match: live_match, user: user, status: "live", platform: "matchlivetv",
|
|
privacy_status: "public", publish_token: "tok-live", started_at: Time.current
|
|
)
|
|
|
|
replay_match = team_replay.matches.create!(opponent_name: "Rival B", sport_key: "basket")
|
|
replay_session = StreamSession.create!(
|
|
match: replay_match, user: user, status: "ended", platform: "matchlivetv",
|
|
privacy_status: "public", publish_token: "tok-replay", started_at: 2.days.ago, ended_at: 1.day.ago
|
|
)
|
|
team_replay.recordings.create!(
|
|
stream_session: replay_session,
|
|
team: team_replay,
|
|
status: "ready",
|
|
privacy_status: "public",
|
|
storage_backend: "local",
|
|
storage_key: "teams/#{team_replay.id}/test.mp4",
|
|
recorded_at: 1.day.ago
|
|
)
|
|
|
|
team_upcoming.matches.create!(
|
|
opponent_name: "Rival C",
|
|
sport_key: "pallavolo",
|
|
scheduled_at: 2.days.from_now,
|
|
location: "VenueUnique42"
|
|
)
|
|
end
|
|
|
|
it "include solo squadre con presenza pubblica" do
|
|
ids = club_entries.map { |e| e.team.id }
|
|
|
|
expect(ids).to include(team_live.id, team_replay.id, team_upcoming.id)
|
|
expect(ids).not_to include(team_empty.id)
|
|
end
|
|
|
|
it "filtra per sport" do
|
|
ids = club_entries(sport: "basket").map { |e| e.team.id }
|
|
|
|
expect(ids).to contain_exactly(team_replay.id)
|
|
end
|
|
|
|
it "filtra per testo libero" do
|
|
ids = club_entries(q: "VenueUnique42").map { |e| e.team.id }
|
|
|
|
expect(ids).to contain_exactly(team_upcoming.id)
|
|
end
|
|
|
|
it "filtra per diretta in corso" do
|
|
ids = club_entries(live: true).map { |e| e.team.id }
|
|
|
|
expect(ids).to contain_exactly(team_live.id)
|
|
end
|
|
|
|
it "filtra per replay" do
|
|
ids = club_entries(replays: true).map { |e| e.team.id }
|
|
|
|
expect(ids).to contain_exactly(team_replay.id)
|
|
end
|
|
|
|
it "ordina le dirette per prime" do
|
|
slugs = club_entries.map { |e| e.team.slug }
|
|
|
|
expect(slugs.first).to eq(team_live.slug)
|
|
end
|
|
|
|
def club_entries(**params)
|
|
described_class.call(**params).select { |e| e.team.club_id == club.id }
|
|
end
|
|
end
|