From 6ca6cf0ca6373e12132d9787617383e7abba629c Mon Sep 17 00:00:00 2001 From: wpalani Date: Sat, 28 Oct 2023 17:33:23 -0700 Subject: [PATCH] Webinars ad banner cypress tests and fixtures --- src/app/components/webinars-banner/index.js | 4 +- tests/cypress/fixtures/webinars-inactive.json | 40 ++++++++++ tests/cypress/fixtures/webinars-past.json | 40 ++++++++++ tests/cypress/fixtures/webinars.json | 40 ++++++++++ tests/cypress/integration/home.cy.js | 79 +++++++++++++++++++ 5 files changed, 201 insertions(+), 2 deletions(-) create mode 100644 tests/cypress/fixtures/webinars-inactive.json create mode 100644 tests/cypress/fixtures/webinars-past.json create mode 100644 tests/cypress/fixtures/webinars.json diff --git a/src/app/components/webinars-banner/index.js b/src/app/components/webinars-banner/index.js index 160cab147..7bb7c8bb4 100644 --- a/src/app/components/webinars-banner/index.js +++ b/src/app/components/webinars-banner/index.js @@ -94,14 +94,14 @@ const WebinarsBanner = () => {
- FREE Monthly Webinar: {nextWebinar.title} + FREE Monthly Webinar: {nextWebinar.title} {(nextWebinar.hasDescription || nextWebinar.hasTopics) &&
{nextWebinar.description &&

{nextWebinar.description}

} {nextWebinar.topics && <> - Topics: + Topics:
    {nextWebinar.topics.map((topic, index) => {topic})}
diff --git a/tests/cypress/fixtures/webinars-inactive.json b/tests/cypress/fixtures/webinars-inactive.json new file mode 100644 index 000000000..757996293 --- /dev/null +++ b/tests/cypress/fixtures/webinars-inactive.json @@ -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 +} \ No newline at end of file diff --git a/tests/cypress/fixtures/webinars-past.json b/tests/cypress/fixtures/webinars-past.json new file mode 100644 index 000000000..7e335f10f --- /dev/null +++ b/tests/cypress/fixtures/webinars-past.json @@ -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 +} \ No newline at end of file diff --git a/tests/cypress/fixtures/webinars.json b/tests/cypress/fixtures/webinars.json new file mode 100644 index 000000000..1da2da14b --- /dev/null +++ b/tests/cypress/fixtures/webinars.json @@ -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 +} \ No newline at end of file diff --git a/tests/cypress/integration/home.cy.js b/tests/cypress/integration/home.cy.js index 1927225b6..429dee3d7 100644 --- a/tests/cypress/integration/home.cy.js +++ b/tests/cypress/integration/home.cy.js @@ -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'); + }); });