Disable fast boot + Remove deprecated ElementsList.test.tsx
This commit is contained in:
parent
0d05f0959c
commit
701989649c
2 changed files with 1 additions and 252 deletions
|
@ -1,251 +0,0 @@
|
||||||
import { describe, expect, it, vi } from 'vitest';
|
|
||||||
import * as React from 'react';
|
|
||||||
import { fireEvent, render, screen } from '../../utils/test-utils';
|
|
||||||
import { ElementsList } from './ElementsList';
|
|
||||||
import { IContainerModel } from '../../Interfaces/IContainerModel';
|
|
||||||
import { PositionReference } from '../../Enums/PositionReference';
|
|
||||||
import { FindContainerById } from '../../utils/itertools';
|
|
||||||
import { DEFAULT_MAINCONTAINER_PROPS } from '../../utils/default';
|
|
||||||
import { Orientation } from '../../Enums/Orientation';
|
|
||||||
|
|
||||||
describe.concurrent('Elements sidebar', () => {
|
|
||||||
it('With a MainContainer', () => {
|
|
||||||
render(<ElementsList
|
|
||||||
symbols={new Map()}
|
|
||||||
mainContainer={{
|
|
||||||
children: [],
|
|
||||||
parent: null,
|
|
||||||
properties: DEFAULT_MAINCONTAINER_PROPS,
|
|
||||||
userData: {}
|
|
||||||
}}
|
|
||||||
selectedContainer={undefined}
|
|
||||||
onPropertyChange={() => {}}
|
|
||||||
selectContainer={() => {}}
|
|
||||||
addContainer={() => {}}
|
|
||||||
/>);
|
|
||||||
|
|
||||||
expect(screen.getByText(/Elements/i));
|
|
||||||
expect(screen.queryByText('id')).toBeNull();
|
|
||||||
expect(screen.getByText(/main/i));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('With a selected MainContainer', () => {
|
|
||||||
const mainContainer: IContainerModel = {
|
|
||||||
children: [],
|
|
||||||
parent: null,
|
|
||||||
properties: DEFAULT_MAINCONTAINER_PROPS,
|
|
||||||
userData: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
const { container } = render(<ElementsList
|
|
||||||
symbols={new Map()}
|
|
||||||
mainContainer={mainContainer}
|
|
||||||
selectedContainer={mainContainer}
|
|
||||||
onPropertyChange={() => {}}
|
|
||||||
selectContainer={() => {}}
|
|
||||||
addContainer={() => {}}
|
|
||||||
/>);
|
|
||||||
|
|
||||||
expect(screen.getByText(/Elements/i));
|
|
||||||
expect(screen.getByText(/main/i));
|
|
||||||
expect(screen.queryByText('id')).toBeDefined();
|
|
||||||
expect(screen.queryByText('parentId')).toBeDefined();
|
|
||||||
expect(screen.queryByText('x')).toBeDefined();
|
|
||||||
expect(screen.queryByText('y')).toBeDefined();
|
|
||||||
expect(screen.queryByText('width')).toBeDefined();
|
|
||||||
expect(screen.queryByText('height')).toBeDefined();
|
|
||||||
const propertyId = container.querySelector('#id');
|
|
||||||
const propertyParentId = container.querySelector('#parentId');
|
|
||||||
const propertyX = container.querySelector('#x');
|
|
||||||
const propertyY = container.querySelector('#y');
|
|
||||||
const propertyWidth = container.querySelector('#width');
|
|
||||||
const propertyHeight = container.querySelector('#height');
|
|
||||||
expect((propertyId as HTMLInputElement).value).toBe(mainContainer.properties.id.toString());
|
|
||||||
expect(propertyParentId).toBeDefined();
|
|
||||||
expect((propertyParentId as HTMLInputElement).value).toBe('');
|
|
||||||
expect(propertyX).toBeDefined();
|
|
||||||
expect((propertyX as HTMLInputElement).value).toBe(mainContainer.properties.x.toString());
|
|
||||||
expect(propertyY).toBeDefined();
|
|
||||||
expect((propertyY as HTMLInputElement).value).toBe(mainContainer.properties.y.toString());
|
|
||||||
expect(propertyWidth).toBeDefined();
|
|
||||||
expect((propertyWidth as HTMLInputElement).value).toBe(mainContainer.properties.width.toString());
|
|
||||||
expect(propertyHeight).toBeDefined();
|
|
||||||
expect((propertyHeight as HTMLInputElement).value).toBe(mainContainer.properties.height.toString());
|
|
||||||
});
|
|
||||||
|
|
||||||
it('With multiple containers', () => {
|
|
||||||
const children: IContainerModel[] = [];
|
|
||||||
const mainContainer: IContainerModel = {
|
|
||||||
children,
|
|
||||||
parent: null,
|
|
||||||
properties: DEFAULT_MAINCONTAINER_PROPS,
|
|
||||||
userData: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
children.push(
|
|
||||||
{
|
|
||||||
children: [],
|
|
||||||
parent: mainContainer,
|
|
||||||
properties: {
|
|
||||||
id: 'child-1',
|
|
||||||
parentId: 'main',
|
|
||||||
linkedSymbolId: '',
|
|
||||||
displayedText: 'child-1',
|
|
||||||
orientation: Orientation.Horizontal,
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
minWidth: 1,
|
|
||||||
minHeight: 1,
|
|
||||||
width: 0,
|
|
||||||
height: 0,
|
|
||||||
margin: {},
|
|
||||||
isFlex: false,
|
|
||||||
maxWidth: Infinity,
|
|
||||||
maxHeight: Infinity,
|
|
||||||
type: 'type',
|
|
||||||
isAnchor: false,
|
|
||||||
warning: '',
|
|
||||||
hideChildrenInTreeview: false,
|
|
||||||
showChildrenDimensions: [],
|
|
||||||
showSelfDimensions: [],
|
|
||||||
showDimensionWithMarks: [],
|
|
||||||
markPosition: [],
|
|
||||||
positionReference: PositionReference.TopLeft
|
|
||||||
},
|
|
||||||
userData: {}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
children.push(
|
|
||||||
{
|
|
||||||
children: [],
|
|
||||||
parent: mainContainer,
|
|
||||||
properties: {
|
|
||||||
id: 'child-2',
|
|
||||||
parentId: 'main',
|
|
||||||
linkedSymbolId: '',
|
|
||||||
displayedText: 'child-2',
|
|
||||||
orientation: Orientation.Horizontal,
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
margin: {},
|
|
||||||
minWidth: 1,
|
|
||||||
minHeight: 1,
|
|
||||||
width: 0,
|
|
||||||
height: 0,
|
|
||||||
positionReference: PositionReference.TopLeft,
|
|
||||||
isFlex: false,
|
|
||||||
maxWidth: Infinity,
|
|
||||||
maxHeight: Infinity,
|
|
||||||
type: 'type',
|
|
||||||
warning: '',
|
|
||||||
hideChildrenInTreeview: false,
|
|
||||||
showChildrenDimensions: [],
|
|
||||||
showSelfDimensions: [],
|
|
||||||
showDimensionWithMarks: [],
|
|
||||||
markPosition: [],
|
|
||||||
isAnchor: false
|
|
||||||
},
|
|
||||||
userData: {}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
render(<ElementsList
|
|
||||||
symbols={new Map()}
|
|
||||||
mainContainer={mainContainer}
|
|
||||||
selectedContainer={mainContainer}
|
|
||||||
onPropertyChange={() => {}}
|
|
||||||
selectContainer={() => {}}
|
|
||||||
addContainer={() => {}}
|
|
||||||
/>);
|
|
||||||
|
|
||||||
expect(screen.getByText(/Elements/i));
|
|
||||||
expect(screen.queryByText('id')).toBeDefined();
|
|
||||||
expect(screen.getByText(/main/i));
|
|
||||||
expect(screen.getByText(/child-1/i));
|
|
||||||
expect(screen.getByText(/child-2/i));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('With multiple containers, change selection', () => {
|
|
||||||
const children: IContainerModel[] = [];
|
|
||||||
const mainContainer: IContainerModel = {
|
|
||||||
children,
|
|
||||||
parent: null,
|
|
||||||
properties: DEFAULT_MAINCONTAINER_PROPS,
|
|
||||||
userData: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
const child1Model: IContainerModel = {
|
|
||||||
children: [],
|
|
||||||
parent: mainContainer,
|
|
||||||
properties: {
|
|
||||||
id: 'child-1',
|
|
||||||
parentId: 'main',
|
|
||||||
linkedSymbolId: '',
|
|
||||||
displayedText: 'child-1',
|
|
||||||
orientation: Orientation.Horizontal,
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
minWidth: 1,
|
|
||||||
minHeight: 1,
|
|
||||||
width: 0,
|
|
||||||
height: 0,
|
|
||||||
warning: '',
|
|
||||||
positionReference: PositionReference.TopLeft,
|
|
||||||
margin: {},
|
|
||||||
isFlex: false,
|
|
||||||
maxWidth: Infinity,
|
|
||||||
maxHeight: Infinity,
|
|
||||||
type: 'type',
|
|
||||||
hideChildrenInTreeview: false,
|
|
||||||
showChildrenDimensions: [],
|
|
||||||
showSelfDimensions: [],
|
|
||||||
showDimensionWithMarks: [],
|
|
||||||
markPosition: [],
|
|
||||||
isAnchor: false
|
|
||||||
},
|
|
||||||
userData: {}
|
|
||||||
};
|
|
||||||
children.push(child1Model);
|
|
||||||
|
|
||||||
let selectedContainer: IContainerModel | undefined = mainContainer;
|
|
||||||
const selectContainer = vi.fn((containerId: string) => {
|
|
||||||
selectedContainer = FindContainerById(mainContainer, containerId);
|
|
||||||
});
|
|
||||||
|
|
||||||
const { container, rerender } = render(<ElementsList
|
|
||||||
symbols={new Map()}
|
|
||||||
mainContainer={mainContainer}
|
|
||||||
selectedContainer={selectedContainer}
|
|
||||||
onPropertyChange={() => {}}
|
|
||||||
selectContainer={selectContainer}
|
|
||||||
addContainer={() => {}}
|
|
||||||
/>);
|
|
||||||
|
|
||||||
expect(screen.getByText(/Elements/i));
|
|
||||||
expect(screen.queryByText('id')).toBeDefined();
|
|
||||||
expect(screen.getByText(/main/i));
|
|
||||||
const child1 = screen.getByText(/child-1/i);
|
|
||||||
expect(child1);
|
|
||||||
const propertyId = container.querySelector('#id');
|
|
||||||
const propertyParentId = container.querySelector('#parentId');
|
|
||||||
expect((propertyId as HTMLInputElement).value).toBe(mainContainer.properties.id.toString());
|
|
||||||
expect((propertyParentId as HTMLInputElement).value).toBe('');
|
|
||||||
|
|
||||||
fireEvent.click(child1);
|
|
||||||
|
|
||||||
rerender(<ElementsList
|
|
||||||
symbols={new Map()}
|
|
||||||
mainContainer={mainContainer}
|
|
||||||
selectedContainer={selectedContainer}
|
|
||||||
onPropertyChange={() => {}}
|
|
||||||
selectContainer={selectContainer}
|
|
||||||
addContainer={() => {}}
|
|
||||||
/>);
|
|
||||||
|
|
||||||
expect((propertyId as HTMLInputElement).value === 'main').toBeFalsy();
|
|
||||||
expect((propertyParentId as HTMLInputElement).value === '').toBeFalsy();
|
|
||||||
expect((propertyId as HTMLInputElement).value).toBe(child1Model.properties.id.toString());
|
|
||||||
expect((propertyParentId as HTMLInputElement).value).toBe(child1Model.properties.parentId?.toString());
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -12,7 +12,7 @@ import { Position } from '../Enums/Position';
|
||||||
/// EDITOR DEFAULTS ///
|
/// EDITOR DEFAULTS ///
|
||||||
|
|
||||||
/** Enable fast boot and disable main menu (default = false) */
|
/** Enable fast boot and disable main menu (default = false) */
|
||||||
export const FAST_BOOT = true;
|
export const FAST_BOOT = false;
|
||||||
|
|
||||||
/** Disable any call to the API (default = false) */
|
/** Disable any call to the API (default = false) */
|
||||||
export const DISABLE_API = false;
|
export const DISABLE_API = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue