扩展 PlatformProfileModalShell 透传共享 footer 插槽能力 将昵称修改弹窗改为使用标准 profile modal footer 补充 modal shell 与昵称弹窗的 footer 接法回归测试 更新 PlatformUiKit 收口计划与共享决策记录
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
/* @vitest-environment jsdom */
|
|
|
|
import { render, screen } from '@testing-library/react';
|
|
import { expect, test, vi } from 'vitest';
|
|
|
|
import { PlatformActionButton } from '../common/PlatformActionButton';
|
|
import { PlatformProfileModalShell } from './PlatformProfileModalShell';
|
|
|
|
test('PlatformProfileModalShell forwards footer content into shared modal footer chrome', () => {
|
|
render(
|
|
<PlatformProfileModalShell
|
|
title="修改昵称"
|
|
onClose={vi.fn()}
|
|
panelClassName="platform-remap-surface !max-w-sm rounded-[1.4rem]"
|
|
bodyClassName="px-5 py-5"
|
|
footerClassName="grid grid-cols-2 gap-3 px-5 pb-5 pt-0 sm:px-5"
|
|
footer={
|
|
<>
|
|
<PlatformActionButton tone="secondary">取消</PlatformActionButton>
|
|
<PlatformActionButton>保存</PlatformActionButton>
|
|
</>
|
|
}
|
|
>
|
|
<div>昵称输入区</div>
|
|
</PlatformProfileModalShell>,
|
|
);
|
|
|
|
const dialog = screen.getByRole('dialog', { name: '修改昵称' });
|
|
const body = screen.getByText('昵称输入区').parentElement;
|
|
const footerButton = screen.getByRole('button', { name: '保存' });
|
|
const footer = footerButton.closest('div');
|
|
|
|
expect(dialog).toBeTruthy();
|
|
expect(body?.className).toContain('px-5');
|
|
expect(body?.className).toContain('py-5');
|
|
expect(footer?.className).toContain('border-t');
|
|
expect(footer?.className).toContain('grid');
|
|
expect(footer?.className).toContain('pt-0');
|
|
});
|