test: preserve native focus sequence when discarding note drafts
Wait for detail navigation and continued editing focus, and focus the cancel button before synthetic clicks so confirmation restores the actual opener. Keep draft discard and final entry focus assertions unchanged. Validate in CI without touching parallel work.
This commit is contained in:
@@ -49,3 +49,9 @@ MCP 列表断言纳入新增图像卡片的数量和名称;覆盖层原生点
|
||||
避免磨砂顶栏覆盖 `nearest` 保留在顶部的控件,并补充命中遮挡诊断。
|
||||
保留所有业务、覆盖层和原生交互断言,不改变产品默认值、关闭沙箱或跳过测试。
|
||||
这些修正由新候选 CI 验证。
|
||||
|
||||
`5368e0e` 的 CI `36962139369` 中上述四项通过,余下新记录取消焦点用例失败,
|
||||
5623 通过、59 跳过、1 失败。测试用 `fireEvent.click` 点击取消不会像原生点击
|
||||
那样移动焦点,确认框记住的仍是先前的返回总览按钮。用例先等打开详情的焦点完成,
|
||||
明确聚焦取消按钮后再点击,并等继续编辑实际聚焦编辑器后进行下一步;
|
||||
保留放弃草稿后回到记录与未保存新记录的断言,不改产品焦点规则或延长超时。
|
||||
|
||||
@@ -825,14 +825,20 @@ describe('MagicNotesWorkspace overview navigation', () => {
|
||||
it('cancels a new entry only after confirming that its draft will be discarded', async () => {
|
||||
render(<MagicNotesWorkspace onNotify={onNotify} />)
|
||||
await openNote()
|
||||
await waitFor(() => expect(screen.getByRole('button', { name: '返回总览' })).toHaveFocus())
|
||||
newEntry()
|
||||
const composer = document.querySelector('.magic-note-composer')!
|
||||
fireEvent.click(screen.getByTestId('magic-note-editor'))
|
||||
fireEvent.click(within(composer as HTMLElement).getByRole('button', { name: '取消' }))
|
||||
const cancel = within(composer as HTMLElement).getByRole('button', { name: '取消' })
|
||||
// fireEvent.click does not focus like a native click; the modal must restore its actual opener.
|
||||
cancel.focus()
|
||||
fireEvent.click(cancel)
|
||||
expect(await screen.findByRole('alertdialog')).toBeVisible()
|
||||
fireEvent.click(screen.getByRole('button', { name: '继续编辑' }))
|
||||
await waitFor(() => expect(screen.getByTestId('magic-note-editor')).toHaveFocus())
|
||||
expect(document.querySelector('.magic-note-composer')).toHaveClass('magic-note-composer--active')
|
||||
fireEvent.click(within(document.querySelector('.magic-note-composer') as HTMLElement).getByRole('button', { name: '取消' }))
|
||||
cancel.focus()
|
||||
fireEvent.click(cancel)
|
||||
fireEvent.click(await screen.findByRole('button', { name: '放弃草稿并切换' }))
|
||||
await waitFor(() => expect(document.querySelector('.magic-note-composer')).not.toHaveClass('magic-note-composer--active'))
|
||||
await waitFor(() => expect(document.getElementById(`magic-note-entry-${entryId}`)).toHaveFocus())
|
||||
|
||||
Reference in New Issue
Block a user