1fb72ba26c
恢复移动端首次进入欢迎遮罩与单次关闭状态 恢复删除前的桌面端创作主页提示与旧 IP 资源 保留移动端仅“我的”页签及项目画布硬门禁 补充现役依赖、静态资源与回归测试门禁 同步平台入口权威文档
98 lines
2.6 KiB
TypeScript
98 lines
2.6 KiB
TypeScript
/* @vitest-environment jsdom */
|
|
|
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
import { expect, test, vi } from 'vitest';
|
|
|
|
import {
|
|
PlatformActiveMobileWelcomeDialog,
|
|
shouldOpenActiveMobileWelcomeDialog,
|
|
shouldShowActiveMobileWelcomeDialog,
|
|
} from './PlatformActiveMobileWelcomeDialog';
|
|
|
|
test('shows the active mobile welcome when entering the mobile site shell', () => {
|
|
expect(
|
|
shouldShowActiveMobileWelcomeDialog({
|
|
isDesktopLayout: false,
|
|
selectionStage: 'platform',
|
|
platformTab: 'platform',
|
|
pathname: '/',
|
|
}),
|
|
).toBe(true);
|
|
expect(
|
|
shouldShowActiveMobileWelcomeDialog({
|
|
isDesktopLayout: true,
|
|
selectionStage: 'platform',
|
|
platformTab: 'platform',
|
|
pathname: '/',
|
|
}),
|
|
).toBe(false);
|
|
expect(
|
|
shouldShowActiveMobileWelcomeDialog({
|
|
isDesktopLayout: false,
|
|
selectionStage: 'profile',
|
|
platformTab: 'profile',
|
|
pathname: '/profile',
|
|
}),
|
|
).toBe(true);
|
|
expect(
|
|
shouldShowActiveMobileWelcomeDialog({
|
|
isDesktopLayout: false,
|
|
selectionStage: 'creation-home',
|
|
platformTab: 'creation-home',
|
|
pathname: '/creation',
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
|
|
test('keeps the active mobile welcome dismissed across site navigation', () => {
|
|
expect(
|
|
shouldOpenActiveMobileWelcomeDialog({
|
|
isDesktopLayout: false,
|
|
selectionStage: 'platform',
|
|
platformTab: 'platform',
|
|
pathname: '/',
|
|
isDismissed: false,
|
|
}),
|
|
).toBe(true);
|
|
expect(
|
|
shouldOpenActiveMobileWelcomeDialog({
|
|
isDesktopLayout: false,
|
|
selectionStage: 'profile',
|
|
platformTab: 'profile',
|
|
pathname: '/profile',
|
|
isDismissed: true,
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
|
|
test('renders the restored copy and closes with the acknowledge button', () => {
|
|
const onClose = vi.fn();
|
|
|
|
render(
|
|
<PlatformActiveMobileWelcomeDialog
|
|
open
|
|
platformThemeClass="platform-theme--light"
|
|
onClose={onClose}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.getByRole('dialog', { name: '欢迎' })).toBeTruthy();
|
|
expect(
|
|
screen.getByRole('heading', { level: 2, name: '欢迎' }),
|
|
).toBeTruthy();
|
|
expect(
|
|
document.querySelector('.platform-mobile-home-welcome-dialog__copy')
|
|
?.textContent,
|
|
).toBe(
|
|
'尼嚎,新陶泥er!移动端仅支持作品展示体验创作工具请使用电脑端访问该地址',
|
|
);
|
|
expect(
|
|
document
|
|
.querySelector('.platform-mobile-home-welcome-dialog__icon')
|
|
?.getAttribute('src'),
|
|
).toBe('/branding/mobile-home-welcome-taonier-ip.png');
|
|
|
|
fireEvent.click(screen.getByRole('button', { name: '好' }));
|
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
});
|