From 78f03daf42c5f1e18438f79400bc7b0c26ffc9f0 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 19 Oct 2022 09:14:17 +0200 Subject: [PATCH 1/5] add groupId to variables in spec --- webapp/components/ContributionForm/ContributionForm.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/webapp/components/ContributionForm/ContributionForm.spec.js b/webapp/components/ContributionForm/ContributionForm.spec.js index 0e14841d1..1ef1777fe 100644 --- a/webapp/components/ContributionForm/ContributionForm.spec.js +++ b/webapp/components/ContributionForm/ContributionForm.spec.js @@ -138,6 +138,7 @@ describe('ContributionForm.vue', () => { categoryIds: [], id: null, image: null, + groupId: null, }, } postTitleInput = wrapper.find('.ds-input') @@ -260,6 +261,7 @@ describe('ContributionForm.vue', () => { content: propsData.contribution.content, categoryIds: [], id: propsData.contribution.id, + groupId: null, image: { sensitive: false, }, From 61ae38065c251dc8f6496ed6642ea59487ce3039 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 19 Oct 2022 09:14:42 +0200 Subject: [PATCH 2/5] add callback for data object to Wrapper function --- webapp/pages/group/_id/_slug.spec.js | 237 ++++++++++++++------------- 1 file changed, 125 insertions(+), 112 deletions(-) diff --git a/webapp/pages/group/_id/_slug.spec.js b/webapp/pages/group/_id/_slug.spec.js index 1f92212ab..cbac1419a 100644 --- a/webapp/pages/group/_id/_slug.spec.js +++ b/webapp/pages/group/_id/_slug.spec.js @@ -6,10 +6,10 @@ const localVue = global.localVue localVue.filter('date', (d) => d) config.stubs['client-only'] = '' -// config.stubs['v-popover'] = '' +config.stubs['v-popover'] = '' config.stubs['nuxt-link'] = '' -// config.stubs['infinite-loading'] = '' -// config.stubs['follow-list'] = '' +config.stubs['infinite-loading'] = '' +config.stubs['follow-list'] = '' describe('GroupProfileSlug', () => { let wrapper @@ -196,10 +196,11 @@ describe('GroupProfileSlug', () => { }) describe('mount', () => { - Wrapper = () => { + Wrapper = (data = () => {}) => { return mount(GroupProfileSlug, { mocks, localVue, + data, }) } @@ -213,15 +214,16 @@ describe('GroupProfileSlug', () => { 'auth/isModerator': () => false, }, } - wrapper = Wrapper() - wrapper.setData({ - Group: [ - { - ...yogaPractice, - myRole: 'owner', - }, - ], - GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + wrapper = Wrapper(() => { + return { + Group: [ + { + ...yogaPractice, + myRole: 'owner', + }, + ], + GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + } }) }) @@ -361,15 +363,16 @@ describe('GroupProfileSlug', () => { 'auth/isModerator': () => false, }, } - wrapper = Wrapper() - wrapper.setData({ - Group: [ - { - ...yogaPractice, - myRole: 'usual', - }, - ], - GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + wrapper = Wrapper(() => { + return { + Group: [ + { + ...yogaPractice, + myRole: 'usual', + }, + ], + GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + } }) }) @@ -469,15 +472,16 @@ describe('GroupProfileSlug', () => { 'auth/isModerator': () => false, }, } - wrapper = Wrapper() - wrapper.setData({ - Group: [ - { - ...yogaPractice, - myRole: 'pending', - }, - ], - GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + wrapper = Wrapper(() => { + return { + Group: [ + { + ...yogaPractice, + myRole: 'pending', + }, + ], + GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + } }) }) @@ -577,15 +581,16 @@ describe('GroupProfileSlug', () => { 'auth/isModerator': () => false, }, } - wrapper = Wrapper() - wrapper.setData({ - Group: [ - { - ...yogaPractice, - myRole: null, - }, - ], - GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + wrapper = Wrapper(() => { + return { + Group: [ + { + ...yogaPractice, + myRole: null, + }, + ], + GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + } }) }) @@ -689,15 +694,16 @@ describe('GroupProfileSlug', () => { 'auth/isModerator': () => false, }, } - wrapper = Wrapper() - wrapper.setData({ - Group: [ - { - ...schoolForCitizens, - myRole: 'owner', - }, - ], - GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + wrapper = Wrapper(() => { + return { + Group: [ + { + ...schoolForCitizens, + myRole: 'owner', + }, + ], + GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + } }) }) @@ -801,15 +807,16 @@ describe('GroupProfileSlug', () => { 'auth/isModerator': () => false, }, } - wrapper = Wrapper() - wrapper.setData({ - Group: [ - { - ...schoolForCitizens, - myRole: 'usual', - }, - ], - GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + wrapper = Wrapper(() => { + return { + Group: [ + { + ...schoolForCitizens, + myRole: 'usual', + }, + ], + GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + } }) }) @@ -913,15 +920,16 @@ describe('GroupProfileSlug', () => { 'auth/isModerator': () => false, }, } - wrapper = Wrapper() - wrapper.setData({ - Group: [ - { - ...schoolForCitizens, - myRole: 'pending', - }, - ], - GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + wrapper = Wrapper(() => { + return { + Group: [ + { + ...schoolForCitizens, + myRole: 'pending', + }, + ], + GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + } }) }) @@ -1025,15 +1033,16 @@ describe('GroupProfileSlug', () => { 'auth/isModerator': () => false, }, } - wrapper = Wrapper() - wrapper.setData({ - Group: [ - { - ...schoolForCitizens, - myRole: null, - }, - ], - GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + wrapper = Wrapper(() => { + return { + Group: [ + { + ...schoolForCitizens, + myRole: null, + }, + ], + GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + } }) }) @@ -1141,15 +1150,16 @@ describe('GroupProfileSlug', () => { 'auth/isModerator': () => false, }, } - wrapper = Wrapper() - wrapper.setData({ - Group: [ - { - ...investigativeJournalism, - myRole: 'owner', - }, - ], - GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + wrapper = Wrapper(() => { + return { + Group: [ + { + ...investigativeJournalism, + myRole: 'owner', + }, + ], + GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + } }) }) @@ -1256,15 +1266,16 @@ describe('GroupProfileSlug', () => { 'auth/isModerator': () => false, }, } - wrapper = Wrapper() - wrapper.setData({ - Group: [ - { - ...investigativeJournalism, - myRole: 'usual', - }, - ], - GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + wrapper = Wrapper(() => { + return { + Group: [ + { + ...investigativeJournalism, + myRole: 'usual', + }, + ], + GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + } }) }) @@ -1371,15 +1382,16 @@ describe('GroupProfileSlug', () => { 'auth/isModerator': () => false, }, } - wrapper = Wrapper() - wrapper.setData({ - Group: [ - { - ...investigativeJournalism, - myRole: 'pending', - }, - ], - GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + wrapper = Wrapper(() => { + return { + Group: [ + { + ...investigativeJournalism, + myRole: 'pending', + }, + ], + GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + } }) }) @@ -1474,15 +1486,16 @@ describe('GroupProfileSlug', () => { 'auth/isModerator': () => false, }, } - wrapper = Wrapper() - wrapper.setData({ - Group: [ - { - ...investigativeJournalism, - myRole: null, - }, - ], - GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + wrapper = Wrapper(() => { + return { + Group: [ + { + ...investigativeJournalism, + myRole: null, + }, + ], + GroupMembers: [peterLustig, jennyRostock, bobDerBaumeister, huey], + } }) }) From 25001ce6abcbcadd06325f6fc02fe413587c4364 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 19 Oct 2022 09:21:08 +0200 Subject: [PATCH 3/5] mock route params --- webapp/pages/post/_id/_slug/index.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webapp/pages/post/_id/_slug/index.spec.js b/webapp/pages/post/_id/_slug/index.spec.js index 4737386ef..2dd4522b2 100644 --- a/webapp/pages/post/_id/_slug/index.spec.js +++ b/webapp/pages/post/_id/_slug/index.spec.js @@ -56,6 +56,10 @@ describe('PostSlug', () => { }, $route: { hash: '', + params: { + slug: 'slug', + id: 'id', + }, }, // If you are mocking the router, then don't use VueRouter with localVue: https://vue-test-utils.vuejs.org/guides/using-with-vue-router.html $router: { From 7b69a4dc3ffa6f40ce63a5f9aa638bb6ca53631a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 19 Oct 2022 09:24:08 +0200 Subject: [PATCH 4/5] deactivate deprecated test --- webapp/pages/post/{_id.spec.js => _id.spec.js.old} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename webapp/pages/post/{_id.spec.js => _id.spec.js.old} (100%) diff --git a/webapp/pages/post/_id.spec.js b/webapp/pages/post/_id.spec.js.old similarity index 100% rename from webapp/pages/post/_id.spec.js rename to webapp/pages/post/_id.spec.js.old From 89e1de0f14db076542bc58231b98f9d21f926ad7 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 19 Oct 2022 09:28:15 +0200 Subject: [PATCH 5/5] mock route query group id --- webapp/pages/post/create.spec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webapp/pages/post/create.spec.js b/webapp/pages/post/create.spec.js index 5bfae19ed..4f786aaa9 100644 --- a/webapp/pages/post/create.spec.js +++ b/webapp/pages/post/create.spec.js @@ -11,6 +11,11 @@ describe('create.vue', () => { $env: { CATEGORIES_ACTIVE: false, }, + $route: { + query: { + groupId: null, + }, + }, } describe('mount', () => {