Skip to content

Commit

Permalink
Webinars ad banner cypress tests and fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
wpalani committed Oct 29, 2023
1 parent 0455430 commit 6ca6cf0
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/components/webinars-banner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ const WebinarsBanner = () => {
</div>

<div className="nfd-flex nfd-flex-col nfd-gap-4 nfd-w-full">
<Title as="h3" className="nfd-text-base">FREE Monthly Webinar: {nextWebinar.title}</Title>
<Title as="h2" className="nfd-text-base">FREE Monthly Webinar: {nextWebinar.title}</Title>

{(nextWebinar.hasDescription || nextWebinar.hasTopics) &&
<div>
{nextWebinar.description && <p className="nfd-mb-1.5">{nextWebinar.description}</p>}
{nextWebinar.topics &&
<>
<Title as="h5">Topics:</Title>
<Title as="h3" size="5">Topics:</Title>
<ul className="nfd-list-none nfd-list-inside nfd-flex nfd-flex-wrap nfd-gap-x-4 nfd-row-gap-2 nfd-mt-2 nfd-pr-2">
{nextWebinar.topics.map((topic, index) => <WebinarListItem key={index}>{topic}</WebinarListItem>)}
</ul>
Expand Down
40 changes: 40 additions & 0 deletions tests/cypress/fixtures/webinars-inactive.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"items": [
{
"title": "Maximize Productivity with Time Management",
"description" : "Phasellus sagittis gravida molestie. Vivamus dictum, massa luctus tempus imperdiet, ligula leo ultrices purus, sit amet consectetur ligula turpis non nisi.",
"date": "November 15, 2022",
"time": "2pm - 3pm EST",
"ctaText": "Sign Up Today",
"link": "https://www.bluehost.com/blog/events/how-to-start-with-seo-yoast/"
},
{
"title": "Build your brand with WordPress",
"description": "Join us for a free webinar on how to build your brand with WordPress.",
"topics": [
"Explore SEO and WordPress",
"Gain valuable tips for building your brand",
"Content marketing",
"eCommerce integration"
],
"date": "August 31, 2040",
"time": "1pm - 2pm EST",
"ctaText": "Register Now",
"link": "https://www.bluehost.com/blog/events/next-event-post"
},
{
"title": "Mastering the Art of Public Speaking",
"topics": [
"Overcoming stage fright and nervousness",
"Crafting compelling speeches and presentations",
"Engaging your audience effectively",
"Tips for confident and impactful public speaking"
],
"date": "December 10, 2050",
"time": "3pm - 4pm EST",
"ctaText": "Enroll Now",
"link": "https://www.bluehost.com/blog/events/yoast-seo-news-october-edition/"
}
],
"isActive": false
}
40 changes: 40 additions & 0 deletions tests/cypress/fixtures/webinars-past.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"items": [
{
"title": "Maximize Productivity with Time Management",
"description" : "Phasellus sagittis gravida molestie. Vivamus dictum, massa luctus tempus imperdiet, ligula leo ultrices purus, sit amet consectetur ligula turpis non nisi.",
"date": "November 15, 2022",
"time": "2pm - 3pm EST",
"ctaText": "Sign Up Today",
"link": "https://www.bluehost.com/blog/events/how-to-start-with-seo-yoast/"
},
{
"title": "Build your brand with WordPress",
"description": "Join us for a free webinar on how to build your brand with WordPress.",
"topics": [
"Explore SEO and WordPress",
"Gain valuable tips for building your brand",
"Content marketing",
"eCommerce integration"
],
"date": "August 31, 2022",
"time": "1pm - 2pm EST",
"ctaText": "Register Now",
"link": "https://www.bluehost.com/blog/events/next-event-post"
},
{
"title": "Mastering the Art of Public Speaking",
"topics": [
"Overcoming stage fright and nervousness",
"Crafting compelling speeches and presentations",
"Engaging your audience effectively",
"Tips for confident and impactful public speaking"
],
"date": "December 10, 2022",
"time": "3pm - 4pm EST",
"ctaText": "Enroll Now",
"link": "https://www.bluehost.com/blog/events/yoast-seo-news-october-edition/"
}
],
"isActive": true
}
40 changes: 40 additions & 0 deletions tests/cypress/fixtures/webinars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"items": [
{
"title": "Maximize Productivity with Time Management",
"description" : "Phasellus sagittis gravida molestie. Vivamus dictum, massa luctus tempus imperdiet, ligula leo ultrices purus, sit amet consectetur ligula turpis non nisi.",
"date": "November 15, 2022",
"time": "2pm - 3pm EST",
"ctaText": "Sign Up Today",
"link": "https://www.bluehost.com/blog/events/how-to-start-with-seo-yoast/"
},
{
"title": "Build your brand with WordPress",
"description": "Join us for a free webinar on how to build your brand with WordPress.",
"topics": [
"Explore SEO and WordPress",
"Gain valuable tips for building your brand",
"Content marketing",
"eCommerce integration"
],
"date": "August 31, 2040",
"time": "1pm - 2pm EST",
"ctaText": "Register Now",
"link": "https://www.bluehost.com/blog/events/next-event-post"
},
{
"title": "Mastering the Art of Public Speaking",
"topics": [
"Overcoming stage fright and nervousness",
"Crafting compelling speeches and presentations",
"Engaging your audience effectively",
"Tips for confident and impactful public speaking"
],
"date": "December 10, 2050",
"time": "3pm - 4pm EST",
"ctaText": "Enroll Now",
"link": "https://www.bluehost.com/blog/events/yoast-seo-news-october-edition/"
}
],
"isActive": true
}
79 changes: 79 additions & 0 deletions tests/cypress/integration/home.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,83 @@ describe('Home Page', function () {
.should('be.visible');
});

it('Webinars Section Exists', () => {
cy.intercept(
'https://cdn.hiive.space/resources/bluehost-webinars.json',
{ fixture: 'webinars.json' }
);
cy.reload();
cy
.get('.wppbh-webinars-banner-section').contains('h2', 'FREE Monthly Webinar: Build your brand with WordPress')
.scrollIntoView()
.should('be.visible');
});

it('Webinars Section Renders Correctly', () => {
// Title
cy
.get('.wppbh-webinars-banner-section')
.contains('h2', 'FREE Monthly Webinar: Build your brand with WordPress')
.scrollIntoView()
.should('be.visible');

// Description
cy
.get('.wppbh-webinars-banner-section p:first-of-type')
.contains('Join us for a free webinar on how to build your brand with WordPress.')
.scrollIntoView()
.should('be.visible');

// Topics
cy
.get('.wppbh-webinars-banner-section h3')
.contains('Topics:')
.scrollIntoView()
.should('be.visible');

// Date
cy
.get('.wppbh-webinars-banner-section')
.contains('August 31, 2040')
.scrollIntoView()
.should('be.visible');

// Time
cy
.get('.wppbh-webinars-banner-section')
.contains('1pm - 2pm EST')
.scrollIntoView()
.should('be.visible');

// CTA
cy
.get('.wppbh-webinars-banner-section a:first-of-type')
.contains('Register Now')
.scrollIntoView()
.should('be.visible')
.should('have.attr', 'href')
.and('include', 'https://www.bluehost.com/blog/events/next-event-post');
});

it('Webinars Section Doesn\'t Render When Active Propety is False', () => {
cy.intercept(
'https://cdn.hiive.space/resources/bluehost-webinars.json',
{ fixture: 'webinars-inactive.json' }
);
cy.reload();
cy
.get('.wppbh-webinars-banner-section')
.should('not.exist');
});

it('Webinars Section Doesn\'t Render Items Are in the Past', () => {
cy.intercept(
'https://cdn.hiive.space/resources/bluehost-webinars.json',
{ fixture: 'webinars-past.json' }
);
cy.reload();
cy
.get('.wppbh-webinars-banner-section')
.should('not.exist');
});
});

0 comments on commit 6ca6cf0

Please sign in to comment.