-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into slo/fix-discover-link
- Loading branch information
Showing
72 changed files
with
2,433 additions
and
1,923 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
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
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
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
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
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
11 changes: 11 additions & 0 deletions
11
packages/kbn-language-documentation-popover/setup_tests.ts
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,11 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import '@testing-library/jest-dom'; |
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
95 changes: 95 additions & 0 deletions
95
packages/kbn-language-documentation-popover/src/components/as_flyout/index.test.tsx
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,95 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import React from 'react'; | ||
import { screen, render, fireEvent, waitFor } from '@testing-library/react'; | ||
import { LanguageDocumentationFlyout } from '.'; | ||
|
||
jest.mock('../../sections', () => { | ||
const module = jest.requireActual('../../sections'); | ||
return { | ||
...module, | ||
getESQLDocsSections: () => ({ | ||
groups: [ | ||
{ | ||
label: 'Section one', | ||
description: 'Section 1 description', | ||
items: [], | ||
}, | ||
{ | ||
label: 'Section two', | ||
items: [ | ||
{ | ||
label: 'Section two item 1', | ||
description: 'Section two item 1 description', | ||
}, | ||
{ | ||
label: 'Section two item 2', | ||
description: 'Section two item 2 description', | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'Section three', | ||
items: [ | ||
{ | ||
label: 'Section three item 1', | ||
description: 'Section three item 1 description', | ||
}, | ||
{ | ||
label: 'Section three item 2', | ||
description: 'Section three item 2 description', | ||
}, | ||
], | ||
}, | ||
], | ||
initialSection: <span>Here is the initial section</span>, | ||
}), | ||
}; | ||
}); | ||
|
||
describe('###Documentation flyout component', () => { | ||
const renderFlyout = (linkToDocumentation?: string) => { | ||
return render( | ||
<LanguageDocumentationFlyout | ||
isHelpMenuOpen={true} | ||
onHelpMenuVisibilityChange={jest.fn()} | ||
linkToDocumentation={linkToDocumentation} | ||
/> | ||
); | ||
}; | ||
it('has a header element for navigation through the sections', () => { | ||
renderFlyout(); | ||
expect(screen.getByTestId('language-documentation-navigation-search')).toBeInTheDocument(); | ||
expect(screen.getByTestId('language-documentation-navigation-dropdown')).toBeInTheDocument(); | ||
expect(screen.queryByTestId('language-documentation-navigation-link')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('has a link if linkToDocumentation prop is given', () => { | ||
renderFlyout('meow'); | ||
expect(screen.getByTestId('language-documentation-navigation-link')).toBeInTheDocument(); | ||
}); | ||
|
||
it('contains the two last sections', async () => { | ||
renderFlyout(); | ||
await waitFor(() => { | ||
expect(screen.getByText('Section two')).toBeInTheDocument(); | ||
expect(screen.getByText('Section three')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('contains the correct section if user updates the search input', async () => { | ||
renderFlyout(); | ||
const input = screen.getByTestId('language-documentation-navigation-search'); | ||
fireEvent.change(input, { target: { value: 'two' } }); | ||
await waitFor(() => { | ||
expect(screen.getByText('Section two')).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.