Skip to content
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 InlineHelp ,MacWindow , Newsletter , Profile ,Remember and Warning components #1827

Merged
merged 39 commits into from
Jul 16, 2023

Conversation

reachaadrika
Copy link
Contributor

Description

  • In this PR , I have included the tests for some small UI components in the website , these components are present in the standalone files in the website . Following are the standalone files for which I have included the tests for :

1. InlineHelp.js : This is a toggle / hover component where when we hover on the Question Mark Icon , a helper text appears . The tests I have included here are as follows :

  • toggles help text visibility on click and hover
    image

2. MacWindow.js : In this component , a MAC like UI has to appear , the tests I have included here are as follows :

  • renders the component props
    image

3. NewsletterSubscribe : In this component , I have added the following tests :

  • renders the component with props
    image

4.Profile : For this profile component , I have added the following tests :

  • renders null when profiles array is empty
  • renders profile links and names when profiles array is not empty
    image

5. Remember : I have included following tests for this component :

  • renders the component with the provided title and children
  • renders the component with default title and no children
    image

6. Warning : I have included following tests for this component :
-renders the component with the provided title and description
image

Related issue(s)
fixes #1826

@netlify
Copy link

netlify bot commented Jun 22, 2023

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 0122320
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/64b3df92e28d49000879ac4c
😎 Deploy Preview https://deploy-preview-1827--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions
Copy link

github-actions bot commented Jun 23, 2023

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 57
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🔴 PWA 30

Lighthouse ran on https://deploy-preview-1827--asyncapi-website.netlify.app/

cy.get('[data-testid="InlineHelp"]').should('not.exist');

// Click on the question mark icon to show text
cy.get('svg').click();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-testID @reachaadrika

cy.get('[data-testid="InlineHelp"]').should('be.visible').should('contain', text);

// Click on the question mark icon again to hide text
cy.get('svg').click();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-testID @reachaadrika

cy.get('[data-testid="InlineHelp"]').should('not.exist');

// Hover the question mark icon to show text
cy.get('svg').trigger('mouseover');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-testID @reachaadrika

cy.get('[data-testid="InlineHelp"]').should('be.visible').should('contain', text);

// Move the cursor from the question mark icon to hide text
cy.get('svg').trigger('mouseout');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-testID @reachaadrika

Comment on lines 20 to 21
cy.get('div')
.should('have.class', className)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-testID @reachaadrika

it('renders the component with default props', () => {
mount(<NewsletterSubscribe />);

cy.get('div.p-8.text-center').should('exist');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-testID @reachaadrika

mount(<NewsletterSubscribe />);

cy.get('div.p-8.text-center').should('exist');
cy.contains('Subscribe to our newsletter').should('exist');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declare all the hardcode text in a constant variable, and use it here
const NewsletterConstants = [
"sentence1",
"sentence2"
]
And use Newsletter[0] like that, so the code becomes maintainable, when the text changes.


cy.get('div.p-8.text-center').should('exist');
cy.contains('Subscribe to our newsletter').should('exist');
cy.contains( 'We respect your inbox. No spam, promise ✌️').should('exist');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as discussed above

Copy link
Member

@imabp imabp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor Changes, please fix asap

@akshatnema
Copy link
Member

@reachaadrika Kindly update the PR title related to changes inside PR

@akshatnema akshatnema added the gsoc This label should be used for issues or discussions related to ideas for Google Summer of Code label Jun 27, 2023
@reachaadrika reachaadrika changed the title feat: adding unit tests for other additional components feat: adding unit tests for InlineHelp ,MacWindow , Newsletter , Profile ,Remember and Warning components Jun 27, 2023
Copy link
Member

@akshatnema akshatnema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the relevant changes inside test files as well, regarding naming conventions.

{title}
</div>
<div className="hidden sm:block"> {/* This block is used for aligning the title on the center */}
<div className="hidden sm:block" data-testid="MacWindow-title"> {/* This block is used for aligning the title on the center */}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div className="hidden sm:block" data-testid="MacWindow-title"> {/* This block is used for aligning the title on the center */}
<div className="hidden sm:block" data-testid="MacWindow-title-center"> {/* This block is used for aligning the title on the center */}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

components/NewsletterSubscribe.js Outdated Show resolved Hide resolved
@@ -13,13 +13,14 @@ export default function NewsletterSubscribe ({
const paragraphTextColor = dark ? 'text-gray-300' : ''

return (
<div className={className}>
<div className={className} data-testid="NewsletterSubscribe-div">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div className={className} data-testid="NewsletterSubscribe-div">
<div className={className} data-testid="NewsletterSubscribe-main">

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -3,9 +3,9 @@ export default function Profile({profiles = [], className}) {
return null;
}
return (
<div className="p-4 grid grid-cols-2 sm:grid-cols-4 gap-5 border border-slate-100 mt-4 rounded drop-shadow-md">
<div className="p-4 grid grid-cols-2 sm:grid-cols-4 gap-5 border border-slate-100 mt-4 rounded drop-shadow-md" data-testid="Profiles-div">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div className="p-4 grid grid-cols-2 sm:grid-cols-4 gap-5 border border-slate-100 mt-4 rounded drop-shadow-md" data-testid="Profiles-div">
<div className="p-4 grid grid-cols-2 sm:grid-cols-4 gap-5 border border-slate-100 mt-4 rounded drop-shadow-md" data-testid="Profiles-main">

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -2,10 +2,10 @@ import LightBulb from './icons/LightBulb'

export default function Remember({ title = 'Remember', className, children }) {
return (
<div className={`${className} p-4 mt-4 mb-8 bg-secondary-100 rounded text-gray-900`}>
<h5 className="pb-2 mb-4 border-b border-gray-900 text-lg">
<div className={`${className} p-4 mt-4 mb-8 bg-secondary-100 rounded text-gray-900`} data-testid="Remember-div">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div className={`${className} p-4 mt-4 mb-8 bg-secondary-100 rounded text-gray-900`} data-testid="Remember-div">
<div className={`${className} p-4 mt-4 mb-8 bg-secondary-100 rounded text-gray-900`} data-testid="Remember-main">

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -225,7 +225,7 @@
"github": "M3lkior",
"twitter": "ldussart",
"country": "🇫🇷",
"bio": "Ludovic has been working for Ineat for the last 10 years. Starting as a java developer, he is now a Solutions Architect, working with his customers to build EDA-oriented digital products wherever possible. His first contributions to AsyncAPI date back to 2020 around the kafka and avro specifications. Since then, Ludovic has been spreading the word about AsyncAPI to companies in Northern France, to accelerate adoption of the initiative.",
"bio": "Ludovic is an Ineat employee since 10 years. Starting as java developer, he is now Solutions Architect and work with his customers to build digital products, EDA oriented when possible. His first contributions on AsyncAPI was in 2020 around the kafka and avro specifications. Since this day, Ludovic talk about AsyncAPI in the North of France compagnies in order to speedup the initiative adoption.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the Ambassadors data has been changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not mean to change , this , it reflects the changes made by a merge commit . This is not the change I made .

Comment on lines 9 to 10
const title = '';
const children = '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some title and child elements here to test the component correctly and preview the Component in Cypress.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 7 to 8
const className = 'my-mac-window';
const contentClassName = 'my-content';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add correct classNames accordingly to check the properties similarly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 11 to 12
cy.contains(NewsletterConstants[0]).should('exist');
cy.contains(NewsletterConstants[1]).should('exist');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should insert the data inside forms instead of checking the data inside array this way. You can refer to - https://www.browserstack.com/guide/how-to-fill-and-submit-forms-in-cypress, to type the content inside forms and then check after submitting it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay @akshatnema will keep in mind

{
name: 'John Doe',
link: 'https://example.com/john',
avatar: 'john-avatar.png',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add proper filepath for avatar here from public folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@reachaadrika reachaadrika requested a review from Mayaleeeee as a code owner July 14, 2023 21:14
reachaadrika and others added 8 commits July 15, 2023 02:44
Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com>
Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com>
Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com>
Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com>
Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com>
@akshatnema
Copy link
Member

/rtm

@asyncapi-bot asyncapi-bot merged commit 277288d into asyncapi:master Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gsoc This label should be used for issues or discussions related to ideas for Google Summer of Code ready-to-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add tests for some other components
4 participants