diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 99917815c..cb59c19dc 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -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' }), diff --git a/frontend/src/app/data-cy.directive.ts b/frontend/src/app/data-cy.directive.ts new file mode 100644 index 000000000..1e8e9aec7 --- /dev/null +++ b/frontend/src/app/data-cy.directive.ts @@ -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'); + } + } +}