Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACA-2214] Sharing URL being constructed from ECM Host incorrectly #981

Merged
merged 6 commits into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-tomcat-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ npm run build.e2e -- --base-href ./
node -e "
const fs = require('fs');
const config = require('./dist/app/app.config.json');
config.baseShareUrl = 'http://localhost:4000/content-app';
config.baseShareUrl = 'http://localhost:4000/content-app/#/preview/s/';
fs.writeFileSync(
'./dist/app/app.config.json',
JSON.stringify(config, null, 2)
Expand Down
2 changes: 1 addition & 1 deletion src/app.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ecmHost": "{protocol}//{hostname}{:port}",
"aosHost": "{protocol}//{hostname}{:port}/alfresco/aos",
"baseShareUrl": null,
"baseShareUrl": "{protocol}//{hostname}{:port}/#/preview/s",
"providers": "ECM",
"authType": "BASIC",
"oauth2": {
Expand Down
46 changes: 34 additions & 12 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,31 @@
*/

import { AppComponent } from './app.component';
import { SetInitialStateAction } from './store/actions';

describe('AppComponent', () => {
let component;
const storeMock = <any>{
let component: AppComponent;

const storeMock: any = {
dispatch: jasmine.createSpy('dispatch')
};

const configMock: any = {
get: (key: string) => {
if (key === 'baseShareUrl') {
return 'http://localhost:4200//#/preview/s';
}
return null;
}
};

beforeAll(() => {
component = new AppComponent(
null,
null,
null,
storeMock,
null,
configMock,
null,
null,
null,
Expand All @@ -47,48 +58,59 @@ describe('AppComponent', () => {
);
});

describe('onFileUploadedError', () => {
afterEach(() => {
storeMock.dispatch['calls'].reset();
beforeEach(() => {
storeMock.dispatch = jasmine.createSpy('dispatch');
});

it('should setup baseShareUrl as per config', done => {
storeMock.dispatch.and.callFake((action: SetInitialStateAction) => {
expect(action.payload.sharedUrl).toBe(
'http://localhost:4200//#/preview/s/'
DenysVuika marked this conversation as resolved.
Show resolved Hide resolved
);
done();
});

component.loadAppSettings();
});

describe('onFileUploadedError', () => {
it('should dispatch 403 error message', () => {
component.onFileUploadedError({ error: { status: 403 } });
component.onFileUploadedError(<any>{ error: { status: 403 } });
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
'APP.MESSAGES.UPLOAD.ERROR.403'
);
});

it('should dispatch 404 error message', () => {
component.onFileUploadedError({ error: { status: 404 } });
component.onFileUploadedError(<any>{ error: { status: 404 } });
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
'APP.MESSAGES.UPLOAD.ERROR.404'
);
});

it('should dispatch 409 error message', () => {
component.onFileUploadedError({ error: { status: 409 } });
component.onFileUploadedError(<any>{ error: { status: 409 } });
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
'APP.MESSAGES.UPLOAD.ERROR.CONFLICT'
);
});

it('should dispatch 500 error message', () => {
component.onFileUploadedError({ error: { status: 500 } });
component.onFileUploadedError(<any>{ error: { status: 500 } });
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
'APP.MESSAGES.UPLOAD.ERROR.500'
);
});

it('should dispatch 504 error message', () => {
component.onFileUploadedError({ error: { status: 504 } });
component.onFileUploadedError(<any>{ error: { status: 504 } });
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
'APP.MESSAGES.UPLOAD.ERROR.504'
);
});

it('should dispatch generic error message', () => {
component.onFileUploadedError({ error: { status: 999 } });
component.onFileUploadedError(<any>{ error: { status: 999 } });
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
'APP.MESSAGES.UPLOAD.ERROR.GENERIC'
);
Expand Down
11 changes: 6 additions & 5 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,19 @@ export class AppComponent implements OnInit, OnDestroy {
});
}

private loadAppSettings() {
const baseShareUrl =
this.config.get<string>('baseShareUrl') ||
this.config.get<string>('ecmHost');
loadAppSettings() {
let baseShareUrl = this.config.get<string>('baseShareUrl');
if (!baseShareUrl.endsWith('/')) {
baseShareUrl += '/';
}

const state: AppState = {
...INITIAL_APP_STATE,
languagePicker: this.config.get<boolean>('languagePicker'),
appName: this.config.get<string>('application.name'),
headerColor: this.config.get<string>('headerColor'),
logoPath: this.config.get<string>('application.logo'),
sharedUrl: `${baseShareUrl}/#/preview/s/`
sharedUrl: baseShareUrl
};

this.store.dispatch(new SetInitialStateAction(state));
Expand Down