-
-
Notifications
You must be signed in to change notification settings - Fork 637
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add unit tests for AlgoliaSearch,GeneratorInstallation and Open…
…APIComparison component (#1916) Co-authored-by: akshatnema <[email protected]>
- Loading branch information
1 parent
ac4dad3
commit 103a859
Showing
4 changed files
with
114 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { mount } from 'cypress/react' | ||
import AlgoliaSearch from '../../components/AlgoliaSearch' | ||
import { SearchButton } from '../../components/AlgoliaSearch'; | ||
import { DocSearchModal } from '@docsearch/react' | ||
|
||
describe('AlgoliaSearch component', () => { | ||
it('renders without errors', () => { | ||
mount( | ||
<AlgoliaSearch> | ||
<SearchButton>Search</SearchButton> | ||
</AlgoliaSearch> | ||
) | ||
}) | ||
|
||
it('performs search for a specific page', () => { | ||
mount( | ||
<AlgoliaSearch> | ||
<SearchButton>Open Search</SearchButton> | ||
</AlgoliaSearch> | ||
); | ||
cy.get('button').click(); // Open the search modal | ||
cy.get('input[placeholder="Search resources"]').type('welcome') | ||
cy.should('have.value', 'welcome') | ||
// Check if the docsearch-list element contains the text 'Welcome' | ||
cy.get('#docsearch-list').contains('Welcome') | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { mount } from 'cypress/react'; | ||
import GeneratorInstallation from '../../components/GeneratorInstallation'; | ||
|
||
describe('GeneratorInstallation', () => { | ||
it('renders without errors', () => { | ||
mount(<GeneratorInstallation />); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { mount } from '@cypress/react' | ||
import OpenAPIComparison from '../../components/OpenAPIComparison' | ||
|
||
describe('OpenAPIComparison', () => { | ||
it('renders without errors', () => { | ||
mount(<OpenAPIComparison />); | ||
|
||
}); | ||
|
||
it('changes background color on hover', () => { | ||
mount(<OpenAPIComparison />); | ||
|
||
// Hover over the "Info" element | ||
cy.contains('Info').trigger('mouseover'); | ||
cy.get('[data-testid="OpenAPI-sec-info"]').should('exist'); | ||
|
||
// Hover over the "Servers" element | ||
cy.contains('Servers').trigger('mouseover'); | ||
cy.get('[data-testid="OpenAPI-sec-servers"]').should('exist'); | ||
|
||
// Hover over the "Paths" element | ||
cy.contains('Paths').trigger('mouseover'); | ||
cy.get('[data-testid="OpenAPI-paths"]').should('exist'); | ||
|
||
// Hover over the "Path Item" element | ||
cy.contains('Path Item').trigger('mouseover'); | ||
cy.get('[data-testid="OpenAPI-path-item"]').should('exist'); | ||
|
||
// Hover over the "Summary and description" element | ||
cy.contains('Summary and description').trigger('mouseover'); | ||
cy.get('[data-testid="OpenAPI-summary"]').should('exist'); | ||
|
||
// Hover over the "Operation (GET, PUT, POST, etc.)" element | ||
cy.contains('Operation (GET, PUT, POST, etc.)').trigger('mouseover'); | ||
cy.get('[data-testid="OpenAPI-operation"]').should('exist'); | ||
|
||
// Hover over the "Request" element | ||
cy.contains('Request').trigger('mouseover'); | ||
cy.get('[data-testid="OpenAPI-request"]').should('exist'); | ||
|
||
// Hover over the "Responses" element | ||
cy.contains('Responses').trigger('mouseover'); | ||
cy.get('[data-testid="OpenAPI-responses"]').should('exist'); | ||
|
||
// Hover over the "Tags" element | ||
cy.contains('Tags').trigger('mouseover'); | ||
cy.get('[data-testid="OpenAPI-tags"]').should('exist'); | ||
|
||
// Hover over the "External Docs" element | ||
cy.contains('External Docs').trigger('mouseover'); | ||
cy.get('[data-testid="OpenAPI-external"]').should('exist'); | ||
|
||
// Hover over the "Components" element | ||
cy.contains('Components').trigger('mouseover'); | ||
cy.get('[data-testid="OpenAPI-components"]').should('exist'); | ||
}); | ||
}); |