Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: [M3-8444] - Add assertions for bucket details drawer tests #10971

Merged
merged 6 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
} from 'support/intercepts/object-storage';
import { mockGetRegions } from 'support/intercepts/regions';
import { ui } from 'support/ui';
Expand Down Expand Up @@ -102,14 +103,72 @@ describe('Object Storage Gen2 create bucket tests', () => {
});
};

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');
} 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');
mjac0bs marked this conversation as resolved.
Show resolved Hide resolved
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 all endpoint types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this test is only for E0, should we specify that? + Same for the below tests

Suggested change
* Confirms correct information displays in the details drawer for all endpoint types
* Confirms correct information displays in the details drawer for a bucket with endpoint E0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice suggestion, I'll update it, thank you!

*/
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 @@ -125,6 +184,7 @@ describe('Object Storage Gen2 create bucket tests', () => {
);

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

cy.visitWithLogin('/object-storage/buckets/create');
cy.wait([
Expand Down Expand Up @@ -213,9 +273,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 @@ -236,10 +302,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 all endpoint types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Confirms correct information displays in the details drawer for all endpoint types
* 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 @@ -255,6 +323,7 @@ describe('Object Storage Gen2 create bucket tests', () => {
);

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

cy.visitWithLogin('/object-storage/buckets/create');
cy.wait([
Expand Down Expand Up @@ -328,9 +397,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 @@ -351,10 +426,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 all endpoint types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Confirms correct information displays in the details drawer for all endpoint types
* 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 @@ -370,6 +447,7 @@ describe('Object Storage Gen2 create bucket tests', () => {
);

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

cy.visitWithLogin('/object-storage/buckets/create');
cy.wait([
Expand Down Expand Up @@ -405,9 +483,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 @@ -443,9 +519,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 @@ -466,10 +548,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 all endpoint types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Confirms correct information displays in the details drawer for all endpoint types
* 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 @@ -485,6 +569,7 @@ describe('Object Storage Gen2 create bucket tests', () => {
);

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

cy.visitWithLogin('/object-storage/buckets/create');
cy.wait([
Expand Down Expand Up @@ -521,9 +606,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 @@ -559,9 +642,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
23 changes: 23 additions & 0 deletions packages/manager/cypress/support/intercepts/object-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,26 @@ export const mockGetObjectStorageEndpoints = (
paginateResponse(endpoints)
);
};

/**
* Intercepts GET request to fetch access information (ACL, CORS) for a given Bucket and mock the response.
*
*
* @param label - Object storage bucket label.
* @param cluster - Object storage bucket cluster.
*
* @returns Cypress chainable.
*/
export const mockGetBucketAccess = (
label: string,
cluster: string
): Cypress.Chainable<null> => {
return cy.intercept(
'GET',
apiMatcher(`object-storage/buckets/${cluster}/${label}/access`),
{
body: {},
statusCode: 200,
}
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @AzureLatte just a heads up that I'd also created a mock intercept for bucket access here. Will keep an eye on this PR, and if this gets merged in first will update my PR accordingly!

};
Loading