修复上传素材切换侧栏
上传到画布后保持当前左侧侧栏状态。 补充上传工作流和画布 drop 回归断言。 更新跟踪记录并完成浏览器回归。
This commit is contained in:
@@ -1608,9 +1608,17 @@ describe('ImageCanvasEditorView', () => {
|
||||
imageSrc: expect.stringMatching(/^data:image\/png;base64,/u),
|
||||
}),
|
||||
);
|
||||
expect(screen.getByRole('heading', { name: '素材' })).toBeTruthy();
|
||||
expect(
|
||||
screen.getByRole('button', { name: '选择图层测试上传.png' }),
|
||||
).toBeTruthy();
|
||||
screen.getByRole('button', { name: '打开素材' }).getAttribute(
|
||||
'aria-pressed',
|
||||
),
|
||||
).toBe('true');
|
||||
expect(
|
||||
screen
|
||||
.getByRole('button', { name: '选择测试上传.png' })
|
||||
.className.includes('image-canvas-editor__layer--selected'),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('drops files into the asset panel only once without creating canvas layers', async () => {
|
||||
|
||||
@@ -346,7 +346,6 @@ export function ImageCanvasEditorView() {
|
||||
setAssets,
|
||||
setLayers,
|
||||
setGenerateDialog,
|
||||
setActiveSidebarPanel,
|
||||
appendCanvasLayersWithResources,
|
||||
selectSingleLayer,
|
||||
});
|
||||
|
||||
@@ -67,8 +67,7 @@ function UploadWorkflowHarness({
|
||||
const [layers, setLayers] = useState<CanvasLayer[]>([]);
|
||||
const [generateDialog, setGenerateDialog] =
|
||||
useState<GenerateDialogState | null>(null);
|
||||
const [activeSidebarPanel, setActiveSidebarPanel] =
|
||||
useState<SidebarPanel | null>('assets');
|
||||
const [activeSidebarPanel] = useState<SidebarPanel | null>('assets');
|
||||
const [selectedLayerId, setSelectedLayerId] = useState<string | null>(null);
|
||||
const uploadIndexRef = useRef(0);
|
||||
|
||||
@@ -88,7 +87,6 @@ function UploadWorkflowHarness({
|
||||
setAssets,
|
||||
setLayers,
|
||||
setGenerateDialog,
|
||||
setActiveSidebarPanel,
|
||||
appendCanvasLayersWithResources: (nextLayers) => {
|
||||
setLayers((currentLayers) => [...currentLayers, ...nextLayers]);
|
||||
},
|
||||
@@ -290,7 +288,7 @@ describe('useImageCanvasUploadWorkflow', () => {
|
||||
expect(clickUploadInput).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('creates an uploading asset card, adds a canvas layer, and patches the layer with the persisted asset id', async () => {
|
||||
it('creates an uploading asset card, adds a canvas layer, keeps the sidebar, and patches the layer with the persisted asset id', async () => {
|
||||
const deferredAsset = createDeferred<{
|
||||
assetId: string;
|
||||
folderId: string;
|
||||
@@ -315,7 +313,7 @@ describe('useImageCanvasUploadWorkflow', () => {
|
||||
'layer-upload-1:画布素材.png:upload-1:-160:-107.5',
|
||||
);
|
||||
});
|
||||
expect(screen.getByTestId('sidebar').textContent).toBe('layers');
|
||||
expect(screen.getByTestId('sidebar').textContent).toBe('assets');
|
||||
expect(screen.getByTestId('selected-layer').textContent).toBe(
|
||||
'layer-upload-1',
|
||||
);
|
||||
|
||||
@@ -17,7 +17,6 @@ import type {
|
||||
EditorAsset,
|
||||
EditorAssetFolder,
|
||||
GenerateDialogState,
|
||||
SidebarPanel,
|
||||
UploadTarget,
|
||||
} from './ImageCanvasEditorTypes';
|
||||
import { isImageFile, readImageFileAsDataUrl } from './ImageCanvasFileModel';
|
||||
@@ -45,7 +44,6 @@ type UseImageCanvasUploadWorkflowOptions = {
|
||||
setAssets: Dispatch<SetStateAction<EditorAsset[]>>;
|
||||
setLayers: Dispatch<SetStateAction<CanvasLayer[]>>;
|
||||
setGenerateDialog: Dispatch<SetStateAction<GenerateDialogState | null>>;
|
||||
setActiveSidebarPanel: Dispatch<SetStateAction<SidebarPanel | null>>;
|
||||
appendCanvasLayersWithResources: (nextLayers: CanvasLayer[]) => void;
|
||||
selectSingleLayer: (layerId: string | null) => void;
|
||||
};
|
||||
@@ -78,7 +76,6 @@ export function useImageCanvasUploadWorkflow({
|
||||
setAssets,
|
||||
setLayers,
|
||||
setGenerateDialog,
|
||||
setActiveSidebarPanel,
|
||||
appendCanvasLayersWithResources,
|
||||
selectSingleLayer,
|
||||
}: UseImageCanvasUploadWorkflowOptions) {
|
||||
@@ -316,7 +313,6 @@ export function useImageCanvasUploadWorkflow({
|
||||
if (options.addToCanvas) {
|
||||
appendCanvasLayersWithResources([nextLayer]);
|
||||
selectSingleLayer(nextLayer.id);
|
||||
setActiveSidebarPanel('layers');
|
||||
}
|
||||
|
||||
setAssets((currentAssets) =>
|
||||
@@ -445,7 +441,6 @@ export function useImageCanvasUploadWorkflow({
|
||||
canvasSize.width,
|
||||
openEditorLoginModal,
|
||||
selectSingleLayer,
|
||||
setActiveSidebarPanel,
|
||||
setAssetFolders,
|
||||
setAssets,
|
||||
setLayers,
|
||||
|
||||
Reference in New Issue
Block a user