diff --git a/src/API/index.js b/src/API/index.js index b706fd9a..f8f018d8 100644 --- a/src/API/index.js +++ b/src/API/index.js @@ -12,7 +12,9 @@ const typesUrlForProvider = (provider, region) => { }; export const fetchSourcesList = async (provider) => { - const { data } = await axios.get(provisioningUrl(`sources?provider=${provider}`)); + const { + data: { data }, + } = await axios.get(provisioningUrl(`sources?provider=${provider}`)); return data; }; @@ -22,13 +24,17 @@ export const fetchSourceUploadInfo = async (sourceID) => { }; export const fetchPubkeysList = async () => { - const { data } = await axios.get(provisioningUrl('pubkeys')); + const { + data: { data }, + } = await axios.get(provisioningUrl('pubkeys')); return data; }; export const fetchInstanceTypesList = async (region, provider) => { const url = typesUrlForProvider(provider, region); - const { data } = await axios.get(url); + const { + data: { data }, + } = await axios.get(url); return data; }; @@ -61,6 +67,8 @@ export const fetchReservationByProvider = async (reservationID, provider) => { }; export const fetchLaunchTemplates = async (sourceID, region) => { - const { data } = await axios.get(provisioningUrl(`sources/${sourceID}/launch_templates?region=${region}`)); + const { + data: { data }, + } = await axios.get(provisioningUrl(`sources/${sourceID}/launch_templates?region=${region}`)); return data; }; diff --git a/src/Components/InstanceTypesSelect/InstanceTypesSelect.test.js b/src/Components/InstanceTypesSelect/InstanceTypesSelect.test.js index 7be86064..27e1ae01 100644 --- a/src/Components/InstanceTypesSelect/InstanceTypesSelect.test.js +++ b/src/Components/InstanceTypesSelect/InstanceTypesSelect.test.js @@ -8,13 +8,13 @@ describe('InstanceTypesSelect', () => { test('populate AWS instance types select', async () => { await mountSelectAndClick(); const items = await screen.findAllByLabelText(/^Instance Type/); - expect(items).toHaveLength(awsInstanceTypeList.filter((type) => type.architecture === 'x86_64').length); // arm64 is filtered + expect(items).toHaveLength(awsInstanceTypeList.data.filter((type) => type.architecture === 'x86_64').length); // arm64 is filtered }); test('populate Azure instance types select', async () => { await mountSelectAndClick('azure'); const items = await screen.findAllByLabelText(/^Instance Type/); - expect(items).toHaveLength(azureInstanceTypeList.filter((type) => type.architecture === 'x86_64').length); // arm64 is filtered + expect(items).toHaveLength(azureInstanceTypeList.data.filter((type) => type.architecture === 'x86_64').length); // arm64 is filtered }); describe('search', () => { diff --git a/src/Components/ProvisioningWizard/steps/Pubkeys/Pubkeys.test.js b/src/Components/ProvisioningWizard/steps/Pubkeys/Pubkeys.test.js index 5f72ff3a..5d31e003 100644 --- a/src/Components/ProvisioningWizard/steps/Pubkeys/Pubkeys.test.js +++ b/src/Components/ProvisioningWizard/steps/Pubkeys/Pubkeys.test.js @@ -23,7 +23,7 @@ describe('Pubkeys', () => { const { server, rest } = window.msw; server.use( rest.get(provisioningUrl('pubkeys'), (req, res, ctx) => { - return res(ctx.status(200), ctx.json([])); + return res(ctx.status(200), ctx.json({ data: [] })); }) ); render(); @@ -35,7 +35,7 @@ describe('Pubkeys', () => { render(, { contextValues: { provider: 'azure' } }); const select = await screen.findByText('Select public key...'); await userEvent.click(select); - await userEvent.click(screen.getByText(pubkeysList[0].name)); + await userEvent.click(screen.getByText(pubkeysList.data[0].name)); expect(screen.getByText('Key format is not support', { exact: false })).toBeInTheDocument(); }); diff --git a/src/Components/SourcesSelect/SourcesSelect.test.js b/src/Components/SourcesSelect/SourcesSelect.test.js index a593e780..87dc617b 100644 --- a/src/Components/SourcesSelect/SourcesSelect.test.js +++ b/src/Components/SourcesSelect/SourcesSelect.test.js @@ -12,7 +12,7 @@ describe('SourcesSelect', () => { await userEvent.click(selectDropdown); const items = await screen.findAllByLabelText('Source account'); - expect(items).toHaveLength(sourcesList.length); + expect(items).toHaveLength(sourcesList.data.length); }); test('filters and preselect single available source', async () => { @@ -30,7 +30,7 @@ describe('SourcesSelect', () => { await userEvent.click(selectDropdown); const items = await screen.findAllByLabelText('Source account'); - expect(items).toHaveLength(sourcesList.length); + expect(items).toHaveLength(sourcesList.data.length); }); test('gcp source verifying email', async () => { diff --git a/src/Components/TemplateSelect/TemplateSelect.test.js b/src/Components/TemplateSelect/TemplateSelect.test.js index 3a13d8b4..57d0df4f 100644 --- a/src/Components/TemplateSelect/TemplateSelect.test.js +++ b/src/Components/TemplateSelect/TemplateSelect.test.js @@ -12,14 +12,14 @@ describe('TemplateSelect', () => { await userEvent.click(selectDropdown); const items = await screen.findAllByLabelText('template option'); - expect(items).toHaveLength(templates.length); + expect(items).toHaveLength(templates.data.length); }); test('clear chosen template', async () => { render(, { provider: 'aws', contextValues: { chosenSource: '1' } }); const selectDropdown = await screen.findByText('Select templates'); await userEvent.click(selectDropdown); - await userEvent.click(await screen.findByText(templates[0].name)); + await userEvent.click(await screen.findByText(templates.data[0].name)); await userEvent.click(await screen.findByLabelText('clear template selection')); const placeholder = await screen.findByText('Select templates'); expect(placeholder).toBeInTheDocument(); @@ -30,7 +30,7 @@ describe('TemplateSelect', () => { const chosenSource = '1'; server.use( rest.get(provisioningUrl(`sources/${chosenSource}/launch_templates`), (req, res, ctx) => { - return res(ctx.status(200), ctx.json([])); + return res(ctx.status(200), ctx.json({ data: [] })); }) ); render(, { provider: 'aws', contextValues: { chosenSource: chosenSource } }); diff --git a/src/mocks/fixtures/instanceTypes.fixtures.js b/src/mocks/fixtures/instanceTypes.fixtures.js index 88954d80..d1a869d1 100644 --- a/src/mocks/fixtures/instanceTypes.fixtures.js +++ b/src/mocks/fixtures/instanceTypes.fixtures.js @@ -1,92 +1,96 @@ -export const awsInstanceTypeList = [ - { - id: 1, - name: 'm5dn.12xlarge', - vcpus: 48, - cores: 24, - memory: 196608, - supported: true, - architecture: 'x86_64', - }, - { - id: 2, - name: 't4g.nano', - vcpus: 2, - cores: 2, - memory: 512, - architecture: 'arm64', - }, - { - id: 3, - name: 't1.micro', - vcpus: 1, - cores: 2, - memory: 128, - supported: true, - architecture: 'x86_64', - }, - { - id: 4, - name: 't1.nano', - vcpus: 1, - cores: 1, - memory: 512, - architecture: 'x86_64', - supported: false, - }, -]; +export const awsInstanceTypeList = { + data: [ + { + id: 1, + name: 'm5dn.12xlarge', + vcpus: 48, + cores: 24, + memory: 196608, + supported: true, + architecture: 'x86_64', + }, + { + id: 2, + name: 't4g.nano', + vcpus: 2, + cores: 2, + memory: 512, + architecture: 'arm64', + }, + { + id: 3, + name: 't1.micro', + vcpus: 1, + cores: 2, + memory: 128, + supported: true, + architecture: 'x86_64', + }, + { + id: 4, + name: 't1.nano', + vcpus: 1, + cores: 1, + memory: 512, + architecture: 'x86_64', + supported: false, + }, + ], +}; -export const azureInstanceTypeList = [ - { - name: 'Standard_A1_v2', - vcpus: 1, - cores: 1, - memory_mib: 2000, - storage_gb: 10, - supported: true, - architecture: 'x86_64', - azure: { - gen_v1: true, - gen_v2: false, +export const azureInstanceTypeList = { + data: [ + { + name: 'Standard_A1_v2', + vcpus: 1, + cores: 1, + memory_mib: 2000, + storage_gb: 10, + supported: true, + architecture: 'x86_64', + azure: { + gen_v1: true, + gen_v2: false, + }, }, - }, - { - name: 'Standard_A2_v2', - vcpus: 2, - cores: 2, - memory_mib: 4000, - storage_gb: 20, - supported: true, - architecture: 'x86_64', - azure: { - gen_v1: true, - gen_v2: false, + { + name: 'Standard_A2_v2', + vcpus: 2, + cores: 2, + memory_mib: 4000, + storage_gb: 20, + supported: true, + architecture: 'x86_64', + azure: { + gen_v1: true, + gen_v2: false, + }, }, - }, - { - name: 'Standard_A2m_v2', - vcpus: 2, - cores: 2, - memory_mib: 16000, - storage_gb: 20, - supported: true, - architecture: 'x86_64', - azure: { - gen_v1: true, - gen_v2: false, + { + name: 'Standard_A2m_v2', + vcpus: 2, + cores: 2, + memory_mib: 16000, + storage_gb: 20, + supported: true, + architecture: 'x86_64', + azure: { + gen_v1: true, + gen_v2: false, + }, }, - }, - { - name: 'Standard_D16ps_v5', - vcpus: 16, - cores: 16, - memory_mib: 64000, - storage_gb: 0, - supported: true, - architecture: 'arm64', - azure: { - gen_v1: false, - gen_v2: true, + { + name: 'Standard_D16ps_v5', + vcpus: 16, + cores: 16, + memory_mib: 64000, + storage_gb: 0, + supported: true, + architecture: 'arm64', + azure: { + gen_v1: false, + gen_v2: true, + }, }, - }, -]; + ], +}; diff --git a/src/mocks/fixtures/pubkeys.fixtures.js b/src/mocks/fixtures/pubkeys.fixtures.js index 6981b01a..db24213a 100644 --- a/src/mocks/fixtures/pubkeys.fixtures.js +++ b/src/mocks/fixtures/pubkeys.fixtures.js @@ -1,10 +1,12 @@ -export const pubkeysList = [ - { - id: 1, - name: 'lzap-ed25519-2021', - body: 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEhnn80ZywmjeBFFOGm+cm+5HUwm62qTVnjKlOdYFLHN lzap', - fingerprint: 'SHA256:gL/y6MvNmJ8jDXtsL/oMmK8jUuIefN39BBuvYw/Rndk', - type: 'ssh-ed25519', - }, - { id: 2, name: 'pk2' }, -]; +export const pubkeysList = { + data: [ + { + id: 1, + name: 'lzap-ed25519-2021', + body: 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEhnn80ZywmjeBFFOGm+cm+5HUwm62qTVnjKlOdYFLHN lzap', + fingerprint: 'SHA256:gL/y6MvNmJ8jDXtsL/oMmK8jUuIefN39BBuvYw/Rndk', + type: 'ssh-ed25519', + }, + { id: 2, name: 'pk2' }, + ], +}; diff --git a/src/mocks/fixtures/sources.fixtures.js b/src/mocks/fixtures/sources.fixtures.js index acfe221a..dc47a05a 100644 --- a/src/mocks/fixtures/sources.fixtures.js +++ b/src/mocks/fixtures/sources.fixtures.js @@ -1,17 +1,21 @@ -export const sourcesList = [ - { - name: 'Source 1', - id: '1', - }, - { name: 'Source 2', id: '2' }, -]; +export const sourcesList = { + data: [ + { + name: 'Source 1', + id: '1', + }, + { name: 'Source 2', id: '2' }, + ], +}; -export const gcpSourcesList = [ - { - name: 'GCP Source 1', - id: '10', - }, -]; +export const gcpSourcesList = { + data: [ + { + name: 'GCP Source 1', + id: '10', + }, + ], +}; export const gcpSourceUploadInfo = () => ({ gcp: {} }); diff --git a/src/mocks/fixtures/templates.fixtures.js b/src/mocks/fixtures/templates.fixtures.js index 484cd3ef..7130e673 100644 --- a/src/mocks/fixtures/templates.fixtures.js +++ b/src/mocks/fixtures/templates.fixtures.js @@ -1,4 +1,6 @@ -export const templates = [ - { id: '1', name: 'template-1' }, - { id: '2', name: 'template-2' }, -]; +export const templates = { + data: [ + { id: '1', name: 'template-1' }, + { id: '2', name: 'template-2' }, + ], +};