Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Stop saving Single image fetch error to the Store (#305)
Olga Bulat9dbfdd25ecb7
diff --git a/src/store-modules/search-store.js b/src/store-modules/search-store.jsindex a086f6f78..5e9bd04e8 100644--- a/src/store-modules/search-store.js+++ b/src/store-modules/search-store.js@@ -212,18 +212,16 @@ const actions = (AudioService, ImageService) => ({sessionId: rootState.user.usageSessionId,})- commit(FETCH_START_MEDIA, { mediaType: IMAGE })commit(SET_IMAGE, { image: {} })return ImageService.getMediaDetail(params).then(({ data }) => {- commit(FETCH_END_MEDIA, { mediaType: IMAGE })commit(SET_IMAGE, { image: data })}).catch((error) => {if (error.response && error.response.status === 404) {commit(MEDIA_NOT_FOUND, { mediaType: IMAGE })} else {- dispatch(HANDLE_MEDIA_ERROR, { mediaType: IMAGE, error })+ throw new Error(`Error fetching the image: ${error}`)}})},diff --git a/test/unit/specs/store/search-store.spec.js b/test/unit/specs/store/search-store.spec.jsindex bd6e38142..2adda542b 100644--- a/test/unit/specs/store/search-store.spec.js+++ b/test/unit/specs/store/search-store.spec.js@@ -455,12 +455,8 @@ describe('Search Store', () => {FETCH_IMAGE]action({ commit, dispatch, state, rootState }, params).then(() => {- expect(commit).toBeCalledWith(FETCH_START_MEDIA, { mediaType: IMAGE })expect(commit).toBeCalledWith(SET_IMAGE, { image: {} })- expect(commit).toBeCalledWith(FETCH_END_MEDIA, { mediaType: IMAGE })-expect(commit).toBeCalledWith(SET_IMAGE, { image: imageDetailData })-expect(imageServiceMock.getMediaDetail).toBeCalledWith(params)done()@@ -507,7 +503,6 @@ describe('Search Store', () => {const params = { id: 'foo' }const action = store.actions(failedMock, failedMock)[FETCH_IMAGE]action({ commit, dispatch, state, rootState }, params).then(() => {- expect(commit).toBeCalledWith(FETCH_START_MEDIA, { mediaType: IMAGE })expect(commit).toBeCalledWith(MEDIA_NOT_FOUND, { mediaType: IMAGE })done()