-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
501d0fe
commit 41e397d
Showing
47 changed files
with
837 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"extends": "../../.eslintrc.json", | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts"], | ||
"parserOptions": { | ||
"project": [ | ||
"projects/sample-code-flow-standalone/tsconfig.app.json", | ||
"projects/sample-code-flow-standalone/tsconfig.spec.json", | ||
"projects/sample-code-flow-standalone/e2e/tsconfig.json" | ||
], | ||
"createDefaultProgram": true | ||
}, | ||
"rules": { | ||
"@angular-eslint/component-selector": [ | ||
"error", | ||
{ | ||
"type": "element", | ||
"prefix": "app", | ||
"style": "kebab-case" | ||
} | ||
], | ||
"@angular-eslint/directive-selector": [ | ||
"error", | ||
{ | ||
"type": "attribute", | ||
"prefix": "app", | ||
"style": "camelCase" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"files": ["*.html"], | ||
"rules": {} | ||
} | ||
] | ||
} |
37 changes: 37 additions & 0 deletions
37
projects/sample-code-flow-standalone/e2e/protractor.conf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// @ts-check | ||
// Protractor configuration file, see link for more information | ||
// https://github.com/angular/protractor/blob/master/lib/config.ts | ||
|
||
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter'); | ||
|
||
/** | ||
* @type { import("protractor").Config } | ||
*/ | ||
exports.config = { | ||
allScriptsTimeout: 11000, | ||
specs: ['./src/**/*.e2e-spec.ts'], | ||
capabilities: { | ||
browserName: 'chrome', | ||
}, | ||
directConnect: true, | ||
SELENIUM_PROMISE_MANAGER: false, | ||
baseUrl: 'http://localhost:4200/', | ||
framework: 'jasmine', | ||
jasmineNodeOpts: { | ||
showColors: true, | ||
defaultTimeoutInterval: 30000, | ||
print: function () {}, | ||
}, | ||
onPrepare() { | ||
require('ts-node').register({ | ||
project: require('path').join(__dirname, './tsconfig.json'), | ||
}); | ||
jasmine.getEnv().addReporter( | ||
new SpecReporter({ | ||
spec: { | ||
displayStacktrace: StacktraceOption.PRETTY, | ||
}, | ||
}) | ||
); | ||
}, | ||
}; |
25 changes: 25 additions & 0 deletions
25
projects/sample-code-flow-standalone/e2e/src/app.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { AppPage } from './app.po'; | ||
import { browser, logging } from 'protractor'; | ||
|
||
describe('workspace-project App', () => { | ||
let page: AppPage; | ||
|
||
beforeEach(() => { | ||
page = new AppPage(); | ||
}); | ||
|
||
it('should display welcome message', async () => { | ||
await page.navigateTo(); | ||
expect(await page.getTitleText()).toEqual('sample-code-flow-standalone app is running!'); | ||
}); | ||
|
||
afterEach(async () => { | ||
// Assert that there are no errors emitted from the browser | ||
const logs = await browser.manage().logs().get(logging.Type.BROWSER); | ||
expect(logs).not.toContain( | ||
jasmine.objectContaining({ | ||
level: logging.Level.SEVERE, | ||
} as logging.Entry) | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { browser, by, element } from 'protractor'; | ||
|
||
export class AppPage { | ||
async navigateTo(): Promise<unknown> { | ||
return browser.get(browser.baseUrl); | ||
} | ||
|
||
async getTitleText(): Promise<string> { | ||
return element(by.css('app-root .content span')).getText(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* To learn more about this file see: https://angular.io/config/tsconfig. */ | ||
{ | ||
"extends": "../../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../../out-tsc/e2e", | ||
"module": "commonjs", | ||
"target": "es2018", | ||
"types": ["jasmine", "node"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Karma configuration file, see link for more information | ||
// https://karma-runner.github.io/1.0/config/configuration-file.html | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
basePath: '', | ||
frameworks: ['jasmine', '@angular-devkit/build-angular'], | ||
plugins: [ | ||
require('karma-jasmine'), | ||
require('karma-chrome-launcher'), | ||
require('karma-jasmine-html-reporter'), | ||
require('karma-coverage'), | ||
require('@angular-devkit/build-angular/plugins/karma'), | ||
], | ||
client: { | ||
jasmine: { | ||
// you can add configuration options for Jasmine here | ||
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html | ||
// for example, you can disable the random execution with `random: false` | ||
// or set a specific seed with `seed: 4321` | ||
}, | ||
clearContext: false, // leave Jasmine Spec Runner output visible in browser | ||
}, | ||
jasmineHtmlReporter: { | ||
suppressAll: true, // removes the duplicated traces | ||
}, | ||
coverageReporter: { | ||
dir: require('path').join(__dirname, '../../coverage/sample-code-flow-standalone'), | ||
subdir: '.', | ||
reporters: [{ type: 'html' }, { type: 'text-summary' }], | ||
}, | ||
reporters: ['progress', 'kjhtml'], | ||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: true, | ||
browsers: ['Chrome'], | ||
singleRun: false, | ||
restartOnFileChange: true, | ||
}); | ||
}; |
Empty file.
9 changes: 9 additions & 0 deletions
9
projects/sample-code-flow-standalone/src/app/app.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<app-navigation></app-navigation> | ||
|
||
<div class="container-fluid"> | ||
<div class="row"> | ||
<div class="col-sm-12 body-content"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
</div> | ||
</div> |
31 changes: 31 additions & 0 deletions
31
projects/sample-code-flow-standalone/src/app/app.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { AppComponent } from './app.component'; | ||
|
||
describe('AppComponent', () => { | ||
beforeEach( | ||
waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [AppComponent], | ||
}).compileComponents(); | ||
}) | ||
); | ||
|
||
it('should create the app', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.debugElement.componentInstance; | ||
expect(app).toBeTruthy(); | ||
}); | ||
|
||
it(`should have as title 'sample-code-flow-standalone'`, () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.debugElement.componentInstance; | ||
expect(app.title).toEqual('sample-code-flow-standalone'); | ||
}); | ||
|
||
it('should render title in a h1 tag', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
const compiled = fixture.debugElement.nativeElement; | ||
expect(compiled.querySelector('h1').textContent).toContain('Welcome to sample-code-flow-standalone!'); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
projects/sample-code-flow-standalone/src/app/app.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { OidcSecurityService } from 'angular-auth-oidc-client'; | ||
import {RouterOutlet} from "@angular/router"; | ||
import {NavigationComponent} from "./navigation/navigation.component"; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.css'], | ||
standalone: true, | ||
imports: [ | ||
RouterOutlet, | ||
NavigationComponent | ||
] | ||
}) | ||
export class AppComponent implements OnInit { | ||
constructor(private oidcSecurityService: OidcSecurityService) {} | ||
|
||
ngOnInit() { | ||
this.oidcSecurityService.checkAuth().subscribe(({ isAuthenticated, userData, accessToken }) => { | ||
console.log('app authenticated', isAuthenticated); | ||
console.log(`Current access token is '${accessToken}'`); | ||
}); | ||
} | ||
|
||
login() { | ||
console.log('start login'); | ||
this.oidcSecurityService.authorize(); | ||
} | ||
|
||
refreshSession() { | ||
console.log('start refreshSession'); | ||
this.oidcSecurityService.authorize(); | ||
} | ||
|
||
logout() { | ||
console.log('start logoff'); | ||
this.oidcSecurityService.logoff().subscribe((result) => console.log(result)); | ||
} | ||
} |
Oops, something went wrong.