|
|
@@ -60,6 +60,7 @@ vi.mock('../../../shared/pageContext', () => ({
|
|
|
book: '预约咨询',
|
|
|
tryAi: '用我的照片试发型',
|
|
|
browse: '先看发型模板',
|
|
|
+ edit: '编辑个人主页',
|
|
|
yearUnit: '年',
|
|
|
untitled: '发型师',
|
|
|
stats: { experience: '经验', rating: '评分', reviews: '评价' },
|
|
|
@@ -146,6 +147,7 @@ describe('StylistProfilePage', () => {
|
|
|
expect(screen.getByRole('heading', { name: 'YASUAKI OGAWA' })).toBeInTheDocument()
|
|
|
})
|
|
|
expect(screen.getByRole('link', { name: '预约咨询' })).toHaveAttribute('href', 'https://example.com/booking')
|
|
|
+ expect(screen.getByRole('link', { name: '编辑个人主页' })).toHaveAttribute('href', '/zh/profile/manage')
|
|
|
expect(screen.getByText('22年')).toBeInTheDocument()
|
|
|
expect(screen.getByText('柔和长发')).toBeInTheDocument()
|
|
|
expect(screen.queryByText('顾客反馈')).not.toBeInTheDocument()
|
|
|
@@ -160,9 +162,21 @@ describe('StylistProfilePage', () => {
|
|
|
expect(getPublicStylistProfile).toHaveBeenCalledWith('yasuaki-ogawa')
|
|
|
})
|
|
|
expect(screen.getByText('层次剪发')).toBeInTheDocument()
|
|
|
+ expect(screen.queryByRole('link', { name: '编辑个人主页' })).not.toBeInTheDocument()
|
|
|
expect(screen.queryByText('使用次数')).not.toBeInTheDocument()
|
|
|
})
|
|
|
|
|
|
+ it('lets a logged-in stylist open the profile editor from a live slug page', async () => {
|
|
|
+ isAuthenticated.mockReturnValue(true)
|
|
|
+ getPublicStylistProfile.mockResolvedValue(liveProfile)
|
|
|
+ renderProfile('/zh/profile/yasuaki-ogawa')
|
|
|
+
|
|
|
+ await waitFor(() => {
|
|
|
+ expect(screen.getByRole('heading', { name: 'YASUAKI OGAWA' })).toBeInTheDocument()
|
|
|
+ })
|
|
|
+ expect(screen.getByRole('link', { name: '编辑个人主页' })).toHaveAttribute('href', '/zh/profile/manage')
|
|
|
+ })
|
|
|
+
|
|
|
it('falls back to the demo page when the logged-in session has expired', async () => {
|
|
|
isAuthenticated.mockReturnValue(true)
|
|
|
getStylistMe.mockRejectedValue(new ApiError('UNAUTHORIZED', '登录已过期', 401))
|