Skip to content

Commit

Permalink
Fix API key modal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Strift committed Feb 11, 2025
1 parent 2a443ab commit 140de96
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 38 deletions.
37 changes: 37 additions & 0 deletions cypress/e2e/test-api-key-modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const WAITING_TIME = Cypress.env('waitingTime')

describe(`API key modal`, () => {
before(() => {
cy.deleteAllIndexes()
cy.wait(WAITING_TIME)
})

beforeEach(() => {
cy.visit('/')
})

describe('Landing page', () => {
it('Does not redirect if no API key is set', () => {
cy.url().should('match', /\//)
})

it('Should display the default view', () => {
cy.contains(
'This dashboard will help you check the search results with ease.'
)
cy.contains('Set your API key (optional)')
cy.contains('Select an index')
})
})

describe('Opening the modal', () => {
it('Should display a message telling that no api key is required', () => {
cy.get('span').contains('API Key').parent().click()
cy.wait(WAITING_TIME)
cy.get('div[aria-label=settings-api-key]').within(() => {
cy.contains('Enter your admin API key (optional)')
cy.contains('No API key provided.')
})
})
})
})
34 changes: 0 additions & 34 deletions cypress/e2e/test-no-api-key-required.cy.js

This file was deleted.

8 changes: 4 additions & 4 deletions src/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ const ApiKey = ({ requireApiKeyToWork }) => {
<ApiKeyModalContent closeModal={() => dialog.hide()} />
) : (
<Typography variant="typo11" color="gray.6">
You haven&apos;t set an API key yet, if you want to set one you can
read the{' '}
<Link href="https://docs.meilisearch.com/reference/api/keys.html">
documentation
No API key provided. Learn about{' '}
<Link href="https://www.meilisearch.com/docs/reference/api/keys">
API keys
</Link>
.
</Typography>
)}
</Modal>
Expand Down

0 comments on commit 140de96

Please sign in to comment.