|
| 1 | +import {setup} from '../../setup.mjs'; |
| 2 | + |
| 3 | +const appName = 'WrapperIdCheck'; |
| 4 | + |
| 5 | +setup({ |
| 6 | + neoConfig: { |
| 7 | + allowVdomUpdatesInTests: true, |
| 8 | + useDomApiRenderer : true, |
| 9 | + workerId: 'main' |
| 10 | + }, |
| 11 | + appConfig: { |
| 12 | + name: appName |
| 13 | + } |
| 14 | +}); |
| 15 | + |
| 16 | +import {test, expect} from '@playwright/test'; |
| 17 | +import Neo from '../../../../src/Neo.mjs'; |
| 18 | +import * as core from '../../../../src/core/_export.mjs'; |
| 19 | +import SplitButton from '../../../../src/button/Split.mjs'; |
| 20 | +import GridBody from '../../../../src/grid/Body.mjs'; |
| 21 | + |
| 22 | +test.describe('Wrapper Component IDs', () => { |
| 23 | + |
| 24 | + test('SplitButton should have correct wrapper ID', async () => { |
| 25 | + const btn = Neo.create(SplitButton, { |
| 26 | + appName, |
| 27 | + id: 'my-split' |
| 28 | + }); |
| 29 | + |
| 30 | + // The root vdom node (the wrapper) should have the wrapper suffix |
| 31 | + expect(btn.vdom.id).toBe('my-split__wrapper'); |
| 32 | + // The getVdomRoot() node (the actual button) should have the component ID |
| 33 | + expect(btn.getVdomRoot().id).toBe('my-split'); |
| 34 | + |
| 35 | + btn.destroy(); |
| 36 | + }); |
| 37 | + |
| 38 | + test('GridBody should have correct wrapper ID', async () => { |
| 39 | + const mockGrid = { |
| 40 | + id: 'mock-grid', |
| 41 | + on: () => {}, |
| 42 | + isClass: true, |
| 43 | + vdom: {id: 'mock-grid'} |
| 44 | + }; |
| 45 | + |
| 46 | + const gridBody = Neo.create(GridBody, { |
| 47 | + appName, |
| 48 | + id: 'my-grid-body', |
| 49 | + parentComponent: mockGrid |
| 50 | + }); |
| 51 | + |
| 52 | + // The root vdom node (the wrapper) should have the wrapper suffix |
| 53 | + expect(gridBody.vdom.id).toBe('my-grid-body__wrapper'); |
| 54 | + // The getVdomRoot() node should have the component ID |
| 55 | + expect(gridBody.getVdomRoot().id).toBe('my-grid-body'); |
| 56 | + |
| 57 | + // Unregister manually to avoid destroy() complexity with mock parent |
| 58 | + Neo.manager.Component.unregister(gridBody); |
| 59 | + }); |
| 60 | +}); |
0 commit comments