test(e2e): save inside editor dialog with exact 保存修改
UI-06/13b click 保存修改 only inside 编辑受控块; UI-13a asserts the dialog is absent instead of a page-wide /保存/ match. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,6 +2,10 @@ import { test, expect, type Page, type BrowserContext, type Response } from '@pl
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import {
|
||||
BLOCK_EDITOR_DIALOG_LABEL,
|
||||
BLOCK_EDITOR_SAVE_NAME,
|
||||
} from '../src/lib/blockEditorDialog';
|
||||
|
||||
/**
|
||||
* Document revision runtime — real UI acceptance (UI-01..UI-16).
|
||||
@@ -361,18 +365,25 @@ async function closeNamedDialog(page: Page, name: string, timeout = 10_000) {
|
||||
await expect(dialog).toHaveCount(0, { timeout });
|
||||
}
|
||||
|
||||
function blockEditorDialog(target: Page) {
|
||||
return target.getByRole('dialog', { name: BLOCK_EDITOR_DIALOG_LABEL });
|
||||
}
|
||||
|
||||
async function openFirstPaneEditorAndFill(target: Page, text: string) {
|
||||
const pane = target.getByTestId('active-document-pane');
|
||||
const block = pane.getByTestId('document-block').first();
|
||||
await block.dblclick({ timeout: 15_000 });
|
||||
const editor = target.locator('textarea, [contenteditable="true"]').last();
|
||||
const dialog = blockEditorDialog(target);
|
||||
await expect(dialog).toBeVisible({ timeout: 10_000 });
|
||||
const editor = dialog.locator('textarea, [contenteditable="true"]').first();
|
||||
await expect(editor).toBeVisible({ timeout: 10_000 });
|
||||
await editor.fill(text);
|
||||
return editor;
|
||||
}
|
||||
|
||||
async function saveOpenEditor(target: Page) {
|
||||
await target.getByRole('button', { name: /保存修改|保存/ }).click();
|
||||
const dialog = blockEditorDialog(target);
|
||||
await dialog.getByRole('button', { name: BLOCK_EDITOR_SAVE_NAME, exact: true }).click();
|
||||
}
|
||||
|
||||
async function editFirstPaneBlockAndSave(target: Page, text: string) {
|
||||
@@ -1092,7 +1103,7 @@ test.describe.serial('document-revision-runtime UI acceptance', () => {
|
||||
await expect(pageB.getByText('双击任意段落就地编辑')).toHaveCount(0);
|
||||
const pane = pageB.getByTestId('active-document-pane');
|
||||
await pane.getByTestId('document-block').first().dblclick({ timeout: 15_000 });
|
||||
await expect(pageB.getByRole('button', { name: /保存修改|保存并关闭/ })).toHaveCount(0);
|
||||
await expect(blockEditorDialog(pageB)).toHaveCount(0);
|
||||
await shot(pageB, 'UI-13a-reviewer-readonly.png');
|
||||
await ctxB.close();
|
||||
recordPass({
|
||||
|
||||
Reference in New Issue
Block a user