Skip to content

Commit

Permalink
Add tests for panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Strift committed Feb 11, 2025
1 parent 140de96 commit 927016a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
26 changes: 0 additions & 26 deletions cypress/e2e/test-interface.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,6 @@ describe(`Test interface`, () => {
cy.visit('/')
})

// TODO: replace with a test about the side panel
it.skip('Should open the help center on click on the "?" button', () => {
cy.get('button[aria-label="help"]').click()
cy.get('div[aria-label="Help Center"]').within(() => {
cy.contains('Help Center')
cy.contains(
'If you need help with anything, here are a few links that can be useful.'
)
cy.contains('Explore our repositories on Github')
cy.contains('Join our Discord and find the help you need')
cy.contains('Learn how to tune your Meilisearch')
cy.get('a')
.first()
.should('have.attr', 'href', 'https://github.com/meilisearch')
.next()
.should('have.attr', 'href', 'https://discord.meilisearch.com')
.next()
.should(
'have.attr',
'href',
'https://docs.meilisearch.com/?utm_campaign=oss&utm_source=integration&utm_medium=minidashboard'
)
cy.get('button[aria-label="close"]').click()
})
})

it('Should contain a "Show more" button if a document has more than 6 fields', () => {
cy.get('ul')
.children()
Expand Down
22 changes: 22 additions & 0 deletions cypress/e2e/test-side-panel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const WAITING_TIME = Cypress.env('waitingTime')

Check failure on line 1 in cypress/e2e/test-side-panel.js

View workflow job for this annotation

GitHub Actions / linter-check

'WAITING_TIME' is assigned a value but never used

describe(`Right side panel`, () => {
beforeEach(() => {
cy.visit('/')
})

it('Should be opened by default', () => {
cy.get('[data-testid="right-panel"]').should('be.visible')
})

it('Should be closed when clicking on the close button', () => {
cy.get('button[aria-label="Close Panel"]').click()
cy.get('[data-testid="right-panel"]').should('not.be.visible')
})

it('Should be opened when clicking on the menu bars button', () => {
cy.get('button[aria-label="Close Panel"]').click()
cy.get('button[aria-label="Open Panel"]').click()
cy.get('[data-testid="right-panel"]').should('be.visible')
})
})
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const App = () => {
const [requireApiKeyToWork, setRequireApiKeyToWork] = useState(false)
const [currentIndex, setCurrentIndex] = useLocalStorage('currentIndex')
const [isApiKeyBannerVisible, setIsApiKeyBannerVisible] = useState(false)
const [isRightPanelOpen, setIsRightPanelOpen] = useState(false)
const [isRightPanelOpen, setIsRightPanelOpen] = useState(true)
const dialog = useDialogState({ animated: true, visible: false })

const {
Expand Down
6 changes: 5 additions & 1 deletion src/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ const Header = ({
<RightSideWrapper>
<ApiKey requireApiKeyToWork={requireApiKeyToWork} />
{!isRightPanelOpen && onTogglePanel && (
<IconButton onClick={onTogglePanel} type="button">
<IconButton
onClick={onTogglePanel}
type="button"
aria-label="Open Panel"
>
<MenuBarsIcon />
</IconButton>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/RightPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ const CloudCardLink = styled(Link)`
`

const RightPanel = ({ isOpen, onClose }) => (
<PanelWrapper isOpen={isOpen}>
<PanelWrapper isOpen={isOpen} data-testid="right-panel">
<Header>
<Title>Getting started</Title>
<CloseButton onClick={onClose}>
<CloseButton onClick={onClose} aria-label="Close Panel">
<MenuBarsIcon />
</CloseButton>
</Header>
Expand Down

0 comments on commit 927016a

Please sign in to comment.