[ACA-1991] correctly show error for moderated libraries (#823)

* correctly show error for moderated libraries

* fix unit test

* update e2e tests
This commit is contained in:
Denys Vuika 2018-11-23 15:24:33 +00:00 committed by GitHub
parent 13db4fb339
commit 0b0a2ad75c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 15 deletions

View File

@ -72,14 +72,14 @@ describe('Generic errors', () => {
await browser.get(URL); await browser.get(URL);
expect(await page.isGenericErrorDisplayed()).toBe(true, 'Generic error page not displayed'); expect(await page.isGenericErrorDisplayed()).toBe(true, 'Generic error page not displayed');
expect(await page.getGenericErrorTitle()).toContain(`This file or folder no longer exists or you don't have permission to view it.`); expect(await page.getGenericErrorTitle()).toContain(`This item no longer exists or you don't have permission to view it.`);
}); });
it('Invalid URL - [C217315]', async () => { it('Invalid URL - [C217315]', async () => {
await page.load('/invalid page'); await page.load('/invalid page');
expect(await page.isGenericErrorDisplayed()).toBe(true, 'Generic error page not displayed'); expect(await page.isGenericErrorDisplayed()).toBe(true, 'Generic error page not displayed');
expect(await page.getGenericErrorTitle()).toContain(`This file or folder no longer exists or you don't have permission to view it.`); expect(await page.getGenericErrorTitle()).toContain(`This item no longer exists or you don't have permission to view it.`);
}); });
@ -92,7 +92,7 @@ describe('Generic errors', () => {
await browser.get(URL); await browser.get(URL);
expect(await page.isGenericErrorDisplayed()).toBe(true, 'Generic error page not displayed'); expect(await page.isGenericErrorDisplayed()).toBe(true, 'Generic error page not displayed');
expect(await page.getGenericErrorTitle()).toContain(`This file or folder no longer exists or you don't have permission to view it.`); expect(await page.getGenericErrorTitle()).toContain(`This item no longer exists or you don't have permission to view it.`);
await loginPage.loginWith(username); await loginPage.loginWith(username);
}); });

View File

@ -41,10 +41,10 @@ import { ContentApiService } from '../../services/content-api.service';
import { ExperimentalDirective } from '../../directives/experimental.directive'; import { ExperimentalDirective } from '../../directives/experimental.directive';
import { ContentManagementService } from '../../services/content-management.service'; import { ContentManagementService } from '../../services/content-management.service';
import { EffectsModule } from '@ngrx/effects'; import { EffectsModule } from '@ngrx/effects';
import { LibraryEffects } from '../../store/effects'; import { LibraryEffects, RouterEffects } from '../../store/effects';
import { of } from 'rxjs'; import { of } from 'rxjs';
describe('LibrariesComponent', () => { describe('FavoriteLibrariesComponent', () => {
let fixture: ComponentFixture<FavoriteLibrariesComponent>; let fixture: ComponentFixture<FavoriteLibrariesComponent>;
let component: FavoriteLibrariesComponent; let component: FavoriteLibrariesComponent;
let alfrescoApi: AlfrescoApiService; let alfrescoApi: AlfrescoApiService;
@ -64,7 +64,10 @@ describe('LibrariesComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [AppTestingModule, EffectsModule.forRoot([LibraryEffects])], imports: [
AppTestingModule,
EffectsModule.forRoot([RouterEffects, LibraryEffects])
],
declarations: [ declarations: [
DataTableComponent, DataTableComponent,
TimeAgoPipe, TimeAgoPipe,

View File

@ -36,15 +36,16 @@ import {
UpdateLibraryAction, UpdateLibraryAction,
UPDATE_LIBRARY, UPDATE_LIBRARY,
LeaveLibraryAction, LeaveLibraryAction,
LEAVE_LIBRARY LEAVE_LIBRARY,
NavigateRouteAction
} from '../actions'; } from '../actions';
import { ContentManagementService } from '../../services/content-management.service'; import { ContentManagementService } from '../../services/content-management.service';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppStore } from '../states'; import { AppStore } from '../states';
import { appSelection } from '../selectors/app.selectors'; import { appSelection } from '../selectors/app.selectors';
import { ContentApiService } from '../../services/content-api.service'; import { ContentApiService } from '../../services/content-api.service';
import { Router } from '@angular/router';
import { SiteBody } from 'alfresco-js-api-node'; import { SiteBody } from 'alfresco-js-api-node';
import { SnackbarErrorAction } from '../actions/snackbar.actions';
@Injectable() @Injectable()
export class LibraryEffects { export class LibraryEffects {
@ -52,8 +53,7 @@ export class LibraryEffects {
private store: Store<AppStore>, private store: Store<AppStore>,
private actions$: Actions, private actions$: Actions,
private content: ContentManagementService, private content: ContentManagementService,
private contentApi: ContentApiService, private contentApi: ContentApiService
private router: Router
) {} ) {}
@Effect({ dispatch: false }) @Effect({ dispatch: false })
@ -109,10 +109,17 @@ export class LibraryEffects {
if (libraryId) { if (libraryId) {
this.contentApi this.contentApi
.getNode(libraryId, { relativePath: '/documentLibrary' }) .getNode(libraryId, { relativePath: '/documentLibrary' })
.pipe(map(node => node.entry)) .pipe(map(node => node.entry.id))
.subscribe(documentLibrary => { .subscribe(
this.router.navigate(['libraries', documentLibrary.id]); id => {
}); this.store.dispatch(new NavigateRouteAction(['libraries', id]));
},
() => {
this.store.dispatch(
new SnackbarErrorAction('APP.MESSAGES.ERRORS.MISSING_CONTENT')
);
}
);
} }
}) })
); );

View File

@ -250,7 +250,7 @@
}, },
"MESSAGES": { "MESSAGES": {
"ERRORS":{ "ERRORS":{
"MISSING_CONTENT": "This file or folder no longer exists or you don't have permission to view it.", "MISSING_CONTENT": "This item no longer exists or you don't have permission to view it.",
"GENERIC": "The action was unsuccessful. Try again or contact your IT Team.", "GENERIC": "The action was unsuccessful. Try again or contact your IT Team.",
"CONFLICT": "This name is already in use, try a different name.", "CONFLICT": "This name is already in use, try a different name.",
"NODE_MOVE": "Move unsuccessful, a file with the same name already exists.", "NODE_MOVE": "Move unsuccessful, a file with the same name already exists.",