@@ -26,165 +26,255 @@ const selectors = {
26
26
x : {
27
27
link : "[data-test-label='x-link']" ,
28
28
icon : "[data-test-label='x-icon']"
29
+ } ,
30
+ github : {
31
+ link : "[data-test-label='github-link']" ,
32
+ icon : "[data-test-label='github-icon']"
29
33
}
30
34
}
31
35
} ;
32
36
33
- describe ( 'Author page (Ghost sourced) ' , ( ) => {
37
+ describe ( 'Author page' , ( ) => {
34
38
before ( ( ) => {
35
39
// Update baseUrl to include current language
36
40
Cypress . config ( 'baseUrl' , 'http://localhost:8080/espanol/news/' ) ;
37
41
} ) ;
38
42
39
- context ( 'Author with profile image' , ( ) => {
40
- beforeEach ( ( ) => {
41
- cy . visit ( '/author/rafael/' ) ;
42
- } ) ;
43
+ context ( 'Ghost sourced' , ( ) => {
44
+ context ( 'Author with profile image' , ( ) => {
45
+ beforeEach ( ( ) => {
46
+ cy . visit ( '/author/rafael/' ) ;
47
+ } ) ;
43
48
44
- it ( 'should render' , ( ) => {
45
- cy . contains ( selectors . authorName , 'Rafael D. Hernandez' ) ;
46
- } ) ;
49
+ it ( 'should render' , ( ) => {
50
+ cy . contains ( selectors . authorName , 'Rafael D. Hernandez' ) ;
51
+ } ) ;
47
52
48
- it ( "should show the author's profile image" , ( ) => {
49
- cy . get ( selectors . authorProfileImage ) . then ( $el =>
50
- expect ( $el [ 0 ] . tagName . toLowerCase ( ) ) . to . equal ( 'img' )
51
- ) ;
52
- } ) ;
53
+ it ( "should show the author's profile image" , ( ) => {
54
+ cy . get ( selectors . authorProfileImage ) . then ( $el =>
55
+ expect ( $el [ 0 ] . tagName . toLowerCase ( ) ) . to . equal ( 'img' )
56
+ ) ;
57
+ } ) ;
53
58
54
- it ( "the author profile image should contain an `alt` attribute with the author's name" , ( ) => {
55
- cy . get < HTMLImageElement > ( selectors . authorProfileImage ) . then ( $el =>
56
- expect ( $el [ 0 ] . alt ) . to . equal ( 'Rafael D. Hernandez' )
57
- ) ;
58
- } ) ;
59
+ it ( "the author profile image should contain an `alt` attribute with the author's name" , ( ) => {
60
+ cy . get < HTMLImageElement > ( selectors . authorProfileImage ) . then ( $el =>
61
+ expect ( $el [ 0 ] . alt ) . to . equal ( 'Rafael D. Hernandez' )
62
+ ) ;
63
+ } ) ;
59
64
60
- it ( "should show the author's location and post count on larger screens" , ( ) => {
61
- cy . get ( selectors . authorLocation ) . should ( 'be.visible' ) ;
62
- cy . get ( selectors . authorPostCount ) . should ( 'be.visible' ) ;
63
- } ) ;
65
+ it ( "should show the author's location and post count on larger screens" , ( ) => {
66
+ cy . get ( selectors . authorLocation ) . should ( 'be.visible' ) ;
67
+ cy . get ( selectors . authorPostCount ) . should ( 'be.visible' ) ;
68
+ } ) ;
64
69
65
- it ( `should show 18 posts on load` , ( ) => {
66
- getPostCards ( ) . should ( 'have.length' , 18 ) ;
67
- } ) ;
70
+ it ( `should show 18 posts on load` , ( ) => {
71
+ getPostCards ( ) . should ( 'have.length' , 18 ) ;
72
+ } ) ;
68
73
69
- it ( 'should show the correct number of total posts' , ( ) => {
70
- loadAndCountAllPostCards ( selectors . authorPostCount ) ;
74
+ it ( 'should show the correct number of total posts' , ( ) => {
75
+ loadAndCountAllPostCards ( selectors . authorPostCount ) ;
76
+ } ) ;
71
77
} ) ;
72
- } ) ;
73
78
74
- context ( 'Author with no profile image' , ( ) => {
75
- beforeEach ( ( ) => {
76
- cy . visit ( '/author/mrugesh/' ) ;
77
- } ) ;
79
+ context ( 'Author with no profile image' , ( ) => {
80
+ beforeEach ( ( ) => {
81
+ cy . visit ( '/author/mrugesh/' ) ;
82
+ } ) ;
78
83
79
- it ( 'should render' , ( ) => {
80
- cy . contains ( selectors . authorName , 'Mrugesh Mohapatra' ) ;
81
- } ) ;
84
+ it ( 'should render' , ( ) => {
85
+ cy . contains ( selectors . authorName , 'Mrugesh Mohapatra' ) ;
86
+ } ) ;
82
87
83
- it ( 'should show the avatar SVG' , ( ) => {
84
- cy . get ( selectors . avatar ) . then ( $el =>
85
- expect ( $el [ 0 ] . tagName . toLowerCase ( ) ) . to . equal ( 'svg' )
86
- ) ;
87
- } ) ;
88
+ it ( 'should show the avatar SVG' , ( ) => {
89
+ cy . get ( selectors . avatar ) . then ( $el =>
90
+ expect ( $el [ 0 ] . tagName . toLowerCase ( ) ) . to . equal ( 'svg' )
91
+ ) ;
92
+ } ) ;
88
93
89
- it ( "the avatar SVG should contain a `title` element with the author's name" , ( ) => {
90
- cy . get ( selectors . avatar ) . contains ( 'title' , 'Mrugesh Mohapatra' ) ;
94
+ it ( "the avatar SVG should contain a `title` element with the author's name" , ( ) => {
95
+ cy . get ( selectors . avatar ) . contains ( 'title' , 'Mrugesh Mohapatra' ) ;
96
+ } ) ;
91
97
} ) ;
92
- } ) ;
93
98
94
- context ( 'Social media' , ( ) => {
95
- // Note: Ghost only supports links to Facebook, Twitter, and websites
96
- context ( 'Facebook' , ( ) => {
97
- context ( 'An author with no Facebook profile link' , ( ) => {
98
- before ( ( ) => {
99
- cy . visit ( '/author/rafael/' ) ;
100
- } ) ;
99
+ context ( 'Social media' , ( ) => {
100
+ // Note: Ghost only supports links to Facebook, Twitter, and websites
101
+ context ( 'Facebook' , ( ) => {
102
+ context ( 'An author with no Facebook profile link' , ( ) => {
103
+ before ( ( ) => {
104
+ cy . visit ( '/author/rafael/' ) ;
105
+ } ) ;
101
106
102
- it ( 'should not show an X link and icon' , ( ) => {
103
- cy . get ( selectors . socialMedia . facebook . link ) . should ( 'not.exist' ) ;
104
- cy . get ( selectors . socialMedia . facebook . icon ) . should ( 'not.exist' ) ;
107
+ it ( 'should not show an X link and icon' , ( ) => {
108
+ cy . get ( selectors . socialMedia . facebook . link ) . should ( 'not.exist' ) ;
109
+ cy . get ( selectors . socialMedia . facebook . icon ) . should ( 'not.exist' ) ;
110
+ } ) ;
105
111
} ) ;
106
- } ) ;
107
112
108
- context ( 'An author with a Facebook profile link' , ( ) => {
109
- before ( ( ) => {
110
- cy . visit ( '/author/freecodecamp/' ) ;
111
- } ) ;
113
+ context ( 'An author with a Facebook profile link' , ( ) => {
114
+ before ( ( ) => {
115
+ cy . visit ( '/author/freecodecamp/' ) ;
116
+ } ) ;
112
117
113
- it ( 'should show a Facebook link and icon' , ( ) => {
114
- cy . get ( selectors . socialMedia . facebook . link )
115
- . should (
116
- 'have.attr' ,
117
- 'href' ,
118
- 'https://www.facebook.com/freecodecamp'
119
- )
120
- . find ( 'svg' )
121
- . should ( 'have.attr' , 'data-test-label' , 'facebook-icon' ) ;
118
+ it ( 'should show a Facebook link and icon' , ( ) => {
119
+ cy . get ( selectors . socialMedia . facebook . link )
120
+ . should (
121
+ 'have.attr' ,
122
+ 'href' ,
123
+ 'https://www.facebook.com/freecodecamp'
124
+ )
125
+ . find ( 'svg' )
126
+ . should ( 'have.attr' , 'data-test-label' , 'facebook-icon' ) ;
127
+ } ) ;
122
128
} ) ;
123
129
} ) ;
124
- } ) ;
125
130
126
- context ( 'Twitter' , ( ) => {
127
- context ( 'Author with no Twitter profile link' , ( ) => {
128
- before ( ( ) => {
129
- cy . visit ( '/author/mrugesh/' ) ;
130
- } ) ;
131
+ context ( 'Twitter' , ( ) => {
132
+ context ( 'Author with no Twitter profile link' , ( ) => {
133
+ before ( ( ) => {
134
+ cy . visit ( '/author/mrugesh/' ) ;
135
+ } ) ;
131
136
132
- it ( 'should not show an X link and icon' , ( ) => {
133
- cy . get ( selectors . socialMedia . x . link ) . should ( 'not.exist' ) ;
134
- cy . get ( selectors . socialMedia . x . icon ) . should ( 'not.exist' ) ;
137
+ it ( 'should not show an X link and icon' , ( ) => {
138
+ cy . get ( selectors . socialMedia . x . link ) . should ( 'not.exist' ) ;
139
+ cy . get ( selectors . socialMedia . x . icon ) . should ( 'not.exist' ) ;
140
+ } ) ;
135
141
} ) ;
136
- } ) ;
137
142
138
- context ( 'Author with a Twitter profile link' , ( ) => {
139
- before ( ( ) => {
140
- cy . visit ( '/author/rafael/' ) ;
143
+ context ( 'Author with a Twitter profile link' , ( ) => {
144
+ before ( ( ) => {
145
+ cy . visit ( '/author/rafael/' ) ;
146
+ } ) ;
147
+
148
+ it ( 'should show an X link and icon' , ( ) => {
149
+ cy . get ( selectors . socialMedia . x . link )
150
+ . should ( 'have.attr' , 'href' , 'https://x.com/RafaelDavisH' )
151
+ . find ( 'svg' )
152
+ . should ( 'have.attr' , 'data-test-label' , 'x-icon' ) ;
153
+ } ) ;
141
154
} ) ;
142
155
143
- it ( 'should show an X link and icon' , ( ) => {
144
- cy . get ( selectors . socialMedia . x . link )
145
- . should ( 'have.attr' , 'href' , 'https://x.com/RafaelDavisH' )
146
- . find ( 'svg' )
147
- . should ( 'have.attr' , 'data-test-label' , 'x-icon' ) ;
156
+ context ( 'Website' , ( ) => {
157
+ context ( 'Author with no website link' , ( ) => {
158
+ before ( ( ) => {
159
+ cy . visit ( '/author/rafael/' ) ;
160
+ } ) ;
161
+
162
+ it ( 'should not show a website link and icon' , ( ) => {
163
+ cy . get ( selectors . socialMedia . website . link ) . should ( 'not.exist' ) ;
164
+ cy . get ( selectors . socialMedia . website . icon ) . should ( 'not.exist' ) ;
165
+ } ) ;
166
+ } ) ;
167
+
168
+ context ( 'Author with a website link' , ( ) => {
169
+ before ( ( ) => {
170
+ cy . visit ( '/author/freecodecamp/' ) ;
171
+ } ) ;
172
+
173
+ it ( 'should show a website link and icon' , ( ) => {
174
+ cy . get ( selectors . socialMedia . website . link )
175
+ . should ( 'have.attr' , 'href' , 'https://www.freecodecamp.org' )
176
+ . find ( 'svg' )
177
+ . should ( 'have.attr' , 'data-test-label' , 'website-icon' ) ;
178
+ } ) ;
179
+ } ) ;
148
180
} ) ;
149
- } ) ;
150
181
151
- context ( 'Website' , ( ) => {
152
- context ( 'Author with no website link ' , ( ) => {
182
+ // Note: All authors should have an RSS link and icon
183
+ context ( 'RSS ' , ( ) => {
153
184
before ( ( ) => {
154
185
cy . visit ( '/author/rafael/' ) ;
155
186
} ) ;
156
187
157
- it ( 'should not show a website link and icon' , ( ) => {
158
- cy . get ( selectors . socialMedia . website . link ) . should ( 'not.exist' ) ;
159
- cy . get ( selectors . socialMedia . website . icon ) . should ( 'not.exist' ) ;
188
+ // TODO: Links for RSS feeds are currently broken, so fix and test them in
189
+ // a future PR
190
+ it ( 'should show an RSS link and icon' , ( ) => {
191
+ cy . get ( selectors . socialMedia . rss . link )
192
+ // .should('have.attr', 'href', 'https://feedly.com/i/subscription/feed/http://localhost:8080/news/author/rafael/rss/')
193
+ . find ( 'svg' )
194
+ . should ( 'have.attr' , 'data-test-label' , 'rss-icon' ) ;
160
195
} ) ;
161
196
} ) ;
197
+ } ) ;
198
+ } ) ;
199
+ } ) ;
200
+
201
+ context ( 'Hashnode sourced' , ( ) => {
202
+ context ( 'Author with profile image' , ( ) => {
203
+ beforeEach ( ( ) => {
204
+ cy . visit ( '/author/rafaeldavish/' ) ;
205
+ } ) ;
162
206
207
+ it ( 'should render' , ( ) => {
208
+ cy . contains ( selectors . authorName , 'Rafael D. Hernandez' ) ;
209
+ } ) ;
210
+
211
+ it ( "should show the author's profile image" , ( ) => {
212
+ cy . get ( selectors . authorProfileImage ) . then ( $el =>
213
+ expect ( $el [ 0 ] . tagName . toLowerCase ( ) ) . to . equal ( 'img' )
214
+ ) ;
215
+ } ) ;
216
+
217
+ it ( "the author profile image should contain an `alt` attribute with the author's name" , ( ) => {
218
+ cy . get < HTMLImageElement > ( selectors . authorProfileImage ) . then ( $el =>
219
+ expect ( $el [ 0 ] . alt ) . to . equal ( 'Rafael D. Hernandez' )
220
+ ) ;
221
+ } ) ;
222
+
223
+ it ( `should show 2 posts on load` , ( ) => {
224
+ getPostCards ( ) . should ( 'have.length' , 2 ) ;
225
+ } ) ;
226
+
227
+ it ( 'should show the correct number of total posts' , ( ) => {
228
+ loadAndCountAllPostCards ( selectors . authorPostCount ) ;
229
+ } ) ;
230
+ } ) ;
231
+
232
+ context ( 'Social media' , ( ) => {
233
+ context ( 'Website' , ( ) => {
163
234
context ( 'Author with a website link' , ( ) => {
164
235
before ( ( ) => {
165
- cy . visit ( '/author/freecodecamp /' ) ;
236
+ cy . visit ( '/author/rafaeldavish /' ) ;
166
237
} ) ;
167
238
168
239
it ( 'should show a website link and icon' , ( ) => {
169
240
cy . get ( selectors . socialMedia . website . link )
170
- . should ( 'have.attr' , 'href' , 'https://www.freecodecamp.org ' )
241
+ . should ( 'have.attr' , 'href' , 'https://rafaeldavis.dev ' )
171
242
. find ( 'svg' )
172
243
. should ( 'have.attr' , 'data-test-label' , 'website-icon' ) ;
173
244
} ) ;
174
245
} ) ;
175
246
} ) ;
176
247
248
+ context ( 'GitHub' , ( ) => {
249
+ context ( 'Author with a GitHub profile link' , ( ) => {
250
+ before ( ( ) => {
251
+ cy . visit ( '/author/rafaeldavish/' ) ;
252
+ } ) ;
253
+
254
+ it ( 'should show a GitHub link and icon' , ( ) => {
255
+ cy . get ( selectors . socialMedia . github . link )
256
+ . should ( 'have.attr' , 'href' , 'https://github.com/RafaelDavisH' )
257
+ . find ( 'svg' )
258
+ . should ( 'have.attr' , 'data-test-label' , 'github-icon' ) ;
259
+ } ) ;
260
+ } ) ;
261
+ } ) ;
262
+
177
263
// Note: All authors should have an RSS link and icon
178
264
context ( 'RSS' , ( ) => {
179
265
before ( ( ) => {
180
- cy . visit ( '/author/rafael /' ) ;
266
+ cy . visit ( '/author/rafaeldavish /' ) ;
181
267
} ) ;
182
268
183
269
// TODO: Links for RSS feeds are currently broken, so fix and test them in
184
270
// a future PR
185
271
it ( 'should show an RSS link and icon' , ( ) => {
186
272
cy . get ( selectors . socialMedia . rss . link )
187
- // .should('have.attr', 'href', 'https://feedly.com/i/subscription/feed/http://localhost:8080/news/author/rafael/rss/')
273
+ // .should(
274
+ // 'have.attr',
275
+ // 'href',
276
+ // 'https://feedly.com/i/subscription/feed/http://localhost:8080/news/author/rafaeldavish/rss/'
277
+ // )
188
278
. find ( 'svg' )
189
279
. should ( 'have.attr' , 'data-test-label' , 'rss-icon' ) ;
190
280
} ) ;
0 commit comments