Skip to content

Commit

Permalink
test: add mindmap collapse test (#9336)
Browse files Browse the repository at this point in the history
  • Loading branch information
doouding committed Dec 26, 2024
1 parent 1afdb68 commit 0de4f7a
Show file tree
Hide file tree
Showing 5 changed files with 485 additions and 5 deletions.
11 changes: 8 additions & 3 deletions blocksuite/affine/block-surface/src/view/mindmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ export class MindMapView extends GfxElementModelView<MindmapElementModel> {
}
>();

private _getCollapseButton(node: MindmapNode | string) {
/**
*
* @param node The mindmap node or its id to get the collapse button
* @returns
*/
getCollapseButton(node: MindmapNode | string) {
const id = typeof node === 'string' ? node : node.id;
return this._collapseButtons.get(`collapse-btn-${id}`);
}
Expand Down Expand Up @@ -149,7 +154,7 @@ export class MindMapView extends GfxElementModelView<MindmapElementModel> {
elm?.id &&
this.model.children.has(elm.id)
) {
const button = this._getCollapseButton(elm.id);
const button = this.getCollapseButton(elm.id);

if (!button) {
return;
Expand All @@ -164,7 +169,7 @@ export class MindMapView extends GfxElementModelView<MindmapElementModel> {

private _updateButtonVisibility(node: string) {
const latestNode = this.model.getNode(node);
const buttonModel = this._getCollapseButton(node);
const buttonModel = this.getCollapseButton(node);

if (!buttonModel) {
return;
Expand Down
7 changes: 5 additions & 2 deletions blocksuite/presets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"scripts": {
"build": "tsc",
"test:unit": "nx vite:test --browser.headless --run",
"test:unit": "vitest --browser.headless --run",
"test:debug": "PWDEBUG=1 npx vitest"
},
"sideEffects": false,
Expand Down Expand Up @@ -37,5 +37,8 @@
"themes",
"!src/__tests__",
"!dist/__tests__"
]
],
"devDependencies": {
"vitest": "^2.1.8"
}
}
Loading

0 comments on commit 0de4f7a

Please sign in to comment.