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: add unit tests for AuthorAvatars , TOC , Hero , Meeting and DemoAnimation and Figure components #1831

Merged
merged 21 commits into from
Jul 20, 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. AuthorAvatars : This is a standalone file in the code , which tells and shares the Author details . For this component I have included following tests :

  • renders the author avatars without links
  • renders the author avatars with links
    image

2. TOC : This is a standalone file in the code , I have included following testcases for this :

  • renders the TOC correctly with empty content
    -renders the TOC correctly
  • expands and collapses the TOC on click
    image

3. Hero : This is also a standalone file , and has the main hero component in the code . For this component I have included following tests :
image

4. Meeting : This is also a standalone file . I have included following test cases .
image

5.Figure : This is also a standalone file .
image

  1. DemoAnimation : This is also a standalone file .
    image

Related issue(s)
fixes #1830

@netlify
Copy link

netlify bot commented Jun 23, 2023

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 6f00ff2
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/64b96cfa1857690008c857dd
😎 Deploy Preview https://deploy-preview-1831--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.

@reachaadrika reachaadrika changed the title add additional tests deat : add additional tests Jun 23, 2023
@reachaadrika reachaadrika changed the title deat : add additional tests feat : add additional tests Jun 23, 2023
@reachaadrika reachaadrika changed the title feat : add additional tests feat: adding unit tests for additional components Jun 23, 2023
@github-actions
Copy link

github-actions bot commented Jun 23, 2023

⚡️ Lighthouse report for the changes in this PR:

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

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

it('renders the TOC correctly with empty content', () => {
mount(<TOC toc={[]} />);

cy.get('.hidden').should('not.exist');
Copy link
Member

Choose a reason for hiding this comment

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

use data-tested @reachaadrika

Copy link
Member

Choose a reason for hiding this comment

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

@reachaadrika Kindly address this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@akshatnema test-id is not working , here tried to use both the divs , since I am only checking for hidden which is an optional css

Comment on lines 50 to 66
it('expands and collapses the TOC on click', () => {
mount(<TOC toc={toc} />);

// Verify initial state
cy.get('.hidden').should('exist'); // TOC content should be hidden

// Click on the TOC header
cy.get('h5').click();

// Verify expanded state
cy.get('.hidden').should('not.exist'); // TOC content should be visible

// Click again on the TOC header
cy.get('h5').click();

// Verify collapsed state
cy.get('.hidden').should('exist'); // TOC content should be hidden
Copy link
Member

Choose a reason for hiding this comment

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

use data-tested @reachaadrika

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this component , I am checking if hidden is present or not and there is a check for this in multiple div blocks , thus data-testid doesn't work here

Comment on lines 35 to 46
cy.get('a')
.should('not.exist');

cy.get('img')
.eq(index)
.should('have.attr', 'src', author.photo)
.should('have.attr', 'title', author.name)
.should('have.class', index > 0 ? `absolute left-${index * 7} top-0` : `relative mr-${(authorsWithoutLinks.length - 1) * 7}`)
.should('have.class', `z-${(authorsWithoutLinks.length - 1 - index) * 10}`)
.should('have.class', 'h-10 w-10 border-2 border-white rounded-full object-cover hover:z-50');
});
});
Copy link
Member

Choose a reason for hiding this comment

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

use data-tested @reachaadrika

Comment on lines 53 to 63
cy.get(`a[alt="${author.name}"][href="${author.link}"]`)
.should('have.length', 1)
.within(() => {
cy.get('img')
.should('have.attr', 'src', author.photo)
.should('have.attr', 'title', author.name)
.should('have.class', index > 0 ? `absolute left-${index * 7} top-0` : `relative mr-${(authors.length - 1) * 7}`)
.should('have.class', `z-${(authors.length - 1 - index) * 10}`)
.should('have.class', 'h-10 w-10 border-2 border-white rounded-full object-cover hover:z-50');
});
});
Copy link
Member

Choose a reason for hiding this comment

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

why not data-tested

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.

Please go through the comments, and run through the code.
You should be using data-testid ..

@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 additional components feat: adding unit tests for AuthorAvatars , TOC , Hero , Meeting and DemoAnimation and Figure components Jun 27, 2023
@@ -71,7 +71,7 @@ export default function Feedback(className = '') {
<div className='block mx-auto w-fit'>
<img src='/img/illustrations/icons/icon-x.svg' className='md:w-14' />
</div>
<div className='text-center mx-auto text-lg mt-4'>
<div className='text-center mx-auto text-lg mt-4' data-testid="Feedback-div2">
Copy link
Member

Choose a reason for hiding this comment

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

Making naming convention with 1,2,3.. as suffux is not good practice, kindly update it with good naming for data-testid.

@@ -50,7 +50,7 @@ export default function Feedback(className = '') {
<div className='block mx-auto w-fit'>
<img src='/img/illustrations/icons/icon-check.svg' className='md:w-14' />
</div>
<div className='text-center mx-auto text-lg mt-4'>
<div className='text-center mx-auto text-lg mt-4' data-testid="Feedback-div">
Copy link
Member

Choose a reason for hiding this comment

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

Unit test for this component is not added in PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this component , I require another file namely Routers which is in another PR once that is merged I will push the tests for this component , since pushing this separately can cause conflicts

Copy link
Member

Choose a reason for hiding this comment

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

So,on which PR, these particular changes are dependent on?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For Feedback , it is dependent on Layout component pr #1914 , which has router file , and as you suggested in #1891 , to use the mock data here for PR #1914 , once it gets merged I can make the changes in PR #1914 so that is ready for a fresh review .

<Button className="block md:inline-block" text="Read the docs" href="/docs" icon={<ArrowRight className="-mb-1 h-5 w-5" />}
data-testid="Hero-Button"/>
{/* Wrap SearchButton with AlgoliaSearch component */}
<AlgoliaSearch>
Copy link
Member

Choose a reason for hiding this comment

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

Specify the reason for wrapping the Algolia Search in this component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here will writing the tests for Hero , Search Button was not able to access the context , and some other refs , thus wrapped AlgoliaSearch component around it

@akshatnema akshatnema changed the title feat: adding unit tests for AuthorAvatars , TOC , Hero , Meeting and DemoAnimation and Figure components feat: add unit tests for AuthorAvatars , TOC , Hero , Meeting and DemoAnimation and Figure components Jul 17, 2023
@akshatnema
Copy link
Member

/rtm

@asyncapi-bot
Copy link
Contributor

Hello, @akshatnema! 👋🏼
This PR is not up to date with the base branch and can't be merged.
Please update your branch manually with the latest version of the base branch.
PRO-TIP: Add a comment to your PR with the text: /au or /autoupdate and our bot will take care of updating the branch in the future. The only requirement for this to work is to enable Allow edits from maintainers option in your PR.
Thanks 😄

@akshatnema
Copy link
Member

/rtm

@asyncapi-bot asyncapi-bot merged commit 7d5c2fd into asyncapi:master Jul 20, 2023
12 checks passed
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 ( standalone files )
4 participants