1
1
import React from 'react' ;
2
2
import { Provider } from 'react-redux' ;
3
3
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' ;
5
11
import BottomTabs from '../app/src/components/bottom/BottomTabs' ;
6
12
import ContextManager from '../app/src/components/ContextAPIManager/ContextManager' ;
7
13
import store from '../app/src/redux/store' ;
@@ -10,38 +16,10 @@ import HTMLPanel from '../app/src/components/left/HTMLPanel';
10
16
import StateManager from '../app/src/components/StateManagement/StateManagement' ;
11
17
import CustomizationPanel from '../app/src/containers/CustomizationPanel' ;
12
18
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' ;
45
23
46
24
describe ( 'Bottom Panel Render Test' , ( ) => {
47
25
test ( 'should render all seven tabs' , ( ) => {
@@ -154,7 +132,7 @@ describe('Context Manager', () => {
154
132
expect ( screen . getAllByRole ( 'button' ) ) . toHaveLength ( 3 ) ;
155
133
expect ( screen . getByText ( 'Context Name' ) ) . toBeInTheDocument ( ) ;
156
134
} ) ;
157
- test ( 'Create/Edit Tab should contain all buttons and input fields' , ( ) => {
135
+ test ( 'Assign Tab should contain all buttons and input fields' , ( ) => {
158
136
render (
159
137
< Provider store = { store } >
160
138
< ContextManager />
@@ -181,15 +159,14 @@ describe('State Manager', () => {
181
159
} ) ;
182
160
183
161
describe ( 'Customization Panel' , ( ) => {
184
- test ( 'Should render customization container with no elements added ' , ( ) => {
162
+ test ( 'Should render customization container with no elements in Canvas ' , ( ) => {
185
163
render (
186
164
< Provider store = { store } >
187
165
< BrowserRouter >
188
166
< CustomizationPanel />
189
167
</ BrowserRouter >
190
168
</ Provider >
191
169
) ;
192
- console . log ( store . appState ) ;
193
170
expect ( screen . getByText ( 'Parent Component:' ) ) . toBeInTheDocument ( ) ;
194
171
expect ( screen . getByText ( 'App' ) ) . toBeInTheDocument ( ) ;
195
172
expect (
@@ -198,4 +175,30 @@ describe('Customization Panel', () => {
198
175
)
199
176
) . toBeInTheDocument ( ) ;
200
177
} ) ;
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
+ } ) ;
201
204
} ) ;
0 commit comments