Files
makelore/tests/e2e/app-smoke.spec.ts

85 lines
4.0 KiB
TypeScript

import { closeElectronApp, expect, test } from './fixtures/electron';
test.describe('Makelore Electron smoke flows', () => {
test('loads the bundled mixed-script UI font', async ({ page }) => {
await page.evaluate(async () => {
await document.fonts.load('400 16px "Makelore Latin"', 'Makelore');
await document.fonts.load('400 16px "Makelore CJK"', '中文');
await document.fonts.load('600 16px "Makelore Latin"', 'Makelore');
await document.fonts.load('600 16px "Makelore CJK"', '中文');
});
await expect.poll(async () => page.evaluate(() => getComputedStyle(document.body).fontFamily))
.toContain('Makelore Latin');
await expect.poll(async () => page.evaluate(() => (
Array.from(document.fonts).some((font) => font.family === 'Makelore CJK' && font.status === 'loaded')
))).toBe(true);
});
test('shows the setup wizard on a fresh profile', async ({ page }) => {
await expect(page.getByTestId('setup-page')).toBeVisible();
await expect(page.getByTestId('setup-welcome-step')).toBeVisible();
await expect(page.getByTestId('setup-skip-button')).toBeVisible();
});
test('can skip setup and open the native login surface', async ({ page }) => {
await expect(page.getByTestId('setup-page')).toBeVisible();
await page.getByTestId('setup-skip-button').click();
await expect(page.getByTestId('ai-module-selection-page')).toBeVisible();
await expect(page.getByTestId('main-layout')).toHaveCount(0);
await page.getByTestId('ai-module-option-programming').click();
await expect(page.getByRole('tab', { name: '密码登录', exact: true })).toBeVisible();
await expect(page.getByRole('tab', { name: '密码登录', exact: true }))
.toHaveAttribute('aria-selected', 'true');
await expect(page.getByLabel('用户名', { exact: true })).toBeVisible();
await expect(page.getByLabel('密码', { exact: true })).toBeVisible();
const loginButton = page.getByRole('button', { name: '登录', exact: true });
const rememberPasswordCheckbox = page.getByRole('checkbox', { name: '记住密码', exact: true });
await expect(rememberPasswordCheckbox).toBeVisible();
const [loginButtonBox, rememberPasswordBox] = await Promise.all([
loginButton.boundingBox(),
rememberPasswordCheckbox.boundingBox(),
]);
if (!loginButtonBox || !rememberPasswordBox) {
throw new Error('Login controls did not produce visible bounds');
}
expect(rememberPasswordBox.y).toBeGreaterThan(loginButtonBox.y + loginButtonBox.height);
await expect(page.getByRole('button', { name: '在浏览器中继续', exact: true })).toHaveCount(0);
});
test('redirects a signed-out direct workspace route to login', async ({ page }) => {
await expect(page.getByTestId('setup-page')).toBeVisible();
await page.getByTestId('setup-skip-button').click();
await expect(page.getByTestId('ai-module-selection-page')).toBeVisible();
await page.evaluate(() => {
window.location.hash = '#/chat';
});
await expect(page.getByRole('tab', { name: '密码登录', exact: true })).toBeVisible();
await expect(page.getByTestId('main-layout')).toHaveCount(0);
});
test('persists skipped setup across relaunch for the same isolated profile', async ({ electronApp, launchElectronApp }) => {
const firstWindow = await electronApp.firstWindow();
await firstWindow.waitForLoadState('domcontentloaded');
await firstWindow.getByTestId('setup-skip-button').click();
await expect(firstWindow.getByTestId('ai-module-selection-page')).toBeVisible();
await closeElectronApp(electronApp);
const relaunchedApp = await launchElectronApp();
try {
const relaunchedWindow = await relaunchedApp.firstWindow();
await relaunchedWindow.waitForLoadState('domcontentloaded');
await expect(relaunchedWindow.getByTestId('ai-module-selection-page')).toBeVisible();
await expect(relaunchedWindow.getByTestId('setup-page')).toHaveCount(0);
} finally {
await closeElectronApp(relaunchedApp);
}
});
});