恢复平台账号顶栏与我的页签
按新版创作页原布局恢复泥点入口与账号身份胶囊。 在桌面侧栏补回我的页签及游客、登录态个人页面。 个人页面只复用账号、钱包、统计、设置和法律信息等平台能力。 补充壳层与个人页面回归测试并更新退役边界文档。
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
/* @vitest-environment jsdom */
|
||||
|
||||
import { fireEvent, render, screen, within } from '@testing-library/react';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { PlatformEntryFlowShellImpl } from './PlatformEntryActiveFlowShell';
|
||||
|
||||
const authUiMock = vi.hoisted(() => ({
|
||||
value: {
|
||||
user: null,
|
||||
canAccessProtectedData: false,
|
||||
openLoginModal: vi.fn(),
|
||||
openAccountModal: vi.fn(),
|
||||
openSettingsModal: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('../auth/AuthUiContext', () => ({
|
||||
useAuthUi: () => authUiMock.value,
|
||||
}));
|
||||
|
||||
vi.mock('../creation-home/CreationLandingView', () => ({
|
||||
CreationLandingView: () => (
|
||||
<main aria-label="陶泥儿创作主页">创作主页</main>
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock('../project/ProjectGalleryView', () => ({
|
||||
ProjectGalleryView: () => <main aria-label="项目">项目</main>,
|
||||
}));
|
||||
|
||||
vi.mock('../image-editor/ImageCanvasEditorView', () => ({
|
||||
ImageCanvasEditorView: () => <main aria-label="图片画布编辑器" />,
|
||||
}));
|
||||
|
||||
vi.mock('../../services/platform-entry/platformProfileClient', () => ({
|
||||
getPlatformProfileDashboard: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('./usePlatformProfileCenterController', () => ({
|
||||
usePlatformProfileCenterController: () => ({
|
||||
buyRechargeProduct: vi.fn(),
|
||||
closeNativeWechatPayment: vi.fn(),
|
||||
confirmNativeWechatPayment: vi.fn(),
|
||||
isLoadingRechargeCenter: false,
|
||||
isLoadingWalletLedger: false,
|
||||
isRechargeOpen: false,
|
||||
isWalletLedgerOpen: false,
|
||||
loadRechargeCenter: vi.fn(),
|
||||
nativeWechatPayment: null,
|
||||
openWalletLedgerPanel: vi.fn(),
|
||||
rechargeCenter: null,
|
||||
rechargeError: null,
|
||||
rechargePaymentResult: null,
|
||||
setIsRechargeOpen: vi.fn(),
|
||||
setIsWalletLedgerOpen: vi.fn(),
|
||||
setRechargePaymentResult: vi.fn(),
|
||||
submittingRechargeProductId: null,
|
||||
walletLedger: null,
|
||||
walletLedgerError: null,
|
||||
wechatRechargeOrderConfirmationState: null,
|
||||
}),
|
||||
}));
|
||||
|
||||
describe('PlatformEntryActiveFlowShell', () => {
|
||||
beforeEach(() => {
|
||||
window.history.replaceState(null, '', '/creation');
|
||||
authUiMock.value.openLoginModal.mockReset();
|
||||
});
|
||||
|
||||
it('keeps the active desktop rail and the shared account capsule', async () => {
|
||||
const setSelectionStage = vi.fn();
|
||||
const { container } = render(
|
||||
<PlatformEntryFlowShellImpl
|
||||
selectionStage="creation-home"
|
||||
setSelectionStage={setSelectionStage}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(
|
||||
await screen.findByRole('main', { name: '陶泥儿创作主页' }),
|
||||
).toBeTruthy();
|
||||
const navigation = screen.getByRole('navigation', { name: '平台导航' });
|
||||
expect(
|
||||
within(navigation)
|
||||
.getAllByRole('button')
|
||||
.map((button) => button.getAttribute('aria-label')),
|
||||
).toEqual(['创作', '项目', '我的']);
|
||||
expect(
|
||||
within(navigation)
|
||||
.getByRole('button', { name: '创作' })
|
||||
.getAttribute('aria-current'),
|
||||
).toBe('page');
|
||||
|
||||
const topbar = container.querySelector('.platform-desktop-topbar');
|
||||
expect(topbar).toBeTruthy();
|
||||
expect(
|
||||
topbar?.querySelectorAll('button.platform-desktop-search'),
|
||||
).toHaveLength(1);
|
||||
expect(
|
||||
within(topbar as HTMLElement).queryByRole('button', { name: '设置' }),
|
||||
).toBeNull();
|
||||
|
||||
fireEvent.click(within(navigation).getByRole('button', { name: '我的' }));
|
||||
|
||||
expect(await screen.findByRole('main', { name: '我的' })).toBeTruthy();
|
||||
expect(window.location.pathname).toBe('/');
|
||||
expect(setSelectionStage).toHaveBeenCalledWith('platform', { path: '/' });
|
||||
expect(
|
||||
within(navigation)
|
||||
.getByRole('button', { name: '我的' })
|
||||
.getAttribute('aria-current'),
|
||||
).toBe('page');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user