feat(web): prioritize SMS operations workspace

This commit is contained in:
chick
2026-07-19 10:30:52 +08:00
parent 0112e3320a
commit f7d69a0fa7
10 changed files with 532 additions and 68 deletions
@@ -1,5 +1,5 @@
// @vitest-environment jsdom
import { cleanup, render, screen } from '@testing-library/react';
import { cleanup, render, screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -40,7 +40,7 @@ describe('MessagesModule', () => {
expect(document.body.textContent).not.toContain('secret-pdu');
});
it('provides an intentional send form and submits exactly once', async () => {
it('requires an explicit review step before it submits exactly once', async () => {
const user = userEvent.setup();
const send = vi.fn().mockResolvedValue(undefined);
const dataSource: MessagesDataSource = {
@@ -51,6 +51,11 @@ describe('MessagesModule', () => {
await user.type(screen.getByRole('textbox', { name: '手机号' }), '10086');
await user.type(screen.getByRole('textbox', { name: '短信内容' }), 'CXLL');
await user.click(screen.getByRole('button', { name: '发送短信' }));
expect(send).not.toHaveBeenCalled();
const confirmation = screen.getByRole('region', { name: '确认发送短信' });
expect(confirmation.textContent).toContain('10086');
expect(confirmation.textContent).toContain('CXLL');
await user.click(within(confirmation).getByRole('button', { name: '确认并发送' }));
expect(send).toHaveBeenCalledTimes(1);
expect(send).toHaveBeenCalledWith('alpha', { phoneNumber: '10086', content: 'CXLL' });
expect((await screen.findByRole('status')).textContent).toContain('短信已提交发送');