Skip to content

Commit 2013e50

Browse files
authored
Merge pull request #272 from 0x41head/test-fix
enhancement: Task-description tests reference elements by ID
2 parents b1e0693 + a92e0dc commit 2013e50

File tree

2 files changed

+42
-39
lines changed

2 files changed

+42
-39
lines changed

src/app/component/activity-description/activity-description.component.html

+10-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h1>
1616
<b>UUID</b>
1717
</mat-panel-title>
1818
</mat-expansion-panel-header>
19-
<p [innerHTML]="currentActivity.uuid"></p>
19+
<p id="uuid" [innerHTML]="currentActivity.uuid"></p>
2020
</mat-expansion-panel>
2121

2222
<mat-expansion-panel [expanded]="true">
@@ -25,7 +25,7 @@ <h1>
2525
<b>Description</b>
2626
</mat-panel-title>
2727
</mat-expansion-panel-header>
28-
<p [innerHTML]="currentActivity.description"></p>
28+
<p id="description" [innerHTML]="currentActivity.description"></p>
2929
</mat-expansion-panel>
3030

3131
<mat-expansion-panel>
@@ -34,7 +34,7 @@ <h1>
3434
<b>Risk</b>
3535
</mat-panel-title>
3636
</mat-expansion-panel-header>
37-
<p [innerHTML]="currentActivity.risk"></p>
37+
<p id="risk" [innerHTML]="currentActivity.risk"></p>
3838
</mat-expansion-panel>
3939

4040
<mat-expansion-panel>
@@ -43,7 +43,7 @@ <h1>
4343
<b>Measure</b>
4444
</mat-panel-title>
4545
</mat-expansion-panel-header>
46-
<p [innerHTML]="currentActivity.measure"></p>
46+
<p id="measure" [innerHTML]="currentActivity.measure"></p>
4747
</mat-expansion-panel>
4848

4949
<mat-expansion-panel *ngIf="currentActivity.implementatonGuide">
@@ -52,7 +52,9 @@ <h1>
5252
<b>Implementation Guide</b>
5353
</mat-panel-title>
5454
</mat-expansion-panel-header>
55-
<p [innerHTML]="currentActivity.implementatonGuide"></p>
55+
<p
56+
id="implementatonGuide"
57+
[innerHTML]="currentActivity.implementatonGuide"></p>
5658
</mat-expansion-panel>
5759

5860
<mat-expansion-panel>
@@ -83,7 +85,7 @@ <h1>
8385
<b>Evidence</b>
8486
</mat-panel-title>
8587
</mat-expansion-panel-header>
86-
<p [innerHTML]="currentActivity.evidence"></p>
88+
<p id="evidence" [innerHTML]="currentActivity.evidence"></p>
8789
</mat-expansion-panel>
8890

8991
<mat-expansion-panel>
@@ -92,7 +94,7 @@ <h1>
9294
<b>Assessment</b>
9395
</mat-panel-title>
9496
</mat-expansion-panel-header>
95-
<p [innerHTML]="currentActivity.assessment"></p>
97+
<p id="assessment" [innerHTML]="currentActivity.assessment"></p>
9698
</mat-expansion-panel>
9799

98100
<mat-expansion-panel>
@@ -247,7 +249,7 @@ <h1>
247249
<b>Comments</b>
248250
</mat-panel-title>
249251
</mat-expansion-panel-header>
250-
<p [innerHTML]="currentActivity.comments"></p>
252+
<p id="comments" [innerHTML]="currentActivity.comments"></p>
251253
</mat-expansion-panel>
252254
</mat-accordion>
253255

src/app/component/activity-description/activity-description.component.spec.ts

+32-31
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('ActivityDescriptionComponent', () => {
2828
expect(component).toBeTruthy();
2929
});
3030

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

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

52-
it('check if description is being genenrated', () => {
52+
it('check if description is being generated', () => {
5353
const testDescription = 'Sample Description';
5454
component.currentActivity.description = testDescription;
5555
fixture.detectChanges();
5656
const HTMLElement: HTMLElement = fixture.nativeElement;
57-
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
58-
expect(contentDisplayedinParagraphTag[1].textContent).toContain(
57+
const contentDisplayedinParagraphTag =
58+
HTMLElement.querySelector('#description')!;
59+
expect(contentDisplayedinParagraphTag.textContent).toContain(
5960
testDescription
6061
);
6162
});
6263

63-
it('check if risk is being genenrated', () => {
64+
it('check if risk is being generated', () => {
6465
const testRisk = 'Sample Risk';
6566
component.currentActivity.risk = testRisk;
6667
fixture.detectChanges();
6768
const HTMLElement: HTMLElement = fixture.nativeElement;
68-
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
69-
expect(contentDisplayedinParagraphTag[2].textContent).toContain(testRisk);
69+
const contentDisplayedinParagraphTag = HTMLElement.querySelector('#risk')!;
70+
expect(contentDisplayedinParagraphTag.textContent).toContain(testRisk);
7071
});
7172

72-
it('check if measure is being genenrated', () => {
73+
it('check if measure is being generated', () => {
7374
const testMeasure = 'Sample Measure';
7475
component.currentActivity.measure = testMeasure;
7576
fixture.detectChanges();
7677
const HTMLElement: HTMLElement = fixture.nativeElement;
77-
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
78-
expect(contentDisplayedinParagraphTag[3].textContent).toContain(
79-
testMeasure
80-
);
78+
const contentDisplayedinParagraphTag =
79+
HTMLElement.querySelector('#measure')!;
80+
expect(contentDisplayedinParagraphTag.textContent).toContain(testMeasure);
8181
});
8282

83-
it('check if implementation guide is being genenrated', () => {
83+
it('check if implementation guide is being generated', () => {
8484
const testImplementationGuide = 'Sample Implementation Guide';
8585
component.currentActivity.implementatonGuide = testImplementationGuide;
8686
fixture.detectChanges();
8787
const HTMLElement: HTMLElement = fixture.nativeElement;
88-
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
89-
expect(contentDisplayedinParagraphTag[4].textContent).toContain(
88+
const contentDisplayedinParagraphTag = HTMLElement.querySelector(
89+
'#implementatonGuide'
90+
)!;
91+
expect(contentDisplayedinParagraphTag.textContent).toContain(
9092
testImplementationGuide
9193
);
9294
});
9395

94-
it('check if evidence is being genenrated', () => {
96+
it('check if evidence is being generated', () => {
9597
const testEvidence = 'Sample Evidence';
9698
component.currentActivity.evidence = testEvidence;
9799
fixture.detectChanges();
98100
const HTMLElement: HTMLElement = fixture.nativeElement;
99-
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
100-
expect(contentDisplayedinParagraphTag[7].textContent).toContain(
101-
testEvidence
102-
);
101+
const contentDisplayedinParagraphTag =
102+
HTMLElement.querySelector('#evidence')!;
103+
expect(contentDisplayedinParagraphTag.textContent).toContain(testEvidence);
103104
});
104105

105-
it('check if assessment is being genenrated', () => {
106+
it('check if assessment is being generated', () => {
106107
const testAssessment = 'Sample Assessment';
107108
component.currentActivity.assessment = testAssessment;
108109
fixture.detectChanges();
109110
const HTMLElement: HTMLElement = fixture.nativeElement;
110-
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
111-
expect(contentDisplayedinParagraphTag[8].textContent).toContain(
111+
const contentDisplayedinParagraphTag =
112+
HTMLElement.querySelector('#assessment')!;
113+
expect(contentDisplayedinParagraphTag.textContent).toContain(
112114
testAssessment
113115
);
114116
});
115117

116-
it('check if comments is being genenrated', () => {
118+
it('check if comments is being generated', () => {
117119
const testComments = 'Sample Comments';
118120
component.currentActivity.comments = testComments;
119121
fixture.detectChanges();
120122
const HTMLElement: HTMLElement = fixture.nativeElement;
121-
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
122-
expect(contentDisplayedinParagraphTag[11].textContent).toContain(
123-
testComments
124-
);
123+
const contentDisplayedinParagraphTag =
124+
HTMLElement.querySelector('#comments')!;
125+
expect(contentDisplayedinParagraphTag.textContent).toContain(testComments);
125126
});
126127

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

0 commit comments

Comments
 (0)