-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: [M3-6540] - Surface general errors in the Object Storage Bucket …
…Create Drawer (#9067) Surfaces any general errors as a notice in the Object Storage Create Bucket drawer Previously, only errors specific to the label and region would show --------- Co-authored-by: Banks Nussman <banks@nussman.us>
- Loading branch information
1 parent
46e4754
commit 4a6b0b9
Showing
5 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
packages/manager/src/features/ObjectStorage/BucketLanding/CreateBucketDrawer.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import * as React from 'react'; | ||
import { CreateBucketDrawer } from './CreateBucketDrawer'; | ||
import { waitFor } from '@testing-library/react'; | ||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { rest, server } from 'src/mocks/testServer'; | ||
import { makeResourcePage } from 'src/mocks/serverHandlers'; | ||
import { | ||
accountSettingsFactory, | ||
objectStorageClusterFactory, | ||
regionFactory, | ||
} from 'src/factories'; | ||
|
||
const props = { | ||
isOpen: true, | ||
onClose: jest.fn(), | ||
}; | ||
|
||
jest.mock('src/components/EnhancedSelect/Select'); | ||
|
||
describe('CreateBucketDrawer', () => { | ||
it('Should show a general error notice if the API returns one', async () => { | ||
server.use( | ||
rest.post('*/object-storage/buckets', (req, res, ctx) => { | ||
return res( | ||
ctx.status(500), | ||
ctx.json({ errors: [{ reason: 'Object Storage is offline!' }] }) | ||
); | ||
}), | ||
rest.get('*/regions', async (req, res, ctx) => { | ||
return res( | ||
ctx.json( | ||
makeResourcePage( | ||
regionFactory.buildList(1, { id: 'us-east', label: 'Newark, NJ' }) | ||
) | ||
) | ||
); | ||
}), | ||
rest.get('*object-storage/clusters', (req, res, ctx) => { | ||
return res( | ||
ctx.json( | ||
makeResourcePage( | ||
objectStorageClusterFactory.buildList(1, { | ||
region: 'us-east', | ||
id: 'us-east-1', | ||
}) | ||
) | ||
) | ||
); | ||
}), | ||
rest.get('*/account/settings', (req, res, ctx) => { | ||
return res( | ||
ctx.json(accountSettingsFactory.build({ object_storage: 'active' })) | ||
); | ||
}) | ||
); | ||
|
||
const { | ||
getByTestId, | ||
getByLabelText, | ||
getByPlaceholderText, | ||
findByText, | ||
} = renderWithTheme(<CreateBucketDrawer {...props} />); | ||
|
||
userEvent.type(getByLabelText('Label'), 'my-test-bucket'); | ||
|
||
// We must waitFor because we need to load region and cluster data from the API | ||
await waitFor(() => | ||
userEvent.selectOptions( | ||
getByPlaceholderText('Select a Region'), | ||
'Newark, NJ (us-east-1)' | ||
) | ||
); | ||
|
||
const saveButton = getByTestId('create-bucket-button'); | ||
|
||
userEvent.click(saveButton); | ||
|
||
await findByText('Object Storage is offline!'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters