test: cover design text context menu
This commit is contained in:
@@ -47,29 +47,40 @@ async function readContextMenuProbe(app: ElectronApplication): Promise<ContextMe
|
||||
}
|
||||
|
||||
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 });
|
||||
|
||||
try {
|
||||
const page = await getStableWindow(app);
|
||||
await installContextMenuProbe(app);
|
||||
await page.evaluate(() => {
|
||||
const input = document.createElement('input');
|
||||
input.id = 'context-menu-e2e-input';
|
||||
input.style.position = 'fixed';
|
||||
input.style.inset = '80px auto auto 80px';
|
||||
input.style.zIndex = '2147483647';
|
||||
const composerIds = [
|
||||
'context-menu-e2e-code-composer',
|
||||
'design-chat-composer',
|
||||
];
|
||||
|
||||
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');
|
||||
await input.fill('Makelore');
|
||||
await input.selectText();
|
||||
await input.click({ button: 'right' });
|
||||
for (const selector of [
|
||||
'#context-menu-e2e-code-composer',
|
||||
'#design-chat-composer',
|
||||
]) {
|
||||
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({
|
||||
popupCount: 1,
|
||||
popupCount: 2,
|
||||
template: [
|
||||
{ label: '剪切', role: 'cut', type: 'normal' },
|
||||
{ label: '复制', role: 'copy', type: 'normal' },
|
||||
|
||||
Reference in New Issue
Block a user