Skip to content

Commit 3719ebc

Browse files
committed
use 204 no content for when the spares is not defined #1591
1 parent e17de50 commit 3719ebc

6 files changed

+11
-38
lines changed

src/apiConfigProvider.component.test.tsx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,6 @@ describe('APIConfigProvider', () => {
6464
);
6565
});
6666

67-
it('settings are loaded (without spares)', async () => {
68-
server.use(
69-
http.get('/v1/settings/spares-definition', () => {
70-
return HttpResponse.json({ system_types: [] }, { status: 200 });
71-
})
72-
);
73-
renderComponent();
74-
75-
// Preloader is in a loading state when ConfigProvider is
76-
// loading the configuration.
77-
expect(screen.getByText('Loading...')).toBeInTheDocument();
78-
79-
await waitFor(() => {
80-
expect(screen.queryByText('Loading...')).not.toBeInTheDocument();
81-
});
82-
expect(screen.getByTestId('settings')).toBeInTheDocument();
83-
expect(screen.getByTestId('settings')).toHaveTextContent(
84-
JSON.stringify({})
85-
);
86-
});
87-
8867
it('settings are loaded (without spares 204 no content)', async () => {
8968
server.use(
9069
http.get('/v1/settings/spares-definition', () => {

src/catalogue/items/catalogueItemsDetailsPanel.component.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ describe('Catalogue Items details panel', () => {
156156
it('renders details panel correctly (without spares)', async () => {
157157
server.use(
158158
http.get('/v1/settings/spares-definition', () => {
159-
return HttpResponse.json({ system_types: [] }, { status: 200 });
159+
return HttpResponse.json(undefined, { status: 204 });
160160
})
161161
);
162162

src/catalogue/items/catalogueItemsLandingPage.component.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe('Catalogue Items Landing Page', () => {
248248
it('should not display spares number if spares definition is not defined', async () => {
249249
server.use(
250250
http.get('/v1/settings/spares-definition', () => {
251-
return HttpResponse.json({ system_types: [] }, { status: 200 });
251+
return HttpResponse.json(undefined, { status: 204 });
252252
})
253253
);
254254

src/catalogue/items/catalogueItemsTable.component.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ describe('Catalogue Items Table', () => {
916916
it('renders table correctly (section 1 due to column virtualisation without spares)', async () => {
917917
server.use(
918918
http.get('/v1/settings/spares-definition', () => {
919-
return HttpResponse.json({ system_types: [] }, { status: 200 });
919+
return HttpResponse.json(undefined, { status: 204 });
920920
})
921921
);
922922

src/items/itemsTable.component.test.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,9 @@ describe('Items Table', () => {
321321

322322
it('does not display spares definition button when spares is not defined', async () => {
323323
server.use(
324-
http.get<PathParams, DefaultBodyType, SparesDefinition>(
325-
'/v1/settings/spares-definition',
326-
() => {
327-
return HttpResponse.json({ system_types: [] }, { status: 200 });
328-
}
329-
)
324+
http.get('/v1/settings/spares-definition', () => {
325+
return HttpResponse.json(undefined, { status: 204 });
326+
})
330327
);
331328
props.catalogueCategory = getCatalogueCategoryById(
332329
'9'

src/systems/systemItemsTable.component.test.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { screen, waitFor } from '@testing-library/react';
22
import userEvent, { UserEvent } from '@testing-library/user-event';
3-
import { DefaultBodyType, http, HttpResponse, PathParams } from 'msw';
4-
import { SparesDefinition, System } from '../api/api.types';
3+
import { http, HttpResponse } from 'msw';
4+
import { System } from '../api/api.types';
55
import APIConfigProvider from '../apiConfigProvider.component';
66
import { server } from '../mocks/server';
77
import SystemsJSON from '../mocks/Systems.json';
@@ -78,12 +78,9 @@ describe('SystemItemsTable', () => {
7878

7979
it('renders correctly (without spares)', async () => {
8080
server.use(
81-
http.get<PathParams, DefaultBodyType, SparesDefinition>(
82-
'/v1/settings/spares-definition',
83-
() => {
84-
return HttpResponse.json({ system_types: [] }, { status: 200 });
85-
}
86-
)
81+
http.get('/v1/settings/spares-definition', () => {
82+
return HttpResponse.json(undefined, { status: 204 });
83+
})
8784
);
8885
const view = createView();
8986

0 commit comments

Comments
 (0)