Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions __tests__/component/Viewer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ describe('Viewer.open()', () => {
})

it('shows an error when the explicit handlerId is not registered', async () => {
const { vm, wrapper, errorText, modalProps } = mountViewer([imageHandler()])
const { vm, wrapper, errorText, modalProps, renderedTags } = mountViewer([imageHandler()])
const f1 = makeFile({ mime: 'image/jpeg' })

await vm.open([f1], f1, undefined, 'does-not-exist')
await wrapper.vm.$nextTick()

expect(errorText()).toBe('There was no plugin available to open this file.')
// No file got opened.
expect(modalProps().show).toBe(false)
// No file got opened, but the modal is shown regardless: it is what
// carries the error, and it hides its content while `show` is false.
expect(renderedTags()).toEqual([])
expect(modalProps().show).toBe(true)
})

it.each([
Expand Down
6 changes: 5 additions & 1 deletion __tests__/component/mountViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const NcModalStub = defineComponent({
emits: ['next', 'previous', 'close'],
template: `
<div
v-show="show"
class="nc-modal-stub"
:style="$attrs.style"
:data-handler="$attrs['data-handler']"
Expand Down Expand Up @@ -203,8 +204,11 @@ export function mountViewer(handlers: IHandler[] = []): MountViewerResult {
modalExists: () => findModal().exists(),
renderedTags,
errorText: () => {
// The real modal hides its content with `v-show`, which the stub
// mirrors: an error inside a modal that is not shown is an error
// nobody can read, so it does not count as being reported.
const ec = wrapper.find('.nc-empty-content-stub')
return ec.exists() ? ec.attributes('data-name') : undefined
return ec.exists() && ec.isVisible() ? ec.attributes('data-name') : undefined
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
:inlineActions="canEdit ? 1 : 0"
:lightBackdrop="lightBackdrop"
:name="modalName"
:show="!!currentFile"
:show="!!currentFile || !!errorString"
:slideshowPaused="editing"
:spreadNavigation="true"
:style="{ width: isSidebarShown ? `${sidebarPosition}px` : null }"
Expand Down
Loading