From 34ac7b97bd22a888529e4c803f74a3aa53a7cdcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 30 Oct 2023 15:57:30 +0100 Subject: [PATCH 1/5] Make filter menu visible if categories are inactive --- .../FilterMenu/FilterMenuComponent.vue | 28 ++++++++++--------- webapp/pages/index.vue | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/webapp/components/FilterMenu/FilterMenuComponent.vue b/webapp/components/FilterMenu/FilterMenuComponent.vue index e362e758f..7897a285d 100644 --- a/webapp/components/FilterMenu/FilterMenuComponent.vue +++ b/webapp/components/FilterMenu/FilterMenuComponent.vue @@ -3,7 +3,7 @@

{{ $t('filter-menu.filter-by') }}

-
+
{ - this.$emit('showFilterMenu') - this.$toast.success(this.$t('filter-menu.save.success')) - }) - .catch(() => { - this.$toast.error(this.$t('filter-menu.save.error')) - }) + if (this.categoriesActive) { + this.$apollo + .mutate({ + mutation: SaveCategories(), + variables: { activeCategories: this.filteredCategoryIds }, + }) + .then(() => { + this.$emit('showFilterMenu') + this.$toast.success(this.$t('filter-menu.save.success')) + }) + .catch(() => { + this.$toast.error(this.$t('filter-menu.save.error')) + }) + } }, }, } diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue index 7b5c4a903..6067119e1 100644 --- a/webapp/pages/index.vue +++ b/webapp/pages/index.vue @@ -19,7 +19,7 @@
-
+
Date: Tue, 31 Oct 2023 11:10:38 +0100 Subject: [PATCH 2/5] replace deprecated jest methods in webapp unit tests --- .../components/DonationInfo/DonationInfo.spec.js | 4 ++-- webapp/components/Group/GroupMember.spec.js | 12 ++++++------ webapp/components/LoginForm/LoginForm.spec.js | 14 +++++++------- webapp/components/PostTeaser/PostTeaser.spec.js | 2 +- webapp/pages/index.spec.js | 4 ++-- webapp/pages/login.spec.js | 2 +- webapp/pages/logout.spec.js | 4 ++-- webapp/pages/map.spec.js | 10 +++++----- webapp/pages/password-reset.spec.js | 2 +- webapp/pages/post/edit/_id.spec.js | 2 +- webapp/pages/registration.spec.js | 2 +- webapp/pages/terms-and-conditions-confirm.spec.js | 2 +- 12 files changed, 30 insertions(+), 30 deletions(-) diff --git a/webapp/components/DonationInfo/DonationInfo.spec.js b/webapp/components/DonationInfo/DonationInfo.spec.js index 76aef9444..ac537be5b 100644 --- a/webapp/components/DonationInfo/DonationInfo.spec.js +++ b/webapp/components/DonationInfo/DonationInfo.spec.js @@ -46,7 +46,7 @@ describe('DonationInfo.vue', () => { // it looks to me that toLocaleString for some reason is not working as expected it.skip('creates a label from the given amounts and a translation string', () => { - expect(mocks.$t).nthCalledWith(1, 'donations.amount-of-total', { + expect(mocks.$t).toHaveBeenNthCalledWith(1, 'donations.amount-of-total', { amount: '10.000', total: '50.000', }) @@ -55,7 +55,7 @@ describe('DonationInfo.vue', () => { describe('given english locale', () => { it('creates a label from the given amounts and a translation string', () => { - expect(mocks.$t).toBeCalledWith( + expect(mocks.$t).toHaveBeenCalledWith( 'donations.amount-of-total', expect.objectContaining({ amount: '10,000', diff --git a/webapp/components/Group/GroupMember.spec.js b/webapp/components/Group/GroupMember.spec.js index ef8b96568..8efc754ad 100644 --- a/webapp/components/Group/GroupMember.spec.js +++ b/webapp/components/Group/GroupMember.spec.js @@ -94,20 +94,20 @@ describe('GroupMember', () => { describe('with server error', () => { it('toasts an error message', () => { - expect(toastErrorMock).toBeCalledWith('Oh no!') + expect(toastErrorMock).toHaveBeenCalledWith('Oh no!') }) }) describe('with server success', () => { it('calls the API', () => { - expect(apolloMock).toBeCalledWith({ + expect(apolloMock).toHaveBeenCalledWith({ mutation: changeGroupMemberRoleMutation(), variables: { groupId: 'group-id', userId: 'user', roleInGroup: 'admin' }, }) }) it('toasts a success message', () => { - expect(toastSuccessMock).toBeCalledWith('group.changeMemberRole') + expect(toastSuccessMock).toHaveBeenCalledWith('group.changeMemberRole') }) }) }) @@ -150,7 +150,7 @@ describe('GroupMember', () => { }) it('toasts an error message', () => { - expect(toastErrorMock).toBeCalledWith('Oh no!!') + expect(toastErrorMock).toHaveBeenCalledWith('Oh no!!') }) it('closes the modal', () => { @@ -165,7 +165,7 @@ describe('GroupMember', () => { }) it('calls the API', () => { - expect(apolloMock).toBeCalledWith({ + expect(apolloMock).toHaveBeenCalledWith({ mutation: removeUserFromGroupMutation(), variables: { groupId: 'group-id', userId: 'user' }, }) @@ -176,7 +176,7 @@ describe('GroupMember', () => { }) it('toasts a success message', () => { - expect(toastSuccessMock).toBeCalledWith('group.memberRemoved') + expect(toastSuccessMock).toHaveBeenCalledWith('group.memberRemoved') }) it('closes the modal', () => { diff --git a/webapp/components/LoginForm/LoginForm.spec.js b/webapp/components/LoginForm/LoginForm.spec.js index e0972b453..2004656a5 100644 --- a/webapp/components/LoginForm/LoginForm.spec.js +++ b/webapp/components/LoginForm/LoginForm.spec.js @@ -75,8 +75,8 @@ describe('LoginForm', () => { describe('no categories saved', () => { it('resets the categories', async () => { await fillIn(Wrapper()) - expect(storeMocks.mutations['posts/RESET_CATEGORIES']).toBeCalled() - expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).not.toBeCalled() + expect(storeMocks.mutations['posts/RESET_CATEGORIES']).toHaveBeenCalled() + expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).not.toHaveBeenCalled() }) }) @@ -84,11 +84,11 @@ describe('LoginForm', () => { it('sets the categories', async () => { authUserMock.mockReturnValue({ activeCategories: ['cat1', 'cat9', 'cat12'] }) await fillIn(Wrapper()) - expect(storeMocks.mutations['posts/RESET_CATEGORIES']).toBeCalled() - expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toBeCalledTimes(3) - expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toBeCalledWith({}, 'cat1') - expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toBeCalledWith({}, 'cat9') - expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toBeCalledWith({}, 'cat12') + expect(storeMocks.mutations['posts/RESET_CATEGORIES']).toHaveBeenCalled() + expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toHaveBeenCalledTimes(3) + expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toHaveBeenCalledWith({}, 'cat1') + expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toHaveBeenCalledWith({}, 'cat9') + expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toHaveBeenCalledWith({}, 'cat12') }) }) }) diff --git a/webapp/components/PostTeaser/PostTeaser.spec.js b/webapp/components/PostTeaser/PostTeaser.spec.js index 0d48729d3..315f922cd 100644 --- a/webapp/components/PostTeaser/PostTeaser.spec.js +++ b/webapp/components/PostTeaser/PostTeaser.spec.js @@ -73,7 +73,7 @@ describe('PostTeaser', () => { it('has no validation errors', () => { const spy = jest.spyOn(global.console, 'error') Wrapper() - expect(spy).not.toBeCalled() + expect(spy).not.toHaveBeenCalled() spy.mockReset() }) diff --git a/webapp/pages/index.spec.js b/webapp/pages/index.spec.js index c16560a84..86a852a83 100644 --- a/webapp/pages/index.spec.js +++ b/webapp/pages/index.spec.js @@ -114,11 +114,11 @@ describe('PostIndex', () => { }) it('resets the category filter', () => { - expect(mutations['posts/RESET_CATEGORIES']).toBeCalled() + expect(mutations['posts/RESET_CATEGORIES']).toHaveBeenCalled() }) it('sets the category', () => { - expect(mutations['posts/TOGGLE_CATEGORY']).toBeCalledWith({}, 'cat3') + expect(mutations['posts/TOGGLE_CATEGORY']).toHaveBeenCalledWith({}, 'cat3') }) }) }) diff --git a/webapp/pages/login.spec.js b/webapp/pages/login.spec.js index a65fc79a0..31ff2b489 100644 --- a/webapp/pages/login.spec.js +++ b/webapp/pages/login.spec.js @@ -71,7 +71,7 @@ describe('Login.vue', () => { asyncData = true tosVersion = '0.0.4' wrapper = await Wrapper() - expect(redirect).toBeCalledWith('/') + expect(redirect).toHaveBeenCalledWith('/') }) }) }) diff --git a/webapp/pages/logout.spec.js b/webapp/pages/logout.spec.js index 460d321aa..c0edd1c4b 100644 --- a/webapp/pages/logout.spec.js +++ b/webapp/pages/logout.spec.js @@ -36,8 +36,8 @@ describe('logout.vue', () => { }) it('logs out and redirects to login', () => { - expect(mocks.$store.dispatch).toBeCalledWith('auth/logout') - expect(mocks.$router.replace).toBeCalledWith('/login') + expect(mocks.$store.dispatch).toHaveBeenCalledWith('auth/logout') + expect(mocks.$router.replace).toHaveBeenCalledWith('/login') }) }) }) diff --git a/webapp/pages/map.spec.js b/webapp/pages/map.spec.js index a9e21c876..a0ad95605 100644 --- a/webapp/pages/map.spec.js +++ b/webapp/pages/map.spec.js @@ -114,19 +114,19 @@ describe('map', () => { }) it('initializes on style load', () => { - expect(mapOnMock).toBeCalledWith('style.load', expect.any(Function)) + expect(mapOnMock).toHaveBeenCalledWith('style.load', expect.any(Function)) }) it('initializes on mouseenter', () => { - expect(mapOnMock).toBeCalledWith('mouseenter', 'markers', expect.any(Function)) + expect(mapOnMock).toHaveBeenCalledWith('mouseenter', 'markers', expect.any(Function)) }) it('initializes on mouseleave', () => { - expect(mapOnMock).toBeCalledWith('mouseleave', 'markers', expect.any(Function)) + expect(mapOnMock).toHaveBeenCalledWith('mouseleave', 'markers', expect.any(Function)) }) it('calls add map control', () => { - expect(mapAddControlMock).toBeCalled() + expect(mapAddControlMock).toHaveBeenCalled() }) describe('trigger style load event', () => { @@ -137,7 +137,7 @@ describe('map', () => { }) it('calls loadMarkersIconsAndAddMarkers', () => { - expect(spy).toBeCalled() + expect(spy).toHaveBeenCalled() }) }) diff --git a/webapp/pages/password-reset.spec.js b/webapp/pages/password-reset.spec.js index 9337d1d59..328f04606 100644 --- a/webapp/pages/password-reset.spec.js +++ b/webapp/pages/password-reset.spec.js @@ -68,7 +68,7 @@ describe('password-reset.vue', () => { asyncData = true isLoggedIn = true wrapper = await Wrapper() - expect(redirect).toBeCalledWith('/') + expect(redirect).toHaveBeenCalledWith('/') }) }) }) diff --git a/webapp/pages/post/edit/_id.spec.js b/webapp/pages/post/edit/_id.spec.js index 2773483a4..8a30d7ac5 100644 --- a/webapp/pages/post/edit/_id.spec.js +++ b/webapp/pages/post/edit/_id.spec.js @@ -76,7 +76,7 @@ describe('post/_id.vue', () => { authorId = 'some-author' userId = 'some-user' wrapper = await Wrapper() - expect(error).toBeCalledWith({ message: 'error-pages.cannot-edit-post', statusCode: 403 }) + expect(error).toHaveBeenCalledWith({ message: 'error-pages.cannot-edit-post', statusCode: 403 }) }) it('renders with asyncData of same user', async () => { diff --git a/webapp/pages/registration.spec.js b/webapp/pages/registration.spec.js index a276c2b8b..b34ba3ba7 100644 --- a/webapp/pages/registration.spec.js +++ b/webapp/pages/registration.spec.js @@ -327,7 +327,7 @@ describe('Registration', () => { asyncData = true isLoggedIn = true wrapper = await Wrapper() - expect(redirect).toBeCalledWith('/') + expect(redirect).toHaveBeenCalledWith('/') }) // copied from webapp/components/Registration/Signup.spec.js as testing template diff --git a/webapp/pages/terms-and-conditions-confirm.spec.js b/webapp/pages/terms-and-conditions-confirm.spec.js index c8faeb6f1..268eb83ed 100644 --- a/webapp/pages/terms-and-conditions-confirm.spec.js +++ b/webapp/pages/terms-and-conditions-confirm.spec.js @@ -71,7 +71,7 @@ describe('terms-and-conditions-confirm.vue', () => { asyncData = true tosAgree = true wrapper = await Wrapper() - expect(redirect).toBeCalledWith('/') + expect(redirect).toHaveBeenCalledWith('/') }) }) }) From 57b6b81a5fc616645ffe6a374c1ebb98e9395921 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 31 Oct 2023 11:24:27 +0100 Subject: [PATCH 3/5] linting --- webapp/pages/post/edit/_id.spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webapp/pages/post/edit/_id.spec.js b/webapp/pages/post/edit/_id.spec.js index 8a30d7ac5..205a7c4fe 100644 --- a/webapp/pages/post/edit/_id.spec.js +++ b/webapp/pages/post/edit/_id.spec.js @@ -76,7 +76,10 @@ describe('post/_id.vue', () => { authorId = 'some-author' userId = 'some-user' wrapper = await Wrapper() - expect(error).toHaveBeenCalledWith({ message: 'error-pages.cannot-edit-post', statusCode: 403 }) + expect(error).toHaveBeenCalledWith({ + message: 'error-pages.cannot-edit-post', + statusCode: 403, + }) }) it('renders with asyncData of same user', async () => { From 21fd669a601d95e6741d0d28c59c449fcf511b26 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 31 Oct 2023 14:25:12 +0100 Subject: [PATCH 4/5] increase cypress page load timeout --- cypress/cypress.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/cypress.config.js b/cypress/cypress.config.js index b1d80575e..b9862613b 100644 --- a/cypress/cypress.config.js +++ b/cypress/cypress.config.js @@ -32,6 +32,7 @@ module.exports = defineConfig({ e2e: { projectId: "qa7fe2", defaultCommandTimeout: 10000, + pageLoadTimeout:180000, chromeWebSecurity: false, baseUrl: "http://localhost:3000", specPattern: "cypress/e2e/**/*.feature", From 2049ce183f90eb13fe985a516478496fc00c008d Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 31 Oct 2023 15:35:27 +0100 Subject: [PATCH 5/5] increase cypress default command timeout --- cypress/cypress.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/cypress.config.js b/cypress/cypress.config.js index b9862613b..db8308557 100644 --- a/cypress/cypress.config.js +++ b/cypress/cypress.config.js @@ -31,7 +31,7 @@ const { parsed } = dotenv.config({ path: '../backend/.env' }) module.exports = defineConfig({ e2e: { projectId: "qa7fe2", - defaultCommandTimeout: 10000, + defaultCommandTimeout: 60000, pageLoadTimeout:180000, chromeWebSecurity: false, baseUrl: "http://localhost:3000",