@@ -8,6 +8,7 @@ import { initialOAuthState, useOAuthStore } from 'uiSrc/store'
8
8
import { INFINITE_MESSAGES } from 'uiSrc/components'
9
9
import { act , cleanup , constants , fireEvent , render , screen } from 'testSrc/helpers'
10
10
import OAuthCreateDb from './OAuthCreateDb'
11
+ import { REQUIRE_LOGIN_ON_NEW_DB } from './constants'
11
12
12
13
vi . spyOn ( utils , 'sendEventTelemetry' )
13
14
vi . spyOn ( utils , 'showInfinityToast' )
@@ -85,18 +86,66 @@ describe('OAuthCreateDb', () => {
85
86
} )
86
87
} )
87
88
88
- it ( 'should render proper components if user is logged in' , ( ) => {
89
+ it ( 'should call proper actions after click on sign button w/o recommended settings' , async ( ) => {
90
+ render ( < OAuthCreateDb /> )
91
+
92
+ await act ( async ( ) => {
93
+ fireEvent . click ( screen . getByTestId ( 'oauth-recommended-settings-checkbox' ) )
94
+ } )
95
+
96
+ fireEvent . click ( screen . getByTestId ( 'google-oauth' ) )
97
+
98
+ expect ( sendEventTelemetry ) . toBeCalledWith ( {
99
+ event : TelemetryEvent . CLOUD_SIGN_IN_SOCIAL_ACCOUNT_SELECTED ,
100
+ eventData : {
101
+ accountOption : OAuthStrategy . Google ,
102
+ action : OAuthSocialAction . Create ,
103
+ cloudRecommendedSettings : 'disabled' ,
104
+ } ,
105
+ } )
106
+
107
+ expect ( useOAuthStore . getState ( ) . isOpenSocialDialog ) . toEqual ( false )
108
+ } )
109
+
110
+ it . skipIf ( REQUIRE_LOGIN_ON_NEW_DB ) ( 'should render proper components when user is logged in' , ( ) => {
111
+ useOAuthStore . setState ( { ...initialOAuthState ,
112
+ agreement : true ,
113
+ user : {
114
+ ...initialOAuthState . user ,
115
+ data : { } ,
116
+ } ,
117
+ } )
118
+
119
+ render ( < OAuthCreateDb /> )
120
+
121
+ expect ( screen . getByTestId ( 'oauth-advantages' ) ) . toBeInTheDocument ( )
122
+ expect ( screen . getByTestId ( 'oauth-recommended-settings-checkbox' ) ) . toBeInTheDocument ( )
123
+ expect ( screen . getByTestId ( 'oauth-create-db' ) ) . toBeInTheDocument ( )
124
+
125
+ expect ( screen . queryByTestId ( 'oauth-agreement-checkbox' ) ) . not . toBeInTheDocument ( )
126
+ expect ( screen . queryByTestId ( 'oauth-container-social-buttons' ) ) . not . toBeInTheDocument ( )
127
+ } )
128
+
129
+ it . skipIf ( ! REQUIRE_LOGIN_ON_NEW_DB ) ( 'should render oauth form elements if user logged in' , ( ) => {
130
+ useOAuthStore . setState ( { ...initialOAuthState ,
131
+ agreement : true ,
132
+ user : {
133
+ ...initialOAuthState . user ,
134
+ data : { } ,
135
+ } ,
136
+ } )
137
+
89
138
render ( < OAuthCreateDb /> )
90
139
91
140
expect ( screen . getByTestId ( 'oauth-advantages' ) ) . toBeInTheDocument ( )
92
- // expect(screen.getByTestId('oauth-create-db')).toBeInTheDocument()
93
141
expect ( screen . getByTestId ( 'oauth-recommended-settings-checkbox' ) ) . toBeInTheDocument ( )
142
+ expect ( screen . getByTestId ( 'oauth-agreement-checkbox' ) ) . toBeInTheDocument ( )
143
+ expect ( screen . getByTestId ( 'oauth-container-social-buttons' ) ) . toBeInTheDocument ( )
94
144
95
- // expect(screen.queryByTestId('oauth-agreement-checkbox')).not.toBeInTheDocument()
96
- // expect(screen.queryByTestId('oauth-container-social-buttons')).not.toBeInTheDocument()
145
+ expect ( screen . queryByTestId ( 'oauth-create-db' ) ) . not . toBeInTheDocument ( )
97
146
} )
98
147
99
- it ( 'should call proper actions after click create' , async ( ) => {
148
+ it . skipIf ( REQUIRE_LOGIN_ON_NEW_DB ) ( 'should call proper actions after click create' , async ( ) => {
100
149
const name = CloudJobName . CreateFreeSubscriptionAndDatabase
101
150
useOAuthStore . setState ( { ...initialOAuthState ,
102
151
agreement : true ,
@@ -120,7 +169,7 @@ describe('OAuthCreateDb', () => {
120
169
)
121
170
} )
122
171
123
- it ( 'should call proper actions after click create without recommened settings' , async ( ) => {
172
+ it . skipIf ( REQUIRE_LOGIN_ON_NEW_DB ) ( 'should call proper actions after click create without recommened settings' , async ( ) => {
124
173
useOAuthStore . setState ( { ...initialOAuthState ,
125
174
agreement : true ,
126
175
source : 'source' ,
0 commit comments