From 145a60bcddb94b6f305870f14d373de9eb2cb39d Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 28 Mar 2023 08:07:34 +0200 Subject: [PATCH 1/6] yarn installAll --- e2e-tests/yarn.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-tests/yarn.lock b/e2e-tests/yarn.lock index c0f623e47..1fffb6870 100644 --- a/e2e-tests/yarn.lock +++ b/e2e-tests/yarn.lock @@ -2193,10 +2193,10 @@ crypto-browserify@^3.0.0: randombytes "^2.0.0" randomfill "^1.0.3" -cypress@^10.4.0: - version "10.8.0" - resolved "https://registry.yarnpkg.com/cypress/-/cypress-10.8.0.tgz#12a681f2642b6f13d636bab65d5b71abdb1497a5" - integrity sha512-QVse0dnLm018hgti2enKMVZR9qbIO488YGX06nH5j3Dg1isL38DwrBtyrax02CANU6y8F4EJUuyW6HJKw1jsFA== +cypress@^12.7.0: + version "12.8.1" + resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.8.1.tgz#0c6e67f34554d553138697aaf349b637d80004eb" + integrity sha512-lIFbKdaSYAOarNLHNFa2aPZu6YSF+8UY4VRXMxJrFUnk6RvfG0AWsZ7/qle/aIz30TNUD4aOihz2ZgS4vuQVSA== dependencies: "@cypress/request" "^2.88.10" "@cypress/xvfb" "^1.2.4" @@ -2215,7 +2215,7 @@ cypress@^10.4.0: commander "^5.1.0" common-tags "^1.8.0" dayjs "^1.10.4" - debug "^4.3.2" + debug "^4.3.4" enquirer "^2.3.6" eventemitter2 "6.4.7" execa "4.1.0" From 5fded941b9b8be5eac0bd4c2def46aca23e2146b Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 29 Mar 2023 14:20:19 +0200 Subject: [PATCH 2/6] add watch tabIndex, when > currentPage = 1 --- admin/src/pages/CreationConfirm.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index b367d1b7f..3d5127f1a 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -116,6 +116,11 @@ export default { pageSize: 25, } }, + watch: { + tabIndex() { + this.currentPage = 1 + }, + }, methods: { deleteCreation() { this.$apollo @@ -361,7 +366,7 @@ export default { { key: 'confirmedBy', label: this.$t('moderator') }, { key: 'chatCreation', label: this.$t('chat') }, ], - ][this.tabIndex] + ] }, statusFilter() { return FILTER_TAB_MAP[this.tabIndex] From 5ca2a571f4130768a9e37dd654429272a8d69099 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 29 Mar 2023 14:26:27 +0200 Subject: [PATCH 3/6] restore code --- admin/src/pages/CreationConfirm.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 3d5127f1a..0b43be840 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -366,7 +366,7 @@ export default { { key: 'confirmedBy', label: this.$t('moderator') }, { key: 'chatCreation', label: this.$t('chat') }, ], - ] + ][this.tabIndex] }, statusFilter() { return FILTER_TAB_MAP[this.tabIndex] From c5b591ca5d0ef0aad735a75c36596639d4b9f1e3 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 5 Apr 2023 13:18:44 +0200 Subject: [PATCH 4/6] Test that currentPage is reset when switching tab. --- admin/src/pages/CreationConfirm.spec.js | 43 ++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index c9d9661c2..74fe23428 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -39,7 +39,7 @@ const mocks = { const defaultData = () => { return { adminListContributions: { - contributionCount: 2, + contributionCount: 30, contributionList: [ { id: 1, @@ -152,6 +152,35 @@ describe('CreationConfirm', () => { }) describe('actions in overlay', () => { + describe('change pagination', () => { + it('has pagination buttons', () => { + expect(wrapper.findComponent({ name: 'BPagination' }).exists()).toBe(true) + }) + + describe('next page', () => { + beforeAll(async () => { + jest.clearAllMocks() + }) + + beforeEach(() => { + wrapper.vm.currentPage = 2 + }) + + it('has currentPage set to 2', () => { + expect(wrapper.vm.currentPage).toBe(2) + }) + + it('calls the API again', () => { + expect(adminListContributionsMock).toBeCalledWith({ + currentPage: 2, + order: 'DESC', + pageSize: 25, + statusFilter: ['IN_PROGRESS', 'PENDING'], + }) + }) + }) + }) + describe('delete creation', () => { beforeEach(async () => { await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click') @@ -367,6 +396,10 @@ describe('CreationConfirm', () => { await wrapper.find('a[data-test="denied"]').trigger('click') }) + it('refresh the currentPage to 1', () => { + expect(wrapper.vm.currentPage).toBe(1) + }) + it('refetches contributions with proper filter', () => { expect(adminListContributionsMock).toBeCalledWith({ currentPage: 1, @@ -383,6 +416,10 @@ describe('CreationConfirm', () => { await wrapper.find('a[data-test="deleted"]').trigger('click') }) + it('refresh the currentPage to 1', () => { + expect(wrapper.vm.currentPage).toBe(1) + }) + it('refetches contributions with proper filter', () => { expect(adminListContributionsMock).toBeCalledWith({ currentPage: 1, @@ -399,6 +436,10 @@ describe('CreationConfirm', () => { await wrapper.find('a[data-test="all"]').trigger('click') }) + it('refresh the currentPage to 1', () => { + expect(wrapper.vm.currentPage).toBe(1) + }) + it('refetches contributions with proper filter', () => { expect(adminListContributionsMock).toBeCalledWith({ currentPage: 1, From 94f09633133510ac2000ee8e1f923f61cdb7c78f Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 11 Apr 2023 12:35:20 +0200 Subject: [PATCH 5/6] test reset current page on tab change properly --- admin/src/pages/CreationConfirm.spec.js | 79 ++++++++++++------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index 74fe23428..8c51d9475 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -152,35 +152,6 @@ describe('CreationConfirm', () => { }) describe('actions in overlay', () => { - describe('change pagination', () => { - it('has pagination buttons', () => { - expect(wrapper.findComponent({ name: 'BPagination' }).exists()).toBe(true) - }) - - describe('next page', () => { - beforeAll(async () => { - jest.clearAllMocks() - }) - - beforeEach(() => { - wrapper.vm.currentPage = 2 - }) - - it('has currentPage set to 2', () => { - expect(wrapper.vm.currentPage).toBe(2) - }) - - it('calls the API again', () => { - expect(adminListContributionsMock).toBeCalledWith({ - currentPage: 2, - order: 'DESC', - pageSize: 25, - statusFilter: ['IN_PROGRESS', 'PENDING'], - }) - }) - }) - }) - describe('delete creation', () => { beforeEach(async () => { await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click') @@ -396,10 +367,6 @@ describe('CreationConfirm', () => { await wrapper.find('a[data-test="denied"]').trigger('click') }) - it('refresh the currentPage to 1', () => { - expect(wrapper.vm.currentPage).toBe(1) - }) - it('refetches contributions with proper filter', () => { expect(adminListContributionsMock).toBeCalledWith({ currentPage: 1, @@ -416,10 +383,6 @@ describe('CreationConfirm', () => { await wrapper.find('a[data-test="deleted"]').trigger('click') }) - it('refresh the currentPage to 1', () => { - expect(wrapper.vm.currentPage).toBe(1) - }) - it('refetches contributions with proper filter', () => { expect(adminListContributionsMock).toBeCalledWith({ currentPage: 1, @@ -436,10 +399,6 @@ describe('CreationConfirm', () => { await wrapper.find('a[data-test="all"]').trigger('click') }) - it('refresh the currentPage to 1', () => { - expect(wrapper.vm.currentPage).toBe(1) - }) - it('refetches contributions with proper filter', () => { expect(adminListContributionsMock).toBeCalledWith({ currentPage: 1, @@ -448,6 +407,44 @@ describe('CreationConfirm', () => { statusFilter: ['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'], }) }) + + describe('change pagination', () => { + it('has pagination buttons', () => { + expect(wrapper.findComponent({ name: 'BPagination' }).exists()).toBe(true) + }) + + describe('next page', () => { + beforeEach(() => { + jest.clearAllMocks() + wrapper.findComponent({ name: 'BPagination' }).vm.$emit('input', 2) + }) + + it('calls the API again', () => { + expect(adminListContributionsMock).toBeCalledWith({ + currentPage: 2, + order: 'DESC', + pageSize: 25, + statusFilter: ['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'], + }) + }) + }) + }) + + describe('click tab "open" again', () => { + beforeEach(async () => { + jest.clearAllMocks() + await wrapper.find('a[data-test="open"]').trigger('click') + }) + + it('refetches contributions with proper filter and current page = 1', () => { + expect(adminListContributionsMock).toBeCalledWith({ + currentPage: 1, + order: 'DESC', + pageSize: 25, + statusFilter: ['IN_PROGRESS', 'PENDING'], + }) + }) + }) }) }) }) From 2e88ac3cb962797ec31b6820acdc8e238504a373 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 11 Apr 2023 12:38:25 +0200 Subject: [PATCH 6/6] move describe block --- admin/src/pages/CreationConfirm.spec.js | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index 8c51d9475..091d7a011 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -427,21 +427,21 @@ describe('CreationConfirm', () => { statusFilter: ['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'], }) }) - }) - }) - describe('click tab "open" again', () => { - beforeEach(async () => { - jest.clearAllMocks() - await wrapper.find('a[data-test="open"]').trigger('click') - }) + describe('click tab "open" again', () => { + beforeEach(async () => { + jest.clearAllMocks() + await wrapper.find('a[data-test="open"]').trigger('click') + }) - it('refetches contributions with proper filter and current page = 1', () => { - expect(adminListContributionsMock).toBeCalledWith({ - currentPage: 1, - order: 'DESC', - pageSize: 25, - statusFilter: ['IN_PROGRESS', 'PENDING'], + it('refetches contributions with proper filter and current page = 1', () => { + expect(adminListContributionsMock).toBeCalledWith({ + currentPage: 1, + order: 'DESC', + pageSize: 25, + statusFilter: ['IN_PROGRESS', 'PENDING'], + }) + }) }) }) })