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-8436] - Add cypress test for create validation & API errors for OBJ Gen 2 #11066

Merged
merged 6 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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-11066-tests-1728400382103.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Add cypress test for create validation & API errors for OBJ Gen 2 ([#11066](https://github.com/linode/manager/pull/11066))
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
mockGetBuckets,
mockDeleteBucket,
mockCreateBucket,
mockCreateBucketError,
} from 'support/intercepts/object-storage';
import { mockGetRegions } from 'support/intercepts/regions';
import { ui } from 'support/ui';
Expand Down Expand Up @@ -579,4 +580,79 @@ describe('Object Storage Gen2 create bucket tests', () => {
cy.wait(['@deleteBucket', '@getBuckets']);
cy.findByText(bucketLabel).should('not.exist');
});

/**
* Confirms UI flow for when creating a bucket results in validation and API errors
* - Confirms trying to create a bucket without an endpoint leads to a validation error that later disappears when an endpoint is specified
* - Confirms trying to create a bucket without a label leads to a validation error that later disappears when a label is specified
* - Confirms an error returned by the API is displayed and does not crash Cloud Manager
*/
it('handles errors and validation', () => {
const bucketLabel = randomLabel();
const mockErrorMessage = 'An unknown error has occurred.';
mockGetBuckets([]).as('getBuckets');
mockGetObjectStorageEndpoints(mockEndpoints).as(
'getObjectStorageEndpoints'
);
mockGetRegions(mockRegions);
mockCreateBucketError(mockErrorMessage).as('createBucket');

cy.visitWithLogin('/object-storage/buckets/create');
cy.wait([
'@getFeatureFlags',
'@getAccount',
'@getBuckets',
'@getObjectStorageEndpoints',
]);

ui.drawer
.findByTitle('Create Bucket')
.should('be.visible')
.within(() => {
ui.regionSelect.find().click().type(`${mockRegion.label}{enter}`);

// Confirms error appears when an endpoint isn't selected, and disappears after one is selected
ui.buttonGroup
.findButtonByTitle('Create Bucket')
.should('be.visible')
.should('be.enabled')
.click();

cy.contains('Endpoint Type is required.').should('be.visible');

cy.findByLabelText('Object Storage Endpoint Type')
.should('be.visible')
.click();

ui.autocompletePopper
.findByTitle('Standard (E3)')
.scrollIntoView()
.should('be.visible')
.should('be.enabled')
.click();

cy.contains('Endpoint Type is required.').should('not.exist');

// confirms error appears when label isn't filled in and disappears once a label is entered
ui.buttonGroup
.findButtonByTitle('Create Bucket')
.should('be.visible')
.should('be.enabled')
.click();

cy.contains('Label is required.').should('be.visible');
cy.findByText('Label').click().type(bucketLabel);
cy.contains('Label is required.').should('not.exist');

// confirms (mock) API error appears
ui.buttonGroup
.findButtonByTitle('Create Bucket')
.should('be.visible')
.should('be.enabled')
.click();

cy.wait('@createBucket');
cy.findByText(mockErrorMessage).should('be.visible');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export const OMC_CreateBucketDrawer = (props: Props) => {
// since this is optional in the schema.
if (Boolean(endpoints) && !formValues.endpoint_type) {
setError('endpoint_type', {
message: 'Endpoint Type is required',
message: 'Endpoint Type is required.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Great attention to detail by adding the period (.) here.

type: 'manual',
});
return;
Expand Down