Skip to content

Commit

Permalink
write banner tests
Browse files Browse the repository at this point in the history
  • Loading branch information
a2937 committed Aug 21, 2024
1 parent 133d090 commit ca5831b
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions cypress/e2e/english/landing/landing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const selectors = {
authorProfileImage: "[data-test-label='profile-image']",
avatar: "[data-test-label='avatar']",
siteNavLogo: "[data-test-label='site-nav-logo']",
postPublishedTime: "[data-test-label='post-published-time']"
postPublishedTime: "[data-test-label='post-published-time']",
banner: "[data-test-label='banner']"
};

describe('Landing', () => {
Expand Down Expand Up @@ -68,6 +69,55 @@ describe('Landing', () => {
.contains('title', 'Mrugesh Mohapatra');
});

it('the default banner text should be default if not authenticated', function () {
cy.get(selectors.banner).contains(
'Learn to code — free 3,000-hour curriculum'
);
});

it('the default banner text should link to the homepage', function () {
cy.get(selectors.banner)
.should('have.attr', 'href')
.should('equal', 'https://www.freecodecamp.org/');
});

it('the authenticated banner text should tell people to donate', function () {
cy.setCookie('jwt_access_token', 'dadadsdadsadasd');
cy.visit('/');
cy.get(selectors.banner).contains(
'Support our charity and our mission. Donate to freeCodeCamp.org.'
);
});

it('the authenticated banner link should link to the donate page', function () {
cy.setCookie('jwt_access_token', 'dadadsdadsadasd');
cy.visit('/');
cy.get(selectors.banner)
.should('have.attr', 'href')
.should('equal', 'https://www.freecodecamp.org/donate');
});

it('the donor banner text should thank people', function () {
cy.setCookie('jwt_access_token', 'dadadsdadsadasd');
cy.setCookie('isDonor', 'true');
cy.visit('/');
cy.get(selectors.banner).contains(
'Thank you for supporting freeCodeCamp through your donations.'
);
});

it('the donor banner should link to how to donate', function () {
cy.setCookie('jwt_access_token', 'dadadsdadsadasd');
cy.setCookie('isDonor', 'true');
cy.visit('/');
cy.get(selectors.banner)
.should('have.attr', 'href')
.should(
'equal',
'https://www.freecodecamp.org/news/how-to-donate-to-free-code-camp/'
);
});

it("posts written by 'freeCodeCamp.org' should not show the `author-list`, which contain's the author's name and profile image", () => {
cy.get(selectors.postCard)
.contains('Common Technical Support Questions – freeCodeCamp FAQ')
Expand All @@ -81,7 +131,6 @@ describe('Landing', () => {

cy.get(selectors.featureImage).should('have.length', numberOfPosts);
});

// Note: Remove this testing block once we migrate all posts to Hashnode
context('Duplicate slugs', () => {
it('should render the older Ghost-sourced post', () => {
Expand Down

0 comments on commit ca5831b

Please sign in to comment.