add song reporting

This commit is contained in:
2026-03-15 22:23:11 +01:00
parent e4f829d0c8
commit 67884e4638
24 changed files with 644 additions and 36 deletions

View File

@@ -1,24 +1,73 @@
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {BehaviorSubject, of} from 'rxjs';
import {ListComponent} from './list.component';
import {ShowService} from '../services/show.service';
import {UserService} from '../../../services/user/user.service';
import {FilterStoreService} from '../../../services/filter-store.service';
describe('ListComponent', () => {
let component: ListComponent;
let fixture: ComponentFixture<ListComponent>;
let shows$: BehaviorSubject<unknown[]>;
let user$: BehaviorSubject<unknown>;
beforeEach(waitForAsync(() => {
void TestBed.configureTestingModule({
beforeEach(async () => {
shows$ = new BehaviorSubject<unknown[]>([]);
user$ = new BehaviorSubject<unknown>({id: 'user-1'});
await TestBed.configureTestingModule({
imports: [ListComponent],
providers: [
{
provide: ShowService,
useValue: {
list$: () => shows$.asObservable(),
listPublicSince$: () => of([]),
},
},
{
provide: UserService,
useValue: {
user$: user$.asObservable(),
},
},
FilterStoreService,
],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
void expect(component).toBeTruthy();
});
it('should list own drafts and pending published shows in my shows', done => {
shows$.next([
{id: 'draft-own', owner: 'user-1', published: false, reportedType: null},
{id: 'pending-own', owner: 'user-1', published: true, reportedType: 'pending'},
{id: 'reported-own', owner: 'user-1', published: true, reportedType: 'reported'},
{id: 'draft-other', owner: 'user-2', published: false, reportedType: null},
] as never);
component.privateShows$.subscribe(shows => {
expect(shows.map(show => show.id)).toEqual(['draft-own', 'pending-own']);
done();
});
});
it('should ignore show filters for my shows', done => {
const filterStore = TestBed.inject(FilterStoreService);
filterStore.updateShowFilter({time: 0, showType: 'service-worship'});
shows$.next([
{id: 'older-draft', owner: 'user-1', published: false, reportedType: null, showType: 'misc-private'},
{id: 'pending-own', owner: 'user-1', published: true, reportedType: 'pending', showType: 'home-group'},
] as never);
component.privateShows$.subscribe(shows => {
expect(shows.map(show => show.id)).toEqual(['older-draft', 'pending-own']);
done();
});
});
});