-
-
Notifications
You must be signed in to change notification settings - Fork 638
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: adding unit tests for layout component #1914
Conversation
✅ Deploy Preview for asyncapi-website ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-1914--asyncapi-website.netlify.app/ |
components/layout/Container.js
Outdated
<Tag className={fluid ? fluidClassNames : normalClassNames}> | ||
<Tag | ||
className={fluid ? fluidClassNames : normalClassNames} | ||
data-testid="Container-div" |
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.
data-testid="Container-div" | |
data-testid="Container-main" |
Applicable everywhere
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
components/layout/JobsLayout.js
Outdated
<ApplyJobButton | ||
job={post} | ||
className="mt-4 inline-block" | ||
data-testid="ApplyJobLayout" |
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.
data-testid="ApplyJobLayout" | |
data-testid="ApplyJobButton" |
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
components/AlgoliaSearch.js
Outdated
onOpen: () => {}, | ||
onClose: () => {}, | ||
onInput: () => {}, |
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.
Why are the functions, part of React Context?
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
}, | ||
{ | ||
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', | ||
}; |
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.
Test data shouldn't be part of test files. Make these content available inside fixtures
folder
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
@@ -0,0 +1,32 @@ | |||
import { mount } from 'cypress/react'; |
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.
Delete this component test file as it is no more in use inside codebase.
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
cypress/test/layout/JobsLayout.cy.js
Outdated
const post = { | ||
title: 'API Architect', | ||
date: '06/22/2021', | ||
category: 'Architect', | ||
closingOn: '08/22/2021', | ||
contact: 'https://apiture.com/careers/?gh_jid=5303104002', | ||
company: { | ||
name: 'Apiture', | ||
logoUrl: '/img/logos/companies/apiture.png', | ||
}, | ||
toc: [ | ||
{ | ||
content: 'About the team', | ||
slug: 'about-the-team', | ||
lvl: 2, | ||
i: 0, | ||
seen: 0, | ||
}, | ||
{ | ||
content: 'TL;DR', | ||
slug: 'tldr', | ||
lvl: 2, | ||
i: 1, | ||
seen: 0, | ||
}, | ||
{ | ||
content: 'About the job', | ||
slug: 'about-the-job', | ||
lvl: 2, | ||
i: 2, | ||
seen: 0, | ||
}, | ||
{ | ||
content: 'About you', | ||
slug: 'about-you', | ||
lvl: 2, | ||
i: 3, | ||
seen: 0, | ||
}, | ||
{ | ||
content: 'Pay and benefits', | ||
slug: 'pay-and-benefits', | ||
lvl: 2, | ||
i: 4, | ||
seen: 0, | ||
}, | ||
], | ||
readingTime: 5, | ||
excerpt: | ||
'About the team\n\nWe are an open API banking platform, focused on creating cutting-edge technology for financial institutions.\nThe platform allows banks the fast and flexible deployment of features that', | ||
sectionSlug: '/jobs', | ||
sectionWeight: 0, | ||
id: 'pages/jobs/apiture-api-architect.md', | ||
isIndex: false, | ||
slug: '/jobs/apiture-api-architect', | ||
}; |
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.
Add this static data in fixtures/post.json
and then use it here.
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
cypress/utils/router.js
Outdated
MockRouter.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
}; |
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.
Why do we need to define propTypes
like this? We are not using Typescript and eslint warnings can be ignored for now.
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
Co-authored-by: Akshat Nema <[email protected]>
Co-authored-by: Akshat Nema <[email protected]>
Co-authored-by: Akshat Nema <[email protected]>
Co-authored-by: Akshat Nema <[email protected]>
Co-authored-by: Akshat Nema <[email protected]>
Co-authored-by: Akshat Nema <[email protected]>
Co-authored-by: Akshat Nema <[email protected]>
components/Head.js
Outdated
{/* Twitter Card data */} | ||
<meta name="twitter:card" value="summary_large_image" /> | ||
<meta name="twitter:card" content="summary_large_image" /> |
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.
Why value
has been changed to content
?
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.
Changed this to some error , resolved this to previous one since it is not needed now .
…into layout_tests
…into layout_tests
/rtm |
Description
A brief Introduction , about Layout component , this component , has the basic layouts for all other components , and it renders the pattern in which these components have to be rendered
BlogLayout : This component renders the Blog like structure and renders the blog posts for this .
Column Layout : This component renders any children component in column component
DocsLayout : This component renders the Docs like structure and renders the docs posts for this
-JobsLayout : This component renders the Jobs like structure and renders the docs posts for this
-Layout , this component is the main file and renders the component based on various if and else basis , according to the pathnames , here I have added some extra divs that wraps these components for testing .
NOTE :- These components had extensive use of routers , thus I mocked routers since cypress doesn't provide this functionality I have mocked a Router and then wrapped the children components and have passed the pathname to it as value .
Related issue(s)
fixes #1913