From 0e0f1e2486663e2fdd2fbd50c01f47ca8b56bb9d Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Thu, 29 Aug 2024 10:31:58 +0545 Subject: [PATCH 1/3] fix: viewer stuck on loading if ocis images are not available --- src/App.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/App.vue b/src/App.vue index edf22e8..c51f583 100644 --- a/src/App.vue +++ b/src/App.vue @@ -155,6 +155,9 @@ async function parseImageUrl(name: string) { } else { file = getMediaFile(name) } + if (!file) { + return + } const url = await getUrlForResource(unref(currentFileContext).space, file) // reload the active files // TODO: implement caching From 50f5149cecbebda951c061940a6ceeaabb597670 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Thu, 29 Aug 2024 10:34:44 +0545 Subject: [PATCH 2/3] docs: add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9849069..6d07a4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- viewer stuck on loading if ocis images are not available (https://github.com/JankariTech/web-app-presentation-viewer/pull/75) + ### Changed - Parse and update local image urls directly in the markdown content (https://github.com/JankariTech/web-app-presentation-viewer/pull/61) From 800f5a84fc58744a16f9401062dc2ebad80afec5 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Thu, 29 Aug 2024 11:02:32 +0545 Subject: [PATCH 3/3] test(unit): add test for non-existing ocis image --- tests/unit/App.spec.ts | 18 ++- tests/unit/__snapshots__/App.spec.ts.snap | 186 +--------------------- 2 files changed, 17 insertions(+), 187 deletions(-) diff --git a/tests/unit/App.spec.ts b/tests/unit/App.spec.ts index 79ed139..147e43a 100644 --- a/tests/unit/App.spec.ts +++ b/tests/unit/App.spec.ts @@ -6,7 +6,10 @@ vi.mock('@ownclouders/web-pkg', () => ({ useAppDefaults: vi.fn().mockImplementation(() => ({ loadFolderForFileContext: vi.fn(), currentFileContext: {}, - activeFiles: [] + activeFiles: [ + { name: 'cool.png', path: '/cool.png', mimeType: 'image/png' }, + { name: 'sub', path: '/sub' } + ] })), useAppFileHandling: vi.fn().mockImplementation(() => ({ getUrlForResource: vi.fn(), @@ -16,9 +19,15 @@ vi.mock('@ownclouders/web-pkg', () => ({ currentTheme: { isDark: false } })), useClientService: vi.fn().mockImplementation(() => ({ - webdav: vi.fn() + webdav: { + listFiles: () => ({ + children: [{ name: 'another-cool.jpg', path: '/another-cool.jpg', mimeType: 'image/jpeg' }] + }) + } })), - useAppsStore: vi.fn(), + useAppsStore: () => ({ + externalAppConfig: () => [] + }), useConfigStore: vi.fn().mockImplementation(() => ({ serverUrl: 'https://localhost:9200' })), @@ -64,6 +73,9 @@ Ordered list: ### ocCIS Image ![cool](./cool.png) +![non-existing](./non-existing-image.png) + +![sub-folder-image](./sub/another-cool.jpg) --- ### Code block diff --git a/tests/unit/__snapshots__/App.spec.ts.snap b/tests/unit/__snapshots__/App.spec.ts.snap index 94e3893..cccdd97 100644 --- a/tests/unit/__snapshots__/App.spec.ts.snap +++ b/tests/unit/__snapshots__/App.spec.ts.snap @@ -1,97 +1,5 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`App component > mount component 1`] = ` -"
- -
-
-
-

Slide 1

-

Lorem Bold Italic strike through

-
-

Quote statement

-
-
    -
  • check box
  • -
-
    -
  • check box
  • -
-
- - - - - -
-
-
-
-
-
-
-
-
-
-
- - - -
- - -
-
-
-
-
-
" -`; - exports[`App component > render markdown slides 1`] = ` "
@@ -136,98 +44,8 @@ exports[`App component > render markdown slides 1`] = ` - -
-
-
-
-
-
-
-
-
-
-
- - - -
- - -
-
-
-
- -" -`; - -exports[`App component > render slides 1`] = ` -"
- -
-
-
-

Slide 1

-

Lorem Bold Italic strike through

-
-

Quote statement

-
-
    -
  • check box
  • -
-
    -
  • check box
  • -
-
- - - -