-
Notifications
You must be signed in to change notification settings - Fork 0
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
d6504ab
commit 87c1bd7
Showing
40 changed files
with
966 additions
and
296 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1,60 @@ | ||
<app-mqtt-playground></app-mqtt-playground> | ||
<sbb-header-lean [label]="title" [subtitle]="'Version ' + version" collapseBreakpoint="mobile"> | ||
<sbb-header-environment>{{ environmentLabel }}</sbb-header-environment> | ||
<sbb-usermenu [menu]="menu" [userName]="userData().userData?.preferred_username" | ||
[displayName]="userData().userData ? organisation()?.name : undefined" (loginRequest)="login()"> | ||
<sbb-icon svgIcon="kom:user-small" *sbbIcon></sbb-icon> | ||
</sbb-usermenu> | ||
<sbb-menu #menu="sbbMenu"> | ||
<button sbb-menu-item (click)="logout()"> | ||
<sbb-icon svgIcon="kom:exit-small" class="sbb-icon-fit"></sbb-icon> | ||
<span i18n>Logout</span> | ||
</button> | ||
</sbb-menu> | ||
<svg brand style="width: 0"><!-- Optional --></svg> | ||
</sbb-header-lean> | ||
@if (userData().userData) { | ||
<sbb-icon-sidebar-container class="sbb-icon-sidebar-after-header"> | ||
<sbb-icon-sidebar expanded> | ||
<a | ||
sbbIconSidebarItem | ||
i18n-label | ||
label="SFERA" | ||
routerLink="/sfera" | ||
routerLinkActive="sbb-active" | ||
[routerLinkActiveOptions]="{ | ||
paths: 'exact', | ||
fragment: 'ignored', | ||
queryParams: 'ignored', | ||
matrixParams: 'ignored', | ||
}" | ||
> | ||
<sbb-icon svgIcon="kom:railway-switch-small"></sbb-icon> | ||
</a> | ||
<a | ||
sbbIconSidebarItem | ||
i18n-label | ||
label="MQTT" | ||
routerLink="/mqtt" | ||
routerLinkActive="sbb-active" | ||
> | ||
<sbb-icon svgIcon="kom:arrows-up-down-small"></sbb-icon> | ||
</a> | ||
<a | ||
sbbIconSidebarItem | ||
i18n-label | ||
label="Auth insights" | ||
routerLink="/auth-insights" | ||
routerLinkActive="sbb-active" | ||
> | ||
<sbb-icon svgIcon="kom:user-key-small"></sbb-icon> | ||
</a> | ||
</sbb-icon-sidebar> | ||
<sbb-icon-sidebar-content role="main" class="app-main-content"> | ||
<router-outlet></router-outlet> | ||
</sbb-icon-sidebar-content> | ||
</sbb-icon-sidebar-container> | ||
} @else { | ||
<div class="after-header app-main-content"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
} |
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 @@ | ||
.app-main-content { | ||
padding: 0 1em; | ||
} | ||
|
||
.after-header { | ||
position: absolute; | ||
top: var(--sbb-header-lean-height); | ||
left: 0; | ||
right: 0; | ||
} |
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 |
---|---|---|
@@ -1,25 +1,74 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { AppComponent } from './app.component'; | ||
import { AuthService } from "./auth.service"; | ||
import { AuthService, Tenant } from "./auth.service"; | ||
import { MqService } from "./mq.service"; | ||
import { OidcSecurityService, UserDataResult } from "angular-auth-oidc-client"; | ||
import { signal } from "@angular/core"; | ||
import { of } from "rxjs"; | ||
import { SbbIconTestingModule } from "@sbb-esta/angular/icon/testing"; | ||
import { NoopAnimationsModule } from "@angular/platform-browser/animations"; | ||
import { By } from "@angular/platform-browser"; | ||
import { SbbMenuItem } from "@sbb-esta/angular/menu"; | ||
import { RouterTestingModule } from "@angular/router/testing"; | ||
|
||
const mockAuth: Partial<AuthService> = {}; | ||
const mockAuth: Partial<AuthService> = { | ||
tenant: () => of({name: 'Organisation'} as Tenant) | ||
}; | ||
const mockOidc: Partial<OidcSecurityService> = { | ||
userData: signal({userData: {name: 'User'}} as UserDataResult), | ||
logoffLocalMultiple: () => Promise.resolve(true), | ||
}; | ||
const mockMq: Partial<MqService> = {}; | ||
|
||
describe('AppComponent', () => { | ||
let component: AppComponent; | ||
let fixture: ComponentFixture<AppComponent> | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [AppComponent], | ||
imports: [NoopAnimationsModule, RouterTestingModule, SbbIconTestingModule, AppComponent,], | ||
providers: [ | ||
{provide: AuthService, useValue: mockAuth}, | ||
{provide: MqService, useValue: mockMq} | ||
{provide: OidcSecurityService, useValue: mockOidc}, | ||
{provide: MqService, useValue: mockMq}, | ||
] | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AppComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}) | ||
|
||
it('should create the app', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app).toBeTruthy(); | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should render title', () => { | ||
expect( | ||
fixture.nativeElement.querySelector('.sbb-header-lean-titlebox > span').textContent, | ||
).toContain('DAS playground'); | ||
}); | ||
|
||
it('should render organisation', () => { | ||
expect( | ||
fixture.nativeElement.querySelector('.sbb-usermenu-user-info-display-name').textContent, | ||
).toContain('Organisation'); | ||
}); | ||
|
||
it('should logout', () => { | ||
const logoutSpy = spyOn(mockOidc as OidcSecurityService, 'logoffLocalMultiple'); | ||
|
||
// Open user menu | ||
const usermenuOpenButton = fixture.debugElement.query(By.css('.sbb-menu-trigger-usermenu')); | ||
usermenuOpenButton.nativeElement.click(); | ||
fixture.detectChanges(); | ||
|
||
// Logout | ||
const logoutButton = fixture.debugElement.query(By.directive(SbbMenuItem)); | ||
logoutButton.nativeElement.click(); | ||
|
||
expect(logoutSpy).toHaveBeenCalled(); | ||
}); | ||
}); |
Oops, something went wrong.