From a210cfcb9b9ed2179f340226524c45527d2ed5c5 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Fri, 20 Apr 2018 18:41:17 +0200 Subject: [PATCH 1/4] Fix #169: Fixed template syntax error --- front/src/components/playlists/PlaylistModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/src/components/playlists/PlaylistModal.vue b/front/src/components/playlists/PlaylistModal.vue index 03e36ee88..404948dc0 100644 --- a/front/src/components/playlists/PlaylistModal.vue +++ b/front/src/components/playlists/PlaylistModal.vue @@ -48,7 +48,7 @@
{{ $t('Add track') }}
From a4ce093919f5456514877d89e57418ff1f292972 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Fri, 20 Apr 2018 18:41:29 +0200 Subject: [PATCH 2/4] Fix lint errors --- front/test/unit/specs/store/auth.spec.js | 4 ++-- front/test/unit/specs/store/player.spec.js | 4 ++-- front/test/unit/specs/store/queue.spec.js | 2 +- front/test/unit/specs/store/radios.spec.js | 1 - 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/front/test/unit/specs/store/auth.spec.js b/front/test/unit/specs/store/auth.spec.js index 6b187f5c6..3d175e9f9 100644 --- a/front/test/unit/specs/store/auth.spec.js +++ b/front/test/unit/specs/store/auth.spec.js @@ -134,7 +134,7 @@ describe('store/auth', () => { action: store.actions.login, payload: {credentials: credentials}, expectedMutations: [ - { type: 'token', payload: 'test' }, + { type: 'token', payload: 'test' } ], expectedActions: [ { type: 'fetchProfile' } @@ -183,7 +183,7 @@ describe('store/auth', () => { ], expectedActions: [ { type: 'favorites/fetch', payload: null, options: {root: true} }, - { type: 'playlists/fetchOwn', payload: null, options: {root: true} }, + { type: 'playlists/fetchOwn', payload: null, options: {root: true} } ] }, done) }) diff --git a/front/test/unit/specs/store/player.spec.js b/front/test/unit/specs/store/player.spec.js index b55fb010d..1e6c9b33a 100644 --- a/front/test/unit/specs/store/player.spec.js +++ b/front/test/unit/specs/store/player.spec.js @@ -132,7 +132,7 @@ describe('store/player', () => { testAction({ action: store.actions.trackEnded, payload: {test: 'track'}, - params: {rootState: {queue: {currentIndex:0, tracks: [1, 2]}}}, + params: {rootState: {queue: {currentIndex: 0, tracks: [1, 2]}}}, expectedActions: [ { type: 'trackListened', payload: {test: 'track'} }, { type: 'queue/next', payload: null, options: {root: true} } @@ -143,7 +143,7 @@ describe('store/player', () => { testAction({ action: store.actions.trackEnded, payload: {test: 'track'}, - params: {rootState: {queue: {currentIndex:1, tracks: [1, 2]}}}, + params: {rootState: {queue: {currentIndex: 1, tracks: [1, 2]}}}, expectedActions: [ { type: 'trackListened', payload: {test: 'track'} }, { type: 'radios/populateQueue', payload: null, options: {root: true} }, diff --git a/front/test/unit/specs/store/queue.spec.js b/front/test/unit/specs/store/queue.spec.js index 5304d1d75..0df7608e7 100644 --- a/front/test/unit/specs/store/queue.spec.js +++ b/front/test/unit/specs/store/queue.spec.js @@ -326,7 +326,7 @@ describe('store/queue', () => { action: store.actions.shuffle, params: {state: {currentIndex: 1, tracks: tracks}}, expectedMutations: [ - { type: 'player/currentTime', payload: 0, options: {root: true}}, + { type: 'player/currentTime', payload: 0, options: {root: true} }, { type: 'tracks', payload: [] } ], expectedActions: [ diff --git a/front/test/unit/specs/store/radios.spec.js b/front/test/unit/specs/store/radios.spec.js index 6de6b8dd9..3a8c48f04 100644 --- a/front/test/unit/specs/store/radios.spec.js +++ b/front/test/unit/specs/store/radios.spec.js @@ -97,6 +97,5 @@ describe('store/radios', () => { expectedActions: [] }, done) }) - }) }) From 083b7b8e2fb86ab4459bd1a9b603eddf31f6d49f Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Fri, 20 Apr 2018 18:46:18 +0200 Subject: [PATCH 3/4] Added one basic unittest for component --- front/test/unit/specs/components/common.spec.js | 10 ++++++++++ front/test/unit/utils.js | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 front/test/unit/specs/components/common.spec.js diff --git a/front/test/unit/specs/components/common.spec.js b/front/test/unit/specs/components/common.spec.js new file mode 100644 index 000000000..1af4144ca --- /dev/null +++ b/front/test/unit/specs/components/common.spec.js @@ -0,0 +1,10 @@ +import Username from '@/components/common/Username.vue' + +import { render } from '../../utils' + +describe('Username', () => { + it('displays username', () => { + const vm = render(Username, {username: 'Hello'}) + expect(vm.$el.textContent).to.equal('Hello') + }) +}) diff --git a/front/test/unit/utils.js b/front/test/unit/utils.js index 233ee982e..6471fc97f 100644 --- a/front/test/unit/utils.js +++ b/front/test/unit/utils.js @@ -1,4 +1,11 @@ // helper for testing action with expected mutations +import Vue from 'vue' + +export const render = (Component, propsData) => { + const Constructor = Vue.extend(Component) + return new Constructor({ propsData: propsData }).$mount() +} + export const testAction = ({action, payload, params, expectedMutations, expectedActions}, done) => { let mutationsCount = 0 let actionsCount = 0 From 84c4e5ebbbc7f9cf6b6bce6b0cfec114e88d1db7 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Fri, 20 Apr 2018 19:25:29 +0200 Subject: [PATCH 4/4] Added CI check to catch build errors --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 217047794..b2078f153 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,6 +46,7 @@ test_front: script: - yarn install + - yarn run build | tee /dev/stderr | (! grep -i 'ERROR in') - yarn run unit cache: key: "$CI_PROJECT_ID__front_dependencies" @@ -70,7 +71,9 @@ build_front: - yarn install - yarn run i18n-extract - yarn run i18n-compile - - yarn run build + # this is to ensure we don't have any errors in the output, + # cf https://code.eliotberriot.com/funkwhale/funkwhale/issues/169 + - yarn run build | tee /dev/stderr | (! grep -i 'ERROR in') cache: key: "$CI_PROJECT_ID__front_dependencies" paths: