Skip to content

Commit ab4c716

Browse files
committed
fix(linkTool): add test case to ensure text formatting preservation when applying link
1 parent 6ac0b56 commit ab4c716

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

test/cypress/tests/inline-tools/link.cy.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,75 @@ describe('Inline Tool Link', () => {
121121
.should('exist')
122122
.should('contain', 'Text with link');
123123
});
124+
125+
it('should preserve bold and italic when applying link', () => {
126+
cy.createEditor({
127+
data: {
128+
blocks: [
129+
{
130+
type: 'paragraph',
131+
data: {
132+
text: 'Bold and italic text',
133+
},
134+
},
135+
],
136+
},
137+
});
138+
139+
cy.get('[data-cy=editorjs]')
140+
.find('.ce-paragraph')
141+
.selectText('Bold and italic text');
142+
143+
cy.get('[data-cy=editorjs]')
144+
.find('[data-item-name=bold]')
145+
.click();
146+
147+
cy.get('[data-cy=editorjs]')
148+
.find('div.ce-block')
149+
.find('b')
150+
.should('exist')
151+
.should('contain', 'Bold and italic text');
152+
153+
cy.get('[data-cy=editorjs]')
154+
.find('div.ce-block')
155+
.find('b')
156+
.selectText('Bold and italic text');
157+
158+
cy.get('[data-cy=editorjs]')
159+
.find('[data-item-name=italic]')
160+
.click();
161+
162+
cy.get('[data-cy=editorjs]')
163+
.find('div.ce-block')
164+
.find('b')
165+
.should('exist')
166+
.find('i')
167+
.should('exist')
168+
.should('contain', 'Bold and italic text');
169+
170+
cy.get('[data-cy=editorjs]')
171+
.find('div.ce-block')
172+
.find('b')
173+
.find('i')
174+
.selectText('Bold and italic text');
175+
176+
cy.get('[data-cy=editorjs]')
177+
.find('[data-item-name=link]')
178+
.click();
179+
180+
cy.get('[data-cy=editorjs]')
181+
.find('.ce-inline-tool-input')
182+
.type('https://editorjs.io')
183+
.type('{enter}');
184+
185+
cy.get('[data-cy=editorjs]')
186+
.find('div.ce-block')
187+
.find('b')
188+
.should('exist')
189+
.find('i')
190+
.should('exist')
191+
.find('a')
192+
.should('have.attr', 'href', 'https://editorjs.io')
193+
.should('contain', 'Bold and italic text');
194+
});
124195
});

0 commit comments

Comments
 (0)