This repository has been archived by the owner on Sep 6, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display tooltip with build status on all icons
- Loading branch information
Showing
12 changed files
with
123 additions
and
56 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 was deleted.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
web/app/common/components/status-icon/status-icon.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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
<ng-container *ngIf="status" [ngSwitch]="status"> | ||
<mat-icon *ngSwitchCase="BuildStatus.SUCCESS" class="fci-status-icon-success"> | ||
<mat-icon *ngSwitchCase="BuildStatus.SUCCESS" class="fci-status-icon-success" [matTooltip]="getTooltipString()" matTooltipPosition="above"> | ||
check_circle | ||
</mat-icon> | ||
<mat-icon *ngSwitchCase="BuildStatus.PENDING" class="fci-status-icon-pending"> | ||
<mat-icon *ngSwitchCase="BuildStatus.PENDING" class="fci-status-icon-pending" [matTooltip]="getTooltipString()" matTooltipPosition="above"> | ||
timelapse | ||
</mat-icon> | ||
<mat-icon *ngSwitchCase="isRunningState()" class="fci-status-icon-running"> | ||
<mat-icon *ngSwitchCase="isRunningState()" class="fci-status-icon-running" [matTooltip]="getTooltipString()" matTooltipPosition="above"> | ||
directions_run | ||
</mat-icon> | ||
<mat-icon *ngSwitchCase="BuildStatus.INTERNAL_ISSUE" class="fci-status-icon-internal"> | ||
<mat-icon *ngSwitchCase="BuildStatus.INTERNAL_ISSUE" class="fci-status-icon-internal" [matTooltip]="getTooltipString()" matTooltipPosition="above"> | ||
warning | ||
</mat-icon> | ||
<mat-icon *ngSwitchCase="isFailedState()" class="fci-status-icon-failed"> | ||
<mat-icon *ngSwitchCase="isFailedState()" class="fci-status-icon-failed" [matTooltip]="getTooltipString()" matTooltipPosition="above"> | ||
cancel | ||
</mat-icon> | ||
</ng-container> |
85 changes: 64 additions & 21 deletions
85
web/app/common/components/status-icon/status-icon.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 |
---|---|---|
@@ -1,64 +1,107 @@ | ||
import {DebugElement} from '@angular/core/src/debug/debug_node'; | ||
import {async, ComponentFixture, TestBed} from '@angular/core/testing'; | ||
import {MatTooltip, MatTooltipModule} from '@angular/material'; | ||
import {MatIconModule} from '@angular/material/icon'; | ||
import {By} from '@angular/platform-browser'; | ||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; | ||
|
||
import {BuildStatus} from '../../constants'; | ||
|
||
import {StatusIconComponent} from './status-icon.component'; | ||
|
||
interface ExpectedIcon { | ||
iconString: string; | ||
class: string; | ||
tooltipString: string; | ||
} | ||
|
||
const EXPECTED_STATUSES = new Map<BuildStatus, ExpectedIcon>([ | ||
[ | ||
BuildStatus.SUCCESS, | ||
{iconString: 'check_circle', class: 'fci-status-icon-success'} | ||
BuildStatus.SUCCESS, { | ||
iconString: 'check_circle', | ||
class: 'fci-status-icon-success', | ||
tooltipString: 'Success' | ||
} | ||
], | ||
[ | ||
BuildStatus.PENDING, { | ||
iconString: 'timelapse', | ||
class: 'fci-status-icon-pending', | ||
tooltipString: 'Pending' | ||
} | ||
], | ||
[ | ||
BuildStatus.PENDING, | ||
{iconString: 'timelapse', class: 'fci-status-icon-pending'} | ||
BuildStatus.FAILED, { | ||
iconString: 'cancel', | ||
class: 'fci-status-icon-failed', | ||
tooltipString: 'Failed' | ||
} | ||
], | ||
[BuildStatus.FAILED, {iconString: 'cancel', class: 'fci-status-icon-failed'}], | ||
[ | ||
BuildStatus.INTERNAL_ISSUE, | ||
{iconString: 'warning', class: 'fci-status-icon-internal'} | ||
BuildStatus.INTERNAL_ISSUE, { | ||
iconString: 'warning', | ||
class: 'fci-status-icon-internal', | ||
tooltipString: 'Internal CI Issue' | ||
} | ||
], | ||
[ | ||
BuildStatus.MISSING_FASTFILE, | ||
{iconString: 'cancel', class: 'fci-status-icon-failed'} | ||
BuildStatus.MISSING_FASTFILE, { | ||
iconString: 'cancel', | ||
class: 'fci-status-icon-failed', | ||
tooltipString: 'Missing Fastfile' | ||
} | ||
], | ||
[ | ||
BuildStatus.INSTALLING_XCODE, | ||
{iconString: 'directions_run', class: 'fci-status-icon-running'} | ||
BuildStatus.INSTALLING_XCODE, { | ||
iconString: 'directions_run', | ||
class: 'fci-status-icon-running', | ||
tooltipString: 'Installing XCode' | ||
} | ||
] | ||
]); | ||
|
||
describe('StatusIconComponent', () => { | ||
let component: StatusIconComponent; | ||
let fixture: ComponentFixture<StatusIconComponent>; | ||
let iconEl: HTMLElement; | ||
let iconEl: DebugElement; | ||
|
||
beforeEach(async(() => { | ||
TestBed | ||
.configureTestingModule( | ||
{imports: [MatIconModule], declarations: [StatusIconComponent]}) | ||
.configureTestingModule({ | ||
imports: [MatIconModule, MatTooltipModule, BrowserAnimationsModule], | ||
declarations: [StatusIconComponent] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(StatusIconComponent); | ||
component = fixture.componentInstance; | ||
iconEl = fixture.nativeElement; | ||
iconEl = fixture.debugElement; | ||
expect(component.status).toBeUndefined(); | ||
}); | ||
|
||
EXPECTED_STATUSES.forEach((expectedIcon, status) => { | ||
it(`should have expect icon and class when status is ${status}`, () => { | ||
component.status = status; | ||
fixture.detectChanges(); | ||
describe(`${status} status`, () => { | ||
it('should have expected icon and class', () => { | ||
component.status = status; | ||
fixture.detectChanges(); | ||
|
||
const icon = iconEl.query(By.css('.mat-icon')).nativeElement; | ||
expect(icon.textContent.trim()).toBe(expectedIcon.iconString); | ||
expect(icon.classList).toContain(expectedIcon.class); | ||
}); | ||
|
||
it('should have expected tooltip String', () => { | ||
component.status = status; | ||
fixture.detectChanges(); | ||
|
||
const icon = iconEl.query(By.css('.mat-icon')); | ||
const tooltipDir: MatTooltip = | ||
icon.injector.get<MatTooltip>(MatTooltip); | ||
|
||
const icon = iconEl.querySelector('.mat-icon'); | ||
expect(icon.textContent.trim()).toBe(expectedIcon.iconString); | ||
expect(icon.classList).toContain(expectedIcon.class); | ||
expect(tooltipDir.message).toBe(expectedIcon.tooltipString); | ||
}); | ||
}); | ||
}); | ||
}); |
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
21 changes: 21 additions & 0 deletions
21
web/app/common/components/status-icon/status-icon.module.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,21 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {NgModule} from '@angular/core'; | ||
import {MatIconModule, MatTooltipModule} from '@angular/material'; | ||
|
||
import {StatusIconComponent} from './status-icon.component'; | ||
|
||
@NgModule({ | ||
declarations: [StatusIconComponent], | ||
imports: [ | ||
/** Angular Library Imports */ | ||
CommonModule, | ||
/** Internal Imports */ | ||
/** Angular Material Imports */ | ||
MatIconModule, MatTooltipModule, | ||
/** Third-Party Module Imports */ | ||
], | ||
exports: [StatusIconComponent] | ||
}) | ||
|
||
export class StatusIconModule { | ||
} |
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
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