mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACS-10196] other a11y all libraries error message not provided for name and library id fields (#4883)
* [ACS-10196] prevent instant error validation on create library dialog opening * [ACS-10196] add unit tests * [ACS-10196] review fix
This commit is contained in:
@@ -52,6 +52,7 @@ import { Node, NodeEntry, SiteBodyCreate, SiteEntry, UserInfo, VersionPaging } f
|
|||||||
import {
|
import {
|
||||||
DocumentListService,
|
DocumentListService,
|
||||||
FileModel,
|
FileModel,
|
||||||
|
LibraryDialogComponent,
|
||||||
NewVersionUploaderDataAction,
|
NewVersionUploaderDataAction,
|
||||||
NewVersionUploaderDialogData,
|
NewVersionUploaderDialogData,
|
||||||
NewVersionUploaderService,
|
NewVersionUploaderService,
|
||||||
@@ -62,6 +63,7 @@ import {
|
|||||||
import { FolderInformationComponent } from '../dialogs/folder-details/folder-information.component';
|
import { FolderInformationComponent } from '../dialogs/folder-details/folder-information.component';
|
||||||
import { provideEffects } from '@ngrx/effects';
|
import { provideEffects } from '@ngrx/effects';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { EventEmitter } from '@angular/core';
|
||||||
|
|
||||||
describe('ContentManagementService', () => {
|
describe('ContentManagementService', () => {
|
||||||
let dialog: MatDialog;
|
let dialog: MatDialog;
|
||||||
@@ -1867,6 +1869,60 @@ describe('ContentManagementService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('createLibrary', () => {
|
||||||
|
let dialogRefMock: jasmine.SpyObj<MatDialogRef<LibraryDialogComponent, SiteEntry | null>>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
dialogRefMock = jasmine.createSpyObj<MatDialogRef<LibraryDialogComponent, SiteEntry | null>>('MatDialogRef', ['afterClosed'], {
|
||||||
|
componentInstance: { error: new EventEmitter<string>() } as LibraryDialogComponent
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should open LibraryDialogComponent with autoFocus set to false', () => {
|
||||||
|
dialogRefMock.afterClosed.and.returnValue(of(null));
|
||||||
|
spyOn(dialog, 'open').and.returnValue(dialogRefMock);
|
||||||
|
contentManagementService.createLibrary();
|
||||||
|
|
||||||
|
expect(dialog.open).toHaveBeenCalledWith(LibraryDialogComponent, jasmine.objectContaining({ autoFocus: false }));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show library creation error notifications', () => {
|
||||||
|
dialogRefMock.afterClosed.and.returnValue(of(null));
|
||||||
|
spyOn(dialog, 'open').and.returnValue(dialogRefMock);
|
||||||
|
contentManagementService.createLibrary();
|
||||||
|
dialogRefMock.componentInstance.error.emit('Library creation error');
|
||||||
|
|
||||||
|
expect(showErrorSpy).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should emit guid, call libraryCreated hook and focus when site is created', (done) => {
|
||||||
|
const mockSiteEntry = new SiteEntry({ entry: { guid: 'guid', id: 'id', visibility: 'PUBLIC', title: 'title' } });
|
||||||
|
const button = document.createElement('button');
|
||||||
|
dialogRefMock.afterClosed.and.returnValue(of(mockSiteEntry));
|
||||||
|
spyOn(dialog, 'open').and.returnValue(dialogRefMock);
|
||||||
|
spyOn(appHookService.libraryCreated, 'next');
|
||||||
|
spyOn(document, 'querySelector').and.returnValue(button);
|
||||||
|
spyOn(button, 'focus');
|
||||||
|
|
||||||
|
contentManagementService.createLibrary().subscribe((guid) => {
|
||||||
|
expect(guid).toBe('guid');
|
||||||
|
expect(appHookService.libraryCreated.next).toHaveBeenCalledWith(mockSiteEntry);
|
||||||
|
expect(button.focus).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should emit null when node is missing guid', (done) => {
|
||||||
|
dialogRefMock.afterClosed.and.returnValue(of(null));
|
||||||
|
spyOn(dialog, 'open').and.returnValue(dialogRefMock);
|
||||||
|
|
||||||
|
contentManagementService.createLibrary().subscribe((guid) => {
|
||||||
|
expect(guid).toBeNull();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('folderInformationDialog', () => {
|
describe('folderInformationDialog', () => {
|
||||||
it('should open folder information dialog', () => {
|
it('should open folder information dialog', () => {
|
||||||
spyOn(dialog, 'open');
|
spyOn(dialog, 'open');
|
||||||
|
|||||||
@@ -281,6 +281,7 @@ export class ContentManagementService {
|
|||||||
|
|
||||||
createLibrary(): Observable<string> {
|
createLibrary(): Observable<string> {
|
||||||
const dialogInstance = this.dialogRef.open(LibraryDialogComponent, {
|
const dialogInstance = this.dialogRef.open(LibraryDialogComponent, {
|
||||||
|
autoFocus: false,
|
||||||
width: '400px'
|
width: '400px'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user