Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #205 from aeleftheriadis/feature/fix-e2e-tests
Browse files Browse the repository at this point in the history
Added Greek translation and fixed Frontend tests and configuration
  • Loading branch information
brunobritodev committed Dec 24, 2019
2 parents 8943c9c + 13a3ff4 commit 33236f8
Show file tree
Hide file tree
Showing 31 changed files with 862 additions and 315 deletions.
15 changes: 13 additions & 2 deletions src/Frontend/Jp.AdminUI/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/node_modules/protractor/bin/protractor",
"args":["${workspaceFolder}/e2e/protractor.conf.js"],
"preLaunchTask": "npm: e2e",
"outFiles": [
"${workspaceFolder}/dist/out-tsc/**/*.js"
]
},

{
"type": "chrome",
"request": "launch",
Expand All @@ -13,4 +24,4 @@
"webRoot": "${workspaceFolder}"
}
]
}
}
17 changes: 17 additions & 0 deletions src/Frontend/Jp.AdminUI/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "e2e",
"problemMatcher": []
},
{
"type": "npm",
"script": "start",
"problemMatcher": []
},
]
}
2 changes: 1 addition & 1 deletion src/Frontend/Jp.AdminUI/e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("jpproject WebApp", function () {

it("should display sign-in page", () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual("SIGN IN TO CONTINUE.");
expect(page.getButtonText()).toEqual("Login");
expect(page.getUrl()).toContain("/login");
});
});
4 changes: 2 additions & 2 deletions src/Frontend/Jp.AdminUI/e2e/app.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class JpProjectWebAppPage {
return browser.getCurrentUrl();
}

getParagraphText() {
return element(by.css("login-container text-center py-2")).getText();
getButtonText() {
return element(by.css(".login-container .card-body .mt-3")).getText();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
allScriptsTimeout: 11000,
allScriptsTimeout: 30000,
specs: [
'./e2e/**/*.e2e-spec.ts'
'./*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
Expand Down
2 changes: 2 additions & 0 deletions src/Frontend/Jp.AdminUI/e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"mapRoot": "../out-tsc/e2e",
"sourceMap": true,
"baseUrl": "./",
"module": "commonjs",
"target": "es5",
Expand Down
24 changes: 8 additions & 16 deletions src/Frontend/Jp.AdminUI/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,40 @@

module.exports = function (config) {
config.set({
basePath: './',
frameworks: ['jasmine', '@angular/cli'],
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
require('@angular-devkit/build-angular/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{ pattern: './src/test.ts', watched: false },
{ pattern: 'src/assets/**/*', watched: false, included: false, served: true },
{ pattern: 'src/assets/i18n/*.json', watched: false, included: false, served: true },
],
proxies: {
'/assets/': '/base/src/assets/'
},
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts','tsx']
angularCli: {
environment: 'dev'
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
captureTimeout: 60000, // it was already there
browserDisconnectTimeout : 60000,
browserDisconnectTolerance : 1,
browserNoActivityTimeout : 60000 //by default 10000
restartOnFileChange: true
});
};
6 changes: 3 additions & 3 deletions src/Frontend/Jp.AdminUI/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/Frontend/Jp.AdminUI/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"lintfix": "ng lint --fix=true",
"modernizr": "modernizr -c modernizr-config.json -d src/modernizr.js",
"postinstall": "node ./node_modules/protractor/bin/webdriver-manager update",
"e2e": "ng e2e",
Expand Down Expand Up @@ -116,6 +117,6 @@
"ts-node": "^8.3.0",
"tslint": "^5.14.0",
"typescript": ">=3.4.0 <3.5.0",
"webdriver-manager": "12.1.5"
"webdriver-manager": "12.1.7"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import { TestBed, async, inject } from "@angular/core/testing";
import { SettingsService } from "./settings.service";
import { HttpClientModule } from "@angular/common/http";
import { OAuthModule } from 'angular-oauth2-oidc';
import { VersionService } from '@shared/services/version.service';

describe("Service: Settings", () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule],
providers: [SettingsService]
imports: [HttpClientModule, OAuthModule.forRoot()],
providers: [SettingsService, VersionService]
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare var $: any;
@Injectable()
export class SettingsService {

private user: UserProfile;
public user: UserProfile;
public app: any;
public layout: any;
userProfileObservable: Observable<object>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class TranslatorService {
{ code: "ru", text: "Russian" },
{ code: "zh-cn", text: "Chinese Simplified" },
{ code: "zh-tw", text: "Chinese Traditional" },
{ code: "el", text: "Greek"}
];

constructor(public translate: TranslateService) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h4><button class="btn btn-info btn-xs" (click)="selectedScope = null"><i class=
'apiResource.scope.Emphasize' | translate }} <i class="fa fa-comment-dots"></i></label>
<div class="col-xl-8">
<label class="switch m-0">
<input type="checkbox" disabled="disabled" [(ngModel)]="selectedScope.Emphasize" />
<input type="checkbox" disabled="disabled" [(ngModel)]="selectedScope.emphasize" />
<span></span>
</label>
</div>
Expand Down Expand Up @@ -240,4 +240,4 @@ <h3>{{ resourceName }}</h3>
<div *ngFor="let error of errors; let i = index"><strong>{{i+1}}</strong> {{error}}</div>
</alert>
</div>
<toaster-container [toasterconfig]="toasterconfig"></toaster-container>
<toaster-container [toasterconfig]="toasterconfig"></toaster-container>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ProblemDetails } from '@shared/viewModel/default-response.model';
import { Scope } from '@shared/viewModel/scope.model';
import { StandardClaims } from '@shared/viewModel/standard-claims.model';
import { ToasterConfig, ToasterService } from 'angular2-toaster';
import { Observable } from 'rxjs';
import { throwError } from 'rxjs';
import { flatMap, map, tap } from 'rxjs/operators';

import { ApiResourceService } from '../api-resource.service';
Expand Down Expand Up @@ -50,7 +50,7 @@ export class ApiResourceScopesComponent implements OnInit {
.pipe(map(p => p["resource"]))
.pipe(flatMap(m => this.apiResourceService.getScopes(m.toString())))
.subscribe(result => this.apiScopes = result);

this.errors = [];
this.model = new Scope();
this.showButtonLoading = false;
Expand Down Expand Up @@ -104,7 +104,7 @@ export class ApiResourceScopesComponent implements OnInit {
this.errors = [];
this.errors.push("Unknown error while trying to save");
this.showButtonLoading = false;
return Observable.throw("Unknown error while trying to save");
return throwError("Unknown error while trying to save");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Observable, Subject } from 'rxjs';
encapsulation: ViewEncapsulation.None
})
export class EmailComponent implements OnInit {

public toasterconfig: ToasterConfig = new ToasterConfig({
positionClass: 'toast-top-right',
showCloseButton: true,
Expand All @@ -26,7 +26,7 @@ export class EmailComponent implements OnInit {
editorConfig: AngularEditorConfig = {
editable: true,
sanitize: false
}
};

emailTypes$: Observable<Array<any>>;
showButtonLoading: boolean;
Expand All @@ -35,7 +35,8 @@ export class EmailComponent implements OnInit {
@ViewChild('editor', { static: true }) editor: any;
instance: any;
linkForThemes: any = null;
editorThemes = ['3024-day', '3024-night', 'ambiance-mobile', 'ambiance', 'base16-dark', 'base16-light', 'blackboard', 'cobalt', 'eclipse', 'elegant', 'erlang-dark', 'lesser-dark', 'mbo', 'mdn-like', 'midnight', 'monokai', 'neat', 'neo', 'night', 'paraiso-dark', 'paraiso-light', 'pastel-on-dark', 'rubyblue', 'solarized', 'the-matrix', 'tomorrow-night-eighties', 'twilight', 'vibrant-ink', 'xq-dark', 'xq-light'];
editorThemes = ['3024-day', '3024-night', 'ambiance-mobile', 'ambiance', 'base16-dark', 'base16-light', 'blackboard', 'cobalt', 'eclipse',
'elegant', 'erlang-dark', 'lesser-dark', 'mbo', 'mdn-like', 'midnight', 'monokai', 'neat', 'neo', 'night', 'paraiso-dark', 'paraiso-light', 'pastel-on-dark', 'rubyblue', 'solarized', 'the-matrix', 'tomorrow-night-eighties', 'twilight', 'vibrant-ink', 'xq-dark', 'xq-light'];
editorOpts = {
mode: 'htmlmixed',
lineNumbers: true,
Expand Down Expand Up @@ -75,7 +76,7 @@ export class EmailComponent implements OnInit {

createCSS(path) {
let link = document.createElement('link');
link.href = path
link.href = path;
link.type = 'text/css';
link.rel = 'stylesheet';
link.id = 'cm_theme';
Expand Down Expand Up @@ -131,6 +132,6 @@ export class EmailComponent implements OnInit {
this.linkForThemes.setAttribute('href', themesBase + this.editorOpts.theme + '.css');
}
this.instance.setOption('theme', this.editorOpts.theme);
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export class EmailSettingsComponent implements OnInit {


public updateSettings() {
this.errors.splice(0,this.errors.length);
var configurations = new Array<GlobalSettings>();
this.errors.splice(0, this.errors.length);
let configurations = new Array<GlobalSettings>();
configurations.push(this.settings.username);
configurations.push(this.settings.password);
configurations.push(this.settings.sendMail);
Expand Down Expand Up @@ -83,11 +83,11 @@ export class EmailSettingsComponent implements OnInit {
});
}

public changeUseSsl(){
public changeUseSsl() {
this.settings.useSsl.value = this.useSsl.toString();
}

public changeSendEmail(){
public changeSendEmail() {
this.settings.sendMail.value = this.sendMail.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ResetPassword } from '@shared/viewModel/reset-password.model';
import { UserProfile } from '@shared/viewModel/userProfile.model';
import { ToasterConfig, ToasterService } from 'angular2-toaster';
import * as jsonpatch from 'fast-json-patch';
import { Observable } from 'rxjs';
import { throwError } from 'rxjs';
import { flatMap, tap } from 'rxjs/operators';


Expand Down Expand Up @@ -80,7 +80,7 @@ export class UserEditComponent implements OnInit {
this.errors = [];
this.errors.push("Unknown error while trying to update");
this.showButtonLoading = false;
return Observable.throw("Unknown error while trying to update");
return throwError("Unknown error while trying to update");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { UserService } from '@shared/services/user.service';
import { ProblemDetails } from '@shared/viewModel/default-response.model';
import { UserLogin } from '@shared/viewModel/user-login.model';
import { ToasterConfig, ToasterService } from 'angular2-toaster';
import { Observable } from 'rxjs';
import { throwError } from 'rxjs';
import { debounceTime, flatMap, map, tap } from 'rxjs/operators';


Expand Down Expand Up @@ -74,7 +74,7 @@ export class UserLoginsComponent implements OnInit {
this.errors = [];
this.errors.push("Unknown error while trying to remove");
this.showButtonLoading = false;
return Observable.throw("Unknown error while trying to remove");
return throwError("Unknown error while trying to remove");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { FooterComponent } from "./footer.component";

import { SettingsService } from "@core/settings/settings.service";
import { HttpClientModule } from "@angular/common/http";
import { OAuthModule } from 'angular-oauth2-oidc';
import { VersionService } from '@shared/services/version.service';

describe("Component: Footer", () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule],
providers: [SettingsService]
imports: [HttpClientModule, OAuthModule.forRoot()],
providers: [SettingsService, VersionService]
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ export class NotificationsComponent implements OnInit {
constructor(private http: HttpClient) { }

ngOnInit() {
//this.notifications = of<Array<NotificationViewModel>>( JSON.parse('{"notifications":[{"icon":"text-info fas fa-kiwi-bird","title":"Session","description":"2019-05 UI Session improvements"},{"icon":"text-warning fab fa-docker","title":"Docker","description":"2019-04 Docker Ready"},{"icon":"text-info fas fa-code-branch","title":"NET Core 2.2","description":"2019-03 Updated to ASP.NET Core 2.2"},{"icon":"text-success fas fa-id-card","title":"ID4","description":"2019-03 IdentityServer4 2.4 Components"},{"icon":"text-info fas fa-rocket","title":"Launch","description":"2018-10 first release"}]}').notifications);
// this.notifications = of<Array<NotificationViewModel>>(
// JSON.parse('{"notifications":[{"icon":"text-info fas fa-kiwi-bird","title":"Session","description":"2019-05 UI Session improvements"},
// {"icon":"text-warning fab fa-docker","title":"Docker","description":"2019-04 Docker Ready"},
// {"icon":"text-info fas fa-code-branch","title":"NET Core 2.2","description":"2019-03 Updated to ASP.NET Core 2.2"},
// {"icon":"text-success fas fa-id-card","title":"ID4","description":"2019-03 IdentityServer4 2.4 Components"},
// {"icon":"text-info fas fa-rocket","title":"Launch","description":"2018-10 first release"}]}').notifications);
this.notifications$ = this.http.get<NotificationViewModel[]>('https://my-json-server.typicode.com/brunohbrito/JPProject.IdentityServer4.AdminUI/notifications');
}

Expand Down

0 comments on commit 33236f8

Please sign in to comment.