Skip to content

Commit 420685e

Browse files
change: [DPS-36773] - Improvements for bucket selection in Akamai Object Storage form (#13444)
Co-authored-by: dmcintyr-akamai <dmcintyr@akamai.com>
1 parent 9f8f7be commit 420685e

10 files changed

Lines changed: 810 additions & 58 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Changed
3+
---
4+
5+
Improvements for bucket selection in Akamai Object Storage Destination form ([#13444](https://github.com/linode/manager/pull/13444))

packages/manager/cypress/e2e/core/delivery/create-destination.spec.ts

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import {
88
mockTestConnection,
99
} from 'support/intercepts/delivery';
1010
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
11+
import { mockGetBuckets } from 'support/intercepts/object-storage';
1112
import { ui } from 'support/ui';
1213
import { logsDestinationForm } from 'support/ui/pages/logs-destination-form';
1314

15+
import { objectStorageBucketFactory } from 'src/factories';
16+
1417
import type { AkamaiObjectStorageDetailsExtended } from '@linode/api-v4';
1518

1619
describe('Create Destination', () => {
@@ -22,11 +25,10 @@ describe('Create Destination', () => {
2225
bypassAccountCapabilities: true,
2326
},
2427
});
28+
cy.visitWithLogin('/logs/delivery/destinations/create');
2529
});
2630

2731
it('create destination with form', () => {
28-
cy.visitWithLogin('/logs/delivery/destinations/create');
29-
3032
// Give Destination a label
3133
logsDestinationForm.setLabel(mockDestinationPayload.label);
3234

@@ -100,4 +102,64 @@ describe('Create Destination', () => {
100102
cy.findByText(mockDestination.label).should('be.visible');
101103
});
102104
});
105+
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'
125+
);
126+
127+
// Endpoint should be disabled in bucket_from_account mode
128+
cy.findByLabelText('Endpoint').should('be.disabled');
129+
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'
136+
);
137+
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'
143+
);
144+
cy.findByLabelText('Endpoint').should(
145+
'have.value',
146+
'eu-central-1.linodeobjects.com'
147+
);
148+
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');
153+
154+
cy.findByLabelText('Bucket').should('have.value', 'my-manual-bucket');
155+
cy.findByLabelText('Endpoint').should('have.value', 'my-endpoint.com');
156+
157+
// Switch back to bucket_from_account
158+
cy.findByLabelText('Select Bucket associated with the account').click();
159+
160+
// Both fields should be cleared
161+
cy.findByLabelText('Bucket').should('have.value', '');
162+
cy.findByLabelText('Endpoint').should('have.value', '');
163+
});
164+
});
103165
});

packages/manager/cypress/e2e/core/delivery/edit-destination.spec.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import {
1010
mockUpdateDestination,
1111
} from 'support/intercepts/delivery';
1212
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
13+
import { mockGetBuckets } from 'support/intercepts/object-storage';
1314
import { ui } from 'support/ui';
1415
import { logsDestinationForm } from 'support/ui/pages/logs-destination-form';
1516
import { randomLabel } from 'support/util/random';
1617

18+
import { objectStorageBucketFactory } from 'src/factories';
1719
import { getDestinationTypeOption } from 'src/features/Delivery/deliveryUtils';
1820

1921
import type { AkamaiObjectStorageDetailsExtended } from '@linode/api-v4';
@@ -120,4 +122,53 @@ describe('Edit Destination', () => {
120122
cy.findByText(newLabel).should('be.visible');
121123
});
122124
});
125+
126+
describe('Bucket end Endpoint fields', () => {
127+
it('populates Bucket and Endpoint when selecting an existing bucket and manually entering data', () => {
128+
mockGetBuckets([
129+
objectStorageBucketFactory.build({
130+
hostname: 'bucket-hostname.us-east-1.linodeobjects.com',
131+
label: 'bucket-with-hostname',
132+
region: 'us-east',
133+
}),
134+
objectStorageBucketFactory.build({
135+
hostname: 'bucket-s3.eu-central-1.linodeobjects.com',
136+
label: 'bucket-with-s3-endpoint',
137+
region: 'eu-central',
138+
s3_endpoint: 'eu-central-1.linodeobjects.com',
139+
}),
140+
]);
141+
142+
// Edit mode defaults to manual bucket entry
143+
cy.findByLabelText('Enter Bucket manually').should('be.checked');
144+
145+
// Endpoint should be enabled in manual mode
146+
cy.findByLabelText('Endpoint').should('be.enabled');
147+
148+
// Switch to bucket_from_account - Bucket and Endpoint should be cleared
149+
cy.findByLabelText('Select Bucket associated with the account').click();
150+
cy.findByLabelText('Bucket').should('have.value', '');
151+
cy.findByLabelText('Endpoint').should('have.value', '');
152+
cy.findByLabelText('Endpoint').should('be.disabled');
153+
154+
// Select a bucket without s3_endpoint - should use hostname as Endpoint
155+
logsDestinationForm.selectBucketFromDropdown('bucket-with-hostname');
156+
cy.findByLabelText('Bucket').should('have.value', 'bucket-with-hostname');
157+
cy.findByLabelText('Endpoint').should(
158+
'have.value',
159+
'bucket-hostname.us-east-1.linodeobjects.com'
160+
);
161+
162+
// Select a bucket with s3_endpoint - should use s3_endpoint
163+
logsDestinationForm.selectBucketFromDropdown('bucket-with-s3-endpoint');
164+
cy.findByLabelText('Bucket').should(
165+
'have.value',
166+
'bucket-with-s3-endpoint'
167+
);
168+
cy.findByLabelText('Endpoint').should(
169+
'have.value',
170+
'eu-central-1.linodeobjects.com'
171+
);
172+
});
173+
});
123174
});

packages/manager/cypress/support/ui/pages/logs-destination-form.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* Create/Edit Stream Page
55
*/
66

7+
import { ui } from 'support/ui';
8+
79
import type { AkamaiObjectStorageDetailsExtended } from '@linode/api-v4';
810

911
export const logsDestinationForm = {
@@ -21,17 +23,30 @@ export const logsDestinationForm = {
2123
},
2224

2325
/**
24-
* Sets destination's host
26+
* Selects a bucket from the "Select Bucket associated with the account" Autocomplete dropdown
27+
*
28+
* @param bucketLabel - bucket label to select from the dropdown
29+
*/
30+
selectBucketFromDropdown: (bucketLabel: string) => {
31+
cy.findByLabelText('Bucket')
32+
.should('be.visible')
33+
.should('be.enabled')
34+
.click();
35+
ui.autocompletePopper.findByTitle(bucketLabel).should('be.visible').click();
36+
},
37+
38+
/**
39+
* Sets destination's endpoint
2540
*
26-
* @param host - destination host to set
41+
* @param endpoint - destination endpoint to set
2742
*/
28-
setHost: (host: string) => {
29-
cy.findByLabelText('Host')
43+
setEndpoint: (endpoint: string) => {
44+
cy.findByLabelText('Endpoint')
3045
.should('be.visible')
3146
.should('be.enabled')
32-
.should('have.attr', 'placeholder', 'Host for the destination')
47+
.should('have.attr', 'placeholder', 'Endpoint for the destination')
3348
.clear();
34-
cy.focused().type(host);
49+
cy.focused().type(endpoint);
3550
},
3651

3752
/**
@@ -79,12 +94,15 @@ export const logsDestinationForm = {
7994
* @param data - object with destination details of AkamaiObjectStorageDetails type
8095
*/
8196
fillDestinationDetailsForm: (data: AkamaiObjectStorageDetailsExtended) => {
82-
// Give Destination a host
83-
logsDestinationForm.setHost(data.host);
97+
// Switch to manual bucket entry
98+
cy.findByLabelText('Enter Bucket manually').click();
8499

85100
// Give Destination a bucket
86101
logsDestinationForm.setBucket(data.bucket_name);
87102

103+
// Give Destination an endpoint
104+
logsDestinationForm.setEndpoint(data.host);
105+
88106
// Give the Destination Access Key ID
89107
logsDestinationForm.setAccessKeyId(data.access_key_id);
90108

0 commit comments

Comments
 (0)