From ab4c7161fe381f6b15864e132fbc791dd15cd369 Mon Sep 17 00:00:00 2001 From: Eugeny Date: Tue, 17 Feb 2026 02:14:59 +0300 Subject: [PATCH] fix(linkTool): add test case to ensure text formatting preservation when applying link --- test/cypress/tests/inline-tools/link.cy.ts | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/test/cypress/tests/inline-tools/link.cy.ts b/test/cypress/tests/inline-tools/link.cy.ts index 0c5e934a..8ae7220d 100644 --- a/test/cypress/tests/inline-tools/link.cy.ts +++ b/test/cypress/tests/inline-tools/link.cy.ts @@ -121,4 +121,75 @@ describe('Inline Tool Link', () => { .should('exist') .should('contain', 'Text with link'); }); + + it('should preserve bold and italic when applying link', () => { + cy.createEditor({ + data: { + blocks: [ + { + type: 'paragraph', + data: { + text: 'Bold and italic text', + }, + }, + ], + }, + }); + + cy.get('[data-cy=editorjs]') + .find('.ce-paragraph') + .selectText('Bold and italic text'); + + cy.get('[data-cy=editorjs]') + .find('[data-item-name=bold]') + .click(); + + cy.get('[data-cy=editorjs]') + .find('div.ce-block') + .find('b') + .should('exist') + .should('contain', 'Bold and italic text'); + + cy.get('[data-cy=editorjs]') + .find('div.ce-block') + .find('b') + .selectText('Bold and italic text'); + + cy.get('[data-cy=editorjs]') + .find('[data-item-name=italic]') + .click(); + + cy.get('[data-cy=editorjs]') + .find('div.ce-block') + .find('b') + .should('exist') + .find('i') + .should('exist') + .should('contain', 'Bold and italic text'); + + cy.get('[data-cy=editorjs]') + .find('div.ce-block') + .find('b') + .find('i') + .selectText('Bold and italic text'); + + cy.get('[data-cy=editorjs]') + .find('[data-item-name=link]') + .click(); + + cy.get('[data-cy=editorjs]') + .find('.ce-inline-tool-input') + .type('https://editorjs.io') + .type('{enter}'); + + cy.get('[data-cy=editorjs]') + .find('div.ce-block') + .find('b') + .should('exist') + .find('i') + .should('exist') + .find('a') + .should('have.attr', 'href', 'https://editorjs.io') + .should('contain', 'Bold and italic text'); + }); });