Skip to content

Commit e87ddd2

Browse files
committed
Moved test to bottomtabs tests
1 parent dc2c231 commit e87ddd2

File tree

2 files changed

+42
-72
lines changed

2 files changed

+42
-72
lines changed

__tests__/BottomTabs.test.tsx

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import React from 'react';
22
import { Provider } from 'react-redux';
33
import '@testing-library/jest-dom';
4-
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
4+
import {
5+
render,
6+
screen,
7+
fireEvent,
8+
waitFor,
9+
within
10+
} from '@testing-library/react';
511
import BottomTabs from '../app/src/components/bottom/BottomTabs';
612
import ContextManager from '../app/src/components/ContextAPIManager/ContextManager';
713
import store from '../app/src/redux/store';
@@ -10,38 +16,10 @@ import HTMLPanel from '../app/src/components/left/HTMLPanel';
1016
import StateManager from '../app/src/components/StateManagement/StateManagement';
1117
import CustomizationPanel from '../app/src/containers/CustomizationPanel';
1218
import { BrowserRouter } from 'react-router-dom';
13-
14-
15-
// newState.appState.components[0].children = [
16-
// {
17-
// type: 'HTML Element',
18-
// typeId: 1000,
19-
// name: 'separator',
20-
// childId: 1000,
21-
// style: {
22-
// border: 'none'
23-
// },
24-
// attributes: {},
25-
// events: {},
26-
// children: [],
27-
// stateProps: [],
28-
// passedInProps: []
29-
// },
30-
// {
31-
// type: 'HTML Element',
32-
// typeId: 11,
33-
// name: 'div',
34-
// childId: 1,
35-
// style: {},
36-
// attributes: {},
37-
// events: {},
38-
// children: [],
39-
// stateProps: [],
40-
// passedInProps: []
41-
// }
42-
// ];
43-
44-
// newState.canvasFocus.childId = 1;
19+
import DragDropPanel from '../app/src/components/left/DragDropPanel';
20+
import MainContainer from '../app/src/containers/MainContainer';
21+
import { DndProvider } from 'react-dnd';
22+
import { HTML5Backend } from 'react-dnd-html5-backend';
4523

4624
describe('Bottom Panel Render Test', () => {
4725
test('should render all seven tabs', () => {
@@ -154,7 +132,7 @@ describe('Context Manager', () => {
154132
expect(screen.getAllByRole('button')).toHaveLength(3);
155133
expect(screen.getByText('Context Name')).toBeInTheDocument();
156134
});
157-
test('Create/Edit Tab should contain all buttons and input fields', () => {
135+
test('Assign Tab should contain all buttons and input fields', () => {
158136
render(
159137
<Provider store={store}>
160138
<ContextManager />
@@ -181,15 +159,14 @@ describe('State Manager', () => {
181159
});
182160

183161
describe('Customization Panel', () => {
184-
test('Should render customization container with no elements added', () => {
162+
test('Should render customization container with no elements in Canvas', () => {
185163
render(
186164
<Provider store={store}>
187165
<BrowserRouter>
188166
<CustomizationPanel />
189167
</BrowserRouter>
190168
</Provider>
191169
);
192-
console.log(store.appState);
193170
expect(screen.getByText('Parent Component:')).toBeInTheDocument();
194171
expect(screen.getByText('App')).toBeInTheDocument();
195172
expect(
@@ -198,4 +175,30 @@ describe('Customization Panel', () => {
198175
)
199176
).toBeInTheDocument();
200177
});
178+
test('Should render all buttons and inputs when Canvas has element', () => {
179+
render(
180+
<Provider store={store}>
181+
<BrowserRouter>
182+
<DndProvider backend={HTML5Backend}>
183+
<DragDropPanel />
184+
<MainContainer />
185+
<CustomizationPanel />
186+
</DndProvider>
187+
</BrowserRouter>
188+
</Provider>
189+
);
190+
const drop = screen.getByTestId('drop');
191+
const div = screen.getAllByText('Div')[0];
192+
expect(drop).toBeInTheDocument();
193+
expect(div).toBeInTheDocument();
194+
fireEvent.dragStart(div);
195+
fireEvent.dragEnter(drop);
196+
fireEvent.dragOver(drop);
197+
fireEvent.drop(drop);
198+
//check if customization panel elements are rendering correctly
199+
const panel = screen.getByTestId('customization');
200+
expect(within(panel).getAllByRole('textbox')).toHaveLength(4);
201+
// check dropdowns
202+
expect(within(panel).getAllByRole('button')).toHaveLength(11);
203+
});
201204
});

__tests__/DragAndDrop.test.tsx

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import { DndProvider } from 'react-dnd';
44
import { HTML5Backend } from 'react-dnd-html5-backend';
55
import { fireEvent, render, screen } from '@testing-library/react';
66
import DragDropPanel from '../app/src/components/left/DragDropPanel';
7-
import ComponentDrag from '../app/src/components/right/ComponentDrag';
7+
import ComponentDrag from '../app/src/components/left/ComponentDrag';
88
import { Provider } from 'react-redux';
99
import store from '../app/src/redux/store';
1010
import MainContainer from '../app/src/containers/MainContainer';
11-
import LeftContainepr from '../app/src/containers/LeftContainer';
12-
import { StyledEngineProvider } from '@mui/material';
13-
import Main from 'electron/main';
14-
import { waitFor, within } from '@testing-library/react';
15-
import { BrowserRouter } from 'react-router-dom';
16-
import CustomizationPanel from '../app/src/containers/CustomizationPanel';
11+
import { within } from '@testing-library/react';
12+
1713

1814
function TestContext(component) {
1915
return (
@@ -77,33 +73,4 @@ describe('Drag and Drop Side Panel', () => {
7773
fireEvent.drop(drop);
7874
expect(within(drop).getByText('div')).toBeInTheDocument();
7975
});
80-
81-
test('Customization panel elements are properly rendering including their input values', () => {
82-
render(
83-
TestContext(
84-
<>
85-
<DragDropPanel />
86-
<MainContainer />
87-
<BrowserRouter>
88-
<CustomizationPanel />
89-
</BrowserRouter>
90-
</>
91-
)
92-
);
93-
const drop = screen.getByTestId('drop');
94-
const div = screen.getAllByText('Div')[0];
95-
expect(drop).toBeInTheDocument();
96-
expect(div).toBeInTheDocument();
97-
fireEvent.dragStart(div);
98-
fireEvent.dragEnter(drop);
99-
fireEvent.dragOver(drop);
100-
fireEvent.drop(drop);
101-
//check if customization panel elements are rendering correctly
102-
const panel = screen.getByTestId('customization')
103-
expect(within(panel).getAllByRole('textbox')).toHaveLength(4);
104-
// check dropdowns
105-
expect(
106-
within(panel).getAllByRole('button')
107-
).toHaveLength(11);
108-
});
10976
});

0 commit comments

Comments
 (0)