-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #10719: enable upload images within Text widgets Description: - add 'prop' called 'enableUploadImg' passing it to 'CompactRichTextEditor' component to enable upload image - add unit test * #10719: revert naming enableUploadImg to be uploadEnabled
- Loading branch information
1 parent
ad51ceb
commit 779416d
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
web/client/components/mapviews/settings/__tests__/CompactRichTextEditor-test.jsx
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,50 @@ | ||
/* | ||
* Copyright 2025, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import CompactRichTextEditor from '../CompactRichTextEditor'; | ||
import expect from 'expect'; | ||
import TestUtils from 'react-dom/test-utils'; | ||
|
||
describe('CompactRichTextEditor component', () => { | ||
beforeEach((done) => { | ||
document.body.innerHTML = '<div id="container"></div>'; | ||
setTimeout(done); | ||
}); | ||
|
||
afterEach((done) => { | ||
ReactDOM.unmountComponentAtNode(document.getElementById("container")); | ||
document.body.innerHTML = ''; | ||
setTimeout(done); | ||
}); | ||
|
||
it('should render with default which does not include image upload', () => { | ||
ReactDOM.render(<CompactRichTextEditor />, document.getElementById("container")); | ||
const textEditorContainer = document.querySelector(".ms-compact-text-editor.rdw-editor-wrapper"); | ||
expect(textEditorContainer).toBeTruthy(); | ||
// check img upload btn | ||
const imageWidget = document.querySelector(".rdw-image-wrapper .rdw-option-wrapper"); | ||
TestUtils.act(() => { | ||
TestUtils.Simulate.click(imageWidget); | ||
}); | ||
const uploadImgInput = document.querySelector(".rdw-image-modal-upload-option"); | ||
expect(uploadImgInput).toBeFalsy(); | ||
}); | ||
it('test rendering TextEditor with enabling image upload [uploadEnabled]', () => { | ||
ReactDOM.render(<CompactRichTextEditor uploadEnabled />, document.getElementById("container")); | ||
const textEditorContainer = document.querySelector(".ms-compact-text-editor.rdw-editor-wrapper"); | ||
expect(textEditorContainer).toBeTruthy(); | ||
const imageWidget = document.querySelector(".rdw-image-wrapper .rdw-option-wrapper"); | ||
TestUtils.act(() => { | ||
TestUtils.Simulate.click(imageWidget); | ||
}); | ||
const uploadImgInput = document.querySelector(".rdw-image-modal-upload-option"); | ||
expect(uploadImgInput).toBeTruthy(); | ||
}); | ||
}); |
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