From c8bc90b760ede71121ed2af3b805c55ceab902fc Mon Sep 17 00:00:00 2001 From: reachaadrika Date: Tue, 4 Jul 2023 00:12:27 +0530 Subject: [PATCH 01/16] tests for newsroom component --- components/newsroom/FeaturedBlogPost.js | 12 +- components/newsroom/Newsroom.js | 14 +- components/newsroom/NewsroomArticle.js | 13 +- components/newsroom/NewsroomBlogPosts.js | 6 +- components/newsroom/NewsroomSection.js | 8 +- components/newsroom/NewsroomYoutube.js | 6 +- components/newsroom/YouTubeCard.js | 5 +- cypress/test/newsroom/FeaturedBlogItem.cy.js | 272 +++++++++++++++++++ cypress/test/newsroom/Newsroom.cy.js | 46 ++++ cypress/test/newsroom/NewsroomArticle.cy.js | 15 + cypress/test/newsroom/NewsroomBlogPost.cy.js | 29 ++ cypress/test/newsroom/NewsroomSection.cy.js | 25 ++ cypress/test/newsroom/NewsroomYoutube.cy.js | 26 ++ cypress/test/newsroom/YoutubeCard.cy.js | 17 ++ cypress/test/newsroom/swiper.cy.js | 16 ++ 15 files changed, 479 insertions(+), 31 deletions(-) create mode 100644 cypress/test/newsroom/FeaturedBlogItem.cy.js create mode 100644 cypress/test/newsroom/Newsroom.cy.js create mode 100644 cypress/test/newsroom/NewsroomArticle.cy.js create mode 100644 cypress/test/newsroom/NewsroomBlogPost.cy.js create mode 100644 cypress/test/newsroom/NewsroomSection.cy.js create mode 100644 cypress/test/newsroom/NewsroomYoutube.cy.js create mode 100644 cypress/test/newsroom/YoutubeCard.cy.js create mode 100644 cypress/test/newsroom/swiper.cy.js diff --git a/components/newsroom/FeaturedBlogPost.js b/components/newsroom/FeaturedBlogPost.js index e4b2b384701..8606591c79c 100644 --- a/components/newsroom/FeaturedBlogPost.js +++ b/components/newsroom/FeaturedBlogPost.js @@ -26,12 +26,12 @@ export default function FeaturedBlogPost({ post, className = ''}) {
- - + +
- + {post.type} @@ -47,7 +47,7 @@ export default function FeaturedBlogPost({ post, className = ''}) {
-
+
@@ -57,13 +57,13 @@ export default function FeaturedBlogPost({ post, className = ''}) { - diff --git a/components/newsroom/Newsroom.js b/components/newsroom/Newsroom.js index 59f9ef9f29b..3f21e93490e 100644 --- a/components/newsroom/Newsroom.js +++ b/components/newsroom/Newsroom.js @@ -10,7 +10,7 @@ import TextLink from '../typography/TextLink' export default function Newsroom() { return ( <> -
+
-
+
From the blog @@ -33,14 +33,14 @@ export default function Newsroom() { Check out these articles written by community members -
+
Read all blog posts
-
+
@@ -55,7 +55,7 @@ export default function Newsroom() { Read about what people are
saying about AsyncAPI
-
+
Follow us on Twitter @@ -72,7 +72,7 @@ export default function Newsroom() {
-
+
Watch our latest videos and live streams on the AsyncAPI YouTube channel -
+
Visit our YouTube channel diff --git a/components/newsroom/NewsroomArticle.js b/components/newsroom/NewsroomArticle.js index c85d4631e7f..83ed98dd019 100644 --- a/components/newsroom/NewsroomArticle.js +++ b/components/newsroom/NewsroomArticle.js @@ -5,27 +5,28 @@ import articlesData from '../../config/articles.json'; export default function NewsroomArticle() { return ( ); } diff --git a/components/newsroom/NewsroomBlogPosts.js b/components/newsroom/NewsroomBlogPosts.js index ed2fc1dc07b..abf303a7e38 100644 --- a/components/newsroom/NewsroomBlogPosts.js +++ b/components/newsroom/NewsroomBlogPosts.js @@ -27,7 +27,7 @@ export default function NewsroomBlogPosts() { const buttonClass = 'shadow-md rounded border mx-2 mb-2 focus:outline-none'; return ( -
+
- -
diff --git a/components/newsroom/NewsroomSection.js b/components/newsroom/NewsroomSection.js index c3d75b3693a..f232e1c1ccc 100644 --- a/components/newsroom/NewsroomSection.js +++ b/components/newsroom/NewsroomSection.js @@ -18,21 +18,21 @@ export default function NewsroomSection() { .slice(0, 1); return (
-
+
-
+
Latest news and blogs Welcome to our Newsroom section. Here, you'll get latest information about our blogs, articles, announcements and Youtube live-streams. Let's get upto date with the recent activities in the organization. -
-
diff --git a/components/newsroom/NewsroomYoutube.js b/components/newsroom/NewsroomYoutube.js index d3c17f1545f..114b72c4ab6 100644 --- a/components/newsroom/NewsroomYoutube.js +++ b/components/newsroom/NewsroomYoutube.js @@ -17,7 +17,7 @@ export default function NewsroomYoutube({ className = '' }) { const buttonClass = 'shadow-md rounded border mx-2 mb-2 focus:outline-none'; return ( -
+
- -
diff --git a/components/newsroom/YouTubeCard.js b/components/newsroom/YouTubeCard.js index bf890438e83..3401a2ad066 100644 --- a/components/newsroom/YouTubeCard.js +++ b/components/newsroom/YouTubeCard.js @@ -9,13 +9,13 @@ export default function YouTubeCard({ video }) {
  • - video -
    +
    {video.title} @@ -29,6 +29,7 @@ export default function YouTubeCard({ video }) { Watch on Youtube diff --git a/cypress/test/newsroom/FeaturedBlogItem.cy.js b/cypress/test/newsroom/FeaturedBlogItem.cy.js new file mode 100644 index 00000000000..df477a388d4 --- /dev/null +++ b/cypress/test/newsroom/FeaturedBlogItem.cy.js @@ -0,0 +1,272 @@ +import { mount } from 'cypress/react' +import FeaturedBlogPost from '../../../components/newsroom/FeaturedBlogPost' + +const post = { + "title": "Awesome 2020 and What Can Get Better In 2021", + "date": "2020-12-23T05:00:00.000Z", + "type": "Communication", + "tags": [ + "Project Status" + ], + "cover": "/img/posts/2020-summary/cover.webp", + "authors": [ + { + "name": "Lukasz Gornicki", + "photo": "/img/avatars/lpgornicki.webp", + "link": "https://twitter.com/derberq", + "byline": "AsyncAPI Maintainer and Dev Comm Keeper" + } + ], + "excerpt": "Fuck you COVID-19, AsyncAPI Community is stronger than you think. See the growth of AsyncAPI in 2020 in hard numbers. How we compare to 2019?", + "toc": [ + { + "content": "Important moments", + "slug": "important-moments", + "lvl": 2, + "i": 0, + "seen": 0 + }, + { + "content": "Slack", + "slug": "slack", + "lvl": 2, + "i": 1, + "seen": 0 + }, + { + "content": "Numbers getting high", + "slug": "numbers-getting-high", + "lvl": 3, + "i": 2, + "seen": 0 + }, + { + "content": "Most present companies", + "slug": "most-present-companies", + "lvl": 3, + "i": 3, + "seen": 0 + }, + { + "content": "What's next with Slack", + "slug": "whats-next-with-slack", + "lvl": 3, + "i": 4, + "seen": 0 + }, + { + "content": "LinkedIn", + "slug": "linkedin", + "lvl": 2, + "i": 5, + "seen": 0 + }, + { + "content": "Followers and impressions", + "slug": "followers-and-impressions", + "lvl": 3, + "i": 6, + "seen": 0 + }, + { + "content": "Sponsored marketing", + "slug": "sponsored-marketing", + "lvl": 3, + "i": 7, + "seen": 0 + }, + { + "content": "What's next with LinkedIn", + "slug": "whats-next-with-linkedin", + "lvl": 3, + "i": 8, + "seen": 0 + }, + { + "content": "Google Analytics", + "slug": "google-analytics", + "lvl": 2, + "i": 9, + "seen": 0 + }, + { + "content": "Traffic got much higher", + "slug": "traffic-got-much-higher", + "lvl": 3, + "i": 10, + "seen": 0 + }, + { + "content": "Top referring channels", + "slug": "top-referring-channels", + "lvl": 3, + "i": 11, + "seen": 0 + }, + { + "content": "Top blog posts", + "slug": "top-blog-posts", + "lvl": 3, + "i": 12, + "seen": 0 + }, + { + "content": "What's next with the website", + "slug": "whats-next-with-the-website", + "lvl": 3, + "i": 13, + "seen": 0 + }, + { + "content": "Twitter", + "slug": "twitter", + "lvl": 2, + "i": 14, + "seen": 0 + }, + { + "content": "Paid marketing", + "slug": "paid-marketing", + "lvl": 3, + "i": 15, + "seen": 0 + }, + { + "content": "Top tweets", + "slug": "top-tweets", + "lvl": 3, + "i": 16, + "seen": 0 + }, + { + "content": "What's next with Twitter", + "slug": "whats-next-with-twitter", + "lvl": 3, + "i": 17, + "seen": 0 + }, + { + "content": "GitHub", + "slug": "github", + "lvl": 2, + "i": 18, + "seen": 0 + }, + { + "content": "Most popular repositories", + "slug": "most-popular-repositories", + "lvl": 3, + "i": 19, + "seen": 0 + }, + { + "content": "Traffic growth", + "slug": "traffic-growth", + "lvl": 3, + "i": 20, + "seen": 0 + }, + { + "content": "What's next with GitHub", + "slug": "whats-next-with-github", + "lvl": 3, + "i": 21, + "seen": 0 + }, + { + "content": "npm", + "slug": "npm", + "lvl": 2, + "i": 22, + "seen": 0 + }, + { + "content": "Top packages", + "slug": "top-packages", + "lvl": 3, + "i": 23, + "seen": 0 + }, + { + "content": "What's next with npm", + "slug": "whats-next-with-npm", + "lvl": 3, + "i": 24, + "seen": 0 + }, + { + "content": "YouTube", + "slug": "youtube", + "lvl": 2, + "i": 25, + "seen": 0 + }, + { + "content": "Watch time goes crazy", + "slug": "watch-time-goes-crazy", + "lvl": 3, + "i": 26, + "seen": 0 + }, + { + "content": "Most popular videos", + "slug": "most-popular-videos", + "lvl": 3, + "i": 27, + "seen": 0 + }, + { + "content": "What's next with YouTube", + "slug": "whats-next-with-youtube", + "lvl": 3, + "i": 28, + "seen": 0 + }, + { + "content": "Open Collective", + "slug": "open-collective", + "lvl": 2, + "i": 29, + "seen": 0 + }, + { + "content": "Ultimate questions - how many people use the spec?", + "slug": "ultimate-questions---how-many-people-use-the-spec", + "lvl": 2, + "i": 30, + "seen": 0 + }, + { + "content": "Final words", + "slug": "final-words", + "lvl": 2, + "i": 31, + "seen": 0 + } + ], + "readingTime": 18, + "sectionSlug": "/blog", + "sectionWeight": 0, + "id": "pages/blog/2020-summary.md", + "isIndex": false, + "slug": "/blog/2020-summary" +} + +describe('Features Component', () => { + it('renders without errors', () => { + mount(); + cy.get('[data-testid="FeaturedBlogPostItem-Link"]').should('have.attr', 'href', post.slug) + cy.get('[data-testid="FeaturedBlogPostItem-Img"]').should('have.attr', 'src', post.cover) + cy.get('[data-testid="FeaturedBlogPost-type"]').should('exist', post.type) + cy.contains(post.title) + cy.contains(post.type) + post.authors.forEach(author => { + cy.contains(author.name) + }) + cy.get('[data-testid="FeaturedBlog-Authorimg"]').should('exist', post.authors) + cy.get('[ data-testid="FeaturedBlogPost-date"]').should('exist', post.date) + cy.get('[ data-testid="FeaturedBlogPost-RT"]').should('exist', post.readingTime) + + + }); +}); diff --git a/cypress/test/newsroom/Newsroom.cy.js b/cypress/test/newsroom/Newsroom.cy.js new file mode 100644 index 00000000000..da26006612d --- /dev/null +++ b/cypress/test/newsroom/Newsroom.cy.js @@ -0,0 +1,46 @@ +import { mount } from 'cypress/react' +import Newsroom from '../../../components/newsroom/Newsroom' +import { TwitterTimelineEmbed } from 'react-twitter-embed' + +const newsroom = ["Latest Updates", "Get a glimpse of latest news, events, and blog posts. Want to publish a blog post? We love community stories.", "Submit yours!"] +const newsroom2 = ["From the blog", "Check out these articles written by community members", "Read all blog posts"] +describe('Features Component', () => { + it('renders without errors', () => { + mount(); + cy.get('[data-testid="Newsroom-main-div"]').contains(newsroom[0]) + cy.get('[data-testid="Newsroom-main-div"]').contains(newsroom[1]) + cy.get('[data-testid="Newsroom-main-div"]').contains(newsroom[2]) + + cy.get('[data-testid="Newsroom-sub-div"]').contains(newsroom2[0]) + cy.get('[data-testid="Newsroom-sub-div"]').contains(newsroom2[1]) + cy.get('[data-testid="Newsroom-sub-div"]').contains(newsroom2[2]) + cy.get('[data-testid="Newsroom-Blog"]').should('exist') + + }); + it('checks link href', () => { + mount(); + cy.get('[data-testid="Newsroom-BlogLink"]').find('a').should('have.attr', 'href', '/blog') // Check the blog href attribute + cy.get('[data-testid="Newsroom-TwitterLink"]').find('a').should('have.attr', 'href', 'https://twitter.com/AsyncAPISpec') //check twitter + cy.get('[data-testid="NewsRoomYoutube"]').find('a').should('have.attr', 'href', 'https://www.youtube.com/c/AsyncAPI') //check youtube link + + }); + + it('checks TwitterTimelineEmbed', () => { + mount( +
    +
    + +
    +
    + ); + + cy.get('[data-testid="NewsroomTwitter"]').should('exist'); // data-test was not working + + }); + + +}); diff --git a/cypress/test/newsroom/NewsroomArticle.cy.js b/cypress/test/newsroom/NewsroomArticle.cy.js new file mode 100644 index 00000000000..d54fbedb580 --- /dev/null +++ b/cypress/test/newsroom/NewsroomArticle.cy.js @@ -0,0 +1,15 @@ +import { mount } from 'cypress/react' +import NewsroomArticle from '../../../components/newsroom/NewsroomArticle' +import articlesData from '../../../config/articles.json' + +describe('Features Component', () => { + it('renders without errors', () => { + mount(); + articlesData.forEach((article, index) => { + cy.get(`[data-testid="article-${ index }"]`).should('have.attr', 'href', article.url); + cy.get(`[data-testid="article-${ index }"]`).should('contain.text', article.title); + cy.get(`[data-testid="article-${ index }"]`).should('contain.text', article.publishDate); + + }); + }); +}); \ No newline at end of file diff --git a/cypress/test/newsroom/NewsroomBlogPost.cy.js b/cypress/test/newsroom/NewsroomBlogPost.cy.js new file mode 100644 index 00000000000..9fab5e82593 --- /dev/null +++ b/cypress/test/newsroom/NewsroomBlogPost.cy.js @@ -0,0 +1,29 @@ +import { mount } from 'cypress/react' +import NewsroomBlogPosts from '../../../components/newsroom/NewsroomBlogPosts'; + + +describe('Features Component', () => { + it('renders without errors', () => { + mount(); + + }); + it('checks if swiper component is present', () => { + mount(); + cy.get('[data-testid="NewsroomBlog-main-div"]').should('exist') + + }); + it('slides to the next slide', () => { + mount(); + cy.get('[data-testid="Blog-Next"]').click(); + + }); + + it('slides to the previous slide', () => { + mount(); + cy.get('[data-testid="Blog-Prev"]').click(); + + }); + + +}); + diff --git a/cypress/test/newsroom/NewsroomSection.cy.js b/cypress/test/newsroom/NewsroomSection.cy.js new file mode 100644 index 00000000000..f4d774e22b9 --- /dev/null +++ b/cypress/test/newsroom/NewsroomSection.cy.js @@ -0,0 +1,25 @@ +import { mount } from 'cypress/react' +import NewsroomSection from '../../../components/newsroom/NewsroomSection'; +const newsroom = ["Latest news and blogs", "Welcome to our Newsroom section. Here, you'll get latest information about our blogs, articles, announcements and Youtube live-streams. Let's get upto date with the recent activities in the organization."] +describe('Features Component', () => { + it('renders without errors', () => { + mount(); + + }); + it('check if Features Blog Post exists', () => { + mount(); + cy.get('[data-testid="NewsroomSection-div"]').should('exist'); + + }); + + it('check content of Newsroom component', () => { + mount(); + cy.get('[data-testid="Newsroom-sectionDiv"]').contains(newsroom[0]); + cy.get('[data-testid="Newsroom-sectionDiv"]').contains(newsroom[1]); + cy.get('[data-testid="NewsroomSection-Link"]').should('have.attr', 'href', '/community/newsroom') + + + }) + +}); + diff --git a/cypress/test/newsroom/NewsroomYoutube.cy.js b/cypress/test/newsroom/NewsroomYoutube.cy.js new file mode 100644 index 00000000000..b1610373849 --- /dev/null +++ b/cypress/test/newsroom/NewsroomYoutube.cy.js @@ -0,0 +1,26 @@ +import { mount } from 'cypress/react' +import NewsroomYoutube from '../../../components/newsroom/NewsroomYoutube'; + +describe('Features Component', () => { + it('renders without errors', () => { + mount(); + }); + + + it('checks if swiper component is present', () => { + mount(); + cy.get('[data-testid="NewsroomYoutube-div"]').should('exist') + + }); + it('slides to the next slide', () => { + mount(); + cy.get('[data-testid="Youtube-Next"]').click(); + + }); + + it('slides to the previous slide', () => { + mount(); + cy.get('[data-testid="Youtube-Prev"]').click(); + + }); +}); \ No newline at end of file diff --git a/cypress/test/newsroom/YoutubeCard.cy.js b/cypress/test/newsroom/YoutubeCard.cy.js new file mode 100644 index 00000000000..0f8881149e0 --- /dev/null +++ b/cypress/test/newsroom/YoutubeCard.cy.js @@ -0,0 +1,17 @@ +import { mount } from '@cypress/react' +import YouTubeCard from '../../../components/newsroom/YouTubeCard' + +const video = { + "image_url": "https://i.ytimg.com/vi/EvC2PZXEM0M/hqdefault.jpg", + "title": "Community Meeting, Tuesday June 27th 2023", + "description": "https://github.com/asyncapi/community/issues/762.", + "videoId": "EvC2PZXEM0M" +} + +describe('Features Component', () => { + it('renders without errors', () => { + mount(); + cy.get('[ data-testid="YoutubeCard-main-div"]').contains(video.title); + cy.get('[ data-testid="YoutubeCard-main-div"]').contains(video.description); + }); +}); \ No newline at end of file diff --git a/cypress/test/newsroom/swiper.cy.js b/cypress/test/newsroom/swiper.cy.js new file mode 100644 index 00000000000..b7863747fc9 --- /dev/null +++ b/cypress/test/newsroom/swiper.cy.js @@ -0,0 +1,16 @@ +import { checkLastSnapIndex } from '../../../components/newsroom/swiper'; + +describe('checkLastSnapIndex', () => { + it('should check the last snap index correctly for different viewport widths', () => { + cy.viewport(1280, 720); // Set the viewport width to 1280px + + const isLastSnapIndex1 = checkLastSnapIndex(3); + expect(isLastSnapIndex1).to.be.false; + + cy.viewport(640, 480); // Set the viewport width to 640px + + const isLastSnapIndex2 = checkLastSnapIndex(4); + expect(isLastSnapIndex2).to.be.true; + }); + }); + From 86a32367b5894d1a08b93fbb4211006932979f7a Mon Sep 17 00:00:00 2001 From: Aadrika Bhargava <64789514+reachaadrika@users.noreply.github.com> Date: Sat, 8 Jul 2023 16:35:53 +0530 Subject: [PATCH 02/16] Update components/newsroom/YouTubeCard.js Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> --- components/newsroom/YouTubeCard.js | 1 - 1 file changed, 1 deletion(-) diff --git a/components/newsroom/YouTubeCard.js b/components/newsroom/YouTubeCard.js index 3401a2ad066..6646273da0b 100644 --- a/components/newsroom/YouTubeCard.js +++ b/components/newsroom/YouTubeCard.js @@ -29,7 +29,6 @@ export default function YouTubeCard({ video }) { Watch on Youtube From 9d20043379c44993b9e74f3fc4990ffc63f93601 Mon Sep 17 00:00:00 2001 From: Aadrika Bhargava <64789514+reachaadrika@users.noreply.github.com> Date: Sat, 8 Jul 2023 16:36:10 +0530 Subject: [PATCH 03/16] Update components/newsroom/YouTubeCard.js Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> --- components/newsroom/YouTubeCard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/newsroom/YouTubeCard.js b/components/newsroom/YouTubeCard.js index 6646273da0b..4eb8eb35c44 100644 --- a/components/newsroom/YouTubeCard.js +++ b/components/newsroom/YouTubeCard.js @@ -15,7 +15,7 @@ export default function YouTubeCard({ video }) { className="h-60 w-full object-cover" /> -
    +
    {video.title} From 00c5f761b8b90fd7c88dc79513f5a76ddb4472e1 Mon Sep 17 00:00:00 2001 From: Aadrika Bhargava <64789514+reachaadrika@users.noreply.github.com> Date: Sat, 8 Jul 2023 16:36:21 +0530 Subject: [PATCH 04/16] Update components/newsroom/NewsroomYoutube.js Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> --- components/newsroom/NewsroomYoutube.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/newsroom/NewsroomYoutube.js b/components/newsroom/NewsroomYoutube.js index 114b72c4ab6..d94af0c2edc 100644 --- a/components/newsroom/NewsroomYoutube.js +++ b/components/newsroom/NewsroomYoutube.js @@ -17,7 +17,7 @@ export default function NewsroomYoutube({ className = '' }) { const buttonClass = 'shadow-md rounded border mx-2 mb-2 focus:outline-none'; return ( -
    +
    Date: Sat, 8 Jul 2023 16:36:39 +0530 Subject: [PATCH 05/16] Update components/newsroom/Newsroom.js Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> --- components/newsroom/Newsroom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/newsroom/Newsroom.js b/components/newsroom/Newsroom.js index 3f21e93490e..ae86f1c3d3c 100644 --- a/components/newsroom/Newsroom.js +++ b/components/newsroom/Newsroom.js @@ -33,7 +33,7 @@ export default function Newsroom() { Check out these articles written by community members -
    +
    Read all blog posts From ad22a06f3f6792db38c05886a066730014f0050c Mon Sep 17 00:00:00 2001 From: Aadrika Bhargava <64789514+reachaadrika@users.noreply.github.com> Date: Sat, 8 Jul 2023 16:36:52 +0530 Subject: [PATCH 06/16] Update components/newsroom/Newsroom.js Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> --- components/newsroom/Newsroom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/newsroom/Newsroom.js b/components/newsroom/Newsroom.js index ae86f1c3d3c..5594538d9d8 100644 --- a/components/newsroom/Newsroom.js +++ b/components/newsroom/Newsroom.js @@ -55,7 +55,7 @@ export default function Newsroom() { Read about what people are
    saying about AsyncAPI
    -
    +
    Follow us on Twitter From af8fe65e0137ffd54e7a9103f630fe47037614f4 Mon Sep 17 00:00:00 2001 From: Aadrika Bhargava <64789514+reachaadrika@users.noreply.github.com> Date: Sat, 8 Jul 2023 16:37:49 +0530 Subject: [PATCH 07/16] Update components/newsroom/Newsroom.js Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> --- components/newsroom/Newsroom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/newsroom/Newsroom.js b/components/newsroom/Newsroom.js index 5594538d9d8..edb3d55d856 100644 --- a/components/newsroom/Newsroom.js +++ b/components/newsroom/Newsroom.js @@ -93,7 +93,7 @@ export default function Newsroom() { Watch our latest videos and live streams on the AsyncAPI YouTube channel -
    +
    Visit our YouTube channel From 83c5e2d2a0fa119deb968786c2a7d7998e40633d Mon Sep 17 00:00:00 2001 From: Aadrika Bhargava <64789514+reachaadrika@users.noreply.github.com> Date: Sat, 8 Jul 2023 16:38:00 +0530 Subject: [PATCH 08/16] Update components/newsroom/Newsroom.js Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> --- components/newsroom/Newsroom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/newsroom/Newsroom.js b/components/newsroom/Newsroom.js index edb3d55d856..0eb6186c8c4 100644 --- a/components/newsroom/Newsroom.js +++ b/components/newsroom/Newsroom.js @@ -72,7 +72,7 @@ export default function Newsroom() {
    -
    +
    Date: Sat, 8 Jul 2023 16:56:09 +0530 Subject: [PATCH 09/16] changes done for newsroom tests --- components/newsroom/NewsroomSection.js | 4 +- cypress/test/mockData/blogmockData.js | 250 ++++++++++++++++++ cypress/test/newsroom/FeaturedBlogItem.cy.js | 253 +------------------ cypress/test/newsroom/Newsroom.cy.js | 10 +- cypress/test/newsroom/NewsroomSection.cy.js | 6 +- cypress/test/newsroom/NewsroomYoutube.cy.js | 2 +- cypress/test/newsroom/YoutubeCard.cy.js | 4 +- 7 files changed, 264 insertions(+), 265 deletions(-) create mode 100644 cypress/test/mockData/blogmockData.js diff --git a/components/newsroom/NewsroomSection.js b/components/newsroom/NewsroomSection.js index f232e1c1ccc..e37658f715c 100644 --- a/components/newsroom/NewsroomSection.js +++ b/components/newsroom/NewsroomSection.js @@ -18,13 +18,13 @@ export default function NewsroomSection() { .slice(0, 1); return (
    -
    +
    -
    +
    Latest news and blogs diff --git a/cypress/test/mockData/blogmockData.js b/cypress/test/mockData/blogmockData.js new file mode 100644 index 00000000000..4b1f28eb65f --- /dev/null +++ b/cypress/test/mockData/blogmockData.js @@ -0,0 +1,250 @@ +export const post = { + "title": "Awesome 2020 and What Can Get Better In 2021", + "date": "2020-12-23T05:00:00.000Z", + "type": "Communication", + "tags": [ + "Project Status" + ], + "cover": "/img/posts/2020-summary/cover.webp", + "authors": [ + { + "name": "Lukasz Gornicki", + "photo": "/img/avatars/lpgornicki.webp", + "link": "https://twitter.com/derberq", + "byline": "AsyncAPI Maintainer and Dev Comm Keeper" + } + ], + "excerpt": "Fuck you COVID-19, AsyncAPI Community is stronger than you think. See the growth of AsyncAPI in 2020 in hard numbers. How we compare to 2019?", + "toc": [ + { + "content": "Important moments", + "slug": "important-moments", + "lvl": 2, + "i": 0, + "seen": 0 + }, + { + "content": "Slack", + "slug": "slack", + "lvl": 2, + "i": 1, + "seen": 0 + }, + { + "content": "Numbers getting high", + "slug": "numbers-getting-high", + "lvl": 3, + "i": 2, + "seen": 0 + }, + { + "content": "Most present companies", + "slug": "most-present-companies", + "lvl": 3, + "i": 3, + "seen": 0 + }, + { + "content": "What's next with Slack", + "slug": "whats-next-with-slack", + "lvl": 3, + "i": 4, + "seen": 0 + }, + { + "content": "LinkedIn", + "slug": "linkedin", + "lvl": 2, + "i": 5, + "seen": 0 + }, + { + "content": "Followers and impressions", + "slug": "followers-and-impressions", + "lvl": 3, + "i": 6, + "seen": 0 + }, + { + "content": "Sponsored marketing", + "slug": "sponsored-marketing", + "lvl": 3, + "i": 7, + "seen": 0 + }, + { + "content": "What's next with LinkedIn", + "slug": "whats-next-with-linkedin", + "lvl": 3, + "i": 8, + "seen": 0 + }, + { + "content": "Google Analytics", + "slug": "google-analytics", + "lvl": 2, + "i": 9, + "seen": 0 + }, + { + "content": "Traffic got much higher", + "slug": "traffic-got-much-higher", + "lvl": 3, + "i": 10, + "seen": 0 + }, + { + "content": "Top referring channels", + "slug": "top-referring-channels", + "lvl": 3, + "i": 11, + "seen": 0 + }, + { + "content": "Top blog posts", + "slug": "top-blog-posts", + "lvl": 3, + "i": 12, + "seen": 0 + }, + { + "content": "What's next with the website", + "slug": "whats-next-with-the-website", + "lvl": 3, + "i": 13, + "seen": 0 + }, + { + "content": "Twitter", + "slug": "twitter", + "lvl": 2, + "i": 14, + "seen": 0 + }, + { + "content": "Paid marketing", + "slug": "paid-marketing", + "lvl": 3, + "i": 15, + "seen": 0 + }, + { + "content": "Top tweets", + "slug": "top-tweets", + "lvl": 3, + "i": 16, + "seen": 0 + }, + { + "content": "What's next with Twitter", + "slug": "whats-next-with-twitter", + "lvl": 3, + "i": 17, + "seen": 0 + }, + { + "content": "GitHub", + "slug": "github", + "lvl": 2, + "i": 18, + "seen": 0 + }, + { + "content": "Most popular repositories", + "slug": "most-popular-repositories", + "lvl": 3, + "i": 19, + "seen": 0 + }, + { + "content": "Traffic growth", + "slug": "traffic-growth", + "lvl": 3, + "i": 20, + "seen": 0 + }, + { + "content": "What's next with GitHub", + "slug": "whats-next-with-github", + "lvl": 3, + "i": 21, + "seen": 0 + }, + { + "content": "npm", + "slug": "npm", + "lvl": 2, + "i": 22, + "seen": 0 + }, + { + "content": "Top packages", + "slug": "top-packages", + "lvl": 3, + "i": 23, + "seen": 0 + }, + { + "content": "What's next with npm", + "slug": "whats-next-with-npm", + "lvl": 3, + "i": 24, + "seen": 0 + }, + { + "content": "YouTube", + "slug": "youtube", + "lvl": 2, + "i": 25, + "seen": 0 + }, + { + "content": "Watch time goes crazy", + "slug": "watch-time-goes-crazy", + "lvl": 3, + "i": 26, + "seen": 0 + }, + { + "content": "Most popular videos", + "slug": "most-popular-videos", + "lvl": 3, + "i": 27, + "seen": 0 + }, + { + "content": "What's next with YouTube", + "slug": "whats-next-with-youtube", + "lvl": 3, + "i": 28, + "seen": 0 + }, + { + "content": "Open Collective", + "slug": "open-collective", + "lvl": 2, + "i": 29, + "seen": 0 + }, + { + "content": "Ultimate questions - how many people use the spec?", + "slug": "ultimate-questions---how-many-people-use-the-spec", + "lvl": 2, + "i": 30, + "seen": 0 + }, + { + "content": "Final words", + "slug": "final-words", + "lvl": 2, + "i": 31, + "seen": 0 + } + ], + "readingTime": 18, + "sectionSlug": "/blog", + "sectionWeight": 0, + "id": "pages/blog/2020-summary.md", + "isIndex": false, + "slug": "/blog/2020-summary" +} \ No newline at end of file diff --git a/cypress/test/newsroom/FeaturedBlogItem.cy.js b/cypress/test/newsroom/FeaturedBlogItem.cy.js index df477a388d4..cdc77d18bca 100644 --- a/cypress/test/newsroom/FeaturedBlogItem.cy.js +++ b/cypress/test/newsroom/FeaturedBlogItem.cy.js @@ -1,257 +1,6 @@ import { mount } from 'cypress/react' import FeaturedBlogPost from '../../../components/newsroom/FeaturedBlogPost' - -const post = { - "title": "Awesome 2020 and What Can Get Better In 2021", - "date": "2020-12-23T05:00:00.000Z", - "type": "Communication", - "tags": [ - "Project Status" - ], - "cover": "/img/posts/2020-summary/cover.webp", - "authors": [ - { - "name": "Lukasz Gornicki", - "photo": "/img/avatars/lpgornicki.webp", - "link": "https://twitter.com/derberq", - "byline": "AsyncAPI Maintainer and Dev Comm Keeper" - } - ], - "excerpt": "Fuck you COVID-19, AsyncAPI Community is stronger than you think. See the growth of AsyncAPI in 2020 in hard numbers. How we compare to 2019?", - "toc": [ - { - "content": "Important moments", - "slug": "important-moments", - "lvl": 2, - "i": 0, - "seen": 0 - }, - { - "content": "Slack", - "slug": "slack", - "lvl": 2, - "i": 1, - "seen": 0 - }, - { - "content": "Numbers getting high", - "slug": "numbers-getting-high", - "lvl": 3, - "i": 2, - "seen": 0 - }, - { - "content": "Most present companies", - "slug": "most-present-companies", - "lvl": 3, - "i": 3, - "seen": 0 - }, - { - "content": "What's next with Slack", - "slug": "whats-next-with-slack", - "lvl": 3, - "i": 4, - "seen": 0 - }, - { - "content": "LinkedIn", - "slug": "linkedin", - "lvl": 2, - "i": 5, - "seen": 0 - }, - { - "content": "Followers and impressions", - "slug": "followers-and-impressions", - "lvl": 3, - "i": 6, - "seen": 0 - }, - { - "content": "Sponsored marketing", - "slug": "sponsored-marketing", - "lvl": 3, - "i": 7, - "seen": 0 - }, - { - "content": "What's next with LinkedIn", - "slug": "whats-next-with-linkedin", - "lvl": 3, - "i": 8, - "seen": 0 - }, - { - "content": "Google Analytics", - "slug": "google-analytics", - "lvl": 2, - "i": 9, - "seen": 0 - }, - { - "content": "Traffic got much higher", - "slug": "traffic-got-much-higher", - "lvl": 3, - "i": 10, - "seen": 0 - }, - { - "content": "Top referring channels", - "slug": "top-referring-channels", - "lvl": 3, - "i": 11, - "seen": 0 - }, - { - "content": "Top blog posts", - "slug": "top-blog-posts", - "lvl": 3, - "i": 12, - "seen": 0 - }, - { - "content": "What's next with the website", - "slug": "whats-next-with-the-website", - "lvl": 3, - "i": 13, - "seen": 0 - }, - { - "content": "Twitter", - "slug": "twitter", - "lvl": 2, - "i": 14, - "seen": 0 - }, - { - "content": "Paid marketing", - "slug": "paid-marketing", - "lvl": 3, - "i": 15, - "seen": 0 - }, - { - "content": "Top tweets", - "slug": "top-tweets", - "lvl": 3, - "i": 16, - "seen": 0 - }, - { - "content": "What's next with Twitter", - "slug": "whats-next-with-twitter", - "lvl": 3, - "i": 17, - "seen": 0 - }, - { - "content": "GitHub", - "slug": "github", - "lvl": 2, - "i": 18, - "seen": 0 - }, - { - "content": "Most popular repositories", - "slug": "most-popular-repositories", - "lvl": 3, - "i": 19, - "seen": 0 - }, - { - "content": "Traffic growth", - "slug": "traffic-growth", - "lvl": 3, - "i": 20, - "seen": 0 - }, - { - "content": "What's next with GitHub", - "slug": "whats-next-with-github", - "lvl": 3, - "i": 21, - "seen": 0 - }, - { - "content": "npm", - "slug": "npm", - "lvl": 2, - "i": 22, - "seen": 0 - }, - { - "content": "Top packages", - "slug": "top-packages", - "lvl": 3, - "i": 23, - "seen": 0 - }, - { - "content": "What's next with npm", - "slug": "whats-next-with-npm", - "lvl": 3, - "i": 24, - "seen": 0 - }, - { - "content": "YouTube", - "slug": "youtube", - "lvl": 2, - "i": 25, - "seen": 0 - }, - { - "content": "Watch time goes crazy", - "slug": "watch-time-goes-crazy", - "lvl": 3, - "i": 26, - "seen": 0 - }, - { - "content": "Most popular videos", - "slug": "most-popular-videos", - "lvl": 3, - "i": 27, - "seen": 0 - }, - { - "content": "What's next with YouTube", - "slug": "whats-next-with-youtube", - "lvl": 3, - "i": 28, - "seen": 0 - }, - { - "content": "Open Collective", - "slug": "open-collective", - "lvl": 2, - "i": 29, - "seen": 0 - }, - { - "content": "Ultimate questions - how many people use the spec?", - "slug": "ultimate-questions---how-many-people-use-the-spec", - "lvl": 2, - "i": 30, - "seen": 0 - }, - { - "content": "Final words", - "slug": "final-words", - "lvl": 2, - "i": 31, - "seen": 0 - } - ], - "readingTime": 18, - "sectionSlug": "/blog", - "sectionWeight": 0, - "id": "pages/blog/2020-summary.md", - "isIndex": false, - "slug": "/blog/2020-summary" -} - +import { post } from '../mockData/blogmockData'; describe('Features Component', () => { it('renders without errors', () => { mount(); diff --git a/cypress/test/newsroom/Newsroom.cy.js b/cypress/test/newsroom/Newsroom.cy.js index da26006612d..2e9bd301292 100644 --- a/cypress/test/newsroom/Newsroom.cy.js +++ b/cypress/test/newsroom/Newsroom.cy.js @@ -19,16 +19,16 @@ describe('Features Component', () => { }); it('checks link href', () => { mount(); - cy.get('[data-testid="Newsroom-BlogLink"]').find('a').should('have.attr', 'href', '/blog') // Check the blog href attribute - cy.get('[data-testid="Newsroom-TwitterLink"]').find('a').should('have.attr', 'href', 'https://twitter.com/AsyncAPISpec') //check twitter - cy.get('[data-testid="NewsRoomYoutube"]').find('a').should('have.attr', 'href', 'https://www.youtube.com/c/AsyncAPI') //check youtube link + cy.get('[data-testid="Newsroom-Blog-Link"]').find('a').should('have.attr', 'href', '/blog') // Check the blog href attribute + cy.get('[ data-testid="Newsroom-Twitter-Link"]').find('a').should('have.attr', 'href', 'https://twitter.com/AsyncAPISpec') //check twitter + cy.get('[data-testid="Newsroom-Youtube"]').find('a').should('have.attr', 'href', 'https://www.youtube.com/c/AsyncAPI') //check youtube link }); it('checks TwitterTimelineEmbed', () => { mount(
    -
    +
    {
    ); - cy.get('[data-testid="NewsroomTwitter"]').should('exist'); // data-test was not working + cy.get('[data-testid="Newsroom-Twitter"]').should('exist'); // data-test was not working }); diff --git a/cypress/test/newsroom/NewsroomSection.cy.js b/cypress/test/newsroom/NewsroomSection.cy.js index f4d774e22b9..af48c41a018 100644 --- a/cypress/test/newsroom/NewsroomSection.cy.js +++ b/cypress/test/newsroom/NewsroomSection.cy.js @@ -8,14 +8,14 @@ describe('Features Component', () => { }); it('check if Features Blog Post exists', () => { mount(); - cy.get('[data-testid="NewsroomSection-div"]').should('exist'); + cy.get('[data-testid="NewsroomSection-Featured"]').should('exist'); }); it('check content of Newsroom component', () => { mount(); - cy.get('[data-testid="Newsroom-sectionDiv"]').contains(newsroom[0]); - cy.get('[data-testid="Newsroom-sectionDiv"]').contains(newsroom[1]); + cy.get('[data-testid="NewsroomSection-main"]').contains(newsroom[0]); + cy.get('[data-testid="NewsroomSection-main"]').contains(newsroom[1]); cy.get('[data-testid="NewsroomSection-Link"]').should('have.attr', 'href', '/community/newsroom') diff --git a/cypress/test/newsroom/NewsroomYoutube.cy.js b/cypress/test/newsroom/NewsroomYoutube.cy.js index b1610373849..991e4c6cd05 100644 --- a/cypress/test/newsroom/NewsroomYoutube.cy.js +++ b/cypress/test/newsroom/NewsroomYoutube.cy.js @@ -9,7 +9,7 @@ describe('Features Component', () => { it('checks if swiper component is present', () => { mount(); - cy.get('[data-testid="NewsroomYoutube-div"]').should('exist') + cy.get('[ data-testid="NewsroomYoutube-main"]').should('exist') }); it('slides to the next slide', () => { diff --git a/cypress/test/newsroom/YoutubeCard.cy.js b/cypress/test/newsroom/YoutubeCard.cy.js index 0f8881149e0..858d55a99ab 100644 --- a/cypress/test/newsroom/YoutubeCard.cy.js +++ b/cypress/test/newsroom/YoutubeCard.cy.js @@ -11,7 +11,7 @@ const video = { describe('Features Component', () => { it('renders without errors', () => { mount(); - cy.get('[ data-testid="YoutubeCard-main-div"]').contains(video.title); - cy.get('[ data-testid="YoutubeCard-main-div"]').contains(video.description); + cy.get('[data-testid="YoutubeCard-main"]').contains(video.title); + cy.get('[data-testid="YoutubeCard-main"]').contains(video.description); }); }); \ No newline at end of file From f03994d946ac9282a53e6b00831e6f2f80cc13fa Mon Sep 17 00:00:00 2001 From: Aadrika Bhargava <64789514+reachaadrika@users.noreply.github.com> Date: Thu, 13 Jul 2023 23:40:07 +0530 Subject: [PATCH 10/16] Update cypress/test/newsroom/NewsroomBlogPost.cy.js Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> --- cypress/test/newsroom/NewsroomBlogPost.cy.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cypress/test/newsroom/NewsroomBlogPost.cy.js b/cypress/test/newsroom/NewsroomBlogPost.cy.js index 9fab5e82593..07377b5b493 100644 --- a/cypress/test/newsroom/NewsroomBlogPost.cy.js +++ b/cypress/test/newsroom/NewsroomBlogPost.cy.js @@ -1,7 +1,6 @@ import { mount } from 'cypress/react' import NewsroomBlogPosts from '../../../components/newsroom/NewsroomBlogPosts'; - describe('Features Component', () => { it('renders without errors', () => { mount(); From 25046487bd8d52c326b51894131a10da2bb012df Mon Sep 17 00:00:00 2001 From: reachaadrika Date: Thu, 13 Jul 2023 23:50:36 +0530 Subject: [PATCH 11/16] changes done for newsroom component --- components/newsroom/NewsroomArticle.js | 2 +- components/newsroom/NewsroomBlogPosts.js | 4 +-- components/newsroom/NewsroomYoutube.js | 6 ++-- cypress/test/newsroom/Newsroom.cy.js | 12 ++++---- cypress/test/newsroom/NewsroomArticle.cy.js | 8 +++--- cypress/test/newsroom/NewsroomBlogPost.cy.js | 29 ++++++++++---------- cypress/test/newsroom/NewsroomSection.cy.js | 12 ++++---- cypress/test/newsroom/NewsroomYoutube.cy.js | 21 +++++++------- cypress/test/newsroom/YoutubeCard.cy.js | 2 +- 9 files changed, 47 insertions(+), 49 deletions(-) diff --git a/components/newsroom/NewsroomArticle.js b/components/newsroom/NewsroomArticle.js index 83ed98dd019..6e75beaba0b 100644 --- a/components/newsroom/NewsroomArticle.js +++ b/components/newsroom/NewsroomArticle.js @@ -12,7 +12,7 @@ export default function NewsroomArticle() { href={ article.url } target="_blank" rel="noopener noreferrer" - data-testid={ `article-${ index }` } + data-testid={ `NewsroomArticle-${ index }` } >
    { article.publishDate } diff --git a/components/newsroom/NewsroomBlogPosts.js b/components/newsroom/NewsroomBlogPosts.js index abf303a7e38..d4f10d8564d 100644 --- a/components/newsroom/NewsroomBlogPosts.js +++ b/components/newsroom/NewsroomBlogPosts.js @@ -53,10 +53,10 @@ export default function NewsroomBlogPosts() {
    - -
    diff --git a/components/newsroom/NewsroomYoutube.js b/components/newsroom/NewsroomYoutube.js index d94af0c2edc..e3530d1942f 100644 --- a/components/newsroom/NewsroomYoutube.js +++ b/components/newsroom/NewsroomYoutube.js @@ -17,7 +17,7 @@ export default function NewsroomYoutube({ className = '' }) { const buttonClass = 'shadow-md rounded border mx-2 mb-2 focus:outline-none'; return ( -
    +
    - -
    diff --git a/cypress/test/newsroom/Newsroom.cy.js b/cypress/test/newsroom/Newsroom.cy.js index 2e9bd301292..dc710f9b36c 100644 --- a/cypress/test/newsroom/Newsroom.cy.js +++ b/cypress/test/newsroom/Newsroom.cy.js @@ -3,22 +3,20 @@ import Newsroom from '../../../components/newsroom/Newsroom' import { TwitterTimelineEmbed } from 'react-twitter-embed' const newsroom = ["Latest Updates", "Get a glimpse of latest news, events, and blog posts. Want to publish a blog post? We love community stories.", "Submit yours!"] -const newsroom2 = ["From the blog", "Check out these articles written by community members", "Read all blog posts"] -describe('Features Component', () => { - it('renders without errors', () => { + +describe('Newsroom Component', () => { + beforeEach(() => { mount(); + }); + it('renders without errors', () => { cy.get('[data-testid="Newsroom-main-div"]').contains(newsroom[0]) cy.get('[data-testid="Newsroom-main-div"]').contains(newsroom[1]) cy.get('[data-testid="Newsroom-main-div"]').contains(newsroom[2]) - cy.get('[data-testid="Newsroom-sub-div"]').contains(newsroom2[0]) - cy.get('[data-testid="Newsroom-sub-div"]').contains(newsroom2[1]) - cy.get('[data-testid="Newsroom-sub-div"]').contains(newsroom2[2]) cy.get('[data-testid="Newsroom-Blog"]').should('exist') }); it('checks link href', () => { - mount(); cy.get('[data-testid="Newsroom-Blog-Link"]').find('a').should('have.attr', 'href', '/blog') // Check the blog href attribute cy.get('[ data-testid="Newsroom-Twitter-Link"]').find('a').should('have.attr', 'href', 'https://twitter.com/AsyncAPISpec') //check twitter cy.get('[data-testid="Newsroom-Youtube"]').find('a').should('have.attr', 'href', 'https://www.youtube.com/c/AsyncAPI') //check youtube link diff --git a/cypress/test/newsroom/NewsroomArticle.cy.js b/cypress/test/newsroom/NewsroomArticle.cy.js index d54fbedb580..5f49663e8e7 100644 --- a/cypress/test/newsroom/NewsroomArticle.cy.js +++ b/cypress/test/newsroom/NewsroomArticle.cy.js @@ -2,13 +2,13 @@ import { mount } from 'cypress/react' import NewsroomArticle from '../../../components/newsroom/NewsroomArticle' import articlesData from '../../../config/articles.json' -describe('Features Component', () => { +describe('Newsroom Article Component', () => { it('renders without errors', () => { mount(); articlesData.forEach((article, index) => { - cy.get(`[data-testid="article-${ index }"]`).should('have.attr', 'href', article.url); - cy.get(`[data-testid="article-${ index }"]`).should('contain.text', article.title); - cy.get(`[data-testid="article-${ index }"]`).should('contain.text', article.publishDate); + cy.get(`[data-testid="NewsroomArticle-${ index }"]`).should('have.attr', 'href', article.url); + cy.get(`[data-testid="NewsroomArticle-${ index }"]`).should('contain.text', article.title); + cy.get(`[data-testid="NewsroomArticle-${ index }"]`).should('contain.text', article.publishDate); }); }); diff --git a/cypress/test/newsroom/NewsroomBlogPost.cy.js b/cypress/test/newsroom/NewsroomBlogPost.cy.js index 9fab5e82593..26f40c45aec 100644 --- a/cypress/test/newsroom/NewsroomBlogPost.cy.js +++ b/cypress/test/newsroom/NewsroomBlogPost.cy.js @@ -1,29 +1,30 @@ import { mount } from 'cypress/react' import NewsroomBlogPosts from '../../../components/newsroom/NewsroomBlogPosts'; - -describe('Features Component', () => { - it('renders without errors', () => { +describe('Newsroom Article Component', () => { + beforeEach(() => { mount(); + }); + + it('renders without errors', () => { }); it('checks if swiper component is present', () => { - mount(); cy.get('[data-testid="NewsroomBlog-main-div"]').should('exist') }); - it('slides to the next slide', () => { - mount(); - cy.get('[data-testid="Blog-Next"]').click(); - + it('checks if the first slide is active', () => { + cy.get('.swiper-slide-active').should('exist') }); - + + it('checks if the second slide is active after clicking next', () => { + cy.get('[data-testid="Blog-Next-button"]').click({force: true }) + cy.get('.swiper-slide-active').should('exist') + }); + it('slides to the previous slide', () => { - mount(); - cy.get('[data-testid="Blog-Prev"]').click(); - + cy.get('[data-testid="Blog-Prev-button"]').click({force: true }) + cy.get('.swiper-slide-active').should('exist') }); - - }); diff --git a/cypress/test/newsroom/NewsroomSection.cy.js b/cypress/test/newsroom/NewsroomSection.cy.js index af48c41a018..4797725040e 100644 --- a/cypress/test/newsroom/NewsroomSection.cy.js +++ b/cypress/test/newsroom/NewsroomSection.cy.js @@ -1,24 +1,22 @@ import { mount } from 'cypress/react' import NewsroomSection from '../../../components/newsroom/NewsroomSection'; const newsroom = ["Latest news and blogs", "Welcome to our Newsroom section. Here, you'll get latest information about our blogs, articles, announcements and Youtube live-streams. Let's get upto date with the recent activities in the organization."] -describe('Features Component', () => { - it('renders without errors', () => { +describe('Newsroom Section Component', () => { + beforeEach(() => { mount(); + }); + + it('renders without errors', () => { }); it('check if Features Blog Post exists', () => { - mount(); cy.get('[data-testid="NewsroomSection-Featured"]').should('exist'); }); it('check content of Newsroom component', () => { - mount(); cy.get('[data-testid="NewsroomSection-main"]').contains(newsroom[0]); cy.get('[data-testid="NewsroomSection-main"]').contains(newsroom[1]); - cy.get('[data-testid="NewsroomSection-Link"]').should('have.attr', 'href', '/community/newsroom') - - }) }); diff --git a/cypress/test/newsroom/NewsroomYoutube.cy.js b/cypress/test/newsroom/NewsroomYoutube.cy.js index 991e4c6cd05..216ded8ab7b 100644 --- a/cypress/test/newsroom/NewsroomYoutube.cy.js +++ b/cypress/test/newsroom/NewsroomYoutube.cy.js @@ -1,26 +1,27 @@ import { mount } from 'cypress/react' import NewsroomYoutube from '../../../components/newsroom/NewsroomYoutube'; -describe('Features Component', () => { - it('renders without errors', () => { +describe('Newsroom Youtube', () => { + beforeEach(() => { mount(); + }); + it('renders without errors', () => { + }); - it('checks if swiper component is present', () => { - mount(); cy.get('[ data-testid="NewsroomYoutube-main"]').should('exist') }); + it('checks if the first slide is active', () => { + cy.get('.swiper-slide-active').should('exist') + }); it('slides to the next slide', () => { - mount(); - cy.get('[data-testid="Youtube-Next"]').click(); - + cy.get('[data-testid="Youtube-Next-button"]').click({force: true }) + cy.get('.swiper-slide-active').should('exist') }); it('slides to the previous slide', () => { - mount(); - cy.get('[data-testid="Youtube-Prev"]').click(); - + cy.get('[data-testid="Youtube-Prev-button"]').click({force: true }) }); }); \ No newline at end of file diff --git a/cypress/test/newsroom/YoutubeCard.cy.js b/cypress/test/newsroom/YoutubeCard.cy.js index 858d55a99ab..130a200bd0a 100644 --- a/cypress/test/newsroom/YoutubeCard.cy.js +++ b/cypress/test/newsroom/YoutubeCard.cy.js @@ -8,7 +8,7 @@ const video = { "videoId": "EvC2PZXEM0M" } -describe('Features Component', () => { +describe('Youtube Card Component', () => { it('renders without errors', () => { mount(); cy.get('[data-testid="YoutubeCard-main"]').contains(video.title); From 62932309fcc4598fd2b820fda63ecc0b41067897 Mon Sep 17 00:00:00 2001 From: Aadrika Bhargava <64789514+reachaadrika@users.noreply.github.com> Date: Fri, 14 Jul 2023 00:26:40 +0530 Subject: [PATCH 12/16] Update cypress/test/newsroom/FeaturedBlogItem.cy.js Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> --- cypress/test/newsroom/FeaturedBlogItem.cy.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/cypress/test/newsroom/FeaturedBlogItem.cy.js b/cypress/test/newsroom/FeaturedBlogItem.cy.js index cdc77d18bca..e27afc0332d 100644 --- a/cypress/test/newsroom/FeaturedBlogItem.cy.js +++ b/cypress/test/newsroom/FeaturedBlogItem.cy.js @@ -15,7 +15,5 @@ describe('Features Component', () => { cy.get('[data-testid="FeaturedBlog-Authorimg"]').should('exist', post.authors) cy.get('[ data-testid="FeaturedBlogPost-date"]').should('exist', post.date) cy.get('[ data-testid="FeaturedBlogPost-RT"]').should('exist', post.readingTime) - - }); }); From a44a1c5bc290441463a6da175bbbe0a3efab4b78 Mon Sep 17 00:00:00 2001 From: Aadrika Bhargava <64789514+reachaadrika@users.noreply.github.com> Date: Fri, 14 Jul 2023 00:28:46 +0530 Subject: [PATCH 13/16] Update cypress/test/newsroom/Newsroom.cy.js Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> --- cypress/test/newsroom/Newsroom.cy.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cypress/test/newsroom/Newsroom.cy.js b/cypress/test/newsroom/Newsroom.cy.js index dc710f9b36c..9d83a743f66 100644 --- a/cypress/test/newsroom/Newsroom.cy.js +++ b/cypress/test/newsroom/Newsroom.cy.js @@ -37,7 +37,6 @@ describe('Newsroom Component', () => { ); cy.get('[data-testid="Newsroom-Twitter"]').should('exist'); // data-test was not working - }); From 991eb189ad22d2eeba5cb7b20bb6b1a63f30d13b Mon Sep 17 00:00:00 2001 From: reachaadrika Date: Fri, 14 Jul 2023 00:50:37 +0530 Subject: [PATCH 14/16] required changes --- components/newsroom/FeaturedBlogPost.js | 4 ++-- components/newsroom/Newsroom.js | 2 +- cypress/test/newsroom/FeaturedBlogItem.cy.js | 9 ++++---- cypress/test/newsroom/Newsroom.cy.js | 24 ++++---------------- 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/components/newsroom/FeaturedBlogPost.js b/components/newsroom/FeaturedBlogPost.js index 8606591c79c..14492ba457c 100644 --- a/components/newsroom/FeaturedBlogPost.js +++ b/components/newsroom/FeaturedBlogPost.js @@ -36,7 +36,7 @@ export default function FeaturedBlogPost({ post, className = ''}) { - + {post.title} @@ -52,7 +52,7 @@ export default function FeaturedBlogPost({ post, className = ''}) {
    - + {post.authors.map((author, index) => author.link ? { e.stopPropagation() }} target="_blank" rel="noreferrer">{author.name} : author.name).reduce((prev, curr) => [prev, ' & ', curr])} diff --git a/components/newsroom/Newsroom.js b/components/newsroom/Newsroom.js index 0eb6186c8c4..6d8a64bd134 100644 --- a/components/newsroom/Newsroom.js +++ b/components/newsroom/Newsroom.js @@ -10,7 +10,7 @@ import TextLink from '../typography/TextLink' export default function Newsroom() { return ( <> -
    +
    { cy.get('[data-testid="FeaturedBlogPostItem-Link"]').should('have.attr', 'href', post.slug) cy.get('[data-testid="FeaturedBlogPostItem-Img"]').should('have.attr', 'src', post.cover) cy.get('[data-testid="FeaturedBlogPost-type"]').should('exist', post.type) - cy.contains(post.title) - cy.contains(post.type) + cy.get('[data-testid="FeaturedBlog-title"]').should('exist',post.title); post.authors.forEach(author => { - cy.contains(author.name) + cy.get('[data-testid="FeaturedBlogPost-AuthorName"]').should('exist',author.name) }) cy.get('[data-testid="FeaturedBlog-Authorimg"]').should('exist', post.authors) - cy.get('[ data-testid="FeaturedBlogPost-date"]').should('exist', post.date) - cy.get('[ data-testid="FeaturedBlogPost-RT"]').should('exist', post.readingTime) + cy.get('[data-testid="FeaturedBlogPost-date"]').should('exist', post.date) + cy.get('[data-testid="FeaturedBlogPost-RT"]').should('exist', post.readingTime) }); }); diff --git a/cypress/test/newsroom/Newsroom.cy.js b/cypress/test/newsroom/Newsroom.cy.js index 9d83a743f66..811715a0df9 100644 --- a/cypress/test/newsroom/Newsroom.cy.js +++ b/cypress/test/newsroom/Newsroom.cy.js @@ -1,20 +1,16 @@ import { mount } from 'cypress/react' import Newsroom from '../../../components/newsroom/Newsroom' -import { TwitterTimelineEmbed } from 'react-twitter-embed' - -const newsroom = ["Latest Updates", "Get a glimpse of latest news, events, and blog posts. Want to publish a blog post? We love community stories.", "Submit yours!"] - +const newsroomHeadings = ["Latest Updates","From the blog"] describe('Newsroom Component', () => { beforeEach(() => { mount(); }); it('renders without errors', () => { - cy.get('[data-testid="Newsroom-main-div"]').contains(newsroom[0]) - cy.get('[data-testid="Newsroom-main-div"]').contains(newsroom[1]) - cy.get('[data-testid="Newsroom-main-div"]').contains(newsroom[2]) - + cy.get('[data-testid="Newsroom-main"]').contains(newsroomHeadings[0]) + cy.get('[data-testid="Newsroom-sub-div"]').contains(newsroomHeadings[1]) cy.get('[data-testid="Newsroom-Blog"]').should('exist') + }); it('checks link href', () => { cy.get('[data-testid="Newsroom-Blog-Link"]').find('a').should('have.attr', 'href', '/blog') // Check the blog href attribute @@ -24,18 +20,6 @@ describe('Newsroom Component', () => { }); it('checks TwitterTimelineEmbed', () => { - mount( -
    -
    - -
    -
    - ); - cy.get('[data-testid="Newsroom-Twitter"]').should('exist'); // data-test was not working }); From 69818a7ba4c51f60c10f6e78e4e12de93ef5e187 Mon Sep 17 00:00:00 2001 From: reachaadrika Date: Fri, 14 Jul 2023 00:52:55 +0530 Subject: [PATCH 15/16] removed subheadings check --- cypress/test/newsroom/NewsroomSection.cy.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cypress/test/newsroom/NewsroomSection.cy.js b/cypress/test/newsroom/NewsroomSection.cy.js index 4797725040e..fd3f59367e0 100644 --- a/cypress/test/newsroom/NewsroomSection.cy.js +++ b/cypress/test/newsroom/NewsroomSection.cy.js @@ -1,6 +1,6 @@ import { mount } from 'cypress/react' import NewsroomSection from '../../../components/newsroom/NewsroomSection'; -const newsroom = ["Latest news and blogs", "Welcome to our Newsroom section. Here, you'll get latest information about our blogs, articles, announcements and Youtube live-streams. Let's get upto date with the recent activities in the organization."] +const newsroom = ["Latest news and blogs"] describe('Newsroom Section Component', () => { beforeEach(() => { mount(); @@ -16,7 +16,6 @@ describe('Newsroom Section Component', () => { it('check content of Newsroom component', () => { cy.get('[data-testid="NewsroomSection-main"]').contains(newsroom[0]); - cy.get('[data-testid="NewsroomSection-main"]').contains(newsroom[1]); }) }); From 144478383269c7ee16a11e73306acb4136decf38 Mon Sep 17 00:00:00 2001 From: akshatnema <20bcs022@iiitdmj.ac.in> Date: Mon, 17 Jul 2023 21:05:08 +0530 Subject: [PATCH 16/16] Update code formatting and spacing --- cypress/test/newsroom/Newsroom.cy.js | 7 ++----- cypress/test/newsroom/NewsroomArticle.cy.js | 1 - cypress/test/newsroom/NewsroomSection.cy.js | 5 +---- cypress/test/newsroom/NewsroomYoutube.cy.js | 8 ++++---- cypress/test/newsroom/swiper.cy.js | 2 -- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/cypress/test/newsroom/Newsroom.cy.js b/cypress/test/newsroom/Newsroom.cy.js index 811715a0df9..6764307f6a0 100644 --- a/cypress/test/newsroom/Newsroom.cy.js +++ b/cypress/test/newsroom/Newsroom.cy.js @@ -5,23 +5,20 @@ describe('Newsroom Component', () => { beforeEach(() => { mount(); }); + it('renders without errors', () => { cy.get('[data-testid="Newsroom-main"]').contains(newsroomHeadings[0]) cy.get('[data-testid="Newsroom-sub-div"]').contains(newsroomHeadings[1]) cy.get('[data-testid="Newsroom-Blog"]').should('exist') - - }); + it('checks link href', () => { cy.get('[data-testid="Newsroom-Blog-Link"]').find('a').should('have.attr', 'href', '/blog') // Check the blog href attribute cy.get('[ data-testid="Newsroom-Twitter-Link"]').find('a').should('have.attr', 'href', 'https://twitter.com/AsyncAPISpec') //check twitter cy.get('[data-testid="Newsroom-Youtube"]').find('a').should('have.attr', 'href', 'https://www.youtube.com/c/AsyncAPI') //check youtube link - }); it('checks TwitterTimelineEmbed', () => { cy.get('[data-testid="Newsroom-Twitter"]').should('exist'); // data-test was not working }); - - }); diff --git a/cypress/test/newsroom/NewsroomArticle.cy.js b/cypress/test/newsroom/NewsroomArticle.cy.js index 5f49663e8e7..bda9ddeff1a 100644 --- a/cypress/test/newsroom/NewsroomArticle.cy.js +++ b/cypress/test/newsroom/NewsroomArticle.cy.js @@ -9,7 +9,6 @@ describe('Newsroom Article Component', () => { cy.get(`[data-testid="NewsroomArticle-${ index }"]`).should('have.attr', 'href', article.url); cy.get(`[data-testid="NewsroomArticle-${ index }"]`).should('contain.text', article.title); cy.get(`[data-testid="NewsroomArticle-${ index }"]`).should('contain.text', article.publishDate); - }); }); }); \ No newline at end of file diff --git a/cypress/test/newsroom/NewsroomSection.cy.js b/cypress/test/newsroom/NewsroomSection.cy.js index fd3f59367e0..a7d5b451de5 100644 --- a/cypress/test/newsroom/NewsroomSection.cy.js +++ b/cypress/test/newsroom/NewsroomSection.cy.js @@ -6,17 +6,14 @@ describe('Newsroom Section Component', () => { mount(); }); - it('renders without errors', () => { + it('renders without errors', () => {}); - }); it('check if Features Blog Post exists', () => { cy.get('[data-testid="NewsroomSection-Featured"]').should('exist'); - }); it('check content of Newsroom component', () => { cy.get('[data-testid="NewsroomSection-main"]').contains(newsroom[0]); }) - }); diff --git a/cypress/test/newsroom/NewsroomYoutube.cy.js b/cypress/test/newsroom/NewsroomYoutube.cy.js index 216ded8ab7b..21ffaee96bc 100644 --- a/cypress/test/newsroom/NewsroomYoutube.cy.js +++ b/cypress/test/newsroom/NewsroomYoutube.cy.js @@ -4,18 +4,18 @@ import NewsroomYoutube from '../../../components/newsroom/NewsroomYoutube'; describe('Newsroom Youtube', () => { beforeEach(() => { mount(); - }); - it('renders without errors', () => { - }); + it('renders without errors', () => {}); + it('checks if swiper component is present', () => { cy.get('[ data-testid="NewsroomYoutube-main"]').should('exist') - }); + it('checks if the first slide is active', () => { cy.get('.swiper-slide-active').should('exist') }); + it('slides to the next slide', () => { cy.get('[data-testid="Youtube-Next-button"]').click({force: true }) cy.get('.swiper-slide-active').should('exist') diff --git a/cypress/test/newsroom/swiper.cy.js b/cypress/test/newsroom/swiper.cy.js index b7863747fc9..e000cadd018 100644 --- a/cypress/test/newsroom/swiper.cy.js +++ b/cypress/test/newsroom/swiper.cy.js @@ -3,12 +3,10 @@ import { checkLastSnapIndex } from '../../../components/newsroom/swiper'; describe('checkLastSnapIndex', () => { it('should check the last snap index correctly for different viewport widths', () => { cy.viewport(1280, 720); // Set the viewport width to 1280px - const isLastSnapIndex1 = checkLastSnapIndex(3); expect(isLastSnapIndex1).to.be.false; cy.viewport(640, 480); // Set the viewport width to 640px - const isLastSnapIndex2 = checkLastSnapIndex(4); expect(isLastSnapIndex2).to.be.true; });