[CST-5270] use data-test as css selector for unit test

This commit is contained in:
Giuseppe Digilio
2022-05-24 16:05:21 +02:00
parent 5842d83e91
commit d1f8bb6d7b
2 changed files with 7 additions and 7 deletions

View File

@@ -1,8 +1,8 @@
<ds-alert [type]="'alert-info'" *ngIf="hasNoData()" [content]="'submission.sections.sherpa-policy.title-empty'"> <ds-alert [type]="'alert-info'" *ngIf="hasNoData()" [content]="'submission.sections.sherpa-policy.title-empty'">
</ds-alert> </ds-alert>
<div *ngIf="!hasNoData()" class="d-flex justify-content-end mt-2 mb-2 refresh-container"> <div *ngIf="!hasNoData()" class="d-flex justify-content-end mt-2 mb-2">
<button type="button" class="btn btn-secondary pull-right" (click)="refresh()"> <button type="button" class="btn btn-secondary pull-right" (click)="refresh()" data-test="refresh-btn">
<span><i class="fas fa-sync"></i> {{'submission.sections.sherpa.publisher.policy.refresh' | translate}} </span> <span><i class="fas fa-sync"></i> {{'submission.sections.sherpa.publisher.policy.refresh' | translate}} </span>
</button> </button>
</div> </div>
@@ -64,4 +64,4 @@
[content]="!!sherpaData.message ? sherpaData.message : 'submission.sections.sherpa.error.message'| translate"> [content]="!!sherpaData.message ? sherpaData.message : 'submission.sections.sherpa.error.message'| translate">
</ds-alert> </ds-alert>
</ng-container> </ng-container>
</ng-container> </ng-container>

View File

@@ -1,8 +1,8 @@
import { SharedModule } from './../../../shared/shared.module'; import { SharedModule } from '../../../shared/shared.module';
import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap';
import { SubmissionServiceStub } from '../../../shared/testing/submission-service.stub'; import { SubmissionServiceStub } from '../../../shared/testing/submission-service.stub';
import { SherpaDataResponse } from '../../../shared/mocks/section-sherpa-policies.service.mock'; import { SherpaDataResponse } from '../../../shared/mocks/section-sherpa-policies.service.mock';
import { ComponentFixture, inject, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { SectionsService } from '../sections.service'; import { SectionsService } from '../sections.service';
import { SectionsServiceStub } from '../../../shared/testing/sections-service.stub'; import { SectionsServiceStub } from '../../../shared/testing/sections-service.stub';
@@ -89,7 +89,7 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => {
}); });
it('should show refresh button', () => { it('should show refresh button', () => {
expect(de.query(By.css('.refresh-container > button'))).toBeTruthy(); expect(de.query(By.css('[data-test="refresh-btn"]'))).toBeTruthy();
}); });
it('should show publisher information', () => { it('should show publisher information', () => {
@@ -105,7 +105,7 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => {
}); });
it('when refresh button click operationsBuilder.remove should have been called', () => { it('when refresh button click operationsBuilder.remove should have been called', () => {
de.query(By.css('.refresh-container > button')).nativeElement.click(); de.query(By.css('[data-test="refresh-btn"]')).nativeElement.click();
expect(operationsBuilder.remove).toHaveBeenCalled(); expect(operationsBuilder.remove).toHaveBeenCalled();
}); });