Explorar o código

Got Karma tests working. Had to update everything to the latest versions, so still need to fix things on the webpack side. Also had to fix places in code where the new typescript compiler was being more strict.

jalbr74 %!s(int64=7) %!d(string=hai) anos
pai
achega
edc812f3b9

+ 29 - 10
client/karma.conf.js

@@ -21,12 +21,19 @@
  */
 
 var webpack = require('webpack');
-var webpackConfig = require('./webpack.test.js');
+// var webpackConfig = require('./webpack.test.js');
 var path = require("path");
 var os = require('os');
 
 module.exports = function (config) {
     config.set({
+        karmaTypescriptConfig: {
+            // tsconfig: "tsconfig.json",
+            files: [
+                "src/temp.ts"
+            ]
+        },
+
         // base path that will be used to resolve all patterns (eg. files, exclude)
         basePath: '',
 
@@ -34,15 +41,16 @@ module.exports = function (config) {
         // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
         frameworks: [ 'jasmine' ],
 
+        // 'node_modules/angular/angular.js',
+        // 'node_modules/angular-mocks/angular-mocks.js',
+        // 'node_modules/angular-translate/dist/angular-translate.js',
+        // 'vendor/angular-ui-router.js',
+        // 'src/main.ts',
+
         // list of files / patterns to load in the browser
-        // Don't forget to add this to webpack.dev.js
         files: [
-            // 'node_modules/angular/angular.js',
-            // 'node_modules/angular-mocks/angular-mocks.js',
-            // 'node_modules/angular-translate/dist/angular-translate.js',
-            // 'vendor/angular-ui-router.js',
-            // 'src/main.ts',
-            'src/**/*.test.ts'
+            // 'src/**/*.test.ts'
+            'src/peoplesearch/orgchart.component.test.ts'
         ],
 
         exclude: [
@@ -60,8 +68,19 @@ module.exports = function (config) {
         },
 
         webpack: {
-            resolve: webpackConfig.resolve,
-            module: webpackConfig.module,
+            // resolve: webpackConfig.resolve,
+            // module: webpackConfig.module,
+            resolve: {
+                extensions: [".ts", ".js"]
+            },
+            module: {
+                rules: [
+                    {
+                        test: /\.ts$/,
+                        loader: 'ts-loader'
+                    }
+                ]
+            },
             plugins: [
                 new webpack.SourceMapDevToolPlugin({
                     filename: null, // if no value is provided the sourcemap is inlined

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 692 - 110
client/package-lock.json


+ 49 - 48
client/package.json

@@ -8,65 +8,66 @@
     "npm": ">=3.9"
   },
   "scripts": {
-    "build": "webpack --config=webpack.build.js --NODE_ENV=production",
+    "build": "webpack --config=webpack.build.js",
     "clean": "rimraf dist/",
-    "test": "karma start --NODE_ENV=test",
-    "test-single-run": "karma start --NODE_ENV=test --singleRun --no-auto-watch",
-    "start": "webpack-dev-server --config=webpack.dev.js --NODE_ENV=dev --colors",
-    "sync": "webpack --config=webpack.build.js --NODE_ENV=production --output-path=../server/target/pwm-1.8.0-SNAPSHOT/public/resources/webjars/pwm-client --watch --colors"
+    "test": "karma start",
+    "test-single-run": "karma start --singleRun --no-auto-watch",
+    "start": "webpack-dev-server --config=webpack.dev.js --colors",
+    "sync": "webpack --config=webpack.build.js --output-path=../server/target/pwm-1.8.0-SNAPSHOT/public/resources/webjars/pwm-client --watch --colors"
   },
   "author": "",
   "license": "ISC",
   "dependencies": {},
   "devDependencies": {
-    "@types/angular": "1.6.6",
-    "@types/angular-mocks": "1.5.5",
-    "@types/angular-translate": "2.4.33",
-    "@types/angular-ui-router": "1.1.34",
-    "@types/jasmine": "2.5.35",
-    "@types/node": "6.0.45",
-    "@uirouter/angularjs": "1.0.5",
-    "angular": "1.6.5",
-    "angular-mocks": "1.6.5",
-    "angular-translate": "2.15.2",
-    "autoprefixer": "6.5.3",
-    "copy-webpack-plugin": "3.0.1",
-    "css-loader": "0.25.0",
-    "file-loader": "0.9.0",
+    "@types/angular": "1.6.42",
+    "@types/angular-mocks": "1.5.11",
+    "@types/angular-translate": "2.15.1",
+    "@types/angular-ui-router": "1.1.40",
+    "@types/jasmine": "2.8.6",
+    "@types/node": "9.4.2",
+    "@uirouter/angularjs": "1.0.14",
+    "angular": "1.6.9",
+    "angular-mocks": "1.6.9",
+    "angular-translate": "2.17.0",
+    "autoprefixer": "7.2.5",
+    "copy-webpack-plugin": "4.4.1",
+    "css-loader": "0.28.9",
+    "file-loader": "1.1.6",
     "fontgen-loader": "0.2.1",
-    "html-loader": "0.4.4",
-    "html-webpack-plugin": "2.22.0",
+    "html-loader": "0.5.5",
+    "html-webpack-plugin": "2.30.1",
     "ignore-loader": "0.1.2",
-    "jasmine": "2.5.2",
-    "jshint": "2.9.3",
-    "jshint-loader": "0.8.3",
-    "json-loader": "0.5.4",
-    "karma": "0.13.19",
-    "karma-jasmine": "1.0.2",
-    "karma-jasmine-html-reporter": "0.2.2",
+    "jasmine": "3.0.0",
+    "jasmine-core": "^2.99.1",
+    "jshint": "2.9.5",
+    "jshint-loader": "0.8.4",
+    "json-loader": "0.5.7",
+    "karma": "2.0.0",
     "karma-chrome-launcher": "2.2.0",
-    "karma-phantomjs-launcher": "0.2.3",
-    "karma-sourcemap-loader": "0.3.6",
+    "karma-jasmine": "1.1.1",
+    "karma-jasmine-html-reporter": "0.2.2",
+    "karma-phantomjs-launcher": "1.0.4",
+    "karma-sourcemap-loader": "0.3.7",
     "karma-spec-reporter": "0.0.32",
-    "karma-webpack": "1.7.0",
-    "ngtemplate-loader": "1.3.1",
-    "node-sass": "3.10.1",
+    "karma-webpack": "2.0.9",
+    "ngtemplate-loader": "2.0.1",
+    "node-sass": "4.7.2",
     "phantomjs": "2.1.7",
-    "phantomjs-prebuilt": "2.1.13",
-    "postcss-loader": "1.0.0",
+    "phantomjs-prebuilt": "2.1.16",
+    "postcss-loader": "2.1.0",
     "raw-loader": "0.5.1",
-    "rimraf": "2.5.4",
-    "sass-loader": "4.0.2",
-    "string-replace-loader": "1.0.5",
-    "style-loader": "0.13.1",
-    "ts-loader": "0.9.1",
-    "tslint": "^3.15.1",
-    "tslint-loader": "2.1.5",
-    "typescript": "2.3.4",
-    "url-loader": "0.5.7",
-    "webpack": "1.13.2",
-    "webpack-dev-server": "1.16.2",
-    "webpack-merge": "0.14.1",
-    "write-file-webpack-plugin": "3.3.0"
+    "rimraf": "2.6.2",
+    "sass-loader": "6.0.6",
+    "string-replace-loader": "1.3.0",
+    "style-loader": "0.20.1",
+    "ts-loader": "3.5.0",
+    "tslint": "^5.9.1",
+    "tslint-loader": "3.5.3",
+    "typescript": "2.7.1",
+    "url-loader": "0.6.2",
+    "webpack": "3.10.0",
+    "webpack-dev-server": "2.11.1",
+    "webpack-merge": "4.1.1",
+    "write-file-webpack-plugin": "4.2.0"
   }
 }

+ 7 - 7
client/src/helpdesk/helpdesk-detail.component.ts

@@ -23,7 +23,7 @@
 
 import {Component} from '../component';
 import {IButtonInfo, IHelpDeskService, ISuccessResponse} from '../services/helpdesk.service';
-import {IScope, ui} from '@types/angular';
+import {IScope, ui} from 'angular';
 import {IQService, noop} from 'angular';
 import {IHelpDeskConfigService, PASSWORD_UI_MODES} from '../services/helpdesk-config.service';
 import DialogService from '../ux/ias-dialog.service';
@@ -129,7 +129,7 @@ export default class HelpDeskDetailComponent {
                     '$scope',
                     'HelpDeskService',
                     'translateFilter',
-                    function ($scope: IScope,
+                    function ($scope: IScope | any,
                               helpDeskService: IHelpDeskService,
                               translateFilter: (id: string) => string) {
                         $scope.status = STATUS_WAIT;
@@ -208,7 +208,7 @@ export default class HelpDeskDetailComponent {
                     '$scope',
                     'HelpDeskService',
                     'translateFilter',
-                    function ($scope: IScope,
+                    function ($scope: IScope | any,
                               helpDeskService: IHelpDeskService,
                               translateFilter: (id: string) => string) {
                         $scope.status = STATUS_CONFIRM;
@@ -241,7 +241,7 @@ export default class HelpDeskDetailComponent {
                     '$scope',
                     'HelpDeskService',
                     'translateFilter',
-                    function ($scope: IScope,
+                    function ($scope: IScope | any,
                               helpDeskService: IHelpDeskService,
                               translateFilter: (id: string) => string) {
                         $scope.status = STATUS_CONFIRM;
@@ -272,7 +272,7 @@ export default class HelpDeskDetailComponent {
                     '$scope',
                     'HelpDeskService',
                     'translateFilter',
-                    function ($scope: IScope,
+                    function ($scope: IScope | any,
                               helpDeskService: IHelpDeskService,
                               translateFilter: (id: string) => string) {
                         $scope.status = STATUS_CONFIRM;
@@ -310,7 +310,7 @@ export default class HelpDeskDetailComponent {
                     'HelpDeskService',
                     'IasDialogService',
                     'translateFilter',
-                    function ($scope: IScope,
+                    function ($scope: IScope | any,
                               helpDeskService: IHelpDeskService,
                               IasDialogService: DialogService,
                               translateFilter: (id: string) => string) {
@@ -384,7 +384,7 @@ export default class HelpDeskDetailComponent {
                     '$scope',
                     'HelpDeskService',
                     'translateFilter',
-                    function ($scope: IScope,
+                    function ($scope: IScope | any,
                               helpDeskService: IHelpDeskService,
                               translateFilter: (id: string) => string) {
                         $scope.status = STATUS_CONFIRM;

+ 0 - 1
client/src/peoplesearch/orgchart.component.test.ts

@@ -31,6 +31,5 @@ describe('testing OrgChartComponent', () => {
 
     it('should fail', () => {
         expect('foo').not.toEqual('bar');
-        expect('foo').not.toEqual('bar');
     });
 });

+ 1 - 1
client/src/peoplesearch/peoplesearch-base.component.ts

@@ -155,7 +155,7 @@ abstract class PeopleSearchBaseComponent {
 
     abstract fetchData(): void;
 
-    protected fetchSearchData(): IPromise<SearchResult> {
+    protected fetchSearchData(): IPromise<void | SearchResult> {
         this.abortPendingRequests();
         this.searchResult = null;
 

+ 7 - 7
client/src/peoplesearch/peoplesearch.module.ts

@@ -21,7 +21,7 @@
  */
 
 
-import { module } from 'angular';
+import {IComponentOptions, module} from 'angular';
 import { HighlightFilter } from './string.filters';
 import { FullNameFilter } from './person.filters';
 import OrgChartComponent from './orgchart.component';
@@ -44,12 +44,12 @@ module(moduleName, [
 ])
     .filter('fullName', FullNameFilter)
     .filter('highlight', HighlightFilter)
-    .component('orgChart', OrgChartComponent)
-    .component('orgChartSearch', OrgChartSearchComponent)
-    .component('personCard', PersonCardComponent)
-    .component('peopleSearchTable', PeopleSearchTableComponent)
-    .component('peopleSearchCards', PeopleSearchCardsComponent)
-    .component('personDetailsDialogComponent', PersonDetailsDialogComponent)
+    .component('orgChart', OrgChartComponent as IComponentOptions)
+    .component('orgChartSearch', OrgChartSearchComponent as IComponentOptions)
+    .component('personCard', PersonCardComponent as IComponentOptions)
+    .component('peopleSearchTable', PeopleSearchTableComponent as IComponentOptions)
+    .component('peopleSearchCards', PeopleSearchCardsComponent as IComponentOptions)
+    .component('personDetailsDialogComponent', PersonDetailsDialogComponent as IComponentOptions)
     .service('PromiseService', PromiseService)
     .service('LocalStorageService', LocalStorageService);
 

+ 4 - 2
client/src/ux/ias-dialog.service.ts

@@ -28,6 +28,7 @@ import {
     IControllerService,
     IDeferred,
     IDocumentService,
+    IHttpResponse,
     IHttpService,
     IPromise,
     IQService,
@@ -112,7 +113,8 @@ export default class DialogService {
         let self = this;
 
         // Initialize scope
-        let scope = options.scope ? options.scope.$new(false) : <IDialogScope>(this.$rootScope.$new(true));
+        let scope: IScope | any = options.scope ? options.scope.$new(false) : <IDialogScope>(this.$rootScope
+            .$new(true));
         scope.cancel = () => { self.cancel(); };
         scope.cancelText = options.cancel;
         scope.close = () => { self.close(scope.data.response); };
@@ -166,7 +168,7 @@ export default class DialogService {
 
             return this.$http
                 .get(options.templateUrl)
-                .then((response) => {
+                .then((response: IHttpResponse<any>) => {
                     self.$templateCache.put(options.templateUrl, response.data);
                     return response.data;
                 });

+ 9 - 9
client/src/ux/ux.module.ts

@@ -21,7 +21,7 @@
  */
 
 
-import { module } from 'angular';
+import {IComponentOptions, module} from 'angular';
 import AppBarComponent from './app-bar.component';
 import AutoCompleteComponent from './auto-complete.component';
 import ButtonComponent from './button.component';
@@ -40,14 +40,14 @@ import DialogService from './ias-dialog.service';
 var moduleName = 'peoplesearch.ux';
 
 module(moduleName, [ ])
-    .component('iasDialog', IasDialogComponent)
-    .component('mfAppBar', AppBarComponent)
-    .component('mfAutoComplete', AutoCompleteComponent)
-    .component('mfButton', ButtonComponent)
-    .component('mfDialog', DialogComponent)
-    .component('mfIconButton', IconButtonComponent)
-    .component('mfIcon', IconComponent)
-    .component('mfSearchBar', SearchBarComponent)
+    .component('iasDialog', IasDialogComponent as IComponentOptions)
+    .component('mfAppBar', AppBarComponent as IComponentOptions)
+    .component('mfAutoComplete', AutoCompleteComponent as IComponentOptions)
+    .component('mfButton', ButtonComponent as IComponentOptions)
+    .component('mfDialog', DialogComponent as IComponentOptions)
+    .component('mfIconButton', IconButtonComponent as IComponentOptions)
+    .component('mfIcon', IconComponent as IComponentOptions)
+    .component('mfSearchBar', SearchBarComponent as IComponentOptions)
     .directive('mfTable', TableDirectiveFactory)
     .directive('mfTableColumn', TableColumnDirectiveFactory)
     .directive('mfTabset', TabsetDirective)

+ 19 - 18
client/tsconfig.json

@@ -1,21 +1,22 @@
 {
-  "compilerOptions": {
-    "baseUrl": "./",
-    "experimentalDecorators": true,
-    "lib": ["es2015", "es2015.iterable", "dom"],
-    "module": "commonjs",
-    "removeComments": true,
-    "sourceMap": true,
-    "target": "es5",
-    "types": [
-      "node"
+    "compilerOptions": {
+        "baseUrl": "./",
+        "experimentalDecorators": true,
+        "lib": [
+            "es2015",
+            "es2015.iterable",
+            "dom"
+        ],
+        "module": "commonjs",
+        "removeComments": true,
+        "sourceMap": true,
+        "target": "es5"
+    },
+    "files": [
+        "src/main.ts"
+    ],
+    "exclude": [
+        "dist",
+        "node_modules"
     ]
-  },
-  "files": [
-    "src/main.ts"
-  ],
-  "exclude": [
-    "dist",
-    "node_modules"
-  ]
 }

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio