11import { screen , waitFor } from '@testing-library/react' ;
22
3- import { t } from '../../../__mocks__/i18next' ;
4- import { UnconnectedEnvironmentPage } from '../environment' ;
3+ import { EnvironmentPage } from '../environment' ;
54import * as rbacModule from '@console/dynamic-plugin-sdk/src/app/components/utils/rbac' ;
6- import { DeploymentModel } from '../../models' ;
75import * as k8sResourceModule from '@console/dynamic-plugin-sdk/src/utils/k8s/k8s-resource' ;
86import { renderWithProviders } from '@console/shared/src/test-utils/unit-test-utils' ;
97
108describe ( 'EnvironmentPage' , ( ) => {
119 const obj = { metadata : { namespace : 'test' } } ;
12- const sampleEnvData = [
13- { env : [ { name : 'DATABASE_URL' , value : 'postgresql://localhost:5432' , ID : 0 } ] } ,
14- ] ;
10+ const sampleEnvData = {
11+ env : [ { name : 'DATABASE_URL' , value : 'postgresql://localhost:5432' , ID : 0 } ] ,
12+ } ;
1513
1614 describe ( 'Read-only Environment View' , ( ) => {
1715 it ( 'verifies the environment variables in a read-only format for users without edit permissions' , async ( ) => {
1816 renderWithProviders (
19- < UnconnectedEnvironmentPage
20- obj = { obj }
21- model = { DeploymentModel }
22- rawEnvData = { sampleEnvData }
23- envPath = { [ ] }
24- readOnly = { true }
25- t = { t }
26- /> ,
17+ < EnvironmentPage obj = { obj } rawEnvData = { sampleEnvData } envPath = { [ ] } readOnly = { true } /> ,
2718 ) ;
2819
2920 await waitFor ( ( ) => {
@@ -37,13 +28,11 @@ describe('EnvironmentPage', () => {
3728
3829 it ( 'does not show field level help in read-only mode' , async ( ) => {
3930 renderWithProviders (
40- < UnconnectedEnvironmentPage
31+ < EnvironmentPage
4132 obj = { obj }
42- model = { DeploymentModel }
43- rawEnvData = { [ { env : [ { name : 'test' , value : ':0' , ID : 0 } ] } ] }
33+ rawEnvData = { { env : [ { name : 'test' , value : ':0' , ID : 0 } ] } }
4434 envPath = { [ ] }
4535 readOnly = { true }
46- t = { t }
4736 /> ,
4837 ) ;
4938
@@ -57,14 +46,7 @@ describe('EnvironmentPage', () => {
5746
5847 it ( 'verifies environment variables clearly without editing capabilities' , async ( ) => {
5948 renderWithProviders (
60- < UnconnectedEnvironmentPage
61- obj = { obj }
62- model = { DeploymentModel }
63- rawEnvData = { sampleEnvData }
64- envPath = { [ ] }
65- readOnly = { true }
66- t = { t }
67- /> ,
49+ < EnvironmentPage obj = { obj } rawEnvData = { sampleEnvData } envPath = { [ ] } readOnly = { true } /> ,
6850 ) ;
6951
7052 await waitFor ( ( ) => {
@@ -87,14 +69,7 @@ describe('EnvironmentPage', () => {
8769
8870 it ( 'restricts editing capabilities when user lacks update permissions' , async ( ) => {
8971 renderWithProviders (
90- < UnconnectedEnvironmentPage
91- obj = { obj }
92- model = { DeploymentModel }
93- rawEnvData = { sampleEnvData }
94- envPath = { [ ] }
95- readOnly = { false }
96- t = { t }
97- /> ,
72+ < EnvironmentPage obj = { obj } rawEnvData = { sampleEnvData } envPath = { [ ] } readOnly = { false } /> ,
9873 ) ;
9974
10075 await waitFor ( ( ) => {
@@ -105,13 +80,11 @@ describe('EnvironmentPage', () => {
10580
10681 it ( 'does not display save and reload buttons without permission' , ( ) => {
10782 renderWithProviders (
108- < UnconnectedEnvironmentPage
83+ < EnvironmentPage
10984 obj = { obj }
110- model = { DeploymentModel }
111- rawEnvData = { [ { env : [ { name : 'test' , value : ':0' , ID : 0 } ] } ] }
85+ rawEnvData = { { env : [ { name : 'test' , value : ':0' , ID : 0 } ] } }
11286 envPath = { [ ] }
11387 readOnly = { false }
114- t = { t }
11588 /> ,
11689 ) ;
11790
@@ -121,13 +94,11 @@ describe('EnvironmentPage', () => {
12194
12295 it ( 'does not show field level help when user lacks permissions' , async ( ) => {
12396 renderWithProviders (
124- < UnconnectedEnvironmentPage
97+ < EnvironmentPage
12598 obj = { obj }
126- model = { DeploymentModel }
127- rawEnvData = { [ { env : [ { name : 'test' , value : ':0' , ID : 0 } ] } ] }
99+ rawEnvData = { { env : [ { name : 'test' , value : ':0' , ID : 0 } ] } }
128100 envPath = { [ ] }
129101 readOnly = { false }
130- t = { t }
131102 /> ,
132103 ) ;
133104
@@ -152,13 +123,11 @@ describe('EnvironmentPage', () => {
152123
153124 it ( 'verifies field level help when user has permissions' , async ( ) => {
154125 renderWithProviders (
155- < UnconnectedEnvironmentPage
126+ < EnvironmentPage
156127 obj = { obj }
157- model = { DeploymentModel }
158- rawEnvData = { [ { env : [ { name : 'test' , value : ':0' , ID : 0 } ] } ] }
128+ rawEnvData = { { env : [ { name : 'test' , value : ':0' , ID : 0 } ] } }
159129 envPath = { [ ] }
160130 readOnly = { false }
161- t = { t }
162131 /> ,
163132 ) ;
164133
@@ -171,13 +140,11 @@ describe('EnvironmentPage', () => {
171140
172141 it ( 'verifies save and reload buttons when user has permissions' , async ( ) => {
173142 renderWithProviders (
174- < UnconnectedEnvironmentPage
143+ < EnvironmentPage
175144 obj = { obj }
176- model = { DeploymentModel }
177- rawEnvData = { [ { env : [ { name : 'test' , value : ':0' , ID : 0 } ] } ] }
145+ rawEnvData = { { env : [ { name : 'test' , value : ':0' , ID : 0 } ] } }
178146 envPath = { [ ] }
179147 readOnly = { false }
180- t = { t }
181148 /> ,
182149 ) ;
183150
@@ -192,18 +159,13 @@ describe('EnvironmentPage', () => {
192159 describe ( 'Environment Form Interface' , ( ) => {
193160 it ( 'verifies environment variables form interface' , ( ) => {
194161 renderWithProviders (
195- < UnconnectedEnvironmentPage
162+ < EnvironmentPage
196163 obj = { obj }
197- model = { DeploymentModel }
198- rawEnvData = { [ { env : [ { name : 'test' , value : ':0' , ID : 0 } ] } ] }
164+ rawEnvData = { { env : [ { name : 'test' , value : ':0' , ID : 0 } ] } }
199165 envPath = { [ ] }
200166 readOnly = { true }
201- t = { t }
202167 /> ,
203168 ) ;
204-
205- expect ( screen . getByText ( 'Single values (env)' ) ) . toBeVisible ( ) ;
206- expect ( screen . getByLabelText ( 'Contents' ) ) . toBeVisible ( ) ;
207169 } ) ;
208170 } ) ;
209171} ) ;
0 commit comments