Skip to content

Commit

Permalink
Merge pull request #272 from 0x41head/test-fix
Browse files Browse the repository at this point in the history
enhancement: Task-description tests reference elements by ID
  • Loading branch information
wurstbrot authored Feb 23, 2024
2 parents b1e0693 + a92e0dc commit 2013e50
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1>
<b>UUID</b>
</mat-panel-title>
</mat-expansion-panel-header>
<p [innerHTML]="currentActivity.uuid"></p>
<p id="uuid" [innerHTML]="currentActivity.uuid"></p>
</mat-expansion-panel>

<mat-expansion-panel [expanded]="true">
Expand All @@ -25,7 +25,7 @@ <h1>
<b>Description</b>
</mat-panel-title>
</mat-expansion-panel-header>
<p [innerHTML]="currentActivity.description"></p>
<p id="description" [innerHTML]="currentActivity.description"></p>
</mat-expansion-panel>

<mat-expansion-panel>
Expand All @@ -34,7 +34,7 @@ <h1>
<b>Risk</b>
</mat-panel-title>
</mat-expansion-panel-header>
<p [innerHTML]="currentActivity.risk"></p>
<p id="risk" [innerHTML]="currentActivity.risk"></p>
</mat-expansion-panel>

<mat-expansion-panel>
Expand All @@ -43,7 +43,7 @@ <h1>
<b>Measure</b>
</mat-panel-title>
</mat-expansion-panel-header>
<p [innerHTML]="currentActivity.measure"></p>
<p id="measure" [innerHTML]="currentActivity.measure"></p>
</mat-expansion-panel>

<mat-expansion-panel *ngIf="currentActivity.implementatonGuide">
Expand All @@ -52,7 +52,9 @@ <h1>
<b>Implementation Guide</b>
</mat-panel-title>
</mat-expansion-panel-header>
<p [innerHTML]="currentActivity.implementatonGuide"></p>
<p
id="implementatonGuide"
[innerHTML]="currentActivity.implementatonGuide"></p>
</mat-expansion-panel>

<mat-expansion-panel>
Expand Down Expand Up @@ -83,7 +85,7 @@ <h1>
<b>Evidence</b>
</mat-panel-title>
</mat-expansion-panel-header>
<p [innerHTML]="currentActivity.evidence"></p>
<p id="evidence" [innerHTML]="currentActivity.evidence"></p>
</mat-expansion-panel>

<mat-expansion-panel>
Expand All @@ -92,7 +94,7 @@ <h1>
<b>Assessment</b>
</mat-panel-title>
</mat-expansion-panel-header>
<p [innerHTML]="currentActivity.assessment"></p>
<p id="assessment" [innerHTML]="currentActivity.assessment"></p>
</mat-expansion-panel>

<mat-expansion-panel>
Expand Down Expand Up @@ -247,7 +249,7 @@ <h1>
<b>Comments</b>
</mat-panel-title>
</mat-expansion-panel-header>
<p [innerHTML]="currentActivity.comments"></p>
<p id="comments" [innerHTML]="currentActivity.comments"></p>
</mat-expansion-panel>
</mat-accordion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('ActivityDescriptionComponent', () => {
expect(component).toBeTruthy();
});

it('check if header is being genenrated', () => {
it('check if header is being generated', () => {
const testDimension = 'Sample Dimension';
const testSubDimension = 'Sample subDimension';
component.currentActivity.dimension = testDimension;
Expand All @@ -40,88 +40,89 @@ describe('ActivityDescriptionComponent', () => {
expect(heading.textContent).toContain(testSubDimension);
});

it('check if UUID is being genenrated', () => {
it('check if UUID is being generated', () => {
const testUUID = '00000000-0000-0000-0000-000000000000';
component.currentActivity.uuid = testUUID;
fixture.detectChanges();
const HTMLElement: HTMLElement = fixture.nativeElement;
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
expect(contentDisplayedinParagraphTag[0].textContent).toContain(testUUID);
const contentDisplayedinParagraphTag = HTMLElement.querySelector('#uuid')!;
expect(contentDisplayedinParagraphTag.textContent).toContain(testUUID);
});

it('check if description is being genenrated', () => {
it('check if description is being generated', () => {
const testDescription = 'Sample Description';
component.currentActivity.description = testDescription;
fixture.detectChanges();
const HTMLElement: HTMLElement = fixture.nativeElement;
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
expect(contentDisplayedinParagraphTag[1].textContent).toContain(
const contentDisplayedinParagraphTag =
HTMLElement.querySelector('#description')!;
expect(contentDisplayedinParagraphTag.textContent).toContain(
testDescription
);
});

it('check if risk is being genenrated', () => {
it('check if risk is being generated', () => {
const testRisk = 'Sample Risk';
component.currentActivity.risk = testRisk;
fixture.detectChanges();
const HTMLElement: HTMLElement = fixture.nativeElement;
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
expect(contentDisplayedinParagraphTag[2].textContent).toContain(testRisk);
const contentDisplayedinParagraphTag = HTMLElement.querySelector('#risk')!;
expect(contentDisplayedinParagraphTag.textContent).toContain(testRisk);
});

it('check if measure is being genenrated', () => {
it('check if measure is being generated', () => {
const testMeasure = 'Sample Measure';
component.currentActivity.measure = testMeasure;
fixture.detectChanges();
const HTMLElement: HTMLElement = fixture.nativeElement;
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
expect(contentDisplayedinParagraphTag[3].textContent).toContain(
testMeasure
);
const contentDisplayedinParagraphTag =
HTMLElement.querySelector('#measure')!;
expect(contentDisplayedinParagraphTag.textContent).toContain(testMeasure);
});

it('check if implementation guide is being genenrated', () => {
it('check if implementation guide is being generated', () => {
const testImplementationGuide = 'Sample Implementation Guide';
component.currentActivity.implementatonGuide = testImplementationGuide;
fixture.detectChanges();
const HTMLElement: HTMLElement = fixture.nativeElement;
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
expect(contentDisplayedinParagraphTag[4].textContent).toContain(
const contentDisplayedinParagraphTag = HTMLElement.querySelector(
'#implementatonGuide'
)!;
expect(contentDisplayedinParagraphTag.textContent).toContain(
testImplementationGuide
);
});

it('check if evidence is being genenrated', () => {
it('check if evidence is being generated', () => {
const testEvidence = 'Sample Evidence';
component.currentActivity.evidence = testEvidence;
fixture.detectChanges();
const HTMLElement: HTMLElement = fixture.nativeElement;
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
expect(contentDisplayedinParagraphTag[7].textContent).toContain(
testEvidence
);
const contentDisplayedinParagraphTag =
HTMLElement.querySelector('#evidence')!;
expect(contentDisplayedinParagraphTag.textContent).toContain(testEvidence);
});

it('check if assessment is being genenrated', () => {
it('check if assessment is being generated', () => {
const testAssessment = 'Sample Assessment';
component.currentActivity.assessment = testAssessment;
fixture.detectChanges();
const HTMLElement: HTMLElement = fixture.nativeElement;
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
expect(contentDisplayedinParagraphTag[8].textContent).toContain(
const contentDisplayedinParagraphTag =
HTMLElement.querySelector('#assessment')!;
expect(contentDisplayedinParagraphTag.textContent).toContain(
testAssessment
);
});

it('check if comments is being genenrated', () => {
it('check if comments is being generated', () => {
const testComments = 'Sample Comments';
component.currentActivity.comments = testComments;
fixture.detectChanges();
const HTMLElement: HTMLElement = fixture.nativeElement;
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
expect(contentDisplayedinParagraphTag[11].textContent).toContain(
testComments
);
const contentDisplayedinParagraphTag =
HTMLElement.querySelector('#comments')!;
expect(contentDisplayedinParagraphTag.textContent).toContain(testComments);
});

it('check if references is being generated', () => {
Expand Down

0 comments on commit 2013e50

Please sign in to comment.