-
Notifications
You must be signed in to change notification settings - Fork 918
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Multiple Datasource Test]Add test for toast button and validation fo…
…rm (#6755) (#6804) * add test for toast button and validation form * Changeset file for PR #6755 created/updated * Update src/plugins/data_source_management/public/components/toast_button/manage_data_source_button.tsx * Update manage_data_source_button.test.tsx * [Multiple Datasource Test] Add test for edit data source form (#6742) * add test for edit data source form * Changeset file for PR #6742 created/updated --------- * [MQL] support enhancing language selector (#6613) Enable with `data.enhancements.enabled: true` Allows for enhancing the data plugin UI service and search service. #### Remaining work * Address issue with time range being invalid if previous state successfully queried and set it with a time range format that is invalid for the new query language * For example, DQL with quick time range (4 weeks to now), get results. Switch to PPL, even though PPL has a default time range enhancement. The props date range saved in the app state takes priority and sets the time range to quick range causing an error. I can still modify the time range and get a successful query but it will first fail until the user updates it to a non quick time range. * Add tests * Disable for plugins that do not support the functionality * By default index patterns are created with a unique ID. However, it can be enabled to create an index pattern with a custom ID that matches the name of the index pattern (which in turn maps to indices). * For seamless integration, the temp data frame would need to check if the index pattern that maps to the data frame name. And get it's id. * This means that dashboards with visualizations that were created with an index pattern unique ID still require the existing index pattern to exist in memory. ### Issues Resolved closes #6639 closes #6311 partially resolves: #5504 * add error data frame move language to left, some styling and disable per app name --------- * Make Field Name Search Filter Case Insensitive (#6759) * Make Field Name Filter Case Insensitive * Changeset file for PR #6759 created/updated --------- * address naming for manage data source button test id --------- (cherry picked from commit f728b5a) Signed-off-by: yujin-emma <yujin.emma.work@gmail.com> Signed-off-by: Yu Jin <112784385+yujin-emma@users.noreply.github.com> Signed-off-by: Kawika Avilla <kavilla414@gmail.com> Signed-off-by: Paul Sebastian <paulstn@amazon.com> Signed-off-by: Suchit Sahoo <suchsah@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Co-authored-by: Lu Yu <nluyu@amazon.com> Co-authored-by: Kawika Avilla <kavilla414@gmail.com> Co-authored-by: Paul Sebastian <paulstn@amazon.com> Co-authored-by: Suchit Sahoo <38322563+LDrago27@users.noreply.github.com>
- Loading branch information
1 parent
a44bf8e
commit a8e034d
Showing
6 changed files
with
187 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fix: | ||
- Add test for toast button and validation form ([#6755](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6755)) |
38 changes: 38 additions & 0 deletions
38
.../data_source_management/public/components/toast_button/manage_data_source_button.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,38 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { getManageDataSourceButton } from './manage_data_source_button'; | ||
import { coreMock } from '../../../../../core/public/mocks'; | ||
import { DSM_APP_ID } from '../../plugin'; | ||
import { render } from '@testing-library/react'; | ||
|
||
describe('ManageDataSourceButton', () => { | ||
const applicationMock = coreMock.createStart().application; | ||
|
||
it('renders without crashing', () => { | ||
const wrapper = render(getManageDataSourceButton()); | ||
expect(wrapper).toBeTruthy(); | ||
}); | ||
|
||
it('renders a button with correct label', () => { | ||
const { getByTestId } = render(getManageDataSourceButton(applicationMock)); | ||
const container = getByTestId('manageDataSourceButtonContainer'); | ||
expect(container).toBeInTheDocument(); | ||
expect(container).toHaveTextContent('Manage data sources'); | ||
}); | ||
|
||
it('navigates to management app on button click', () => { | ||
const { getByTestId } = render(getManageDataSourceButton(applicationMock)); | ||
const button = getByTestId('manageDataSourceButton'); | ||
button.click(); | ||
expect(applicationMock.navigateToApp).toHaveBeenCalledTimes(1); | ||
|
||
expect(applicationMock.navigateToApp).toHaveBeenCalledWith('management', { | ||
path: `opensearch-dashboards/${DSM_APP_ID}`, // Assuming DSM_APP_ID is replaced with a value | ||
}); | ||
}); | ||
}); |
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
26 changes: 26 additions & 0 deletions
26
src/plugins/data_source_management/public/components/toast_button/reload_button.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,26 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { render, fireEvent } from '@testing-library/react'; | ||
import { getReloadButton } from './reload_button'; | ||
|
||
describe('getReloadButton', () => { | ||
it('renders button with correct label', () => { | ||
const { getByText } = render(getReloadButton()); | ||
expect(getByText('Refresh the page')).toBeInTheDocument(); | ||
}); | ||
|
||
it('calls window.location.reload() on button click', () => { | ||
const reloadMock = jest.fn(); | ||
Object.defineProperty(window, 'location', { | ||
value: { reload: reloadMock }, | ||
writable: true, | ||
}); | ||
|
||
const { getByText } = render(getReloadButton()); | ||
fireEvent.click(getByText('Refresh the page')); | ||
expect(reloadMock).toHaveBeenCalled(); | ||
}); | ||
}); |
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