Skip to content

Commit 687c8d3

Browse files
new: STORIF-310 - Bucket tab filters created.
1 parent ea301d0 commit 687c8d3

File tree

11 files changed

+335
-26
lines changed

11 files changed

+335
-26
lines changed

packages/manager/cypress/e2e/core/objectStorage/object-storage.e2e.spec.ts

Lines changed: 170 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
import { createBucket } from '@linode/api-v4/lib/object-storage';
6+
import { getNewRegionLabel } from '@linode/utilities';
67
import { authenticate } from 'support/api/authentication';
78
import {
89
interceptGetNetworkUtilization,
@@ -16,6 +17,7 @@ import {
1617
interceptGetBuckets,
1718
interceptUpdateBucketAccess,
1819
} from 'support/intercepts/object-storage';
20+
import { interceptGetRegions } from 'support/intercepts/regions';
1921
import { ui } from 'support/ui';
2022
import { cleanUp } from 'support/util/cleanup';
2123
import { chooseCluster } from 'support/util/clusters';
@@ -27,6 +29,8 @@ import {
2729
createObjectStorageBucketFactoryLegacy,
2830
} from 'src/factories';
2931

32+
import type { Region } from '@linode/api-v4/lib/object-storage';
33+
3034
/**
3135
* Create a bucket with the given label and cluster.
3236
*
@@ -41,23 +45,29 @@ import {
4145
*/
4246
const setUpBucket = (
4347
label: string,
44-
cluster: string,
48+
region: string,
4549
cors_enabled: boolean = true
4650
) => {
4751
return createBucket(
4852
createObjectStorageBucketFactoryLegacy.build({
49-
cluster,
53+
region,
5054
cors_enabled,
5155
label,
5256

5357
// API accepts either `cluster` or `region`, but not both. Our factory
54-
// populates both fields, so we have to manually set `region` to `undefined`
58+
// populates both fields, so we have to manually set `cluster` to `undefined`
5559
// to avoid 400 responses from the API.
56-
region: undefined,
60+
cluster: undefined,
5761
})
5862
);
5963
};
6064

65+
const setupBuckets = (bucketsDetails: { label: string; region: string }[]) => {
66+
return Promise.all(
67+
bucketsDetails.map(({ label, region }) => setUpBucket(label, region))
68+
);
69+
};
70+
6171
authenticate();
6272
beforeEach(() => {
6373
cy.tag('method:e2e');
@@ -158,17 +168,15 @@ describe('object storage end-to-end tests', () => {
158168
it('can update bucket access', () => {
159169
const bucketLabel = randomLabel();
160170
const bucketClusterObj = chooseCluster();
161-
const bucketCluster = bucketClusterObj.id;
162-
const bucketAccessPage = `/object-storage/buckets/${bucketCluster}/${bucketLabel}/access`;
171+
const bucketRegion = bucketClusterObj.region;
172+
const bucketAccessPage = `/object-storage/buckets/${bucketRegion}/${bucketLabel}/access`;
163173

164174
cy.defer(
165-
() => setUpBucket(bucketLabel, bucketCluster),
175+
() => setUpBucket(bucketLabel, bucketRegion),
166176
'creating Object Storage bucket'
167177
).then(() => {
168-
interceptGetBucketAccess(bucketLabel, bucketCluster).as(
169-
'getBucketAccess'
170-
);
171-
interceptUpdateBucketAccess(bucketLabel, bucketCluster).as(
178+
interceptGetBucketAccess(bucketLabel, bucketRegion).as('getBucketAccess');
179+
interceptUpdateBucketAccess(bucketLabel, bucketRegion).as(
172180
'updateBucketAccess'
173181
);
174182

@@ -198,4 +206,155 @@ describe('object storage end-to-end tests', () => {
198206
cy.findByText('Bucket access updated successfully.');
199207
});
200208
});
209+
210+
/*
211+
* - Confirms that user can filter bucket list by region.
212+
*/
213+
it('can filter the list of buckets by region', () => {
214+
interceptGetBuckets().as('getBuckets');
215+
interceptGetRegions().as('getRegions');
216+
217+
const bucketsDetails = new Array(2).fill({}).map((_, index) => ({
218+
label: randomLabel(),
219+
region: index === 0 ? 'us-ord' : 'us-lax',
220+
}));
221+
222+
cy.defer(
223+
() => setupBuckets(bucketsDetails),
224+
'creating Object Storage bucket'
225+
).then(() => {
226+
cy.visitWithLogin('/object-storage/buckets');
227+
cy.wait(['@getBuckets', '@getRegions']).then(([_, { response }]) => {
228+
const regions: Region[] = response?.body.data;
229+
230+
const selectedBucket = bucketsDetails[0];
231+
const selectedRegion = regions.find(
232+
(region) => region.id === selectedBucket.region
233+
);
234+
235+
expect(
236+
selectedRegion,
237+
`expected region matching ${selectedBucket.region}`
238+
).to.exist;
239+
240+
const selectedRegionLabel = selectedRegion
241+
? getNewRegionLabel(selectedRegion)
242+
: '';
243+
244+
const regionSelect = ui.autocomplete
245+
.findByLabel('Region')
246+
.should('be.visible')
247+
.type(selectedRegionLabel);
248+
249+
ui.autocompletePopper
250+
.findByTitle(selectedRegionLabel, { exact: false })
251+
.should('be.visible')
252+
.click();
253+
254+
regionSelect.click();
255+
256+
cy.get('tbody').within(() => {
257+
cy.get('tr')
258+
.should('have.length', 1)
259+
.within(() => {
260+
cy.findByText(selectedBucket.label).should('be.visible');
261+
});
262+
});
263+
});
264+
});
265+
});
266+
267+
/*
268+
* - Confirms that user can filter bucket list by endpoint.
269+
*/
270+
it('can filter the list of buckets by endpoint', () => {
271+
interceptGetBuckets().as('getBuckets');
272+
interceptGetRegions().as('getRegions');
273+
274+
const bucketsDetails = new Array(2).fill({}).map((_, index) => ({
275+
label: randomLabel(),
276+
region: index === 0 ? 'us-ord' : 'us-lax',
277+
}));
278+
279+
cy.defer(
280+
() => setupBuckets(bucketsDetails),
281+
'creating Object Storage bucket'
282+
).then(() => {
283+
cy.visitWithLogin('/object-storage/buckets');
284+
cy.wait(['@getBuckets', '@getRegions']);
285+
286+
const selectedBucket = bucketsDetails[0];
287+
const selectedBucketRegion = selectedBucket.region;
288+
289+
const endpointSelect = ui.autocomplete.findByLabel('Endpoint');
290+
endpointSelect.should('be.visible').type(selectedBucketRegion);
291+
ui.autocompletePopper
292+
.findByTitle(selectedBucketRegion, { exact: false })
293+
.should('be.visible')
294+
.click();
295+
endpointSelect.click();
296+
297+
cy.get('tbody').within(() => {
298+
cy.get('tr')
299+
.should('have.length', 1)
300+
.within(() => {
301+
cy.findByText(selectedBucket.label).should('be.visible');
302+
});
303+
});
304+
});
305+
});
306+
307+
/*
308+
* - Confirms that when region is selected, endpoint multiselect.
309+
* shows only endpoints related to the selected region.
310+
*/
311+
it('should filter list of endpoints when region is selected', () => {
312+
interceptGetBuckets().as('getBuckets');
313+
interceptGetRegions().as('getRegions');
314+
315+
const bucketsDetails = new Array(2).fill({}).map((_, index) => ({
316+
label: randomLabel(),
317+
region: index === 0 ? 'us-ord' : 'us-lax',
318+
}));
319+
320+
cy.defer(
321+
() => setupBuckets(bucketsDetails),
322+
'creating Object Storage bucket'
323+
).then(() => {
324+
cy.visitWithLogin('/object-storage/buckets');
325+
cy.wait(['@getBuckets', '@getRegions']).then(([_, { response }]) => {
326+
const regions: Region[] = response?.body.data;
327+
328+
const selectedBucket = bucketsDetails[0];
329+
const selectedRegion = regions.find(
330+
(region) => region.id === selectedBucket.region
331+
);
332+
333+
expect(
334+
selectedRegion,
335+
`expected region matching ${selectedBucket.region}`
336+
).to.exist;
337+
338+
const selectedRegionLabel = selectedRegion
339+
? getNewRegionLabel(selectedRegion)
340+
: '';
341+
342+
const regionSelect = ui.autocomplete
343+
.findByLabel('Region')
344+
.should('be.visible')
345+
.type(selectedRegionLabel);
346+
ui.autocompletePopper
347+
.findByTitle(selectedRegionLabel, { exact: false })
348+
.should('be.visible')
349+
.click();
350+
regionSelect.click();
351+
352+
ui.autocomplete.findByLabel('Endpoint').should('be.visible').click();
353+
354+
ui.autocompletePopper
355+
.findByTitle(new RegExp('^.*-.*-.*\..*.'))
356+
.should('have.length', 1);
357+
});
358+
});
359+
});
201360
});

packages/manager/cypress/support/intercepts/object-storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export const interceptDeleteBucket = (
197197
apiMatcher(`object-storage/buckets/${cluster}/*`)
198198
);
199199
}
200-
return cy.intercept('DELETE', apiMatcher('object-storage/buckets/*'));
200+
return cy.intercept('DELETE', apiMatcher('object-storage/buckets/**/*'));
201201
};
202202

203203
/**

packages/manager/cypress/support/intercepts/regions.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ import { makeResponse } from 'support/util/response';
1414
import type { Region, RegionAvailability } from '@linode/api-v4';
1515
import type { ExtendedRegion } from 'support/util/regions';
1616

17+
/**
18+
* Intercepts GET regions request.
19+
*
20+
* @returns Cypress chainable.
21+
*/
22+
export const interceptGetRegions = (): Cypress.Chainable<null> => {
23+
return cy.intercept('GET', apiMatcher('regions*'));
24+
};
25+
1726
/**
1827
* Intercepts GET request to fetch Linode regions and mocks response.
1928
*

0 commit comments

Comments
 (0)