Files
makelore/tests/e2e/settings-proxy.spec.ts
inman 22add3f01f
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled
完善客户端模块与工作区能力
2026-08-13 19:51:02 +08:00

62 lines
2.5 KiB
TypeScript

import type { Locator, Page } from '@playwright/test';
import { completeSetup, expect, test } from './fixtures/electron';
async function ensureSwitchState(toggle: Locator, checked: boolean): Promise<void> {
const currentState = await toggle.getAttribute('data-state');
const isChecked = currentState === 'checked';
if (isChecked !== checked) {
await toggle.click();
}
}
async function readProxyEnabled(page: Page): Promise<boolean> {
return await page.evaluate(async () => {
const settings = await window.electron.ipcRenderer.invoke('settings:getAll');
return Boolean(settings?.proxyEnabled);
});
}
async function openSettingsFromSidebarAccountMenu(page: Page): Promise<void> {
await page.getByTestId('sidebar-member-menu-trigger').click();
await page.getByTestId('sidebar-nav-settings').click();
}
async function unlockDeveloperSettings(page: Page): Promise<void> {
await page.getByTestId('settings-reveal-additional').click();
await page.getByTestId('settings-admin-password-input').fill('zhiniankeji666');
await page.getByTestId('settings-admin-unlock-button').click();
await expect(page.getByTestId('settings-proxy-section')).toBeVisible();
}
test.describe('Makelore administrator-protected proxy settings', () => {
test('keeps proxy save available after administrator unlock', async ({ page }) => {
await completeSetup(page);
await openSettingsFromSidebarAccountMenu(page);
await expect(page.getByTestId('settings-page')).toBeVisible();
await page.getByTestId('settings-reveal-additional').click();
await expect(page.getByTestId('settings-proxy-section')).not.toBeVisible();
await unlockDeveloperSettings(page);
const proxySection = page.getByTestId('settings-proxy-section');
const proxyToggle = page.getByTestId('settings-proxy-toggle');
const proxySaveButton = page.getByTestId('settings-proxy-save-button');
await expect(proxySection).toBeVisible();
await expect(proxyToggle).toBeVisible();
await expect(proxySaveButton).toBeVisible();
await ensureSwitchState(proxyToggle, true);
await expect(proxySaveButton).toBeEnabled();
await proxySaveButton.click();
await expect.poll(async () => await readProxyEnabled(page)).toBe(true);
await ensureSwitchState(proxyToggle, false);
await expect(proxySaveButton).toBeVisible();
await expect(proxySaveButton).toBeEnabled();
await proxySaveButton.click();
await expect.poll(async () => await readProxyEnabled(page)).toBe(false);
});
});