test: cover design text context menu
This commit is contained in:
@@ -19,6 +19,9 @@
|
|||||||
with the current window lifecycle.
|
with the current window lifecycle.
|
||||||
- Restore the smallest Main-owned native text-editing context-menu behavior and add
|
- Restore the smallest Main-owned native text-editing context-menu behavior and add
|
||||||
focused regression coverage at the real window/event seam.
|
focused regression coverage at the real window/event seam.
|
||||||
|
- Verify that the AI Design `design-chat-composer` textarea shares the same
|
||||||
|
primary Renderer seam, and extend the Electron regression to cover both Code
|
||||||
|
and Design textarea controls without adding a duplicate listener.
|
||||||
- Update user-facing documentation or Electron E2E coverage only where current
|
- Update user-facing documentation or Electron E2E coverage only where current
|
||||||
behavior and the shared fixture require it.
|
behavior and the shared fixture require it.
|
||||||
|
|
||||||
@@ -51,9 +54,15 @@
|
|||||||
content still produces no menu.
|
content still produces no menu.
|
||||||
- Registered the listener once during primary-window creation without adding
|
- Registered the listener once during primary-window creation without adding
|
||||||
Renderer, Preload, IPC, Host API, or direct clipboard access.
|
Renderer, Preload, IPC, Host API, or direct clipboard access.
|
||||||
|
- Confirmed `DesignConversationPane` renders the AI Design composer as the
|
||||||
|
ordinary `<textarea id="design-chat-composer">` produced by the shared
|
||||||
|
`Textarea` component inside that same primary Renderer. The window-level
|
||||||
|
listener therefore covers both AI Code and AI Design without a second
|
||||||
|
production listener.
|
||||||
- Added five focused unit cases and an Electron E2E regression that dispatches
|
- Added five focused unit cases and an Electron E2E regression that dispatches
|
||||||
a real right-click inside the primary Renderer window and observes one native
|
real right-clicks on Code and Design textarea controls inside the primary
|
||||||
menu popup with the expected editing actions.
|
Renderer window and observes two native menu popups with the expected editing
|
||||||
|
actions.
|
||||||
- Synchronized `README.md` with the restored desktop behavior and ownership
|
- Synchronized `README.md` with the restored desktop behavior and ownership
|
||||||
boundary.
|
boundary.
|
||||||
|
|
||||||
@@ -69,7 +78,8 @@
|
|||||||
- Green phase:
|
- Green phase:
|
||||||
- `corepack pnpm exec vitest run tests/unit/context-menu.test.ts` — 5 passed.
|
- `corepack pnpm exec vitest run tests/unit/context-menu.test.ts` — 5 passed.
|
||||||
- `corepack pnpm exec playwright test tests/e2e/context-menu.spec.ts` — 1
|
- `corepack pnpm exec playwright test tests/e2e/context-menu.spec.ts` — 1
|
||||||
passed.
|
passed, covering both Code and Design textareas with two observed native
|
||||||
|
popups.
|
||||||
- `corepack pnpm run typecheck` — passed.
|
- `corepack pnpm run typecheck` — passed.
|
||||||
- `corepack pnpm exec eslint electron/main/context-menu.ts electron/main/index.ts tests/unit/context-menu.test.ts tests/e2e/context-menu.spec.ts`
|
- `corepack pnpm exec eslint electron/main/context-menu.ts electron/main/index.ts tests/unit/context-menu.test.ts tests/e2e/context-menu.spec.ts`
|
||||||
— passed.
|
— passed.
|
||||||
|
|||||||
@@ -47,29 +47,40 @@ async function readContextMenuProbe(app: ElectronApplication): Promise<ContextMe
|
|||||||
}
|
}
|
||||||
|
|
||||||
test.describe('Makelore text context menu', () => {
|
test.describe('Makelore text context menu', () => {
|
||||||
test('opens native editing actions for editable text', async ({ launchElectronApp }) => {
|
test('opens native editing actions for Code and Design textareas', async ({ launchElectronApp }) => {
|
||||||
const app = await launchElectronApp({ skipSetup: true });
|
const app = await launchElectronApp({ skipSetup: true });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const page = await getStableWindow(app);
|
const page = await getStableWindow(app);
|
||||||
await installContextMenuProbe(app);
|
await installContextMenuProbe(app);
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
const input = document.createElement('input');
|
const composerIds = [
|
||||||
input.id = 'context-menu-e2e-input';
|
'context-menu-e2e-code-composer',
|
||||||
input.style.position = 'fixed';
|
'design-chat-composer',
|
||||||
input.style.inset = '80px auto auto 80px';
|
];
|
||||||
input.style.zIndex = '2147483647';
|
|
||||||
|
|
||||||
document.body.append(input);
|
for (const [index, id] of composerIds.entries()) {
|
||||||
|
const textarea = document.createElement('textarea');
|
||||||
|
textarea.id = id;
|
||||||
|
textarea.style.position = 'fixed';
|
||||||
|
textarea.style.inset = `${80 + index * 80}px auto auto 80px`;
|
||||||
|
textarea.style.zIndex = '2147483647';
|
||||||
|
document.body.append(textarea);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const input = page.locator('#context-menu-e2e-input');
|
for (const selector of [
|
||||||
await input.fill('Makelore');
|
'#context-menu-e2e-code-composer',
|
||||||
await input.selectText();
|
'#design-chat-composer',
|
||||||
await input.click({ button: 'right' });
|
]) {
|
||||||
|
const textarea = page.locator(selector);
|
||||||
|
await textarea.fill('Makelore');
|
||||||
|
await textarea.selectText();
|
||||||
|
await textarea.click({ button: 'right' });
|
||||||
|
}
|
||||||
|
|
||||||
await expect.poll(async () => await readContextMenuProbe(app)).toEqual({
|
await expect.poll(async () => await readContextMenuProbe(app)).toEqual({
|
||||||
popupCount: 1,
|
popupCount: 2,
|
||||||
template: [
|
template: [
|
||||||
{ label: '剪切', role: 'cut', type: 'normal' },
|
{ label: '剪切', role: 'cut', type: 'normal' },
|
||||||
{ label: '复制', role: 'copy', type: 'normal' },
|
{ label: '复制', role: 'copy', type: 'normal' },
|
||||||
|
|||||||
Reference in New Issue
Block a user