Add new directive for UI tests

This commit is contained in:
Felipe Knorr Kuhn 2022-03-19 22:14:37 -07:00
parent db4a13389a
commit 2d4d9d80bd
No known key found for this signature in database
GPG key ID: 79619B52BB097C1A
2 changed files with 15 additions and 0 deletions

View file

@ -78,6 +78,7 @@ import { ShortenStringPipe } from './shared/pipes/shorten-string-pipe/shorten-st
import { GraphsComponent } from './components/graphs/graphs.component';
import { DifficultyAdjustmentsTable } from './components/difficulty-adjustments-table/difficulty-adjustments-table.components';
import { BlocksList } from './components/blocks-list/blocks-list.component';
import { DataCyDirective } from './data-cy.directive';
@NgModule({
declarations: [
@ -137,6 +138,7 @@ import { BlocksList } from './components/blocks-list/blocks-list.component';
GraphsComponent,
DifficultyAdjustmentsTable,
BlocksList,
DataCyDirective,
],
imports: [
BrowserModule.withServerTransition({ appId: 'serverApp' }),

View file

@ -0,0 +1,13 @@
import { Directive, ElementRef, Renderer2 } from '@angular/core';
import { environment } from '../environments/environment';
@Directive({
selector: '[data-cy]'
})
export class DataCyDirective {
constructor(private el: ElementRef, private renderer: Renderer2) {
if (environment.production) {
renderer.removeAttribute(el.nativeElement, 'data-cy');
}
}
}