fix(home): reposition title and compact account entry

This commit is contained in:
鲨鱼辣椒 committed 2026-10-13 13:55:24 +08:00
1 parent 886b4589a1
commit a9fa221d7a
6 files changed
+80 -13

No files matched your search

+40 -4
View File
@@ -100,6 +100,27 @@ test.describe('Makelore module navigation without setup flow', () => {
await page.goto(applicationUrl);
const trigger = page.getByTestId('home-account-menu-trigger');
const menu = page.getByTestId('home-account-menu');
const surface = page.getByTestId('home-account-trigger-surface');
const checkAccountGeometry = async (width: number) => {
await expect.poll(async () => (await menu.boundingBox())!.width).toBeCloseTo(288, 1);
const visible = (await surface.boundingBox())!;
const target = (await trigger.boundingBox())!;
const avatar = (await surface.locator('span').first().boundingBox())!;
const panel = (await menu.boundingBox())!;
expect(visible.width).toBeCloseTo(128, 1);
expect(visible.height).toBeCloseTo(25, 1);
expect(avatar.width).toBeCloseTo(16, 1);
expect(avatar.height).toBeCloseTo(16, 1);
expect(target.width).toBeCloseTo(128, 1);
expect(target.height).toBeCloseTo(50, 1);
expect(visible.x).toBeGreaterThanOrEqual(16);
expect(visible.x).toBeCloseTo(width === 1440 ? 80 - 1.5 * 96 / 2.54 : 16, 1);
expect(await page.evaluate(() => innerHeight) - visible.y - visible.height).toBeCloseTo(16, 0);
expect(panel.x).toBeCloseTo(visible.x, 1);
expect(visible.y - panel.y - panel.height).toBeCloseTo(8, 1);
expect(panel.y).toBeGreaterThanOrEqual(0);
expect(panel.x + panel.width).toBeLessThanOrEqual(width);
};
await expect(trigger).toContainText('小麦');
await expect(page.locator('[data-testid^="ai-module-option-"]')).toHaveCount(3);
const footer = await trigger.evaluate(element => element.closest('footer')!.getBoundingClientRect().top);
@@ -109,6 +130,7 @@ test.describe('Makelore module navigation without setup flow', () => {
await expect(menu.getByTestId('sidebar-total-token-points')).toHaveText('75 点');
await expect(menu.getByText('永久有效 · 预占 5 点', { exact: true })).toBeVisible();
await expect(menu.getByRole('menuitem', { name: '词元点数与充值', exact: true })).toBeVisible();
await checkAccountGeometry(1440);
await page.screenshot({ path: testInfo.outputPath('home-account-menu-desktop.png') });
await page.keyboard.press('Escape');
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
@@ -145,9 +167,7 @@ test.describe('Makelore module navigation without setup flow', () => {
await trigger.click();
await expect(menu.getByTestId('sidebar-total-token-points')).toHaveText('75 点');
await expect.poll(() => page.evaluate(() => document.documentElement.scrollWidth - innerWidth)).toBeLessThanOrEqual(1);
const menuBox = await menu.boundingBox();
expect(menuBox!.x).toBeGreaterThanOrEqual(0);
expect(menuBox!.x + menuBox!.width).toBeLessThanOrEqual(375);
await checkAccountGeometry(375);
await page.screenshot({ path: testInfo.outputPath('home-account-menu-375.png') });
await menu.getByRole('menuitem', { name: '退出登录', exact: true }).click();
await expect(page).toHaveURL(/\/login$/);
@@ -371,9 +391,25 @@ test.describe('Makelore module navigation without setup flow', () => {
expect(card.imageHeight).toBeGreaterThan(card.height * 0.75);
expect(card.contentLeft).toBeGreaterThanOrEqual(card.imageLeft + card.imageWidth - 1);
}
const heading = await page.getByRole('heading', { name: '今天,想创作什么?', exact: true }).boundingBox();
const title = page.getByRole('heading', { name: '今天,想创作什么?', exact: true });
const heading = await title.boundingBox();
expect(heading).not.toBeNull();
const textWidth = await title.evaluate(element => {
const range = document.createRange(); range.selectNodeContents(element);
return range.getBoundingClientRect().width;
});
expect(Math.abs(heading!.width - textWidth)).toBeLessThan(1);
if (width >= 1024) {
const shift = await title.evaluate(element => {
const intro = element.parentElement!;
const original = intro.style.transform;
const shiftedLeft = element.getBoundingClientRect().left;
try {
intro.style.transform = 'none';
return shiftedLeft - element.getBoundingClientRect().left;
} finally { intro.style.transform = original; }
});
expect(shift).toBeCloseTo(1.5 * 96 / 2.54, 1);
expect(heading!.x + heading!.width).toBeLessThanOrEqual(cards[0]!.left);
expect(Math.abs(heading!.y + heading!.height / 2 - cards[1]!.top - cards[1]!.height / 2)).toBeLessThan(1);
expect(await moduleCards.evaluateAll(elements => elements.every(element => {