-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: supporting edit visualization with input from a dialog Signed-off-by: Yulong Ruan <[email protected]> * fix: save instruction input Signed-off-by: Yulong Ruan <[email protected]> * fix: change internal error to bad request Signed-off-by: Yulong Ruan <[email protected]> * fix: use sass variable for 12px font size Signed-off-by: Yulong Ruan <[email protected]> * add CHANGELOG Signed-off-by: Yulong Ruan <[email protected]> --------- Signed-off-by: Yulong Ruan <[email protected]> (cherry picked from commit 6a49d78) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
- Loading branch information
1 parent
0dec84f
commit b46c79e
Showing
6 changed files
with
253 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render, screen, fireEvent, waitFor } from '@testing-library/react'; | ||
import { VizStyleEditor } from './viz_style_editor'; | ||
|
||
describe('<VizStyleEditor />', () => { | ||
test('should render visual style editor', () => { | ||
const onApplyFn = jest.fn(); | ||
render(<VizStyleEditor onApply={onApplyFn} iconType="icon" />); | ||
expect(screen.queryByText('Edit visual')).toBeInTheDocument(); | ||
|
||
// click Edit visual button to open the modal | ||
expect(screen.queryByTestId('text2vizStyleEditorModal')).toBe(null); | ||
fireEvent.click(screen.getByText('Edit visual')); | ||
expect(screen.queryByTestId('text2vizStyleEditorModal')).toBeInTheDocument(); | ||
|
||
// Click cancel to close the modal | ||
fireEvent.click(screen.getByText('Cancel')); | ||
expect(screen.queryByTestId('text2vizStyleEditorModal')).toBe(null); | ||
|
||
// Apply button is disabled | ||
fireEvent.click(screen.getByText('Edit visual')); | ||
expect(screen.getByTestId('text2vizStyleEditorModalApply')).toBeDisabled(); | ||
|
||
// After input text, Apply button is enabled | ||
fireEvent.input(screen.getByLabelText('Input instructions to tweak the visual'), { | ||
target: { value: 'test input' }, | ||
}); | ||
expect(screen.getByTestId('text2vizStyleEditorModalApply')).not.toBeDisabled(); | ||
fireEvent.click(screen.getByText('Apply')); | ||
expect(onApplyFn).toHaveBeenCalledWith('test input'); | ||
expect(screen.queryByTestId('text2vizStyleEditorModal')).toBe(null); | ||
}); | ||
|
||
test('should open the modal with initial value', () => { | ||
render(<VizStyleEditor onApply={jest.fn()} iconType="icon" value="test input" />); | ||
fireEvent.click(screen.getByText('Edit visual')); | ||
expect(screen.getByDisplayValue('test input')).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.