diff --git a/modules/ui/src/app/components/version/version.component.html b/modules/ui/src/app/components/version/version.component.html index 45a65faaf..d45ea69da 100644 --- a/modules/ui/src/app/components/version/version.component.html +++ b/modules/ui/src/app/components/version/version.component.html @@ -18,10 +18,7 @@ mat-button class="version-content" [class.version-content-update]="version.update_available" - [attr.aria-label]=" - version?.installed_version + - ' New version is available. Click here to update' - " + [attr.aria-label]="getVersionButtonLabel(version.installed_version)" (click)="openConsentDialog(version)"> {{ version?.installed_version }} { expect(component).toBeTruthy(); }); + it('should get correct aria label for version button', () => { + const labelUnavailableVersion = component.getVersionButtonLabel( + UNAVAILABLE_VERSION.installed_version + ); + + const labelAvailableVersion = component.getVersionButtonLabel( + VERSION.installed_version + ); + + expect(labelUnavailableVersion).toContain( + 'Version temporarily unavailable.' + ); + expect(labelAvailableVersion).toContain('New version is available.'); + }); + it('should open consent window on start', () => { const openSpy = spyOn(component.dialog, 'open').and.returnValue({ afterClosed: () => of(true), diff --git a/modules/ui/src/app/components/version/version.component.ts b/modules/ui/src/app/components/version/version.component.ts index c5d7880a9..a85a3ce40 100644 --- a/modules/ui/src/app/components/version/version.component.ts +++ b/modules/ui/src/app/components/version/version.component.ts @@ -22,7 +22,10 @@ import { Output, } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { TestRunService } from '../../services/test-run.service'; +import { + TestRunService, + UNAVAILABLE_VERSION, +} from '../../services/test-run.service'; import { Version } from '../../model/version'; import { MatButtonModule } from '@angular/material/button'; import { MatDialog, MatDialogModule } from '@angular/material/dialog'; @@ -69,6 +72,12 @@ export class VersionComponent implements OnInit, OnDestroy { ); } + getVersionButtonLabel(installedVersion: string): string { + return installedVersion === UNAVAILABLE_VERSION.installed_version + ? 'Version temporarily unavailable. Click to open the Welcome modal' + : `${installedVersion} New version is available. Click to update`; + } + openConsentDialog(version: Version) { const dialogRef = this.dialog.open(ConsentDialogComponent, { ariaLabel: 'Welcome to Testrun modal window',