Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ckeditors are rendered as hidden during tests when testing with react testing libraries #305

Open
M-Ravilal opened this issue Jun 10, 2024 · 1 comment

Comments

@M-Ravilal
Copy link

I am getting the ckeditor rendered as hidden during tests using react testing library. Here is the sample code of the component and test structure
Component setup:

<RichTextEditor
name='choice'
onChange={(event) => choiceChange(event)}
onReady={(editor) => {
setChoiceEditor(editor);
choiceEditorRef.current = editor;
}}
initData={choice}
readOnly={editData?.InUse}
/>

Test setup:
let isEdit = true;
const isTranslateActionType = false;
const renderMultipleChoiceScreen = async () =>
waitFor(() =>
expect(() => {
render(

);
}).not.toThrowError()
);

describe('MultipleChoice', () => {
afterEach(cleanup);

it('should render with all fields in Edit Mode, Select Line', async ()
=> {
await renderMultipleChoiceScreen();

const btnSelect = document.getElementById('select-question');
expect(btnSelect).toBeInTheDocument();
userEvent.click(btnSelect);

const btnReset = document.getElementById('reset');
expect(btnReset).toBeInTheDocument();
userEvent.click(btnReset);

userEvent.click(btnSelect);

const btnUpdate = document.getElementById('update');
expect(btnUpdate).toBeInTheDocument();
expect(btnUpdate).toBeDisabled();

});

tried this way
// CKEDITORS - renders as hidden during tests
expect( document.querySelectorAll('div[style*="display: none"]').length ).toBe(4); expect( document.querySelectorAll('div[style*="visibility: hidden"]').length ).toBe(4);

this works but unable to set the value and test the updated value

  • CKEditor version: 3.1.0
  • Installed CKEditor plugins: ckeditor4-react
@M-Ravilal
Copy link
Author

M-Ravilal commented Jun 11, 2024

@Comandeer @jacekbogdanski , can you please help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant