mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
fixed test files + added clean for environment.ts + fixed set-env script bug
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
"pretest:headless": "yarn run config:test",
|
||||
"prebuild:prod": "yarn run config:prod",
|
||||
"pree2e": "yarn run config:prod",
|
||||
"pree2e:travis": "yarn run config:travis",
|
||||
"start": "yarn run start:prod",
|
||||
"serve": "ng serve",
|
||||
"start:dev": "npm-run-all --parallel config:dev:watch serve",
|
||||
@@ -26,10 +25,9 @@
|
||||
"test:headless": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng test --watch=false --sourceMap=true --browsers=ChromeHeadless --code-coverage",
|
||||
"lint": "ng lint",
|
||||
"e2e": "ng e2e",
|
||||
"e2e:travis": "ng e2e",
|
||||
"compile:server": "webpack --config webpack.server.config.js --progress --colors",
|
||||
"serve:ssr": "node dist/server",
|
||||
"ci": "ng lint && yarn run build:prod && yarn test:headless && yarn run e2e:travis",
|
||||
"ci": "ng lint && yarn run build:prod && yarn test:headless && yarn run e2e",
|
||||
"clean:coverage": "rimraf coverage",
|
||||
"clean:dist": "rimraf dist",
|
||||
"clean:doc": "rimraf doc",
|
||||
@@ -38,7 +36,8 @@
|
||||
"clean:bld": "rimraf build",
|
||||
"clean:node": "rimraf node_modules",
|
||||
"clean:prod": "yarn run clean:coverage && yarn run clean:doc && yarn run clean:dist && yarn run clean:log && yarn run clean:json && yarn run clean:bld",
|
||||
"clean": "yarn run clean:prod && yarn run clean:node"
|
||||
"clean": "yarn run clean:prod && yarn run clean:node && yarn run clean:env",
|
||||
"clean:env": "rimraf src/environments/environment.ts"
|
||||
},
|
||||
"browser": {
|
||||
"fs": false,
|
||||
|
@@ -45,8 +45,11 @@ const processEnv = {
|
||||
} as GlobalConfig;
|
||||
|
||||
import(environmentFilePath)
|
||||
.then((file) => generateEnvironmentFile(merge.all(commonEnv, file.environment, processEnv)))
|
||||
.catch(() => generateEnvironmentFile(merge(commonEnv, processEnv)));
|
||||
.then((file) => generateEnvironmentFile(merge.all([commonEnv, file.environment, processEnv])))
|
||||
.catch(() => {
|
||||
console.log(colors.orange.bold(`No specific environment file found for ` + environment));
|
||||
generateEnvironmentFile(merge(commonEnv, processEnv))
|
||||
});
|
||||
|
||||
function generateEnvironmentFile(file: GlobalConfig): void {
|
||||
file.production = production;
|
||||
|
@@ -7,7 +7,7 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { createSuccessfulRemoteDataObject } from '../../../shared/testing/utils';
|
||||
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
|
||||
|
||||
describe('ItemVersionHistoryComponent', () => {
|
||||
let component: ItemVersionHistoryComponent;
|
||||
|
@@ -31,9 +31,8 @@ import { authMethodsMock, AuthServiceStub } from '../../shared/testing/auth-serv
|
||||
import { AuthService } from './auth.service';
|
||||
import { AuthState } from './auth.reducer';
|
||||
|
||||
import { EPersonMock } from '../../shared/testing/eperson.mock';
|
||||
import { EPersonMock } from '../../shared/testing/eperson-mock';
|
||||
import { AuthStatus } from './models/auth-status.model';
|
||||
import { EPersonMock } from '../../shared/testing/eperson.mock';
|
||||
|
||||
describe('AuthEffects', () => {
|
||||
let authEffects: AuthEffects;
|
||||
|
@@ -26,7 +26,7 @@ import {
|
||||
SetRedirectUrlAction
|
||||
} from './auth.actions';
|
||||
import { AuthTokenInfo } from './models/auth-token-info.model';
|
||||
import { EPersonMock } from '../../shared/testing/eperson-mock';
|
||||
import { EPersonMock } from '../../shared/testing/eperson.mock';
|
||||
import { AuthStatus } from './models/auth-status.model';
|
||||
import { AuthMethod } from './models/auth.method';
|
||||
import { AuthMethodType } from './models/auth.method-type';
|
||||
|
@@ -2,9 +2,9 @@ import { RequestService } from './request.service';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { VersionHistoryDataService } from './version-history-data.service';
|
||||
import { NotificationsServiceStub } from '../../shared/testing/notifications-service-stub';
|
||||
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub';
|
||||
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
|
||||
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
|
||||
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub';
|
||||
import { getMockRequestService } from '../../shared/mocks/request.service.mock';
|
||||
import { GetRequest } from './request.models';
|
||||
|
||||
const url = 'fake-url';
|
||||
|
@@ -7,9 +7,10 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { Version } from '../../../core/shared/version.model';
|
||||
import { VersionHistory } from '../../../core/shared/version-history.model';
|
||||
import { createPaginatedList, createSuccessfulRemoteDataObject$ } from '../../testing/utils';
|
||||
import { VersionHistoryDataService } from '../../../core/data/version-history-data.service';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils';
|
||||
import { createPaginatedList } from '../../testing/utils.test';
|
||||
|
||||
describe('ItemVersionsComponent', () => {
|
||||
let component: ItemVersionsComponent;
|
||||
|
@@ -5,10 +5,11 @@ import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { VersionHistory } from '../../../../core/shared/version-history.model';
|
||||
import { Version } from '../../../../core/shared/version.model';
|
||||
import { createPaginatedList, createSuccessfulRemoteDataObject$ } from '../../../testing/utils';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { VersionHistoryDataService } from '../../../../core/data/version-history-data.service';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../remote-data.utils';
|
||||
import { createPaginatedList } from '../../../testing/utils.test';
|
||||
|
||||
describe('ItemVersionsNoticeComponent', () => {
|
||||
let component: ItemVersionsNoticeComponent;
|
||||
|
@@ -8,10 +8,10 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { LogInContainerComponent } from './log-in-container.component';
|
||||
import { authReducer } from '../../../core/auth/auth.reducer';
|
||||
import { SharedModule } from '../../shared.module';
|
||||
import { createTestComponent } from '../../testing/utils';
|
||||
import { AuthService } from '../../../core/auth/auth.service';
|
||||
import { AuthMethod } from '../../../core/auth/models/auth.method';
|
||||
import { AuthServiceStub } from '../../testing/auth-service-stub';
|
||||
import { AuthServiceStub } from '../../testing/auth-service.stub';
|
||||
import { createTestComponent } from '../../testing/utils.test';
|
||||
|
||||
describe('LogInContainerComponent', () => {
|
||||
|
||||
|
@@ -5,14 +5,19 @@ import { Store, StoreModule } from '@ngrx/store';
|
||||
|
||||
import { LogInComponent } from './log-in.component';
|
||||
import { authReducer } from '../../core/auth/auth.reducer';
|
||||
import { EPersonMock } from '../testing/eperson.mock';
|
||||
import { EPerson } from '../../core/eperson/models/eperson.model';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { LogInComponent } from './log-in.component';
|
||||
import { AuthService } from '../../core/auth/auth.service';
|
||||
import { authMethodsMock, AuthServiceStub } from '../testing/auth-service.stub';
|
||||
import { AppState, storeModuleConfig } from '../../app.reducer';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { SharedModule } from '../shared.module';
|
||||
import { NativeWindowMockFactory } from '../mocks/mock-native-window-ref';
|
||||
import { ActivatedRouteStub } from '../testing/active-router.stub';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { RouterStub } from '../testing/router.stub';
|
||||
import { NativeWindowService } from '../../core/services/window.service';
|
||||
import { provideMockStore } from '@ngrx/store/testing';
|
||||
import { createTestComponent } from '../testing/utils.test';
|
||||
|
||||
describe('LogInComponent', () => {
|
||||
|
||||
|
@@ -8,10 +8,10 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { LogInPasswordComponent } from './log-in-password.component';
|
||||
import { EPerson } from '../../../../core/eperson/models/eperson.model';
|
||||
import { EPersonMock } from '../../../testing/eperson-mock';
|
||||
import { EPersonMock } from '../../../testing/eperson.mock';
|
||||
import { authReducer } from '../../../../core/auth/auth.reducer';
|
||||
import { AuthService } from '../../../../core/auth/auth.service';
|
||||
import { AuthServiceStub } from '../../../testing/auth-service-stub';
|
||||
import { AuthServiceStub } from '../../../testing/auth-service.stub';
|
||||
import { AppState } from '../../../../app.reducer';
|
||||
import { AuthMethod } from '../../../../core/auth/models/auth.method';
|
||||
import { AuthMethodType } from '../../../../core/auth/models/auth.method-type';
|
||||
|
@@ -5,17 +5,17 @@ import { Store, StoreModule } from '@ngrx/store';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { EPerson } from '../../../../core/eperson/models/eperson.model';
|
||||
import { EPersonMock } from '../../../testing/eperson-mock';
|
||||
import { EPersonMock } from '../../../testing/eperson.mock';
|
||||
import { authReducer } from '../../../../core/auth/auth.reducer';
|
||||
import { AuthService } from '../../../../core/auth/auth.service';
|
||||
import { AuthServiceStub } from '../../../testing/auth-service-stub';
|
||||
import { AuthServiceStub } from '../../../testing/auth-service.stub';
|
||||
import { AppState } from '../../../../app.reducer';
|
||||
import { AuthMethod } from '../../../../core/auth/models/auth.method';
|
||||
import { AuthMethodType } from '../../../../core/auth/models/auth.method-type';
|
||||
import { LogInShibbolethComponent } from './log-in-shibboleth.component';
|
||||
import { NativeWindowService } from '../../../../core/services/window.service';
|
||||
import { RouterStub } from '../../../testing/router-stub';
|
||||
import { ActivatedRouteStub } from '../../../testing/active-router-stub';
|
||||
import { RouterStub } from '../../../testing/router.stub';
|
||||
import { ActivatedRouteStub } from '../../../testing/active-router.stub';
|
||||
import { NativeWindowMockFactory } from '../../../mocks/mock-native-window-ref';
|
||||
|
||||
describe('LogInShibbolethComponent', () => {
|
||||
@@ -26,17 +26,21 @@ describe('LogInShibbolethComponent', () => {
|
||||
let user: EPerson;
|
||||
let componentAsAny: any;
|
||||
let setHrefSpy;
|
||||
const shibbolethBaseUrl = 'dspace-rest.test/shibboleth?redirectUrl=';
|
||||
const location = shibbolethBaseUrl + 'http://dspace-angular.test/home';
|
||||
let shibbolethBaseUrl;
|
||||
let location;
|
||||
|
||||
const authState = {
|
||||
let authState;
|
||||
|
||||
beforeEach(() => {
|
||||
user = EPersonMock;
|
||||
shibbolethBaseUrl = 'dspace-rest.test/shibboleth?redirectUrl=';
|
||||
location = shibbolethBaseUrl + 'http://dspace-angular.test/home';
|
||||
|
||||
authState = {
|
||||
authenticated: false,
|
||||
loaded: false,
|
||||
loading: false,
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
user = EPersonMock;
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
|
@@ -4,6 +4,7 @@ import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { LinkMenuItemComponent } from './link-menu-item.component';
|
||||
import { RouterLinkDirectiveStub } from '../../testing/router-link-directive.stub';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
|
||||
describe('LinkMenuItemComponent', () => {
|
||||
let component: LinkMenuItemComponent;
|
||||
@@ -11,12 +12,10 @@ describe('LinkMenuItemComponent', () => {
|
||||
let debugElement: DebugElement;
|
||||
let text;
|
||||
let link;
|
||||
let nameSpace;
|
||||
|
||||
function init() {
|
||||
text = 'HELLO';
|
||||
link = 'http://google.com';
|
||||
nameSpace = '/angular-dspace';
|
||||
}
|
||||
beforeEach(async(() => {
|
||||
init();
|
||||
@@ -52,6 +51,6 @@ describe('LinkMenuItemComponent', () => {
|
||||
const routerLinkQuery = linkDes.map((de) => de.injector.get(RouterLinkDirectiveStub));
|
||||
|
||||
expect(routerLinkQuery.length).toBe(1);
|
||||
expect(routerLinkQuery[0].routerLink).toBe(nameSpace + link);
|
||||
expect(routerLinkQuery[0].routerLink).toBe(environment.ui.nameSpace + link);
|
||||
});
|
||||
});
|
||||
|
@@ -17,7 +17,7 @@ export interface GlobalConfig extends Config {
|
||||
rest: ServerConfig;
|
||||
production: boolean;
|
||||
cache: CacheConfig;
|
||||
auth: AuthConfig;
|
||||
auth?: AuthConfig;
|
||||
form: FormConfig;
|
||||
notifications: INotificationBoardOptions;
|
||||
submission: SubmissionConfig;
|
||||
|
@@ -2,6 +2,11 @@
|
||||
"extends": [
|
||||
"tslint:recommended"
|
||||
],
|
||||
"linterOptions": {
|
||||
"exclude": [
|
||||
"src/environments/environment.ts"
|
||||
]
|
||||
},
|
||||
"rulesDirectory": [
|
||||
"node_modules/codelyzer"
|
||||
],
|
||||
|
Reference in New Issue
Block a user