editor.js/test/cypress/tests/ui/DataEmpty.cy.ts
Peter Savchenko 9c1e2e59ba
feat(ui): placeholders updated (#2758)
* data-empty mark

* Update CHANGELOG.md

* lint

* tests added

* Update DataEmpty.cy.ts

* lint

* fix tests

* Update Placeholders.cy.ts

* upd paragraph

* rm redundant test

* lint fix

* disable test for firefox
2024-07-04 14:55:01 +03:00

71 lines
1.8 KiB
TypeScript

import { createEditorWithTextBlocks } from '../../support/utils/createEditorWithTextBlocks';
describe('inputs [data-empty] mark', function () {
it('should be added to inputs of editor on initialization', function () {
createEditorWithTextBlocks([
'First', // not empty block
'', // empty block
]);
cy.get('[data-cy=editorjs]')
.find('.ce-paragraph')
.first()
.should('have.attr', 'data-empty', 'false');
cy.get('[data-cy=editorjs]')
.find('.ce-paragraph')
.last()
.should('have.attr', 'data-empty', 'true');
});
it('should be added as "false" to the input on typing', function () {
createEditorWithTextBlocks([
'First', // not empty block
'', // empty block
]);
cy.get('[data-cy=editorjs]')
.find('.ce-paragraph')
.last()
.type('Some text');
cy.get('[data-cy=editorjs]')
.find('.ce-paragraph')
.last()
.should('have.attr', 'data-empty', 'false');
});
it('should be added as "true" to the input on chars removal', function () {
createEditorWithTextBlocks([
'', // empty block
'Some text', // not empty block
]);
cy.get('[data-cy=editorjs]')
.find('.ce-paragraph')
.last()
.type('{selectall}{backspace}');
cy.get('[data-cy=editorjs]')
.find('.ce-paragraph')
.last()
.should('have.attr', 'data-empty', 'true');
});
it('should be added to the new block inputs', function () {
createEditorWithTextBlocks([
'First', // not empty block
'', // empty block
]);
cy.get('[data-cy=editorjs]')
.find('.ce-paragraph')
.last()
.type('{enter}');
cy.get('[data-cy=editorjs]')
.find('.ce-paragraph')
.last()
.should('have.attr', 'data-empty', 'true');
});
});