Skip to content

Commit 6684707

Browse files
committed
update state in tests
1 parent 0c66771 commit 6684707

File tree

4 files changed

+92
-46
lines changed

4 files changed

+92
-46
lines changed

src/browser/modules/Stream/CypherFrame/ErrorsView/ErrorsView.test.tsx

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import { createBus } from 'suber'
2424
import { ErrorsView, ErrorsViewProps } from './ErrorsView'
2525
import { BrowserError } from 'services/exceptions'
2626
import { Provider } from 'react-redux'
27-
import { initialState as initialConnectionsState } from 'shared/modules/connections/connectionsDuck'
28-
import { initialState as initialExperimentalFeatureState } from 'shared/modules/experimentalFeatures/experimentalFeaturesDuck'
27+
import { initialState as initialMetaState } from 'shared/modules/dbMeta/dbMetaDuck'
28+
import { initialState as initialSettingsState } from 'shared/modules/settings/settingsDuck'
2929

3030
const withProvider = (store: any, children: any) => {
3131
return <Provider store={store}>{children}</Provider>
@@ -48,8 +48,8 @@ const mount = (props: Partial<ErrorsViewProps>, state?: any) => {
4848
}
4949

5050
const initialState = {
51-
connections: initialConnectionsState,
52-
experimentalFeatures: initialExperimentalFeatureState
51+
meta: initialMetaState,
52+
settings: initialSettingsState
5353
}
5454

5555
const combinedState = { ...initialState, ...state }
@@ -114,18 +114,13 @@ describe('ErrorsView', () => {
114114
}
115115

116116
const state = {
117-
connections: {
118-
activeConnection: 'test',
119-
connectionsById: {
120-
test: {
121-
protocolVersion: 5.7
122-
}
117+
meta: {
118+
server: {
119+
version: '5.26.0'
123120
}
124121
},
125-
experimentalFeatures: {
126-
enableGqlErrors: {
127-
on: true
128-
}
122+
settings: {
123+
enableGqlErrorsAndNotifications: true
129124
}
130125
}
131126

@@ -162,18 +157,13 @@ describe('ErrorsView', () => {
162157
}
163158

164159
const state = {
165-
connections: {
166-
activeConnection: 'test',
167-
connectionsById: {
168-
test: {
169-
protocolVersion: 5.7
170-
}
160+
meta: {
161+
server: {
162+
version: '5.26.0'
171163
}
172164
},
173-
experimentalFeatures: {
174-
enableGqlErrors: {
175-
on: true
176-
}
165+
settings: {
166+
enableGqlErrorsAndNotifications: true
177167
}
178168
}
179169

src/browser/modules/Stream/CypherFrame/WarningsView.test.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import React from 'react'
2323
import { WarningsView, WarningsViewProps } from './WarningsView'
2424
import { Provider } from 'react-redux'
2525

26-
import { initialState as initialConnectionsState } from 'shared/modules/connections/connectionsDuck'
27-
import { initialState as initialExperimentalFeatureState } from 'shared/modules/experimentalFeatures/experimentalFeaturesDuck'
26+
import { initialState as initialMetaState } from 'shared/modules/dbMeta/dbMetaDuck'
27+
import { initialState as initialSettingsState } from 'shared/modules/settings/settingsDuck'
2828
import { createBus } from 'suber'
2929
import { DeepPartial } from 'shared/utils/deepPartial'
3030
import { notificationFilterMinimumSeverityLevel } from 'neo4j-driver-core'
@@ -46,13 +46,9 @@ const mount = (props: DeepPartial<WarningsViewProps>, state?: any) => {
4646
}
4747

4848
const initialState = {
49-
settings: {
50-
maxRows: 1000,
51-
maxFieldItems: 1000
52-
},
5349
app: {},
54-
connections: initialConnectionsState,
55-
experimentalFeatures: initialExperimentalFeatureState
50+
meta: initialMetaState,
51+
settings: initialSettingsState
5652
}
5753

5854
const combinedState = { ...initialState, ...state }
@@ -82,7 +78,7 @@ describe('WarningsView', () => {
8278
expect(container).toMatchSnapshot()
8379
})
8480

85-
test('does displays a warning', () => {
81+
test('does display a warning', () => {
8682
// Given
8783
const props = {
8884
result: {
@@ -141,13 +137,13 @@ describe('WarningsView', () => {
141137
}
142138

143139
const state = {
144-
connections: {
145-
activeConnection: 'test',
146-
connectionsById: {
147-
test: {
148-
protocolVersion: 5.6
149-
}
140+
meta: {
141+
server: {
142+
version: '5.23.0'
150143
}
144+
},
145+
settings: {
146+
enableGqlErrorsAndNotifications: true
151147
}
152148
}
153149

@@ -237,13 +233,13 @@ describe('WarningsView', () => {
237233
}
238234

239235
const state = {
240-
connections: {
241-
activeConnection: 'test',
242-
connectionsById: {
243-
test: {
244-
protocolVersion: 5.6
245-
}
236+
meta: {
237+
server: {
238+
version: '5.23.0'
246239
}
240+
},
241+
settings: {
242+
enableGqlErrorsAndNotifications: true
247243
}
248244
}
249245

src/browser/modules/Stream/CypherFrame/__snapshots__/WarningsView.test.tsx.snap

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,67 @@
22

33
exports[`WarningsView displays nothing if no notifications 1`] = `<div />`;
44

5+
exports[`WarningsView does display a warning 1`] = `
6+
<div>
7+
<div
8+
class="sc-hGPBjI kgdIGh"
9+
>
10+
<div
11+
class="sc-dlVxhl fwhZkz"
12+
>
13+
<div
14+
class="sc-kfPuZi lgMZCo"
15+
>
16+
<div
17+
class="sc-cxpSdN sc-llYSUQ cnlYxc eNTkBC"
18+
>
19+
WARNING
20+
</div>
21+
<h4
22+
class="sc-kLwhqv"
23+
>
24+
My xx1 warning
25+
</h4>
26+
</div>
27+
<div
28+
class="sc-fKVqWL"
29+
>
30+
<div
31+
class="sc-kfPuZi lgMZCo"
32+
>
33+
This is xx2 warning
34+
</div>
35+
<div
36+
class="sc-fKVqWL"
37+
>
38+
<pre
39+
class="sc-hiCibw jvxLJD"
40+
>
41+
EXPLAIN MATCH xx3
42+
<br
43+
class="sc-jJoQJp"
44+
/>
45+
46+
^
47+
</pre>
48+
</div>
49+
</div>
50+
<div
51+
class="sc-fKVqWL"
52+
style="margin-top: 10px;"
53+
>
54+
Status code:
55+
<code
56+
class="sc-ZOtfp koHcGf"
57+
>
58+
xx3.Warning
59+
</code>
60+
</div>
61+
</div>
62+
</div>
63+
</div>
64+
`;
65+
566
exports[`WarningsView does display a warning for GQL status codes 1`] = `
667
<div>
768
<div

src/shared/modules/experimentalFeatures/experimentalFeaturesDuck.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export const showFeature = (state: any, name: any) =>
99
!!(state[NAME][name] || {}).on
1010

1111
export const experimentalFeatureSelfName = 'showSelf'
12-
export const enableGqlErrors = 'enableGqlErrors'
1312

1413
export const initialState = {
1514
[experimentalFeatureSelfName]: {

0 commit comments

Comments
 (0)