Skip to content

Commit

Permalink
ARTESCA-13460 - fix error when create ring location
Browse files Browse the repository at this point in the history
  • Loading branch information
MonPote committed Sep 19, 2024
1 parent a1342a1 commit 82bb19d
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/react/locations/LocationEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ function LocationEditor() {
content={
<Select
id="locationType"
placeholder="Select an option..."
placeholder="Select a location type..."
onChange={onTypeChange}
disabled={editingExisting}
//@ts-expect-error fix this when you are working on it
Expand Down
126 changes: 124 additions & 2 deletions src/react/locations/__tests__/LocationEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { INSTANCE_ID } from '../../actions/__tests__/utils/testUtil';
import userEvent from '@testing-library/user-event';
import { rest } from 'msw';

jest.setTimeout(60_000);
const server = setupServer(getConfigOverlay(TEST_API_BASE_URL, INSTANCE_ID));

beforeAll(() => {
Expand Down Expand Up @@ -73,7 +74,11 @@ describe('LocationEditor', () => {
});
const selectors = {
loadingLocation: () => screen.getByText('Loading location...'),
locationType: () => screen.getByLabelText(/location type \*/i),
selectLocationType: () => screen.getByLabelText(/location type \*/i),
inputLocationType: () =>
screen.getByRole('textbox', { name: /location type \*/i }),
optionLocationType: (locationName: string | RegExp) =>
screen.getByRole('option', { name: locationName }),
};

it('should hide the artesca storage service if it is already created', async () => {
Expand Down Expand Up @@ -104,10 +109,127 @@ describe('LocationEditor', () => {
render(<LocationEditor />, { wrapper: Wrapper });
await waitForElementToBeRemoved(() => selectors.loadingLocation());
//E
selectClick(selectors.locationType());
selectClick(selectors.selectLocationType());
//V
await waitFor(() => {
expect(screen.queryByText('Storage Service for ARTESCA')).toBeNull();
});
});

it(`test if each location display correctly`, async () => {
reduxRender(
<MemoryRouter>
<LocationEditor />
</MemoryRouter>,
);

await waitForElementToBeRemoved(() =>
screen.getByText('Loading location...'),
);

const locationsTests = [
{
name: 'Scality ARTESCA S3',
optionToQuery: () =>
selectors.optionLocationType(/Scality ARTESCA S3/i),
checkField: () => screen.getByText(/access key \*/i),
},
{
name: 'Scality RING with S3 Connector',
optionToQuery: () =>
selectors.optionLocationType(/Scality RING with S3 Connector/i),
checkField: () => screen.getByText(/access key \*/i),
},
{
name: 'Amazon S3',
optionToQuery: () => selectors.optionLocationType(/Amazon S3/i),
checkField: () => screen.getByText(/AWS Access Key \*/i),
},
{
name: 'Google Cloud Storage',
optionToQuery: () =>
selectors.optionLocationType(/Google Cloud Storage/i),
checkField: () => screen.getByText(/GCP Access Key \*/i),
},
{
name: 'Microsoft Azure Blob Storage',
optionToQuery: () =>
selectors.optionLocationType(/Microsoft Azure Blob Storage/i),
checkField: () => screen.getByText(/Blob endpoint \*/i),
},
{
name: 'Microsoft Azure Archive',
optionToQuery: () =>
selectors.optionLocationType(/Microsoft Azure Archive/i),
checkField: () => screen.getByText(/Blob endpoint \*/i),
},
{
name: 'Atlas Object Storage (Free Pro)',
optionToQuery: () =>
selectors.optionLocationType(/Atlas Object Storage \(Free Pro\)/i),
checkField: () => screen.getByText(/access key \*/i),
},
{
name: '3DS Outscale OOS Public',
optionToQuery: () =>
selectors.optionLocationType(/3DS Outscale OOS Public/i),
checkField: () => screen.getByText(/access key \*/i),
},
{
name: '3DS Outscale OOS SNC',
optionToQuery: () =>
selectors.optionLocationType(/3DS Outscale OOS SNC/i),
checkField: () => screen.getByText(/access key \*/i),
},
{
name: 'Flexible Datastore',
optionToQuery: () =>
selectors.optionLocationType(/Flexible Datastore/i),
checkField: () => screen.getByText(/access key \*/i),
},
{
name: 'Tape DMF',
optionToQuery: () => selectors.optionLocationType(/Tape DMF/i),
checkField: () => screen.getByText(/Temperature/i),
},
{
name: 'Ceph RADOS Gateway',
optionToQuery: () =>
selectors.optionLocationType(/Ceph RADOS Gateway/i),
checkField: () => screen.getByText(/access key \*/i),
},
{
name: 'Scality RING with Sproxyd Connector',
optionToQuery: () =>
selectors.optionLocationType(/Scality RING with Sproxyd Connector/i),
checkField: () => screen.getByText(/Bootstrap List \*/i),
},
{
name: 'Wasabi',
optionToQuery: () => selectors.optionLocationType(/Wasabi/i),
checkField: () => screen.getByText(/Wasabi Access Key \*/i),
},
{
name: 'Oracle Cloud Object Storage',
optionToQuery: () =>
selectors.optionLocationType(/Oracle Cloud Object Storage/i),
checkField: () => screen.getByText(/Namespace \*/i),
},
];

for await (const location of locationsTests) {
await userEvent.click(screen.getByLabelText(/select a location type/i));

await userEvent.clear(
screen.getByRole('textbox', { name: /location type \*/i }),
);
await userEvent.type(
screen.getByRole('textbox', { name: /location type \*/i }),
location.name,
);

await userEvent.click(location.optionToQuery());
expect(location.checkField()).toBeInTheDocument();
}
});
});
2 changes: 1 addition & 1 deletion src/react/utils/storageOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const getLocationTypeKey = (
return OUTSCALE_PUBLIC_S3_LOCATION_KEY;
} else if (location.details.endpoint === OUTSCALE_SNC_S3_ENDPOINT) {
return OUTSCALE_SNC_S3_LOCATION_KEY;
} else if (location.details.endpoint.endsWith('oraclecloud.com')) {
} else if (location.details.endpoint?.endsWith('oraclecloud.com')) {
return ORACLE_CLOUD_LOCATION_KEY;
} else {
return 'locationType' in location
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"target": "es2021" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"lib": [
"es2021",
Expand Down

0 comments on commit 82bb19d

Please sign in to comment.