diff --git a/changes/changelog.d/1474.bugfix b/changes/changelog.d/1474.bugfix new file mode 100644 index 000000000..53d8283e0 --- /dev/null +++ b/changes/changelog.d/1474.bugfix @@ -0,0 +1 @@ +Fixes crash in album moderation interface when missing cover (#1474) diff --git a/front/src/views/admin/library/AlbumDetail.vue b/front/src/views/admin/library/AlbumDetail.vue index 9a076221c..33f8808a4 100644 --- a/front/src/views/admin/library/AlbumDetail.vue +++ b/front/src/views/admin/library/AlbumDetail.vue @@ -9,7 +9,7 @@

- +
{{ object.title | truncate(100) }} diff --git a/front/tests/unit/specs/views/admin/library.spec.js b/front/tests/unit/specs/views/admin/library.spec.js new file mode 100644 index 000000000..7b6e033c9 --- /dev/null +++ b/front/tests/unit/specs/views/admin/library.spec.js @@ -0,0 +1,55 @@ +const sinon = require('sinon') +import { expect } from 'chai' +import { shallowMount, createLocalVue } from '@vue/test-utils' +import AlbumDetail from '@/views/admin/library/AlbumDetail.vue' +import GetTextPlugin from 'vue-gettext' + +import HumanDate from '@/components/common/HumanDate.vue' +import DangerousButton from '@/components/common/DangerousButton.vue' + +describe('views/admin/library', () => { + + let wrapper + let sandbox + beforeEach(() => { + sandbox = sinon.createSandbox() + }) + afterEach(() => { + sandbox.restore() + }) + describe('Album details', () => { + + it('displays default cover', async () => { + const album = { cover: null, artist: { id: null }, title: "dummy" } + const localVue = createLocalVue() + localVue.directive('title', (() => null)) + localVue.directive('dropdown', (() => null)) + localVue.use(GetTextPlugin, { translations: {} }) + // overrides axios calls + sandbox.stub(AlbumDetail.methods, "fetchData").callsFake(() => null) + sandbox.stub(AlbumDetail.methods, "fetchStats").callsFake(() => null) + wrapper = shallowMount(AlbumDetail, { + localVue, + data() { + return { + isLoading: false, + isLoadingStats: false, + object: album, + stats: [], + } + }, + mocks: { + $store: { + state: { auth: { profile: null }, ui: { lastDate: null } } + } + }, + stubs: { + 'human-date': HumanDate, + 'dangerous-button': DangerousButton + }, + computed: { labels: () => { return { statsWarning: null } } } + }) + expect(wrapper.find('img').attributes('src')).to.include("default-cover") + }) + }) +}) \ No newline at end of file