合入主线登录和营业时段策略,对齐旧界面与 React 访问流程
This commit is contained in:
commit
42395de23a
113 files changed
+1915
-558
No files matched your search
@@ -16,7 +16,7 @@ const show = (session: SessionInfo, client: ReturnType<typeof fakeClient>['clien
|
||||
|
||||
describe('登录页', () => {
|
||||
it('演示模式:每位成员一个进入按钮,点击后 POST /api/demo-login', async () => {
|
||||
const { client, calls } = fakeClient({ '/api/demo-login': () => ({ user: {} }) });
|
||||
const { client, calls } = fakeClient({ '/api/demo-login': () => ({ user: { id: "signed-in" } }) });
|
||||
const onLoggedIn = vi.fn();
|
||||
show(
|
||||
{ ...base, mode: 'demo', loginOptions: [{ member: 'owner', label: '麦麦' }, { member: 'assistant', label: '娜娜' }] },
|
||||
@@ -35,7 +35,7 @@ describe('登录页', () => {
|
||||
const { client, calls } = fakeClient({
|
||||
'/api/login': () => {
|
||||
if (++attempts === 1) throw new Error('账号或密码不正确');
|
||||
return { user: {} };
|
||||
return { user: { id: "signed-in" } };
|
||||
},
|
||||
});
|
||||
const onLoggedIn = vi.fn();
|
||||
@@ -52,8 +52,35 @@ describe('登录页', () => {
|
||||
await waitFor(() => expect(onLoggedIn).toHaveBeenCalledTimes(1));
|
||||
expect(calls.at(-1)?.body).toEqual({ member: 'owner', password: 'right-password-1' });
|
||||
});
|
||||
it('登录回执缺少用户时展示可复制的诊断;剪贴板拒绝后提示手动复制', async () => {
|
||||
const { client, calls } = fakeClient({ '/api/demo-login': () => ({ error: 'private-response-content' }) });
|
||||
const onLoggedIn = vi.fn();
|
||||
show({ ...base, mode: 'demo', loginOptions: [{ member: 'assistant', label: '阿一' }] }, client, onLoggedIn);
|
||||
fireEvent.click(screen.getByRole('button', { name: /以阿一身份进入演示/ }));
|
||||
const alert = await screen.findByRole('alert');
|
||||
expect(alert).toHaveTextContent('进入演示失败');
|
||||
expect(alert).toHaveTextContent('已收到服务器响应');
|
||||
expect(alert).toHaveTextContent('POST /api/demo-login');
|
||||
expect(alert).toHaveTextContent('HTTP 状态:200');
|
||||
expect(alert).not.toHaveTextContent('private-response-content');
|
||||
expect(calls).toHaveLength(1);
|
||||
expect(onLoggedIn).not.toHaveBeenCalled();
|
||||
const original = Object.getOwnPropertyDescriptor(navigator, 'clipboard');
|
||||
const writeText = vi.fn().mockRejectedValueOnce(new Error('denied')).mockResolvedValueOnce(undefined);
|
||||
Object.defineProperty(navigator, 'clipboard', { configurable: true, value: { writeText } });
|
||||
try {
|
||||
fireEvent.click(screen.getByRole('button', { name: '复制诊断信息' }));
|
||||
fireEvent.click(await screen.findByRole('button', { name: '请长按或选中上方文字复制' }));
|
||||
expect(await screen.findByRole('button', { name: '已复制' })).toBeInTheDocument();
|
||||
expect(writeText.mock.calls[1][0]).toContain('HTTP 状态:200');
|
||||
expect(writeText.mock.calls[1][0]).not.toMatch(/private-response-content|阿一|assistant/);
|
||||
} finally {
|
||||
if (original) Object.defineProperty(navigator, 'clipboard', original);
|
||||
else Reflect.deleteProperty(navigator, 'clipboard');
|
||||
}
|
||||
});
|
||||
it('试用空库:初始化表单校验密码长度,提交店铺与店主资料', async () => {
|
||||
const { client, calls } = fakeClient({ '/api/setup': () => ({ user: {} }) });
|
||||
const { client, calls } = fakeClient({ '/api/setup': () => ({ user: { id: "signed-in" } }) });
|
||||
const onLoggedIn = vi.fn();
|
||||
show({ ...base, setup: true }, client, onLoggedIn);
|
||||
fireEvent.change(screen.getByLabelText('店铺名称'), { target: { value: '新店' } });
|
||||
|
||||
Reference in new issue
Block a user