From 23c2b507a5226fd289b93f85addb3d45799342a5 Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Thu, 4 Nov 2021 15:00:43 +0100 Subject: [PATCH] fix unit tests --- .../tests/unit/__snapshots__/app.spec.js.snap | 18 +++++++++++------- .../web-app-external/tests/unit/app.spec.js | 11 ++++++++--- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/packages/web-app-external/tests/unit/__snapshots__/app.spec.js.snap b/packages/web-app-external/tests/unit/__snapshots__/app.spec.js.snap index 73645f03774..6d642ecb8b0 100644 --- a/packages/web-app-external/tests/unit/__snapshots__/app.spec.js.snap +++ b/packages/web-app-external/tests/unit/__snapshots__/app.spec.js.snap @@ -1,27 +1,31 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`The app provider extension should be able to load an iFrame via get 1`] = ` -
+

"exampleApp" app page

- - +
`; exports[`The app provider extension should be able to load an iFrame via post 1`] = ` -
+

"exampleApp" app page

- +
+
+
+
+
+
`; exports[`The app provider extension should fail for unauthenticated users 1`] = `

"exampleApp" app page

- +
@@ -39,7 +43,7 @@ exports[`The app provider extension should show a loading spinner while loading exports[`The app provider extension should show a meaningful message if an error occurs during loading 1`] = `

"exampleApp" app page

- +
diff --git a/packages/web-app-external/tests/unit/app.spec.js b/packages/web-app-external/tests/unit/app.spec.js index c4b27b4f82a..3d5543638f4 100644 --- a/packages/web-app-external/tests/unit/app.spec.js +++ b/packages/web-app-external/tests/unit/app.spec.js @@ -18,6 +18,9 @@ const componentStubs = { } const $route = { + query: { + 'public-token': 'a-token' + }, params: { app: 'exampleApp', file_id: '2147491323' @@ -30,6 +33,7 @@ const storeOptions = { configuration: jest.fn(() => ({ server: 'http://example.com/' })), + userReady: () => true, capabilities: jest.fn(() => ({ files: { app_providers: [ @@ -84,7 +88,7 @@ describe('The app provider extension', () => { fetchMock.resetMocks() }) - it('should show a loading spinner while loading', () => { + it('should show a loading spinner while loading', async () => { global.fetch = jest.fn(() => setTimeout(() => { Promise.resolve({ @@ -94,19 +98,21 @@ describe('The app provider extension', () => { }, 500) ) const wrapper = createShallowMountWrapper() - + await wrapper.vm.$nextTick() expect(wrapper).toMatchSnapshot() }) it('should show a meaningful message if an error occurs during loading', async () => { fetchMock.mockReject(new Error('fake error message')) const wrapper = createShallowMountWrapper() await wrapper.vm.$nextTick() + await wrapper.vm.$nextTick() expect(wrapper).toMatchSnapshot() }) it('should fail for unauthenticated users', async () => { fetchMock.mockResponseOnce({ status: 401 }) const wrapper = createShallowMountWrapper() await wrapper.vm.$nextTick() + await wrapper.vm.$nextTick() expect(wrapper).toMatchSnapshot() }) it('should be able to load an iFrame via get', async () => { @@ -131,7 +137,6 @@ describe('The app provider extension', () => { json: () => providerSuccessResponsePost }) ) - const wrapper = createShallowMountWrapper() await wrapper.vm.$nextTick() await wrapper.vm.$nextTick()