fix(tests): make WYSIWYG tests more robust and deterministic by initializing and attaching elements consistently, awaiting customElements/firstUpdated, adjusting selectors and assertions, and cleaning up DOM after tests
This commit is contained in:
@@ -47,12 +47,15 @@ tap.test('Block handlers should render content correctly', async () => {
|
||||
|
||||
const handler = BlockRegistry.getHandler('paragraph');
|
||||
expect(handler).toBeDefined();
|
||||
|
||||
|
||||
if (handler) {
|
||||
const rendered = handler.render(testBlock, false);
|
||||
// The render() method returns the HTML template structure
|
||||
// Content is set later in setup()
|
||||
expect(rendered).toContain('contenteditable="true"');
|
||||
expect(rendered).toContain('data-block-type="paragraph"');
|
||||
expect(rendered).toContain('Test paragraph content');
|
||||
expect(rendered).toContain('data-block-id="test-1"');
|
||||
expect(rendered).toContain('class="block paragraph"');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -65,12 +68,13 @@ tap.test('Divider handler should render correctly', async () => {
|
||||
|
||||
const handler = BlockRegistry.getHandler('divider');
|
||||
expect(handler).toBeDefined();
|
||||
|
||||
|
||||
if (handler) {
|
||||
const rendered = handler.render(dividerBlock, false);
|
||||
expect(rendered).toContain('class="block divider"');
|
||||
expect(rendered).toContain('tabindex="0"');
|
||||
expect(rendered).toContain('divider-icon');
|
||||
expect(rendered).toContain('<hr>');
|
||||
expect(rendered).toContain('data-block-id="test-divider"');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -83,12 +87,15 @@ tap.test('Heading handlers should render with correct levels', async () => {
|
||||
|
||||
const handler = BlockRegistry.getHandler('heading-1');
|
||||
expect(handler).toBeDefined();
|
||||
|
||||
|
||||
if (handler) {
|
||||
const rendered = handler.render(headingBlock, false);
|
||||
// The render() method returns the HTML template structure
|
||||
// Content is set later in setup()
|
||||
expect(rendered).toContain('class="block heading-1"');
|
||||
expect(rendered).toContain('contenteditable="true"');
|
||||
expect(rendered).toContain('Test Heading');
|
||||
expect(rendered).toContain('data-block-id="test-h1"');
|
||||
expect(rendered).toContain('data-block-type="heading-1"');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user