Skip to content

Commit 1fd197c

Browse files
feat: add basic testing for sites built from ghost and hashnode
1 parent c36cf8b commit 1fd197c

File tree

12 files changed

+878
-377
lines changed

12 files changed

+878
-377
lines changed

cypress/e2e/espanol/author/author.cy.ts

Lines changed: 185 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -26,165 +26,255 @@ const selectors = {
2626
x: {
2727
link: "[data-test-label='x-link']",
2828
icon: "[data-test-label='x-icon']"
29+
},
30+
github: {
31+
link: "[data-test-label='github-link']",
32+
icon: "[data-test-label='github-icon']"
2933
}
3034
}
3135
};
3236

33-
describe('Author page (Ghost sourced)', () => {
37+
describe('Author page', () => {
3438
before(() => {
3539
// Update baseUrl to include current language
3640
Cypress.config('baseUrl', 'http://localhost:8080/espanol/news/');
3741
});
3842

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+
});
4348

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+
});
4752

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+
});
5358

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+
});
5964

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+
});
6469

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+
});
6873

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+
});
7177
});
72-
});
7378

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+
});
7883

79-
it('should render', () => {
80-
cy.contains(selectors.authorName, 'Mrugesh Mohapatra');
81-
});
84+
it('should render', () => {
85+
cy.contains(selectors.authorName, 'Mrugesh Mohapatra');
86+
});
8287

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+
});
8893

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+
});
9197
});
92-
});
9398

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+
});
101106

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+
});
105111
});
106-
});
107112

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+
});
112117

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+
});
122128
});
123129
});
124-
});
125130

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+
});
131136

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+
});
135141
});
136-
});
137142

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+
});
141154
});
142155

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+
});
148180
});
149-
});
150181

151-
context('Website', () => {
152-
context('Author with no website link', () => {
182+
// Note: All authors should have an RSS link and icon
183+
context('RSS', () => {
153184
before(() => {
154185
cy.visit('/author/rafael/');
155186
});
156187

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');
160195
});
161196
});
197+
});
198+
});
199+
});
200+
201+
context('Hashnode sourced', () => {
202+
context('Author with profile image', () => {
203+
beforeEach(() => {
204+
cy.visit('/author/rafaeldavish/');
205+
});
162206

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', () => {
163234
context('Author with a website link', () => {
164235
before(() => {
165-
cy.visit('/author/freecodecamp/');
236+
cy.visit('/author/rafaeldavish/');
166237
});
167238

168239
it('should show a website link and icon', () => {
169240
cy.get(selectors.socialMedia.website.link)
170-
.should('have.attr', 'href', 'https://www.freecodecamp.org')
241+
.should('have.attr', 'href', 'https://rafaeldavis.dev')
171242
.find('svg')
172243
.should('have.attr', 'data-test-label', 'website-icon');
173244
});
174245
});
175246
});
176247

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+
177263
// Note: All authors should have an RSS link and icon
178264
context('RSS', () => {
179265
before(() => {
180-
cy.visit('/author/rafael/');
266+
cy.visit('/author/rafaeldavish/');
181267
});
182268

183269
// TODO: Links for RSS feeds are currently broken, so fix and test them in
184270
// a future PR
185271
it('should show an RSS link and icon', () => {
186272
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+
// )
188278
.find('svg')
189279
.should('have.attr', 'data-test-label', 'rss-icon');
190280
});

cypress/e2e/espanol/landing/i18n.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const selectors = {
3131
}
3232
};
3333

34-
describe('Landing i18n (Ghost sourced)', () => {
34+
describe('Landing i18n', () => {
3535
before(() => {
3636
// Update baseUrl to include current language
3737
Cypress.config('baseUrl', 'http://localhost:8080/espanol/news/');

cypress/e2e/espanol/landing/landing.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const selectors = {
1212
banner: "[data-test-label='banner']"
1313
};
1414

15-
describe('Landing (Ghost sourced)', () => {
15+
describe('Landing', () => {
1616
before(() => {
1717
// Update baseUrl to include current language
1818
Cypress.config('baseUrl', 'http://localhost:8080/espanol/news/');

cypress/e2e/espanol/landing/meta.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import commonExpectedMeta from '../../../fixtures/common-expected-meta.json';
22

3-
describe('Landing metadata (Ghost sourced)', () => {
3+
describe('Landing metadata', () => {
44
before(() => {
55
// Update baseUrl to include current language
66
Cypress.config('baseUrl', 'http://localhost:8080/espanol/news/');

0 commit comments

Comments
 (0)