test: cover assignment failure recovery
This commit is contained in:
@@ -548,6 +548,71 @@ describe('Users directory', () => {
|
|||||||
expect(mutationStayedActive).toBe(true);
|
expect(mutationStayedActive).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('keeps directory controls blocked until a failed assignment mutation clears', () => {
|
||||||
|
isAdmin.set(true);
|
||||||
|
create();
|
||||||
|
http.expectOne(`${api}?page=1&limit=20`).flush(directoryPage([ada], 1, 60, true));
|
||||||
|
fixture.detectChanges();
|
||||||
|
button('Weiter').click();
|
||||||
|
http.expectOne(`${api}?page=2&limit=20`).flush(directoryPage([ada], 2, 60, true));
|
||||||
|
fixture.detectChanges();
|
||||||
|
button('Zuordnungen verwalten').click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
http.expectOne(`${adminApi}/players?assignment=all&page=1&limit=20`).flush(
|
||||||
|
playersPage({
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: 101,
|
||||||
|
firstName: 'Ada',
|
||||||
|
lastName: 'Lovelace',
|
||||||
|
active: true,
|
||||||
|
team: { id: 5, name: 'First Team', alias: 'first' },
|
||||||
|
currentUser: { id: 7, firstName: 'Ada', lastName: 'Lovelace', status: { id: 1, name: 'Active' } },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const panel = (fixture.nativeElement as HTMLElement).querySelector<HTMLElement>('app-player-assignments')!;
|
||||||
|
panel.querySelector<HTMLButtonElement>('.player-row button')!.click();
|
||||||
|
closeDialog.next(true);
|
||||||
|
fixture.detectChanges();
|
||||||
|
const unlink = http.expectOne(`${adminApi}/7/players/101`);
|
||||||
|
|
||||||
|
const directoryForm = (fixture.nativeElement as HTMLElement).querySelector<HTMLFormElement>('.directory-search')!;
|
||||||
|
const directorySearch = directoryForm.querySelector<HTMLInputElement>('input[type="search"]')!;
|
||||||
|
const directorySearchButton = directoryForm.querySelector<HTMLButtonElement>('button[type="submit"]')!;
|
||||||
|
const [previous, next] = [
|
||||||
|
...(fixture.nativeElement as HTMLElement).querySelectorAll<HTMLButtonElement>('nav.pagination button'),
|
||||||
|
];
|
||||||
|
expect(directorySearch.disabled).toBe(true);
|
||||||
|
expect(directorySearchButton.disabled).toBe(true);
|
||||||
|
expect(previous.disabled).toBe(true);
|
||||||
|
expect(next.disabled).toBe(true);
|
||||||
|
|
||||||
|
directorySearch.value = 'Other';
|
||||||
|
directorySearch.dispatchEvent(new Event('input'));
|
||||||
|
directoryForm.dispatchEvent(new Event('submit'));
|
||||||
|
previous.click();
|
||||||
|
next.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(http.match((request) => request.url.startsWith(api))).toHaveLength(0);
|
||||||
|
expect(unlink.cancelled).toBe(false);
|
||||||
|
|
||||||
|
unlink.flush({ message: 'Assignment failed' }, { status: 500, statusText: 'Server Error' });
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(text()).toContain('Zuordnung konnte nicht geändert werden. Assignment failed');
|
||||||
|
expect(directorySearch.disabled).toBe(false);
|
||||||
|
expect(directorySearchButton.disabled).toBe(false);
|
||||||
|
expect(previous.disabled).toBe(false);
|
||||||
|
expect(next.disabled).toBe(false);
|
||||||
|
expect(http.match((request) => request.url.startsWith(api))).toHaveLength(0);
|
||||||
|
|
||||||
|
directoryForm.dispatchEvent(new Event('submit'));
|
||||||
|
http.expectOne(`${api}?page=1&limit=20&search=Other`).flush(directoryPage([]));
|
||||||
|
});
|
||||||
|
|
||||||
it('shows a persistent explanation for disabled self-deactivation', () => {
|
it('shows a persistent explanation for disabled self-deactivation', () => {
|
||||||
isAdmin.set(true);
|
isAdmin.set(true);
|
||||||
currentUser.set({ id: 1, firstName: 'Grace', lastName: 'Admin', role: { id: 1 } });
|
currentUser.set({ id: 1, firstName: 'Grace', lastName: 'Admin', role: { id: 1 } });
|
||||||
|
|||||||
Reference in New Issue
Block a user