Skip to content

Commit

Permalink
test: [M3-8444] - Add assertions for bucket details drawer tests (#10971
Browse files Browse the repository at this point in the history
)

* Add assertions for bucket details drawer tests

* Added changeset: Add assertions for bucket details drawer tests

* Add one more assertion to check toggle is not visible for E2,E3

* update comments
  • Loading branch information
AzureLatte authored Oct 11, 2024
1 parent 77174ca commit d0927f8
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 11 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10971-tests-1726764686101.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Add assertions for bucket details drawer tests ([#10971](https://github.com/linode/manager/pull/10971))
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
mockGetBuckets,
mockDeleteBucket,
mockCreateBucket,
mockGetBucketAccess,
mockCreateBucketError,
} from 'support/intercepts/object-storage';
import { mockGetRegions } from 'support/intercepts/regions';
Expand All @@ -18,7 +19,7 @@ import {
regionFactory,
} from 'src/factories';
import { chooseRegion } from 'support/util/regions';
import type { ObjectStorageEndpoint } from '@linode/api-v4';
import type { ACLType, ObjectStorageEndpoint } from '@linode/api-v4';

describe('Object Storage Gen2 create bucket tests', () => {
beforeEach(() => {
Expand Down Expand Up @@ -71,14 +72,80 @@ describe('Object Storage Gen2 create bucket tests', () => {
}),
];

const mockAccess = {
acl: 'private' as ACLType,
acl_xml: '',
cors_enabled: true,
cors_xml: '',
};

const bucketRateLimitsNotice =
'Specifies the maximum Requests Per Second (RPS) for a bucket. To increase it to High, open a support ticket. Understand bucket rate limits.';
const CORSNotice =
'CORS (Cross Origin Sharing) is not available for endpoint types E2 and E3';

// For E0/E1, confirm CORS toggle and ACL selection are both present
// For E2/E3, confirm rate limit notice and table are present, ACL selection is present, CORS toggle is absent
const checkBucketDetailsDrawer = (
bucketLabel: string,
endpointType: string
) => {
ui.drawer.findByTitle(bucketLabel).within(() => {
if (
endpointType === 'Standard (E3)' ||
endpointType === 'Standard (E2)'
) {
cy.contains(bucketRateLimitsNotice).should('be.visible');
cy.get('[data-testid="bucket-rate-limit-table"]').should('be.visible');
cy.contains(CORSNotice).should('be.visible');
ui.toggle.find().should('not.exist');
} else {
cy.get('[data-testid="bucket-rate-limit-table"]').should('not.exist');
ui.toggle
.find()
.should('have.attr', 'data-qa-toggle', 'true')
.should('be.visible');
cy.contains('CORS Enabled').should('be.visible');
}

// Verify that all ACL selection show up as options
cy.findByLabelText('Access Control List (ACL)')
.should('be.visible')
.should('have.value', 'Private')
.click();
ui.autocompletePopper
.findByTitle('Public Read')
.should('be.visible')
.should('be.enabled');
ui.autocompletePopper
.findByTitle('Authenticated Read')
.should('be.visible')
.should('be.enabled');
ui.autocompletePopper
.findByTitle('Public Read/Write')
.should('be.visible')
.should('be.enabled');
ui.autocompletePopper
.findByTitle('Private')
.should('be.visible')
.should('be.enabled')
.click();

// Close the Details drawer
cy.get('[data-qa-close-drawer="true"]').should('be.visible').click();
});
};

/**
* Confirms UI flow for creating a gen2 Object Storage bucket with endpoint E0
* Confirms all endpoints are displayed regardless if there's multiple of the same type
* Confirms S3 endpoint hostname displayed to differentiate between identical options in the dropdown
* Confirms correct information displays in the details drawer for a bucket with endpoint E0
*/
it('can create a bucket with E0 endpoint type', () => {
const endpointTypeE0 = 'Legacy (E0)';
const bucketLabel = randomLabel();
const bucketCluster = 'us-iad-12';

mockGetBuckets([]).as('getBuckets');
mockDeleteBucket(bucketLabel, mockRegion.id).as('deleteBucket');
Expand All @@ -94,6 +161,9 @@ describe('Object Storage Gen2 create bucket tests', () => {
);

mockGetRegions(mockRegions);
mockGetBucketAccess(bucketLabel, bucketCluster, mockAccess).as(
'getBucketAccess'
);

cy.visitWithLogin('/object-storage/buckets/create');
cy.wait([
Expand Down Expand Up @@ -182,9 +252,15 @@ describe('Object Storage Gen2 create bucket tests', () => {
.closest('tr')
.within(() => {
cy.findByText(mockRegion.label).should('be.visible');
ui.button.findByTitle('Delete').should('be.visible').click();
// Confirm that clicking "Details" button for the bucket opens details drawer
ui.button.findByTitle('Details').should('be.visible').click();
});

checkBucketDetailsDrawer(bucketLabel, endpointTypeE0);

// Delete the bucket to clean up
ui.button.findByTitle('Delete').should('be.visible').click();

ui.dialog
.findByTitle(`Delete Bucket ${bucketLabel}`)
.should('be.visible')
Expand All @@ -205,10 +281,12 @@ describe('Object Storage Gen2 create bucket tests', () => {

/**
* Confirms UI flow for creating a gen2 Object Storage bucket with endpoint E1
* Confirms correct information displays in the details drawer for a bucket with endpoint E1
*/
it('can create a bucket with E1 endpoint type', () => {
const endpointTypeE1 = 'Standard (E1)';
const bucketLabel = randomLabel();
const bucketCluster = 'us-iad-12';

mockGetBuckets([]).as('getBuckets');
mockDeleteBucket(bucketLabel, mockRegion.id).as('deleteBucket');
Expand All @@ -224,6 +302,9 @@ describe('Object Storage Gen2 create bucket tests', () => {
);

mockGetRegions(mockRegions);
mockGetBucketAccess(bucketLabel, bucketCluster, mockAccess).as(
'getBucketAccess'
);

cy.visitWithLogin('/object-storage/buckets/create');
cy.wait([
Expand Down Expand Up @@ -297,9 +378,15 @@ describe('Object Storage Gen2 create bucket tests', () => {
.closest('tr')
.within(() => {
cy.findByText(mockRegion.label).should('be.visible');
ui.button.findByTitle('Delete').should('be.visible').click();
// Confirm that clicking "Details" button for the bucket opens details drawer
ui.button.findByTitle('Details').should('be.visible').click();
});

checkBucketDetailsDrawer(bucketLabel, endpointTypeE1);

// Delete the bucket to clean up
ui.button.findByTitle('Delete').should('be.visible').click();

ui.dialog
.findByTitle(`Delete Bucket ${bucketLabel}`)
.should('be.visible')
Expand All @@ -320,10 +407,12 @@ describe('Object Storage Gen2 create bucket tests', () => {

/**
* Confirms UI flow for creating a gen2 Object Storage bucket with endpoint E2
* Confirms correct information displays in the details drawer for a bucket with endpoint E2
*/
it('can create a bucket with E2 endpoint type', () => {
const endpointTypeE2 = 'Standard (E2)';
const bucketLabel = randomLabel();
const bucketCluster = 'us-iad-12';

mockGetBuckets([]).as('getBuckets');
mockDeleteBucket(bucketLabel, mockRegion.id).as('deleteBucket');
Expand All @@ -339,6 +428,9 @@ describe('Object Storage Gen2 create bucket tests', () => {
);

mockGetRegions(mockRegions);
mockGetBucketAccess(bucketLabel, bucketCluster, mockAccess).as(
'getBucketAccess'
);

cy.visitWithLogin('/object-storage/buckets/create');
cy.wait([
Expand Down Expand Up @@ -374,9 +466,7 @@ describe('Object Storage Gen2 create bucket tests', () => {

// Confirm bucket rate limits text for E2 endpoint
cy.findByText('Bucket Rate Limits').should('be.visible');
cy.contains(
'Specifies the maximum Requests Per Second (RPS) for a bucket. To increase it to High, open a support ticket. Understand bucket rate limits.'
).should('be.visible');
cy.contains(bucketRateLimitsNotice).should('be.visible');

// Confirm bucket rate limit table should exist when E2 endpoint is selected
cy.get('[data-testid="bucket-rate-limit-table"]').should('exist');
Expand Down Expand Up @@ -412,9 +502,15 @@ describe('Object Storage Gen2 create bucket tests', () => {
.closest('tr')
.within(() => {
cy.findByText(mockRegion.label).should('be.visible');
ui.button.findByTitle('Delete').should('be.visible').click();
// Confirm that clicking "Details" button for the bucket opens details drawer
ui.button.findByTitle('Details').should('be.visible').click();
});

checkBucketDetailsDrawer(bucketLabel, endpointTypeE2);

// Delete the bucket to clean up
ui.button.findByTitle('Delete').should('be.visible').click();

ui.dialog
.findByTitle(`Delete Bucket ${bucketLabel}`)
.should('be.visible')
Expand All @@ -435,10 +531,12 @@ describe('Object Storage Gen2 create bucket tests', () => {

/**
* Confirms UI flow for creating a gen2 Object Storage bucket with endpoint E3
* Confirms correct information displays in the details drawer for a bucket with endpoint E3
*/
it('can create a bucket with E3 endpoint type', () => {
const endpointTypeE3 = 'Standard (E3)';
const bucketLabel = randomLabel();
const bucketCluster = 'us-iad-12';

mockGetBuckets([]).as('getBuckets');
mockDeleteBucket(bucketLabel, mockRegion.id).as('deleteBucket');
Expand All @@ -454,6 +552,9 @@ describe('Object Storage Gen2 create bucket tests', () => {
);

mockGetRegions(mockRegions);
mockGetBucketAccess(bucketLabel, bucketCluster, mockAccess).as(
'getBucketAccess'
);

cy.visitWithLogin('/object-storage/buckets/create');
cy.wait([
Expand Down Expand Up @@ -490,9 +591,7 @@ describe('Object Storage Gen2 create bucket tests', () => {

// Confirm bucket rate limits text for E3 endpoint
cy.findByText('Bucket Rate Limits').should('be.visible');
cy.contains(
'Specifies the maximum Requests Per Second (RPS) for a bucket. To increase it to High, open a support ticket. Understand bucket rate limits.'
).should('be.visible');
cy.contains(bucketRateLimitsNotice).should('be.visible');

// Confirm bucket rate limit table should exist when E3 endpoint is selected
cy.get('[data-testid="bucket-rate-limit-table"]').should('exist');
Expand Down Expand Up @@ -528,9 +627,14 @@ describe('Object Storage Gen2 create bucket tests', () => {
.closest('tr')
.within(() => {
cy.findByText(mockRegion.label).should('be.visible');
ui.button.findByTitle('Delete').should('be.visible').click();
// Confirm that clicking "Details" button for the bucket opens details drawer
ui.button.findByTitle('Details').should('be.visible').click();
});

checkBucketDetailsDrawer(bucketLabel, endpointTypeE3);

// Delete the bucket to clean up
ui.button.findByTitle('Delete').should('be.visible').click();
ui.dialog
.findByTitle(`Delete Bucket ${bucketLabel}`)
.should('be.visible')
Expand Down

0 comments on commit d0927f8

Please sign in to comment.