-
-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add integration tests for dashboard component & community pages #1953
Changes from 11 commits
36cf5b1
1683fba
2d3511f
d21f53b
c9d07ea
e9bdc03
1eaf47f
3d25ae8
9ad0ca2
5049edb
ed1d8d0
37b81e9
1c69e4b
a6d2646
5ece9f1
3efcff7
447c4bf
930e5b9
a2a043c
741b3fa
0009188
8d85110
3fb3789
3c778c5
b1fda59
c64241a
95d5966
47f12db
db03487
c13b3d7
b32aece
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,10 +22,11 @@ describe('Header', () => { | |
'contain', | ||
'Visualize our progress. Get involved.' | ||
); | ||
cy.get('[data-testid="Github-button"]').should('exist'); | ||
cy.get('[data-testid="Slack-button"]').should('exist'); | ||
|
||
cy.contains('Contribution Guide') | ||
.should('have.attr', 'href', 'https://github.com/asyncapi?type=source#-contribute-to-asyncapi') | ||
.should('have.attr', 'target', '_blank'); | ||
cy.contains('View on Github') | ||
cy.contains('Join on Slack') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did we change these tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import MockApp from "../../../../utils/mockApp"; | ||
import Index from '../../../../../pages/community/ambassadors/index' | ||
import ambassadorList from '../../../../../config/ambassador_lists.json' | ||
import ambassadors from '../../../../../config/AMBASSADORS_MEMBERS.json' | ||
import { addAdditionalUserInfo } from "../../../../../pages/community/ambassadors/index"; | ||
import { sortBy } from 'lodash'; | ||
reachaadrika marked this conversation as resolved.
Show resolved
Hide resolved
|
||
describe('Test for Ambassadors', () => { | ||
beforeEach(() => { | ||
cy.mount(<MockApp><Index /></MockApp>) | ||
}); | ||
|
||
it('displays the main Ambassadors section ', () => { | ||
cy.get('[data-testid="Ambassadors-main"]').should('exist') | ||
cy.get('[data-testid="Ambassadors-content"]').should('exist') | ||
cy.get('[data-testid="Ambassadors-button"]').should('exist') | ||
cy.get(`[href="https://github.com/asyncapi/community/blob/master/AMBASSADOR_ORGANIZATION.md#are-you-interested-in-becoming-an-official-asyncapi-ambassador"]`).should('exist'); | ||
cy.get('[data-testid="Ambassadors-Iframe"]').should('exist') | ||
cy.get('[data-testid="Ambassadors-contributions"]').should('exist') | ||
}); | ||
|
||
it('renders the ambassador list with correct data', () => { | ||
ambassadorList.contents.forEach((link) => { | ||
cy.get('[data-testid="Ambassadors-list"]') | ||
.find(`img[alt="${link.title}"]`) | ||
.should('exist') | ||
.and('have.attr', 'src', link.icon); | ||
|
||
cy.get('[data-testid="Ambassadors-list"]') | ||
.contains('h2', link.title) | ||
.should('exist'); | ||
|
||
cy.get('[data-testid="Ambassadors-list"]') | ||
.contains('p', link.details) | ||
.should('exist'); | ||
}); | ||
}); | ||
|
||
it('renders the ambassadors with correct data', () => { | ||
const asyncapiAmbassadors = sortBy( | ||
ambassadors.map((user) => addAdditionalUserInfo(user)), | ||
['name'] | ||
); | ||
cy.get('[data-testid="Ambassadors-members-main"]') | ||
.children() | ||
.should('have.length', asyncapiAmbassadors.length); | ||
|
||
asyncapiAmbassadors.forEach((ambassador) => { | ||
cy.get('[data-testid="Ambassadors-members-details"]') | ||
.contains('div', ambassador.name) | ||
|
||
cy.get('[data-testid="Ambassadors-members-img"]') | ||
.find(`img[alt="${ambassador.name}"]`) | ||
|
||
.and('have.attr', 'src', ambassador.img); | ||
|
||
cy.get('[data-testid="Ambassadors-members"]') | ||
.contains('div', ambassador.title); | ||
|
||
}); | ||
|
||
}); | ||
|
||
it('displays the Tokens of our appreciation section with correct data', () => { | ||
cy.contains('Tokens of our appreciation').should('exist'); | ||
|
||
cy.contains('We appreciate your commitment and passion for sharing your knowledge with your communities. Let us support you!') | ||
.should('exist'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of checking for the content, check for the respective tags, whether they are present. We are not concerned about testing the content inside the tag, we are testing whether the heading and relative content to it is present or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
ambassadorList.tokens.forEach((token) => { | ||
cy.contains('.mt-20 li', token.emoji).should('exist'); | ||
cy.contains('.mt-20 li', token.title).should('exist'); | ||
cy.contains('.mt-20 li', token.details).should('exist'); | ||
}); | ||
}); | ||
|
||
it('displays the Become an AsyncAPI Ambassador section with correct data', () => { | ||
cy.contains('Become an AsyncAPI Ambassador').should('exist'); | ||
|
||
cy.contains('The AsyncAPI Ambassador program is now open for applications! If you’re selected, you’ll join AsyncAPI\'s mission of helping community members all over the world, build the future of Event-Driven APIs.') | ||
.should('exist'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't check for content, check for the tags using data-testid. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
cy.contains('Become an Ambassador now') | ||
.should('have.attr', 'href', 'https://github.com/asyncapi/community/blob/master/AMBASSADOR_ORGANIZATION.md#are-you-interested-in-becoming-an-official-asyncapi-ambassador'); | ||
}); | ||
|
||
it('should display NewsletterSubscribe', () => { | ||
cy.get('[data-testid="NewsletterSubscribe-main"]').should('exist'); | ||
cy.get('[data-testid="NewsletterSubscribe-text-input"]').type("name"); | ||
cy.get('[data-testid="NewsletterSubscribe-email-input"]').type("[email protected]") | ||
cy.get('form[name="form 1"]').should('exist'); | ||
cy.get('input[name="type"]').should('exist'); | ||
cy.get('input[name="name"]').should('exist'); | ||
cy.get('input[name="email"]').should('exist'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import MockApp from "../../../utils/mockApp"; | ||
import Home from "../../../../pages/community/dashboard"; | ||
import Header from "../../../../components/dashboard/Header"; | ||
import { mount } from '@cypress/react' | ||
describe('Integration Test for Dashboard ', () => { | ||
|
||
it('should filter GoodFirstIssues and check dashboard render ', () => { | ||
mount( | ||
<MockApp> | ||
<Home /> | ||
</MockApp> | ||
); | ||
// Click on the first filter option | ||
cy.get(Header).should('exist') | ||
cy.contains('AsyncAPI - Dashboard') | ||
cy.get('[data-testid="Filters-img-container"]').click({ force: true }); | ||
cy.get('[data-testid="Filter-menu"]').within(() => { | ||
cy.get('[data-testid="Select-form"]').eq(0).select('asyncapi/generator', { force: true }); | ||
cy.get('[data-testid="Select-form"]').eq(1).select('docs') | ||
}); | ||
//check if selected is only displayed | ||
cy.contains('asyncapi/generator'); | ||
cy.contains('docs') | ||
//check if this is not selected options are not displayed | ||
cy.should('not.contain', 'asyncapi/community'); | ||
cy.should('not.contain', 'javascript'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import MockApp from "../../../utils/mockApp"; | ||
import CommunityIndexPage from "../../../../pages/community"; | ||
|
||
describe('CommunityIndexPage', () => { | ||
beforeEach(() => { | ||
cy.mount(<MockApp><CommunityIndexPage /></MockApp>) | ||
}); | ||
|
||
it('displays the page title & check for first Community Home Card', () => { | ||
cy.contains('AsyncAPI Community Meetings'); | ||
cy.get('[data-testid="CommunityIndex-HomeCard"]').should('exist') | ||
cy.get('[data-testid="HomeCard-main"]').contains('Thanking our AsyncAPI Ambassadors') | ||
cy.get('[data-testid="HomeCard-title"]').contains('Ambassador Programs') | ||
cy.get(`[href="/community/ambassadors"]`).should('exist'); | ||
cy.get('[data-testid="HomeCard-button"]').should('exist'); | ||
cy.get(".bg-ambassador").should('exist') | ||
}); | ||
|
||
it('checks for CommunityIndex Display Card', () => { | ||
cy.get('[data-testid="CommunityIndex-IssuesCard"]').should('exist') | ||
cy.get('[data-testid="Card-lg-bg"]').should('have.class', 'bg-code-editor-dark') | ||
cy.get('[data-testid="Card-lg-tagline"]').should('have.class', 'bg-pink-100') | ||
cy.get('[data-testid="Card-heading-lg"]').should('exist'); | ||
cy.get('[data-testid="Card-desc-lg"]').should('exist'); | ||
cy.get(`[href="/community/dashboard"]`).should('exist'); | ||
}); | ||
|
||
it('should display the Newsroom Card', () => { | ||
cy.get('[data-testid="CommunityIndex-Newsroom-Card"]').should('exist'); | ||
cy.get('[data-testid="Card-lg-bg"]').should('have.class', 'bg-code-editor-dark'); | ||
cy.get('[data-testid="Card-lg-tagline"]').should('have.class', 'bg-pink-100'); | ||
cy.get('[data-testid="Card-heading-lg"]').should('exist'); | ||
cy.get('[data-testid="Card-desc-lg"]').should('exist'); | ||
cy.get('[href="/community/newsroom"]').should('exist'); | ||
}); | ||
|
||
it('should display the Toolings Card', () => { | ||
cy.get('[data-testid="CommunityIndex-Toolings-Card"]').should('exist'); | ||
cy.get('[data-testid="Card-lg-tagline"]').should('exist') | ||
cy.get('[data-testid="Card-heading-lg"]').should('exist') | ||
cy.get('[data-testid="Card-desc-lg"]').should('exist') | ||
cy.get('[href="/tools"]').should('exist'); | ||
}); | ||
|
||
it('should display other cards correctly', () => { | ||
cy.get('[data-testid="CommunityCards-Goals"]').should('exist'); | ||
cy.get('[href="https://github.com/asyncapi/community/discussions/513"]').should('exist'); | ||
cy.get('[data-testid="CommunityCards-Contributors"]').should('exist'); | ||
cy.get('[href="https://github.com/orgs/asyncapi/discussions/593"]').should('exist'); | ||
cy.get('[data-testid="CommunityCards-TSC"]').should('exist'); | ||
cy.get('[href="/community/tsc"]').should('exist'); | ||
}); | ||
|
||
it('should display slack card ' ,() => { | ||
cy.get('[data-testid="CommunityCards-Slack"]').should('exist'); | ||
cy.get('[data-testid="CommunityIndex-HomeCard"]').should('exist') | ||
cy.get('[data-testid="HomeCard-main"]').contains('All community info, tracked') | ||
cy.get('[data-testid="HomeCard-title"]').contains('AsyncAPI Slack') | ||
cy.get(`[href="https://asyncapi.com/slack-invite"]`).should('exist'); | ||
cy.get('[data-testid="HomeCard-button"]').should('exist'); | ||
cy.get(".bg-channelCover").should('exist') | ||
}); | ||
|
||
it('should display NewsletterSubscribe',()=>{ | ||
cy.get('[data-testid="CommunityCard-subscribe"]').should('exist'); | ||
cy.get('[data-testid="NewsletterSubscribe-main"]').should('exist'); | ||
cy.get('[data-testid="NewsletterSubscribe-text-input"]').type("name"); | ||
cy.get('[data-testid="NewsletterSubscribe-email-input"]').type("[email protected]") | ||
cy.get('form[name="form 1"]').should('exist'); | ||
cy.get('input[name="type"]').should('exist'); | ||
cy.get('input[name="name"]').should('exist'); | ||
cy.get('input[name="email"]').should('exist'); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test shouldn't be repeated for every file. Instead, make integration test for this component in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import MockApp from "../../../utils/mockApp"; | ||
import { mount } from "@cypress/react"; | ||
import NewsroomSection from '../../../../components/newsroom/NewsroomSection' | ||
|
||
describe('Test for Newsroom Section Pages', () => { | ||
it('renders correctly', () => { | ||
mount( | ||
<MockApp> | ||
<NewsroomSection/> | ||
</MockApp> | ||
); | ||
|
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import AppContext from "../../context/AppContext"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
import { MDXProvider } from "../../components/MDX"; | ||
import Layout from "../../components/layout/Layout"; | ||
import AlgoliaSearch from "../../components/AlgoliaSearch"; | ||
import { createRouter } from "./router"; | ||
import MockRouter from "./router"; | ||
|
||
import Head from "next/head"; | ||
|
||
export default function MockApp({ children }) { | ||
return ( | ||
<AppContext.Provider value={{ path: createRouter.asPath }}> | ||
<Head> | ||
<script async defer src="https://buttons.github.io/buttons.js"></script> | ||
</Head> | ||
<MDXProvider> | ||
<AlgoliaSearch> | ||
<div className="flex flex-col min-h-screen"> | ||
<MockRouter pathname="/"> | ||
<Layout> {children} </Layout> | ||
</MockRouter> | ||
</div> | ||
</AlgoliaSearch> | ||
</MDXProvider> | ||
</AppContext.Provider> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines shouldn't be removed. We should also check for buttons using data-testid also, apart from checking it via text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done