11import {
2- mockDestination ,
3- mockDestinationPayload ,
2+ mockAkamaiObjectStorageDestination ,
3+ mockAkamaiObjectStorageDestinationPayload ,
4+ mockCustomHttpsDestination ,
5+ mockCustomHttpsDestinationPayload ,
46} from 'support/constants/delivery' ;
57import {
68 mockCreateDestination ,
@@ -14,152 +16,243 @@ import { logsDestinationForm } from 'support/ui/pages/logs-destination-form';
1416
1517import { objectStorageBucketFactory } from 'src/factories' ;
1618
17- import type { AkamaiObjectStorageDetailsExtended } from '@linode/api-v4' ;
19+ import type {
20+ AkamaiObjectStorageDetailsExtended ,
21+ CustomHTTPSDetailsExtended ,
22+ } from '@linode/api-v4' ;
1823
1924describe ( 'Create Destination' , ( ) => {
2025 beforeEach ( ( ) => {
2126 mockAppendFeatureFlags ( {
2227 aclpLogs : {
2328 enabled : true ,
2429 beta : true ,
30+ customHttpsEnabled : true ,
2531 bypassAccountCapabilities : true ,
2632 } ,
2733 } ) ;
2834 cy . visitWithLogin ( '/logs/delivery/destinations/create' ) ;
2935 } ) ;
36+ describe ( 'given Akamai Object Storage type destination' , ( ) => {
37+ it ( 'create destination with form' , ( ) => {
38+ // Fill in the form with valid data
39+ logsDestinationForm . setLabel (
40+ mockAkamaiObjectStorageDestinationPayload . label
41+ ) ;
42+ logsDestinationForm . fillAkamaiObjectStorageDestinationDetailsForm (
43+ mockAkamaiObjectStorageDestinationPayload . details as AkamaiObjectStorageDetailsExtended
44+ ) ;
45+
46+ // Create Destination should be disabled before test connection
47+ cy . findByRole ( 'button' , { name : 'Create Destination' } ) . should (
48+ 'be.disabled'
49+ ) ;
50+
51+ // Test connection of the destination form - failure
52+ mockTestConnection ( 400 ) ;
53+ ui . button
54+ . findByTitle ( 'Test Connection' )
55+ . should ( 'be.enabled' )
56+ . should ( 'have.attr' , 'type' , 'button' )
57+ . click ( ) ;
58+
59+ ui . toast . assertMessage (
60+ 'Delivery connection test failed. Verify your delivery settings and try again.'
61+ ) ;
62+
63+ // Create Destination should be disabled after test connection failed
64+ cy . findByRole ( 'button' , { name : 'Create Destination' } ) . should (
65+ 'be.disabled'
66+ ) ;
67+
68+ // Test connection of the destination form - success
69+ mockTestConnection ( 200 ) ;
70+ ui . button
71+ . findByTitle ( 'Test Connection' )
72+ . should ( 'be.enabled' )
73+ . should ( 'have.attr' , 'type' , 'button' )
74+ . click ( ) ;
75+
76+ ui . toast . assertMessage (
77+ `Delivery connection test completed successfully. Data can now be sent using this configuration.`
78+ ) ;
79+
80+ // Submit the destination create form - failure
81+ mockCreateDestination ( { } , 400 ) ;
82+ cy . findByRole ( 'button' , { name : 'Create Destination' } )
83+ . should ( 'be.enabled' )
84+ . should ( 'have.attr' , 'type' , 'button' )
85+ . click ( ) ;
86+
87+ ui . toast . assertMessage ( `There was an issue creating your destination` ) ;
88+
89+ // Submit the destination create form - success
90+ mockCreateDestination ( mockAkamaiObjectStorageDestination ) ;
91+ mockGetDestinations ( [ mockAkamaiObjectStorageDestination ] ) ;
92+ cy . findByRole ( 'button' , { name : 'Create Destination' } )
93+ . should ( 'be.enabled' )
94+ . should ( 'have.attr' , 'type' , 'button' )
95+ . click ( ) ;
96+
97+ ui . toast . assertMessage (
98+ `Destination ${ mockAkamaiObjectStorageDestination . label } created successfully`
99+ ) ;
100+
101+ // Verify we redirect to the destinations landing page upon successful creation
102+ cy . url ( ) . should ( 'endWith' , 'destinations' ) ;
103+
104+ // Verify the newly created destination shows on the Destinations landing page
105+ cy . findByText ( mockAkamaiObjectStorageDestination . label )
106+ . closest ( 'tr' )
107+ . within ( ( ) => {
108+ // Verify Destination label shows
109+ cy . findByText ( mockAkamaiObjectStorageDestination . label ) . should (
110+ 'be.visible'
111+ ) ;
112+ } ) ;
113+ } ) ;
114+
115+ describe ( 'Bucket end Endpoint fields' , ( ) => {
116+ it ( 'populates Bucket and Endpoint when selecting an existing bucket and manually entering data' , ( ) => {
117+ mockGetBuckets ( [
118+ objectStorageBucketFactory . build ( {
119+ hostname : 'bucket-hostname.us-east-1.linodeobjects.com' ,
120+ label : 'bucket-with-hostname' ,
121+ region : 'us-east' ,
122+ } ) ,
123+ objectStorageBucketFactory . build ( {
124+ hostname : 'bucket-s3.eu-central-1.linodeobjects.com' ,
125+ label : 'bucket-with-s3-endpoint' ,
126+ region : 'eu-central' ,
127+ s3_endpoint : 'eu-central-1.linodeobjects.com' ,
128+ } ) ,
129+ ] ) ;
130+
131+ // Default radio should be "Select Bucket associated with the account"
132+ cy . findByLabelText ( 'Select Bucket associated with the account' ) . should (
133+ 'be.checked'
134+ ) ;
135+
136+ // Endpoint should be disabled in bucket_from_account mode
137+ cy . findByLabelText ( 'Endpoint' ) . should ( 'be.disabled' ) ;
138+
139+ // Select a bucket without s3_endpoint - should use hostname as Endpoint
140+ logsDestinationForm . selectBucketFromDropdown ( 'bucket-with-hostname' ) ;
141+ cy . findByLabelText ( 'Bucket' ) . should (
142+ 'have.value' ,
143+ 'bucket-with-hostname'
144+ ) ;
145+ cy . findByLabelText ( 'Endpoint' ) . should (
146+ 'have.value' ,
147+ 'bucket-hostname.us-east-1.linodeobjects.com'
148+ ) ;
30149
31- it ( 'create destination with form' , ( ) => {
32- // Give Destination a label
33- logsDestinationForm . setLabel ( mockDestinationPayload . label ) ;
34-
35- logsDestinationForm . fillDestinationDetailsForm (
36- mockDestinationPayload . details as AkamaiObjectStorageDetailsExtended
37- ) ;
38-
39- // Create Destination should be disabled before test connection
40- cy . findByRole ( 'button' , { name : 'Create Destination' } ) . should (
41- 'be.disabled'
42- ) ;
43-
44- // Test connection of the destination form - failure
45- mockTestConnection ( 400 ) ;
46- ui . button
47- . findByTitle ( 'Test Connection' )
48- . should ( 'be.enabled' )
49- . should ( 'have.attr' , 'type' , 'button' )
50- . click ( ) ;
51-
52- ui . toast . assertMessage (
53- 'Delivery connection test failed. Verify your delivery settings and try again.'
54- ) ;
55-
56- // Create Destination should be disabled after test connection failed
57- cy . findByRole ( 'button' , { name : 'Create Destination' } ) . should (
58- 'be.disabled'
59- ) ;
60-
61- // Test connection of the destination form - success
62- mockTestConnection ( 200 ) ;
63- ui . button
64- . findByTitle ( 'Test Connection' )
65- . should ( 'be.enabled' )
66- . should ( 'have.attr' , 'type' , 'button' )
67- . click ( ) ;
68-
69- ui . toast . assertMessage (
70- `Delivery connection test completed successfully. Data can now be sent using this configuration.`
71- ) ;
72-
73- // Submit the destination create form - failure
74- mockCreateDestination ( { } , 400 ) ;
75- cy . findByRole ( 'button' , { name : 'Create Destination' } )
76- . should ( 'be.enabled' )
77- . should ( 'have.attr' , 'type' , 'button' )
78- . click ( ) ;
79-
80- ui . toast . assertMessage ( `There was an issue creating your destination` ) ;
81-
82- // Submit the destination create form - success
83- mockCreateDestination ( mockDestination ) ;
84- mockGetDestinations ( [ mockDestination ] ) ;
85- cy . findByRole ( 'button' , { name : 'Create Destination' } )
86- . should ( 'be.enabled' )
87- . should ( 'have.attr' , 'type' , 'button' )
88- . click ( ) ;
89-
90- ui . toast . assertMessage (
91- `Destination ${ mockDestination . label } created successfully`
92- ) ;
93-
94- // Verify we redirect to the destinations landing page upon successful creation
95- cy . url ( ) . should ( 'endWith' , 'destinations' ) ;
96-
97- // Verify the newly created destination shows on the Destinations landing page
98- cy . findByText ( mockDestination . label )
99- . closest ( 'tr' )
100- . within ( ( ) => {
101- // Verify Destination label shows
102- cy . findByText ( mockDestination . label ) . should ( 'be.visible' ) ;
150+ // Select a bucket with s3_endpoint - should use s3_endpoint as Endpoint
151+ logsDestinationForm . selectBucketFromDropdown ( 'bucket-with-s3-endpoint' ) ;
152+ cy . findByLabelText ( 'Bucket' ) . should (
153+ 'have.value' ,
154+ 'bucket-with-s3-endpoint'
155+ ) ;
156+ cy . findByLabelText ( 'Endpoint' ) . should (
157+ 'have.value' ,
158+ 'eu-central-1.linodeobjects.com'
159+ ) ;
160+
161+ // Switch to manual mode and fill in values
162+ cy . findByLabelText ( 'Enter Bucket manually' ) . click ( ) ;
163+ logsDestinationForm . setBucket ( 'my-manual-bucket' ) ;
164+ logsDestinationForm . setEndpoint ( 'my-endpoint.com' ) ;
165+
166+ cy . findByLabelText ( 'Bucket' ) . should ( 'have.value' , 'my-manual-bucket' ) ;
167+ cy . findByLabelText ( 'Endpoint' ) . should ( 'have.value' , 'my-endpoint.com' ) ;
168+
169+ // Switch back to bucket_from_account
170+ cy . findByLabelText ( 'Select Bucket associated with the account' ) . click ( ) ;
171+
172+ // Both fields should be cleared
173+ cy . findByLabelText ( 'Bucket' ) . should ( 'have.value' , '' ) ;
174+ cy . findByLabelText ( 'Endpoint' ) . should ( 'have.value' , '' ) ;
103175 } ) ;
176+ } ) ;
104177 } ) ;
105178
106- describe ( 'Bucket end Endpoint fields' , ( ) => {
107- it ( 'populates Bucket and Endpoint when selecting an existing bucket and manually entering data' , ( ) => {
108- mockGetBuckets ( [
109- objectStorageBucketFactory . build ( {
110- hostname : 'bucket-hostname.us-east-1.linodeobjects.com' ,
111- label : 'bucket-with-hostname' ,
112- region : 'us-east' ,
113- } ) ,
114- objectStorageBucketFactory . build ( {
115- hostname : 'bucket-s3.eu-central-1.linodeobjects.com' ,
116- label : 'bucket-with-s3-endpoint' ,
117- region : 'eu-central' ,
118- s3_endpoint : 'eu-central-1.linodeobjects.com' ,
119- } ) ,
120- ] ) ;
121-
122- // Default radio should be "Select Bucket associated with the account"
123- cy . findByLabelText ( 'Select Bucket associated with the account' ) . should (
124- 'be.checked'
179+ describe ( 'given Custom HTTPS type destination' , ( ) => {
180+ beforeEach ( ( ) => {
181+ logsDestinationForm . selectDestinationType ( 'Custom HTTPS' ) ;
182+ } ) ;
183+
184+ it ( 'create destination with form' , ( ) => {
185+ // Fill in the form with valid data
186+ logsDestinationForm . setLabel ( mockCustomHttpsDestinationPayload . label ) ;
187+ logsDestinationForm . fillCustomHttpsDestinationDetailsForm (
188+ mockCustomHttpsDestinationPayload . details as CustomHTTPSDetailsExtended
125189 ) ;
126190
127- // Endpoint should be disabled in bucket_from_account mode
128- cy . findByLabelText ( 'Endpoint' ) . should ( 'be.disabled' ) ;
191+ // Create Destination should be disabled before test connection
192+ cy . findByRole ( 'button' , { name : 'Create Destination' } ) . should (
193+ 'be.disabled'
194+ ) ;
129195
130- // Select a bucket without s3_endpoint - should use hostname as Endpoint
131- logsDestinationForm . selectBucketFromDropdown ( 'bucket-with-hostname' ) ;
132- cy . findByLabelText ( 'Bucket' ) . should ( 'have.value' , 'bucket-with-hostname' ) ;
133- cy . findByLabelText ( 'Endpoint' ) . should (
134- 'have.value' ,
135- 'bucket-hostname.us-east-1.linodeobjects.com'
196+ // Test connection of the destination form - failure
197+ mockTestConnection ( 400 ) ;
198+ ui . button
199+ . findByTitle ( 'Test Connection' )
200+ . should ( 'be.enabled' )
201+ . should ( 'have.attr' , 'type' , 'button' )
202+ . click ( ) ;
203+
204+ ui . toast . assertMessage (
205+ 'Delivery connection test failed. Verify your delivery settings and try again.'
136206 ) ;
137207
138- // Select a bucket with s3_endpoint - should use s3_endpoint as Endpoint
139- logsDestinationForm . selectBucketFromDropdown ( 'bucket-with-s3-endpoint' ) ;
140- cy . findByLabelText ( 'Bucket' ) . should (
141- 'have.value' ,
142- 'bucket-with-s3-endpoint'
208+ // Create Destination should be disabled after test connection failed
209+ cy . findByRole ( 'button' , { name : 'Create Destination' } ) . should (
210+ 'be.disabled'
143211 ) ;
144- cy . findByLabelText ( 'Endpoint' ) . should (
145- 'have.value' ,
146- 'eu-central-1.linodeobjects.com'
212+
213+ // Test connection of the destination form - success
214+ mockTestConnection ( 200 ) ;
215+ ui . button
216+ . findByTitle ( 'Test Connection' )
217+ . should ( 'be.enabled' )
218+ . should ( 'have.attr' , 'type' , 'button' )
219+ . click ( ) ;
220+
221+ ui . toast . assertMessage (
222+ `Delivery connection test completed successfully. Data can now be sent using this configuration.`
147223 ) ;
148224
149- // Switch to manual mode and fill in values
150- cy . findByLabelText ( 'Enter Bucket manually' ) . click ( ) ;
151- logsDestinationForm . setBucket ( 'my-manual-bucket' ) ;
152- logsDestinationForm . setEndpoint ( 'my-endpoint.com' ) ;
225+ // Submit the destination create form - failure
226+ mockCreateDestination ( { } , 400 ) ;
227+ cy . findByRole ( 'button' , { name : 'Create Destination' } )
228+ . should ( 'be.enabled' )
229+ . should ( 'have.attr' , 'type' , 'button' )
230+ . click ( ) ;
231+
232+ ui . toast . assertMessage ( `There was an issue creating your destination` ) ;
153233
154- cy . findByLabelText ( 'Bucket' ) . should ( 'have.value' , 'my-manual-bucket' ) ;
155- cy . findByLabelText ( 'Endpoint' ) . should ( 'have.value' , 'my-endpoint.com' ) ;
234+ // Submit the destination create form - success
235+ mockCreateDestination ( mockCustomHttpsDestination ) ;
236+ mockGetDestinations ( [ mockCustomHttpsDestination ] ) ;
237+ cy . findByRole ( 'button' , { name : 'Create Destination' } )
238+ . should ( 'be.enabled' )
239+ . should ( 'have.attr' , 'type' , 'button' )
240+ . click ( ) ;
241+
242+ ui . toast . assertMessage (
243+ `Destination ${ mockCustomHttpsDestination . label } created successfully`
244+ ) ;
156245
157- // Switch back to bucket_from_account
158- cy . findByLabelText ( 'Select Bucket associated with the account' ) . click ( ) ;
246+ // Verify we redirect to the destinations landing page upon successful creation
247+ cy . url ( ) . should ( 'endWith' , 'destinations' ) ;
159248
160- // Both fields should be cleared
161- cy . findByLabelText ( 'Bucket' ) . should ( 'have.value' , '' ) ;
162- cy . findByLabelText ( 'Endpoint' ) . should ( 'have.value' , '' ) ;
249+ // Verify the newly created destination shows on the Destinations landing page
250+ cy . findByText ( mockCustomHttpsDestination . label )
251+ . closest ( 'tr' )
252+ . within ( ( ) => {
253+ // Verify Destination label shows
254+ cy . findByText ( mockCustomHttpsDestination . label ) . should ( 'be.visible' ) ;
255+ } ) ;
163256 } ) ;
164257 } ) ;
165258} ) ;
0 commit comments