Skip to content

Commit 1913192

Browse files
authored
[ENG-10697] Update unique locators for search page (#937)
- Ticket: [[ENG-10697]](https://openscience.atlassian.net/browse/ENG-10697) - Feature flag: n/a ## Summary of Changes 1. Added data attributes for search page.
1 parent 679b0e1 commit 1913192

12 files changed

Lines changed: 291 additions & 83 deletions

File tree

src/app/shared/components/data-resources/data-resources.component.html

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
<div class="flex" [class]="vertical() ? 'flex-column row-gap-2 min-w-max' : 'column-gap-5 row-gap-3 flex-wrap'">
2-
<a class="icon-container" [href]="resourceUrl()" target="_blank" rel="noopener noreferrer">
2+
<a
3+
class="icon-container"
4+
[href]="resourceUrl()"
5+
target="_blank"
6+
rel="noopener noreferrer"
7+
data-test-data-resources-data-link
8+
>
39
<osf-icon
410
[iconClass]="hasData() ? 'custom-icon-data icon-resource-size' : 'custom-icon-data-dark icon-resource-size'"
511
></osf-icon>
612
<p>{{ 'resourceCard.resources.data' | translate }}</p>
713
</a>
814

9-
<a class="icon-container" [href]="resourceUrl()" target="_blank" rel="noopener noreferrer">
15+
<a
16+
class="icon-container"
17+
[href]="resourceUrl()"
18+
target="_blank"
19+
rel="noopener noreferrer"
20+
data-test-data-resources-analytic-code-link
21+
>
1022
<osf-icon
1123
[iconClass]="
1224
hasAnalyticCode() ? 'custom-icon-code icon-resource-size' : 'custom-icon-code-dark icon-resource-size'
@@ -15,7 +27,13 @@
1527
<p>{{ 'resourceCard.resources.analyticCode' | translate }}</p>
1628
</a>
1729

18-
<a class="icon-container" [href]="resourceUrl()" target="_blank" rel="noopener noreferrer">
30+
<a
31+
class="icon-container"
32+
[href]="resourceUrl()"
33+
target="_blank"
34+
rel="noopener noreferrer"
35+
data-test-data-resources-materials-link
36+
>
1937
<osf-icon
2038
[iconClass]="
2139
hasMaterials() ? 'custom-icon-materials icon-resource-size' : 'custom-icon-materials-dark icon-resource-size'
@@ -24,14 +42,26 @@
2442
<p>{{ 'resourceCard.resources.materials' | translate }}</p>
2543
</a>
2644

27-
<a class="icon-container" [href]="resourceUrl()" target="_blank" rel="noopener noreferrer">
45+
<a
46+
class="icon-container"
47+
[href]="resourceUrl()"
48+
target="_blank"
49+
rel="noopener noreferrer"
50+
data-test-data-resources-papers-link
51+
>
2852
<osf-icon
2953
[iconClass]="hasPapers() ? 'custom-icon-papers icon-resource-size' : 'custom-icon-papers-dark icon-resource-size'"
3054
/>
3155
<p>{{ 'resourceCard.resources.papers' | translate }}</p>
3256
</a>
3357

34-
<a class="icon-container" [href]="resourceUrl()" target="_blank" rel="noopener noreferrer">
58+
<a
59+
class="icon-container"
60+
[href]="resourceUrl()"
61+
target="_blank"
62+
rel="noopener noreferrer"
63+
data-test-data-resources-supplements-link
64+
>
3565
<osf-icon
3666
[iconClass]="
3767
hasSupplements()

src/app/shared/components/resource-card/components/file-secondary-metadata/file-secondary-metadata.component.html

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,90 @@
11
<div class="flex flex-column gap-2">
22
@let resourceValue = resource();
33
@if (resourceValue.description) {
4-
<p>{{ 'resourceCard.labels.description' | translate }} {{ resourceValue.description }}</p>
4+
<p data-test-search-result-card-file-description>
5+
{{ 'resourceCard.labels.description' | translate }} {{ resourceValue.description }}
6+
</p>
57
}
68

79
@let limit = 4;
810
@let nodeFunders = resourceValue.isContainedBy?.funders;
911
@if (nodeFunders && nodeFunders.length > 0) {
10-
<p>
12+
<p data-test-search-result-card-file-funders>
1113
{{ 'resourceCard.labels.funder' | translate }}
1214
@for (funder of nodeFunders.slice(0, limit); track $index) {
13-
<a class="font-bold" [href]="funder.absoluteUrl" target="_blank" rel="noopener noreferrer">
15+
<a
16+
class="font-bold"
17+
[href]="funder.absoluteUrl"
18+
target="_blank"
19+
rel="noopener noreferrer"
20+
data-test-search-result-card-file-funder-link
21+
>
1422
{{ funder.name }}{{ $last ? '' : ', ' }}
1523
</a>
1624
}
1725
@if (nodeFunders.length > limit) {
18-
<span>{{ 'resourceCard.andCountMore' | translate: { count: nodeFunders.length - limit } }} </span>
26+
<span data-test-search-result-card-file-funders-more>
27+
{{ 'resourceCard.andCountMore' | translate: { count: nodeFunders.length - limit } }}
28+
</span>
1929
}
2030
</p>
2131
}
2232

2333
@if (resourceValue.resourceNature) {
24-
<p>{{ 'resourceCard.labels.resourceNature' | translate }} {{ resourceValue.resourceNature }}</p>
34+
<p data-test-search-result-card-file-resource-nature>
35+
{{ 'resourceCard.labels.resourceNature' | translate }} {{ resourceValue.resourceNature }}
36+
</p>
2537
}
2638

2739
@let nodeLicense = resourceValue.isContainedBy?.license;
2840
@if (nodeLicense) {
29-
<p>
41+
<p data-test-search-result-card-file-license>
3042
{{ 'common.labels.license' | translate }}:
31-
<a class="font-bold" [attr.href]="nodeLicense!.absoluteUrl || null" target="_blank" rel="noopener noreferrer">
43+
<a
44+
class="font-bold"
45+
[attr.href]="nodeLicense!.absoluteUrl || null"
46+
target="_blank"
47+
rel="noopener noreferrer"
48+
data-test-search-result-card-file-license-link
49+
>
3250
{{ nodeLicense!.name }}
3351
</a>
3452
</p>
3553
}
3654

3755
@if (resourceValue.absoluteUrl) {
38-
<p>
56+
<p data-test-search-result-card-file-url>
3957
{{ 'resourceCard.labels.url' | translate }}
40-
<a class="font-bold" [href]="resourceValue.absoluteUrl" target="_blank" rel="noopener noreferrer">
58+
<a
59+
class="font-bold"
60+
[href]="resourceValue.absoluteUrl"
61+
target="_blank"
62+
rel="noopener noreferrer"
63+
data-test-search-result-card-file-resource-url-link
64+
>
4165
{{ resourceValue.absoluteUrl }}
4266
</a>
4367
</p>
4468
}
4569

4670
@if (resourceValue.doi.length > 0) {
47-
<p>
71+
<p data-test-search-result-card-file-doi>
4872
{{ 'resourceCard.labels.doi' | translate }}
4973
@for (doi of resourceValue.doi.slice(0, limit); track $index) {
50-
<a class="font-bold" [href]="doi" target="_blank" rel="noopener noreferrer">{{ doi }}{{ $last ? '' : ', ' }}</a>
74+
<a
75+
class="font-bold"
76+
[href]="doi"
77+
target="_blank"
78+
rel="noopener noreferrer"
79+
data-test-search-result-card-file-doi-link
80+
>
81+
{{ doi }}{{ $last ? '' : ', ' }}
82+
</a>
5183
}
5284
@if (resourceValue.doi.length > limit) {
53-
<span>{{ 'resourceCard.andCountMore' | translate: { count: resourceValue.doi.length - limit } }} </span>
85+
<span data-test-search-result-card-file-doi-more>
86+
{{ 'resourceCard.andCountMore' | translate: { count: resourceValue.doi.length - limit } }}
87+
</span>
5488
}
5589
</p>
5690
}

src/app/shared/components/resource-card/components/preprint-secondary-metadata/preprint-secondary-metadata.component.html

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,132 @@
11
<div class="flex flex-column gap-2">
22
@let resourceValue = resource();
33
@if (resourceValue.description) {
4-
<p>{{ 'resourceCard.labels.description' | translate }} {{ resourceValue.description }}</p>
4+
<p data-test-search-result-card-preprint-description>
5+
{{ 'resourceCard.labels.description' | translate }} {{ resourceValue.description }}
6+
</p>
57
}
68

79
@if (resourceValue.provider) {
8-
<p>
10+
<p data-test-search-result-card-preprint-provider>
911
{{ 'resourceCard.labels.provider' | translate }}
10-
<a class="font-bold" [href]="resourceValue.provider!.absoluteUrl" target="_blank" rel="noopener noreferrer">
12+
<a
13+
class="font-bold"
14+
[href]="resourceValue.provider!.absoluteUrl"
15+
target="_blank"
16+
rel="noopener noreferrer"
17+
data-test-search-result-card-preprint-provider-link
18+
>
1119
{{ resourceValue.provider!.name }}
1220
</a>
1321
</p>
1422
}
1523

1624
@if (resourceValue.hasDataResource) {
17-
<p>
25+
<p data-test-search-result-card-preprint-associated-data>
1826
{{ 'resourceCard.labels.associatedData' | translate }}
19-
<a class="font-bold" [href]="resourceValue.hasDataResource" target="_blank" rel="noopener noreferrer">
27+
<a
28+
class="font-bold"
29+
[href]="resourceValue.hasDataResource"
30+
target="_blank"
31+
rel="noopener noreferrer"
32+
data-test-search-result-card-preprint-associated-data-link
33+
>
2034
{{ resourceValue.hasDataResource }}
2135
</a>
2236
</p>
2337
}
2438

2539
@if (resourceValue.hasPreregisteredAnalysisPlan) {
26-
<p>
40+
<p data-test-search-result-card-preprint-associated-analysis-plan>
2741
{{ 'resourceCard.labels.associatedAnalysisPlan' | translate }}
2842
<a
2943
class="font-bold"
3044
[href]="resourceValue.hasPreregisteredAnalysisPlan"
3145
target="_blank"
3246
rel="noopener noreferrer"
47+
data-test-search-result-card-preprint-associated-analysis-plan-link
3348
>
3449
{{ resourceValue.hasPreregisteredAnalysisPlan }}
3550
</a>
3651
</p>
3752
}
3853

3954
@if (resourceValue.hasPreregisteredStudyDesign) {
40-
<p>
55+
<p data-test-search-result-card-preprint-associated-study-design>
4156
{{ 'resourceCard.labels.associatedStudyDesign' | translate }}
42-
<a class="font-bold" [href]="resourceValue.hasPreregisteredStudyDesign" target="_blank" rel="noopener noreferrer">
57+
<a
58+
class="font-bold"
59+
[href]="resourceValue.hasPreregisteredStudyDesign"
60+
target="_blank"
61+
rel="noopener noreferrer"
62+
data-test-search-result-card-preprint-associated-study-design-link
63+
>
4364
{{ resourceValue.hasPreregisteredStudyDesign }}
4465
</a>
4566
</p>
4667
}
4768

4869
@if (resourceValue.statedConflictOfInterest) {
49-
<p>
70+
<p data-test-search-result-card-preprint-conflict-of-interest>
5071
{{ 'resourceCard.labels.conflictOfInterestResponse' | translate }}
5172
{{ resourceValue.statedConflictOfInterest }}
5273
</p>
5374
} @else {
54-
<p>
75+
<p data-test-search-result-card-preprint-conflict-of-interest-none>
5576
{{ 'resourceCard.labels.conflictOfInterestResponse' | translate }}
5677
{{ 'resourceCard.labels.noCoi' | translate }}
5778
</p>
5879
}
5980

6081
@if (resourceValue.license?.absoluteUrl) {
61-
<p>
82+
<p data-test-search-result-card-preprint-license>
6283
{{ 'common.labels.license' | translate }}:
6384
<a
6485
class="font-bold"
6586
[attr.href]="resourceValue.license!.absoluteUrl || null"
6687
target="_blank"
6788
rel="noopener noreferrer"
89+
data-test-search-result-card-preprint-license-link
6890
>
6991
{{ resourceValue.license!.name }}
7092
</a>
7193
</p>
7294
}
7395

7496
@if (resourceValue.absoluteUrl) {
75-
<p>
97+
<p data-test-search-result-card-preprint-url>
7698
{{ 'resourceCard.labels.url' | translate }}
77-
<a class="font-bold" [href]="resourceValue.absoluteUrl" target="_blank" rel="noopener noreferrer">
99+
<a
100+
class="font-bold"
101+
[href]="resourceValue.absoluteUrl"
102+
target="_blank"
103+
rel="noopener noreferrer"
104+
data-test-search-result-card-preprint-resource-url-link
105+
>
78106
{{ resourceValue.absoluteUrl }}
79107
</a>
80108
</p>
81109
}
82110

83111
@let limit = 4;
84112
@if (resourceValue.doi.length > 0) {
85-
<p>
113+
<p data-test-search-result-card-preprint-doi>
86114
{{ 'resourceCard.labels.doi' | translate }}
87115
@for (doi of resourceValue.doi.slice(0, limit); track $index) {
88-
<a class="font-bold" [href]="doi" target="_blank" rel="noopener noreferrer">{{ doi }}{{ $last ? '' : ', ' }}</a>
116+
<a
117+
class="font-bold"
118+
[href]="doi"
119+
target="_blank"
120+
rel="noopener noreferrer"
121+
data-test-search-result-card-preprint-doi-link
122+
>
123+
{{ doi }}{{ $last ? '' : ', ' }}
124+
</a>
89125
}
90126
@if (resourceValue.doi.length > limit) {
91-
<span>{{ 'resourceCard.andCountMore' | translate: { count: resourceValue.doi.length - limit } }} </span>
127+
<span data-test-search-result-card-preprint-doi-more>
128+
{{ 'resourceCard.andCountMore' | translate: { count: resourceValue.doi.length - limit } }}
129+
</span>
92130
}
93131
</p>
94132
}

0 commit comments

Comments
 (0)