mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
* remove useless module * upgrade to angular 8 * upgrade material to v8 * upgrade adf libs * migrate demo shell to v8 * upgrade to angular 9 * upgrade material to v9 * remove hammer * upgrade nx * upgrade datetime picker * upgrade flex layout * update core api * remove entry components * code fixes * upgrade testbed usage * code fixes * remove unnecessary core-js from tests * upgrade CLI * ts config fixes * fix builds * fix testing config * compile fixes * fix demo shell dev setup * fix core tests * fix card view import * upgrade nx * disable smart builds for now * remove fdescribe * restore smart builds * fix issues * unify tsconfigs and fix newly found issues * fix configuration and cleanup package scripts * improved production build from the same config * use ADF libs directly instead of node_modules * disable smart build * single app configuration (angular) * fix core build * fix build scripts * lint fixes * fix linting setup * fix linting rules * various fixes * disable affected libs for unit tests * cleanup insights package.json * simplify smart-build * fix content tests * fix tests * test fixes * fix tests * fix test * fix tests * disable AppExtensionsModule (monaco example) * remove monaco extension module * upgrade bundle check rules * fix insights tests and karma config * fix protractor config * e2e workaround * upgrade puppeteer and split linting and build * reusable resources config * update protractor config * fix after rebase * fix protractor config * fix e2e tsconfig * update e2e setup * Save demoshell artifact on S3 and remove travis cache * Push the libs on S3 and fetch before releasing it * Add deps * Add dependencies among libs and run only affected unit test and build * fix the travis stage name * fix after renaming dev to demoshell * force the order of the projects * remove unused dependencies * fix content e2e script * exit codes fix * add extra exit codes to core e2e * postinstall hook and package cleanup * cleanup packages * remove deprecated code and dependency on router * improve bundle analyzer script * minor code fixes * update spec * fix code after rebase * upgrade protractor after rebase * fix e2e mapping lib * Update tsconfig.e2e.json * update e2e tsconfig * fix angular config * fix protractor runs * cache dist folder for libs * update material selectors for dropdowns * selector fixes * remove duplicated e2e that have unit tests already * fix login selector * fix e2e * fix test * fix import issues * fix selector * cleanup old monaco extension files * cleanup demo shell login * add protractor max retries * disable customisations of protractor * fix login validation * fix after rebase * fix after rebase, disable latest versions of libs * Hide the report tab and rollback the localstorage * rename protractor config back to js * restore lint as part of build * cleanup code * do not copy anything to node_modules on dist test * fix unit tests * config fixes * fix code * fix code after rebase * fix tests * remove existing words from spellcheck * remove useless directive decorators * update package.json after rebase * add js-api back * code fixes * add missing export * update configs * fix code * try fix the sso login test * fix * remove puppeteer unit * fix e2e script * fix * make provider easy * fix routes module before upgrade * fix unit tests * upgrade angular cli * upgrade to angular 10 Co-authored-by: maurizio vitale <maurizio.vitale@alfresco.com> Co-authored-by: Eugenio Romano <eugenio.romano@alfresco.com> Co-authored-by: Eugenio Romano <eromano@users.noreply.github.com>
389 lines
13 KiB
TypeScript
389 lines
13 KiB
TypeScript
/*!
|
|
* @license
|
|
* Copyright 2019 Alfresco Software, Ltd.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
import { HostSettingsComponent } from './host-settings.component';
|
|
import { setupTestBed } from '../testing/setup-test-bed';
|
|
import { CoreTestingModule } from '../testing/core.testing.module';
|
|
import { AppConfigService } from '../app-config/app-config.service';
|
|
import { TranslateModule } from '@ngx-translate/core';
|
|
|
|
describe('HostSettingsComponent', () => {
|
|
|
|
let fixture: ComponentFixture<HostSettingsComponent>;
|
|
let component: HostSettingsComponent;
|
|
let appConfigService: AppConfigService;
|
|
let element: any;
|
|
|
|
setupTestBed({
|
|
imports: [
|
|
TranslateModule.forRoot(),
|
|
CoreTestingModule
|
|
]
|
|
});
|
|
|
|
beforeEach(() => {
|
|
fixture = TestBed.createComponent(HostSettingsComponent);
|
|
component = fixture.componentInstance;
|
|
appConfigService = TestBed.inject(AppConfigService);
|
|
element = fixture.nativeElement;
|
|
});
|
|
|
|
afterEach(() => {
|
|
fixture.destroy();
|
|
});
|
|
|
|
describe('Providers', () => {
|
|
|
|
beforeEach(() => {
|
|
appConfigService.config.providers = 'ECM';
|
|
appConfigService.config.authType = 'OAUTH';
|
|
appConfigService.config.oauth2 = {
|
|
host: 'http://localhost:6543',
|
|
redirectUri: '/',
|
|
silentLogin: false,
|
|
implicitFlow: true,
|
|
clientId: 'activiti',
|
|
scope: 'openid',
|
|
secret: ''
|
|
};
|
|
|
|
appConfigService.load();
|
|
fixture.detectChanges();
|
|
});
|
|
|
|
afterEach(() => {
|
|
fixture.destroy();
|
|
});
|
|
|
|
it('should not show the providers select box if you have any provider', (done) => {
|
|
component.providers = ['BPM'];
|
|
component.ngOnInit();
|
|
|
|
fixture.detectChanges();
|
|
|
|
fixture.whenStable().then(() => {
|
|
expect(element.querySelector('#adf-provider-selector')).toBeNull();
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('should show the providers select box if you have any provider', (done) => {
|
|
component.providers = ['BPM', 'ECM'];
|
|
component.ngOnInit();
|
|
|
|
fixture.detectChanges();
|
|
|
|
fixture.whenStable().then(() => {
|
|
expect(element.querySelector('#adf-provider-selector')).not.toBeNull();
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('BPM ', () => {
|
|
|
|
let ecmUrlInput;
|
|
let bpmUrlInput;
|
|
|
|
beforeEach(() => {
|
|
appConfigService.config.providers = 'BPM';
|
|
appConfigService.config.authType = 'BASIC';
|
|
appConfigService.load();
|
|
fixture.detectChanges();
|
|
bpmUrlInput = element.querySelector('#bpmHost');
|
|
ecmUrlInput = element.querySelector('#ecmHost');
|
|
});
|
|
|
|
afterEach(() => {
|
|
fixture.destroy();
|
|
});
|
|
|
|
it('should have a valid form when the url inserted is correct', (done) => {
|
|
const url = 'http://localhost:9999/bpm';
|
|
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('VALID');
|
|
done();
|
|
});
|
|
|
|
component.form.valueChanges.subscribe((values) => {
|
|
expect(values.bpmHost).toEqual(url);
|
|
});
|
|
|
|
bpmUrlInput.value = url;
|
|
bpmUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
|
|
it('should have an invalid form when the inserted url is wrong', (done) => {
|
|
const url = 'wrong';
|
|
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('INVALID');
|
|
expect(component.bpmHost.hasError('pattern')).toBeTruthy();
|
|
done();
|
|
});
|
|
|
|
bpmUrlInput.value = url;
|
|
bpmUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
|
|
it('should not render the ECM url config if setting provider is BPM', () => {
|
|
expect(ecmUrlInput).toEqual(null);
|
|
expect(bpmUrlInput).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('ECM ', () => {
|
|
|
|
let ecmUrlInput;
|
|
let bpmUrlInput;
|
|
|
|
beforeEach(() => {
|
|
appConfigService.config.providers = 'ECM';
|
|
appConfigService.config.authType = 'BASIC';
|
|
appConfigService.load();
|
|
fixture.detectChanges();
|
|
bpmUrlInput = element.querySelector('#bpmHost');
|
|
ecmUrlInput = element.querySelector('#ecmHost');
|
|
});
|
|
|
|
afterEach(() => {
|
|
fixture.destroy();
|
|
});
|
|
|
|
it('should have a valid form when the url inserted is correct', (done) => {
|
|
const url = 'http://localhost:9999/ecm';
|
|
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('VALID');
|
|
done();
|
|
});
|
|
|
|
ecmUrlInput.value = url;
|
|
ecmUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
|
|
it('should have an invalid form when the url inserted is wrong', (done) => {
|
|
const url = 'wrong';
|
|
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('INVALID');
|
|
expect(component.ecmHost.hasError('pattern')).toBeTruthy();
|
|
done();
|
|
});
|
|
|
|
ecmUrlInput.value = url;
|
|
ecmUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
|
|
it('should not render the BPM url config if setting provider is BPM', () => {
|
|
expect(bpmUrlInput).toEqual(null);
|
|
expect(ecmUrlInput).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('ALL ', () => {
|
|
|
|
let ecmUrlInput;
|
|
let bpmUrlInput;
|
|
|
|
beforeEach(() => {
|
|
appConfigService.config.providers = 'ALL';
|
|
appConfigService.config.authType = 'BASIC';
|
|
appConfigService.load();
|
|
fixture.detectChanges();
|
|
bpmUrlInput = element.querySelector('#bpmHost');
|
|
ecmUrlInput = element.querySelector('#ecmHost');
|
|
});
|
|
|
|
afterEach(() => {
|
|
fixture.destroy();
|
|
});
|
|
|
|
it('should have a valid form when the BPM and ECM url inserted are correct', (done) => {
|
|
const urlEcm = 'http://localhost:9999/ecm';
|
|
const urlBpm = 'http://localhost:9999/bpm';
|
|
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('VALID');
|
|
done();
|
|
});
|
|
|
|
ecmUrlInput.value = urlEcm;
|
|
bpmUrlInput.value = urlBpm;
|
|
ecmUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
|
|
it('should have an invalid form when one of the ECM url inserted is wrong', (done) => {
|
|
const url = 'wrong';
|
|
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('INVALID');
|
|
expect(component.ecmHost.hasError('pattern')).toBeTruthy();
|
|
done();
|
|
});
|
|
|
|
ecmUrlInput.value = url;
|
|
ecmUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
|
|
it('should have an invalid form when one of the BPM url inserted is wrong', (done) => {
|
|
const url = 'wrong';
|
|
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('INVALID');
|
|
expect(component.bpmHost.hasError('pattern')).toBeTruthy();
|
|
done();
|
|
});
|
|
|
|
bpmUrlInput.value = url;
|
|
bpmUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
|
|
it('should have an invalid form when both BPM and ECM url inserted are wrong', (done) => {
|
|
const url = 'wrong';
|
|
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('INVALID');
|
|
expect(component.bpmHost.hasError('pattern')).toBeTruthy();
|
|
done();
|
|
});
|
|
|
|
bpmUrlInput.value = url;
|
|
ecmUrlInput.value = url;
|
|
bpmUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
});
|
|
|
|
describe('OAUTH ', () => {
|
|
|
|
let bpmUrlInput;
|
|
let ecmUrlInput;
|
|
let identityUrlInput;
|
|
let oauthHostUrlInput;
|
|
let clientIdInput;
|
|
|
|
beforeEach(() => {
|
|
appConfigService.config.identityHost = 'http://localhost:123';
|
|
appConfigService.config.providers = 'ALL';
|
|
appConfigService.config.authType = 'OAUTH';
|
|
appConfigService.config.oauth2 = {
|
|
host: 'http://localhost:6543',
|
|
redirectUri: '/',
|
|
silentLogin: false,
|
|
implicitFlow: true,
|
|
clientId: 'activiti',
|
|
scope: 'openid',
|
|
secret: ''
|
|
};
|
|
appConfigService.load();
|
|
fixture.detectChanges();
|
|
bpmUrlInput = element.querySelector('#bpmHost');
|
|
ecmUrlInput = element.querySelector('#ecmHost');
|
|
identityUrlInput = element.querySelector('#identityHost');
|
|
oauthHostUrlInput = element.querySelector('#oauthHost');
|
|
clientIdInput = element.querySelector('#clientId');
|
|
});
|
|
|
|
afterEach(() => {
|
|
fixture.destroy();
|
|
});
|
|
|
|
it('should have a valid form when the urls are correct', (done) => {
|
|
const urlBpm = 'http://localhost:9999/bpm';
|
|
const urlEcm = 'http://localhost:9999/bpm';
|
|
const urlIdentity = 'http://localhost:9999/identity';
|
|
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('VALID');
|
|
done();
|
|
});
|
|
|
|
ecmUrlInput.value = urlEcm;
|
|
ecmUrlInput.dispatchEvent(new Event('input'));
|
|
|
|
bpmUrlInput.value = urlBpm;
|
|
bpmUrlInput.dispatchEvent(new Event('input'));
|
|
|
|
identityUrlInput.value = urlIdentity;
|
|
identityUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
|
|
it('should have an invalid form when the url inserted is wrong', (done) => {
|
|
const url = 'wrong';
|
|
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('INVALID');
|
|
expect(component.bpmHost.hasError('pattern')).toBeTruthy();
|
|
done();
|
|
});
|
|
|
|
bpmUrlInput.value = url;
|
|
bpmUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
|
|
it('should have a required identityUrl and invalid form when the identityUrl is missing', (done) => {
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('INVALID');
|
|
expect(component.identityHost.hasError('required')).toBeTruthy();
|
|
done();
|
|
});
|
|
|
|
identityUrlInput.value = '';
|
|
identityUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
|
|
it('should have an invalid form when the identity url inserted is wrong', (done) => {
|
|
const url = 'wrong';
|
|
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('INVALID');
|
|
expect(component.identityHost.hasError('pattern')).toBeTruthy();
|
|
done();
|
|
});
|
|
|
|
identityUrlInput.value = url;
|
|
identityUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
|
|
it('should have an invalid form when the host is wrong', (done) => {
|
|
const hostUrl = 'wrong';
|
|
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('INVALID');
|
|
expect(component.host.hasError('pattern')).toBeTruthy();
|
|
done();
|
|
});
|
|
|
|
oauthHostUrlInput.value = hostUrl;
|
|
oauthHostUrlInput.dispatchEvent(new Event('input'));
|
|
});
|
|
|
|
it('should have a required clientId an invalid form when the clientId is missing', (done) => {
|
|
component.form.statusChanges.subscribe((status: string) => {
|
|
expect(status).toEqual('INVALID');
|
|
expect(component.clientId.hasError('required')).toBeTruthy();
|
|
done();
|
|
});
|
|
|
|
clientIdInput.value = '';
|
|
clientIdInput.dispatchEvent(new Event('input'));
|
|
});
|
|
});
|
|
});
|