Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion modules/ui/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { MatIconTestingModule } from '@angular/material/icon/testing';
import { CertificatesComponent } from './pages/certificates/certificates.component';
import { of } from 'rxjs';
import { WINDOW } from './providers/window.provider';
import { LiveAnnouncer } from '@angular/cdk/a11y';

const windowMock = {
location: {
Expand All @@ -81,6 +82,7 @@ describe('AppComponent', () => {
let store: MockStore<AppState>;
let focusNavigation = true;
let mockFocusManagerService: SpyObj<FocusManagerService>;
let mockLiveAnnouncer: SpyObj<LiveAnnouncer>;

const enterKeyEvent = new KeyboardEvent('keydown', {
key: 'Enter',
Expand Down Expand Up @@ -111,6 +113,7 @@ describe('AppComponent', () => {
mockFocusManagerService = jasmine.createSpyObj('mockFocusManagerService', [
'focusFirstElementInContainer',
]);
mockLiveAnnouncer = jasmine.createSpyObj('mockLiveAnnouncer', ['announce']);

TestBed.configureTestingModule({
imports: [
Expand All @@ -129,6 +132,7 @@ describe('AppComponent', () => {
],
providers: [
{ provide: TestRunService, useValue: mockService },
{ provide: LiveAnnouncer, useValue: mockLiveAnnouncer },
{
provide: State,
useValue: {
Expand Down Expand Up @@ -327,6 +331,21 @@ describe('AppComponent', () => {
expect(component.settingsDrawer.open).toHaveBeenCalledTimes(1);
}));

it('should announce settingsDrawer open on openSetting', fakeAsync(() => {
fixture.detectChanges();

spyOn(component.settingsDrawer, 'open').and.returnValue(
Promise.resolve('open')
);

component.openSetting();
tick();

expect(mockLiveAnnouncer.announce).toHaveBeenCalledWith(
'The settings panel is opened'
);
}));

it('should call settingsDrawer open on click settings button', () => {
fixture.detectChanges();

Expand Down Expand Up @@ -672,7 +691,7 @@ describe('AppComponent', () => {
expect(generalSettingsButton).toBeDefined();
});

it('should call settingsDrawer open on click settings button', () => {
it('should call certificates open on click certificates button', () => {
fixture.detectChanges();

const settingsBtn = compiled.querySelector(
Expand All @@ -684,6 +703,21 @@ describe('AppComponent', () => {

expect(component.certDrawer.open).toHaveBeenCalledTimes(1);
});

it('should announce certificatesDrawer open on openCert', fakeAsync(() => {
fixture.detectChanges();

spyOn(component.certDrawer, 'open').and.returnValue(
Promise.resolve('open')
);

component.openCert();
tick();

expect(mockLiveAnnouncer.announce).toHaveBeenCalledWith(
'The certificates panel is opened'
);
}));
});

@Component({
Expand Down
6 changes: 5 additions & 1 deletion modules/ui/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { appFeatureKey } from './store/reducers';
import { SettingsComponent } from './pages/settings/settings.component';
import { AppStore } from './app.store';
import { TestRunService } from './services/test-run.service';
import { LiveAnnouncer } from '@angular/cdk/a11y';

const DEVICES_LOGO_URL = '/assets/icons/devices.svg';
const DEVICES_RUN_URL = '/assets/icons/device_run.svg';
Expand Down Expand Up @@ -71,7 +72,8 @@ export class AppComponent {
private state: State<AppState>,
private readonly focusManagerService: FocusManagerService,
private testRunService: TestRunService,
public appStore: AppStore
public appStore: AppStore,
private liveAnnouncer: LiveAnnouncer
) {
this.appStore.getDevices();
this.appStore.getSystemStatus();
Expand Down Expand Up @@ -157,10 +159,12 @@ export class AppComponent {
this.settings.getSystemInterfaces();
this.settings.getSystemConfig();
await this.settingsDrawer.open();
await this.liveAnnouncer.announce('The settings panel is opened');
}

async openCert() {
await this.certDrawer.open();
this.liveAnnouncer.announce('The certificates panel is opened');
}

consentShown() {
Expand Down