Simplify Code and Canvas project sidebars
This commit is contained in:
1 parent
049e34cc77
commit
f980827200
7 files changed
+66
-38
No files matched your search
@@ -410,21 +410,16 @@ test.describe('Makelore module navigation without setup flow', () => {
|
||||
await expect(moduleReturn).toHaveAttribute('aria-label', '返回首页');
|
||||
await expect(moduleReturn).toHaveAttribute('title', '返回首页');
|
||||
await expect(page.getByTestId('sidebar-module-return-icon')).toBeVisible();
|
||||
const brandBox = await sidebar.locator('.classroom-brand').boundingBox();
|
||||
await expect(sidebar.locator('.classroom-brand')).toHaveCount(0);
|
||||
await expect(sidebar).not.toContainText('把脑洞变成作品');
|
||||
const returnBox = await moduleReturn.boundingBox();
|
||||
const collapseBox = await page.getByRole('button', { name: '折叠侧栏' }).boundingBox();
|
||||
const sidebarBox = await sidebar.boundingBox();
|
||||
expect(brandBox).not.toBeNull();
|
||||
expect(returnBox).not.toBeNull();
|
||||
expect(collapseBox).not.toBeNull();
|
||||
expect(returnBox!.y + returnBox!.height).toBeLessThanOrEqual(brandBox!.y);
|
||||
expect(returnBox!.y + returnBox!.height).toBeLessThanOrEqual(sidebarBox!.y);
|
||||
const headerBox = await page.getByTestId('coding-conversation-header').boundingBox();
|
||||
const tabsBox = await page.getByRole('tablist', { name: '当前工作' }).boundingBox();
|
||||
const toolbarBox = await page.locator('.classroom-workspace-toolbar').boundingBox();
|
||||
expect(Math.abs(returnBox!.y + returnBox!.height / 2 - headerBox!.y - headerBox!.height / 2)).toBeLessThan(1);
|
||||
expect(Math.abs(brandBox!.y + brandBox!.height / 2 - tabsBox!.y - tabsBox!.height / 2)).toBeLessThan(1);
|
||||
expect(brandBox!.y - sidebarBox!.y).toBe(0);
|
||||
expect(brandBox!.height).toBe(toolbarBox!.height);
|
||||
expect(returnBox!.width).toBe(32);
|
||||
expect(Math.abs(returnBox!.y + returnBox!.height / 2 - collapseBox!.y - collapseBox!.height / 2)).toBeLessThan(1);
|
||||
expect(returnBox!.x + returnBox!.width).toBeLessThanOrEqual(collapseBox!.x);
|
||||
@@ -436,7 +431,8 @@ test.describe('Makelore module navigation without setup flow', () => {
|
||||
const createBox = await sidebar.getByTestId('sidebar-create-project').boundingBox();
|
||||
const headingBox = await sidebar.locator('.classroom-projects-heading').boundingBox();
|
||||
const accountBox = await sidebar.getByTestId('sidebar-member-menu-trigger').boundingBox();
|
||||
expect(createBox!.y - brandBox!.y - brandBox!.height).toBe(10);
|
||||
expect(createBox!.y).toBe(sidebarBox!.y);
|
||||
expect(headingBox!.y - sidebarBox!.y).toBe(56);
|
||||
expect(communityBox!.x).toBe(createBox!.x);
|
||||
expect(communityBox!.y).toBeGreaterThan(headingBox!.y + headingBox!.height);
|
||||
expect(accountBox!.y - communityBox!.y - communityBox!.height).toBeCloseTo(0, 0);
|
||||
@@ -460,7 +456,7 @@ test.describe('Makelore module navigation without setup flow', () => {
|
||||
const fullscreenReturn = await moduleReturn.boundingBox();
|
||||
expect(fullscreenReturn!.y).toBe(returnBox!.y);
|
||||
expect(await page.getByRole('button', { name: '折叠侧栏' }).boundingBox()).toEqual(collapseBox);
|
||||
expect(await sidebar.locator('.classroom-brand').boundingBox()).toEqual(brandBox);
|
||||
expect(await sidebar.getByTestId('sidebar-create-project').boundingBox()).toEqual(createBox);
|
||||
await page.screenshot({ path: test.info().outputPath('chat-fullscreen-return-aligned.png') });
|
||||
await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows()[0].emit('leave-full-screen'));
|
||||
await expect.poll(async () => (await moduleReturn.boundingBox())!.x).toBe(returnBox!.x);
|
||||
@@ -486,13 +482,13 @@ test.describe('Makelore module navigation without setup flow', () => {
|
||||
await expect(sidebarResizer).toHaveAttribute('aria-valuenow', '171');
|
||||
|
||||
const readCodeChrome = () => page.evaluate(() => {
|
||||
if (document.querySelector('[data-testid="sidebar"] .classroom-brand')) throw new Error('Removed Code brand reappeared');
|
||||
const selectors = {
|
||||
sidebar: '[data-testid="sidebar"]',
|
||||
titlebar: '[data-testid="titlebar-sidebar-surface"]',
|
||||
navigation: '[data-testid="classroom-titlebar-navigation"]',
|
||||
home: '[data-testid="sidebar-module-switcher-trigger"]',
|
||||
toggle: '[data-testid="titlebar-sidebar-toggle"]',
|
||||
brand: '[data-testid="sidebar"] .classroom-brand',
|
||||
create: '[data-testid="sidebar-create-project"]',
|
||||
heading: '[data-testid="sidebar"] .classroom-projects-heading',
|
||||
community: '[data-testid="sidebar"] .community-link[data-variant="sidebar"]',
|
||||
@@ -752,7 +748,7 @@ test.describe('Makelore module navigation without setup flow', () => {
|
||||
await expect(page.getByTestId('coding-existing-projects')).toHaveCount(0);
|
||||
await expect(page.getByText('一念成光,万物可创。')).toHaveCount(0);
|
||||
await expect(page.getByRole('img', { name: 'Makelore logo' })).toHaveCount(0);
|
||||
await expect(page.getByTestId('sidebar').locator('.classroom-brand')).toBeVisible();
|
||||
await expect(page.getByTestId('sidebar').locator('.classroom-brand')).toHaveCount(0);
|
||||
await expect(page.getByTestId('sidebar-module-switcher-trigger')).toHaveText('');
|
||||
await expect(page.getByTestId('sidebar-module-return-icon')).toBeVisible();
|
||||
await expect(page.getByTestId('sidebar-create-project')).toBeVisible();
|
||||
|
||||
@@ -189,12 +189,23 @@ describe('ImageWorkspaceSidebar', () => {
|
||||
expect(actions.renameProject).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('selects a project by its workspace identity from the project row', () => {
|
||||
const { target, actions } = prepareProjects();
|
||||
it('shows only project titles under My Projects and keeps recent-first selection by workspace identity', () => {
|
||||
const { workspace, target, actions } = prepareProjects();
|
||||
renderSidebar();
|
||||
|
||||
const sidebar = screen.getByTestId('sidebar-image-workspace');
|
||||
fireEvent.click(within(sidebar).getByRole('button', { name: new RegExp(`^${target.title}`) }));
|
||||
expect(within(sidebar).getByText('我的项目', { exact: true })).toBeInTheDocument();
|
||||
expect(within(sidebar).queryByText('设计项目', { exact: true })).not.toBeInTheDocument();
|
||||
expect(sidebar).not.toHaveTextContent('设计版本');
|
||||
const activeProject = within(sidebar).getByRole('button', { name: workspace.workspace.title, exact: true });
|
||||
const newerProject = within(sidebar).getByRole('button', { name: target.title, exact: true });
|
||||
expect(activeProject.textContent).toBe(workspace.workspace.title);
|
||||
expect(newerProject.textContent).toBe(target.title);
|
||||
expect(activeProject).toHaveAttribute('aria-current', 'page');
|
||||
// The September project is newer than the active August project, despite
|
||||
// arriving second in bootstrap. Removing its date must not change order.
|
||||
expect(newerProject.compareDocumentPosition(activeProject)).toBe(Node.DOCUMENT_POSITION_FOLLOWING);
|
||||
fireEvent.click(newerProject);
|
||||
|
||||
expect(actions.selectProject).toHaveBeenCalledExactlyOnceWith(target.workspaceId);
|
||||
expect(screen.getByLabelText('当前页面')).toHaveTextContent('/image-canvas');
|
||||
|
||||
Reference in new issue
Block a user