import { mount } from '@vue/test-utils' import { describe, expect, it } from 'vitest' import AdminPage from './AdminPage.vue' import DetailPageLayout from './DetailPageLayout.vue' import FormSection from './FormSection.vue' import ListPageLayout from './ListPageLayout.vue' import PageToolbar from './PageToolbar.vue' describe('admin page layout components', () => { it('renders a semantic page root with stable layout classes', () => { const wrapper = mount(AdminPage, { props: { width: 'comfortable', spacing: 'compact' }, slots: { default: '
内容
' }, }) expect(wrapper.element.tagName).toBe('MAIN') expect(wrapper.classes()).toEqual(expect.arrayContaining(['is-width-comfortable', 'is-spacing-compact'])) expect(wrapper.text()).toBe('内容') }) it('keeps page title and actions in separate regions', () => { const wrapper = mount(PageToolbar, { props: { title: '客户管理', description: '维护客户资料' }, slots: { actions: '' }, }) expect(wrapper.get('h1').text()).toBe('客户管理') expect(wrapper.get('.page-toolbar__description').text()).toBe('维护客户资料') expect(wrapper.get('.page-toolbar__actions').text()).toBe('新增') }) it('renders optional list regions only when supplied', () => { const wrapper = mount(ListPageLayout, { slots: { toolbar: '正文
', footer: '' }, }) expect(detail.find('.detail-page-layout__header').exists()).toBe(true) expect(detail.find('.detail-page-layout__footer').text()).toBe('保存') const form = mount(FormSection, { props: { title: '基础信息', description: '填写必填字段' }, slots: { default: '' }, }) expect(form.get('h2').text()).toBe('基础信息') expect(form.get('.form-section__heading p').text()).toBe('填写必填字段') expect(form.find('input').exists()).toBe(true) }) })