diff --git a/.gitignore b/.gitignore index 08ccd2b30..1a111760f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .dbeaver .project *.log +*.bak /node_modules/* messages.pot nbproject diff --git a/CHANGELOG.md b/CHANGELOG.md index 53aa4a9e1..8eb3dab66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,26 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.10.0](https://github.com/gradido/gradido/compare/1.9.0...1.10.0) + +- frontend redeem contribution link [`#1988`](https://github.com/gradido/gradido/pull/1988) +- change new start picture [`#1990`](https://github.com/gradido/gradido/pull/1990) +- feat: Redeem Contribution Link [`#1987`](https://github.com/gradido/gradido/pull/1987) +- fix: Max Amount on Slider for Edit Contribution [`#1986`](https://github.com/gradido/gradido/pull/1986) +- CRUD contribution link admin interface [`#1981`](https://github.com/gradido/gradido/pull/1981) +- fix: `.env` log level for apollo and backend category [`#1967`](https://github.com/gradido/gradido/pull/1967) +- refactor: Admin Pending Creations Table to Contributions Table [`#1949`](https://github.com/gradido/gradido/pull/1949) +- devops: Update Browser List for Unit Tests as Recomended [`#1984`](https://github.com/gradido/gradido/pull/1984) +- feat: CRUD for Contribution Links in Admin Resolver [`#1979`](https://github.com/gradido/gradido/pull/1979) +- 1920 feature create contribution link table [`#1957`](https://github.com/gradido/gradido/pull/1957) +- refactor: 🍰 Delete `user_setting` Table From DB [`#1960`](https://github.com/gradido/gradido/pull/1960) +- locales link german, english navbar [`#1969`](https://github.com/gradido/gradido/pull/1969) + #### [1.9.0](https://github.com/gradido/gradido/compare/1.8.3...1.9.0) +> 2 June 2022 + +- devops: Release Version 1.9.0 [`#1968`](https://github.com/gradido/gradido/pull/1968) - refactor: 🍰 Refactor To `filters` Object And Rename Filters Properties [`#1914`](https://github.com/gradido/gradido/pull/1914) - refactor register button position [`#1964`](https://github.com/gradido/gradido/pull/1964) - fixed redeem link is mobile start false [`#1958`](https://github.com/gradido/gradido/pull/1958) diff --git a/admin/jest.config.js b/admin/jest.config.js index b7226bd8f..9b9842bad 100644 --- a/admin/jest.config.js +++ b/admin/jest.config.js @@ -22,7 +22,7 @@ module.exports = { '^.+\\.(js|jsx)?$': 'babel-jest', '/node_modules/vee-validate/dist/rules': 'babel-jest', }, - setupFiles: ['/test/testSetup.js'], + setupFiles: ['/test/testSetup.js', 'jest-canvas-mock'], testMatch: ['**/?(*.)+(spec|test).js?(x)'], // snapshotSerializers: ['jest-serializer-vue'], transformIgnorePatterns: ['/node_modules/(?!vee-validate/dist/rules)'], diff --git a/admin/package.json b/admin/package.json index e36308fd9..73d8dd879 100644 --- a/admin/package.json +++ b/admin/package.json @@ -3,7 +3,7 @@ "description": "Administraion Interface for Gradido", "main": "index.js", "author": "Moriz Wahl", - "version": "1.9.0", + "version": "1.10.0", "license": "Apache-2.0", "private": false, "scripts": { @@ -38,7 +38,9 @@ "graphql": "^15.6.1", "identity-obj-proxy": "^3.0.0", "jest": "26.6.3", + "jest-canvas-mock": "^2.3.1", "portal-vue": "^2.1.7", + "qrcanvas-vue": "2.1.1", "regenerator-runtime": "^0.13.9", "stats-webpack-plugin": "^0.7.0", "vue": "^2.6.11", diff --git a/admin/public/img/gdd-coin.png b/admin/public/img/gdd-coin.png new file mode 100644 index 000000000..32cb8b2b2 Binary files /dev/null and b/admin/public/img/gdd-coin.png differ diff --git a/admin/src/components/ChangeUserRoleFormular.spec.js b/admin/src/components/ChangeUserRoleFormular.spec.js new file mode 100644 index 000000000..8bcd4d8e5 --- /dev/null +++ b/admin/src/components/ChangeUserRoleFormular.spec.js @@ -0,0 +1,254 @@ +import { mount } from '@vue/test-utils' +import ChangeUserRoleFormular from './ChangeUserRoleFormular.vue' +import { setUserRole } from '../graphql/setUserRole' +import { toastSuccessSpy, toastErrorSpy } from '../../test/testSetup' + +const localVue = global.localVue + +const apolloMutateMock = jest.fn().mockResolvedValue({ + data: { + setUserRole: null, + }, +}) + +const mocks = { + $t: jest.fn((t) => t), + $apollo: { + mutate: apolloMutateMock, + }, + $store: { + state: { + moderator: { + id: 0, + name: 'test moderator', + }, + }, + }, +} + +let propsData +let wrapper + +describe('ChangeUserRoleFormular', () => { + const Wrapper = () => { + return mount(ChangeUserRoleFormular, { localVue, mocks, propsData }) + } + + describe('mount', () => { + beforeEach(() => { + jest.clearAllMocks() + }) + + describe('DOM has', () => { + beforeEach(() => { + propsData = { + item: { + userId: 1, + isAdmin: null, + }, + } + wrapper = Wrapper() + }) + + it('has a DIV element with the class.delete-user-formular', () => { + expect(wrapper.find('.change-user-role-formular').exists()).toBe(true) + }) + }) + + describe('change own role', () => { + beforeEach(() => { + propsData = { + item: { + userId: 0, + isAdmin: null, + }, + } + wrapper = Wrapper() + }) + + it('has the text that you cannot change own role', () => { + expect(wrapper.text()).toContain('userRole.notChangeYourSelf') + }) + + it('has role select disabled', () => { + expect(wrapper.find('select[disabled="disabled"]').exists()).toBe(true) + }) + }) + + describe('change others role', () => { + let rolesToSelect + + describe('general', () => { + beforeEach(() => { + propsData = { + item: { + userId: 1, + isAdmin: null, + }, + } + wrapper = Wrapper() + rolesToSelect = wrapper.find('select.role-select').findAll('option') + }) + + it('has no text that you cannot change own role', () => { + expect(wrapper.text()).not.toContain('userRole.notChangeYourSelf') + }) + + it('has the select label', () => { + expect(wrapper.text()).toContain('userRole.selectLabel') + }) + + it('has a select', () => { + expect(wrapper.find('select.role-select').exists()).toBe(true) + }) + + it('has role select enabled', () => { + expect(wrapper.find('select.role-select[disabled="disabled"]').exists()).toBe(false) + }) + + describe('on API error', () => { + beforeEach(() => { + apolloMutateMock.mockRejectedValue({ message: 'Oh no!' }) + rolesToSelect.at(1).setSelected() + }) + + it('toasts an error message', () => { + expect(toastErrorSpy).toBeCalledWith('Oh no!') + }) + }) + }) + + describe('user is usual user', () => { + beforeEach(() => { + apolloMutateMock.mockResolvedValue({ + data: { + setUserRole: new Date(), + }, + }) + propsData = { + item: { + userId: 1, + isAdmin: null, + }, + } + wrapper = Wrapper() + rolesToSelect = wrapper.find('select.role-select').findAll('option') + }) + + it('has selected option set to "usual user"', () => { + expect(wrapper.find('select.role-select').element.value).toBe('user') + }) + + describe('change select to', () => { + describe('same role', () => { + it('does not call the API', () => { + rolesToSelect.at(0).setSelected() + expect(apolloMutateMock).not.toHaveBeenCalled() + }) + }) + + describe('new role', () => { + beforeEach(() => { + rolesToSelect.at(1).setSelected() + }) + + it('calls the API', () => { + expect(apolloMutateMock).toBeCalledWith( + expect.objectContaining({ + mutation: setUserRole, + variables: { + userId: 1, + isAdmin: true, + }, + }), + ) + }) + + it('emits "updateIsAdmin"', () => { + expect(wrapper.emitted('updateIsAdmin')).toEqual( + expect.arrayContaining([ + expect.arrayContaining([ + { + userId: 1, + isAdmin: expect.any(Date), + }, + ]), + ]), + ) + }) + + it('toasts success message', () => { + expect(toastSuccessSpy).toBeCalledWith('userRole.successfullyChangedTo') + }) + }) + }) + }) + + describe('user is admin', () => { + beforeEach(() => { + apolloMutateMock.mockResolvedValue({ + data: { + setUserRole: null, + }, + }) + propsData = { + item: { + userId: 1, + isAdmin: new Date(), + }, + } + wrapper = Wrapper() + rolesToSelect = wrapper.find('select.role-select').findAll('option') + }) + + it('has selected option set to "admin"', () => { + expect(wrapper.find('select.role-select').element.value).toBe('admin') + }) + + describe('change select to', () => { + describe('same role', () => { + it('does not call the API', () => { + rolesToSelect.at(1).setSelected() + expect(apolloMutateMock).not.toHaveBeenCalled() + }) + }) + + describe('new role', () => { + beforeEach(() => { + rolesToSelect.at(0).setSelected() + }) + + it('calls the API', () => { + expect(apolloMutateMock).toBeCalledWith( + expect.objectContaining({ + mutation: setUserRole, + variables: { + userId: 1, + isAdmin: false, + }, + }), + ) + }) + + it('emits "updateIsAdmin"', () => { + expect(wrapper.emitted('updateIsAdmin')).toEqual( + expect.arrayContaining([ + expect.arrayContaining([ + { + userId: 1, + isAdmin: null, + }, + ]), + ]), + ) + }) + + it('toasts success message', () => { + expect(toastSuccessSpy).toBeCalledWith('userRole.successfullyChangedTo') + }) + }) + }) + }) + }) + }) +}) diff --git a/admin/src/components/ChangeUserRoleFormular.vue b/admin/src/components/ChangeUserRoleFormular.vue new file mode 100644 index 000000000..1217ce7f0 --- /dev/null +++ b/admin/src/components/ChangeUserRoleFormular.vue @@ -0,0 +1,89 @@ + + + + + diff --git a/admin/src/components/ContributionLink.spec.js b/admin/src/components/ContributionLink.spec.js new file mode 100644 index 000000000..f1b9cfb97 --- /dev/null +++ b/admin/src/components/ContributionLink.spec.js @@ -0,0 +1,49 @@ +import { mount } from '@vue/test-utils' +import ContributionLink from './ContributionLink.vue' + +const localVue = global.localVue + +const mocks = { + $t: jest.fn((t) => t), +} + +const propsData = { + items: [ + { + id: 1, + name: 'Meditation', + memo: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut l', + amount: '200', + validFrom: '2022-04-01', + validTo: '2022-08-01', + cycle: 'täglich', + maxPerCycle: '3', + maxAmountPerMonth: 0, + link: 'https://localhost/redeem/CL-1a2345678', + }, + ], + count: 1, +} + +describe('ContributionLink', () => { + let wrapper + + const Wrapper = () => { + return mount(ContributionLink, { localVue, mocks, propsData }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the Div Element ".contribution-link"', () => { + expect(wrapper.find('div.contribution-link').exists()).toBe(true) + }) + + it('emits toggle::collapse new Contribution', async () => { + wrapper.vm.editContributionLinkData() + expect(wrapper.vm.$root.$emit('bv::toggle::collapse', 'newContribution')).toBeTruthy() + }) + }) +}) diff --git a/admin/src/components/ContributionLink.vue b/admin/src/components/ContributionLink.vue new file mode 100644 index 000000000..893e202f4 --- /dev/null +++ b/admin/src/components/ContributionLink.vue @@ -0,0 +1,66 @@ + + diff --git a/admin/src/components/ContributionLinkForm.spec.js b/admin/src/components/ContributionLinkForm.spec.js new file mode 100644 index 000000000..9c7c33c52 --- /dev/null +++ b/admin/src/components/ContributionLinkForm.spec.js @@ -0,0 +1,102 @@ +import { mount } from '@vue/test-utils' +import ContributionLinkForm from './ContributionLinkForm.vue' + +const localVue = global.localVue + +global.alert = jest.fn() + +const propsData = { + contributionLinkData: {}, +} + +const mocks = { + $t: jest.fn((t) => t), +} + +// const mockAPIcall = jest.fn() + +describe('ContributionLinkForm', () => { + let wrapper + + const Wrapper = () => { + return mount(ContributionLinkForm, { localVue, mocks, propsData }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the Div Element ".contribution-link-form"', () => { + expect(wrapper.find('div.contribution-link-form').exists()).toBe(true) + }) + + describe('call onReset', () => { + it('form has the set data', () => { + beforeEach(() => { + wrapper.setData({ + form: { + name: 'name', + memo: 'memo', + amount: 100, + validFrom: 'validFrom', + validTo: 'validTo', + cycle: 'ONCE', + maxPerCycle: 1, + maxAmountPerMonth: 100, + }, + }) + wrapper.vm.onReset() + }) + expect(wrapper.vm.form).toEqual({ + amount: null, + cycle: 'ONCE', + validTo: null, + maxAmountPerMonth: '0', + memo: null, + name: null, + maxPerCycle: 1, + validFrom: null, + }) + }) + }) + + describe('call onSubmit', () => { + it('response with the contribution link url', () => { + wrapper.vm.onSubmit() + }) + }) + + // describe('successfull submit', () => { + // beforeEach(async () => { + // mockAPIcall.mockResolvedValue({ + // data: { + // createContributionLink: { + // link: 'https://localhost/redeem/CL-1a2345678', + // }, + // }, + // }) + // await wrapper.find('input.test-validFrom').setValue('2022-6-18') + // await wrapper.find('input.test-validTo').setValue('2022-7-18') + // await wrapper.find('input.test-name').setValue('test name') + // await wrapper.find('input.test-memo').setValue('test memo') + // await wrapper.find('input.test-amount').setValue('100') + // await wrapper.find('form').trigger('submit') + // }) + + // it('calls the API', () => { + // expect(mockAPIcall).toHaveBeenCalledWith( + // expect.objectContaining({ + // variables: { + // link: 'https://localhost/redeem/CL-1a2345678', + // }, + // }), + // ) + // }) + + // it('displays the new username', () => { + // expect(wrapper.find('div.display-username').text()).toEqual('@username') + // }) + // }) + }) +}) diff --git a/admin/src/components/ContributionLinkForm.vue b/admin/src/components/ContributionLinkForm.vue new file mode 100644 index 000000000..a159d33d3 --- /dev/null +++ b/admin/src/components/ContributionLinkForm.vue @@ -0,0 +1,218 @@ + + diff --git a/admin/src/components/ContributionLinkList.spec.js b/admin/src/components/ContributionLinkList.spec.js new file mode 100644 index 000000000..0b9d131bd --- /dev/null +++ b/admin/src/components/ContributionLinkList.spec.js @@ -0,0 +1,147 @@ +import { mount } from '@vue/test-utils' +import ContributionLinkList from './ContributionLinkList.vue' +import { toastSuccessSpy, toastErrorSpy } from '../../test/testSetup' +// import { deleteContributionLink } from '../graphql/deleteContributionLink' + +const localVue = global.localVue + +const mockAPIcall = jest.fn() + +const mocks = { + $t: jest.fn((t) => t), + $apollo: { + mutate: mockAPIcall, + }, +} + +const propsData = { + items: [ + { + id: 1, + name: 'Meditation', + memo: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut l', + amount: '200', + validFrom: '2022-04-01', + validTo: '2022-08-01', + cycle: 'täglich', + maxPerCycle: '3', + maxAmountPerMonth: 0, + link: 'https://localhost/redeem/CL-1a2345678', + }, + ], +} + +describe('ContributionLinkList', () => { + let wrapper + + const Wrapper = () => { + return mount(ContributionLinkList, { localVue, mocks, propsData }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the Div Element ".contribution-link-list"', () => { + expect(wrapper.find('div.contribution-link-list').exists()).toBe(true) + }) + + it('renders table with contribution link', () => { + expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain( + 'Meditation', + ) + }) + + describe('edit contribution link', () => { + beforeEach(() => { + wrapper.vm.editContributionLink() + }) + + it('emits editContributionLinkData', async () => { + expect(wrapper.vm.$emit('editContributionLinkData')).toBeTruthy() + }) + }) + + describe('delete contribution link', () => { + let spy + + beforeEach(async () => { + jest.clearAllMocks() + wrapper.vm.deleteContributionLink() + }) + + describe('with success', () => { + beforeEach(async () => { + spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm') + spy.mockImplementation(() => Promise.resolve('some value')) + mockAPIcall.mockResolvedValue() + await wrapper.find('.test-delete-link').trigger('click') + }) + + it('opens the modal ', () => { + expect(spy).toBeCalled() + }) + + it.skip('calls the API', () => { + // expect(mockAPIcall).toBeCalledWith( + // expect.objectContaining({ + // mutation: deleteContributionLink, + // variables: { + // id: 1, + // }, + // }), + // ) + }) + + it('toasts a success message', () => { + expect(toastSuccessSpy).toBeCalledWith('TODO: request message deleted ') + }) + }) + + describe('with error', () => { + beforeEach(async () => { + spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm') + spy.mockImplementation(() => Promise.resolve('some value')) + mockAPIcall.mockRejectedValue({ message: 'Something went wrong :(' }) + await wrapper.find('.test-delete-link').trigger('click') + }) + + it('toasts an error message', () => { + expect(toastErrorSpy).toBeCalledWith('Something went wrong :(') + }) + }) + + describe('cancel delete', () => { + beforeEach(async () => { + spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm') + spy.mockImplementation(() => Promise.resolve(false)) + mockAPIcall.mockResolvedValue() + await wrapper.find('.test-delete-link').trigger('click') + }) + + it('does not call the API', () => { + expect(mockAPIcall).not.toBeCalled() + }) + }) + }) + + describe('onClick showButton', () => { + it('modelData contains contribution link', () => { + wrapper.find('button.test-show').trigger('click') + expect(wrapper.vm.modalData).toEqual({ + amount: '200', + cycle: 'täglich', + id: 1, + link: 'https://localhost/redeem/CL-1a2345678', + maxAmountPerMonth: 0, + maxPerCycle: '3', + memo: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut l', + name: 'Meditation', + validFrom: '2022-04-01', + validTo: '2022-08-01', + }) + }) + }) + }) +}) diff --git a/admin/src/components/ContributionLinkList.vue b/admin/src/components/ContributionLinkList.vue new file mode 100644 index 000000000..518d7d57e --- /dev/null +++ b/admin/src/components/ContributionLinkList.vue @@ -0,0 +1,106 @@ + + diff --git a/admin/src/components/CreationFormular.spec.js b/admin/src/components/CreationFormular.spec.js index 08ec71bdc..6e4c1dc6e 100644 --- a/admin/src/components/CreationFormular.spec.js +++ b/admin/src/components/CreationFormular.spec.js @@ -1,14 +1,14 @@ import { mount } from '@vue/test-utils' import CreationFormular from './CreationFormular.vue' -import { createPendingCreation } from '../graphql/createPendingCreation' -import { createPendingCreations } from '../graphql/createPendingCreations' +import { adminCreateContribution } from '../graphql/adminCreateContribution' +import { adminCreateContributions } from '../graphql/adminCreateContributions' import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' const localVue = global.localVue const apolloMutateMock = jest.fn().mockResolvedValue({ data: { - createPendingCreation: [0, 0, 0], + adminCreateContribution: [0, 0, 0], }, }) const stateCommitMock = jest.fn() @@ -110,7 +110,7 @@ describe('CreationFormular', () => { it('sends ... to apollo', () => { expect(apolloMutateMock).toBeCalledWith( expect.objectContaining({ - mutation: createPendingCreation, + mutation: adminCreateContribution, variables: { email: 'benjamin@bluemchen.de', creationDate: getCreationDate(2), @@ -334,10 +334,10 @@ describe('CreationFormular', () => { jest.clearAllMocks() apolloMutateMock.mockResolvedValue({ data: { - createPendingCreations: { + adminCreateContributions: { success: true, - successfulCreation: ['bob@baumeister.de', 'bibi@bloxberg.de'], - failedCreation: [], + successfulContribution: ['bob@baumeister.de', 'bibi@bloxberg.de'], + failedContribution: [], }, }, }) @@ -355,7 +355,7 @@ describe('CreationFormular', () => { it('calls the API', () => { expect(apolloMutateMock).toBeCalledWith( expect.objectContaining({ - mutation: createPendingCreations, + mutation: adminCreateContributions, variables: { pendingCreations: [ { @@ -390,10 +390,10 @@ describe('CreationFormular', () => { jest.clearAllMocks() apolloMutateMock.mockResolvedValue({ data: { - createPendingCreations: { + adminCreateContributions: { success: true, - successfulCreation: [], - failedCreation: ['bob@baumeister.de', 'bibi@bloxberg.de'], + successfulContribution: [], + failedContribution: ['bob@baumeister.de', 'bibi@bloxberg.de'], }, }, }) diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index cdcd6ef1d..2201838de 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -85,8 +85,8 @@ + diff --git a/admin/src/components/Tables/OpenCreationsTable.spec.js b/admin/src/components/Tables/OpenCreationsTable.spec.js index 9ff348562..2b41a9b96 100644 --- a/admin/src/components/Tables/OpenCreationsTable.spec.js +++ b/admin/src/components/Tables/OpenCreationsTable.spec.js @@ -69,6 +69,7 @@ const propsData = { { key: 'edit_creation', label: 'edit' }, { key: 'confirm', label: 'save' }, ], + toggleDetails: false, } const mocks = { @@ -101,7 +102,7 @@ describe('OpenCreationsTable', () => { }) it('has a DIV element with the class .open-creations-table', () => { - expect(wrapper.find('div.open-creations-table').exists()).toBeTruthy() + expect(wrapper.find('div.open-creations-table').exists()).toBe(true) }) it('has a table with three rows', () => { @@ -109,7 +110,7 @@ describe('OpenCreationsTable', () => { }) it('find first button.bi-pencil-square for open EditCreationFormular ', () => { - expect(wrapper.findAll('tr').at(1).find('.bi-pencil-square').exists()).toBeTruthy() + expect(wrapper.findAll('tr').at(1).find('.bi-pencil-square').exists()).toBe(true) }) describe('show edit details', () => { @@ -122,7 +123,15 @@ describe('OpenCreationsTable', () => { }) it.skip('renders the component component-edit-creation-formular', () => { - expect(wrapper.find('div.component-edit-creation-formular').exists()).toBeTruthy() + expect(wrapper.find('div.component-edit-creation-formular').exists()).toBe(true) + }) + }) + + describe('call updateUserData', () => { + it('user creations has updated data', async () => { + wrapper.vm.updateUserData(propsData.items[0], [444, 555, 666]) + await wrapper.vm.$nextTick() + expect(wrapper.vm.items[0].creation).toEqual([444, 555, 666]) }) }) }) diff --git a/admin/src/components/Tables/OpenCreationsTable.vue b/admin/src/components/Tables/OpenCreationsTable.vue index d2e9669e6..1e61f00b0 100644 --- a/admin/src/components/Tables/OpenCreationsTable.vue +++ b/admin/src/components/Tables/OpenCreationsTable.vue @@ -70,12 +70,23 @@ export default { required: true, }, }, + data() { + return { + creationUserData: { + amount: null, + date: null, + memo: null, + moderator: null, + }, + } + }, methods: { updateCreationData(data) { - this.creationUserData.amount = data.amount - this.creationUserData.date = data.date - this.creationUserData.memo = data.memo - this.creationUserData.moderator = data.moderator + this.creationUserData = data + // this.creationUserData.amount = data.amount + // this.creationUserData.date = data.date + // this.creationUserData.memo = data.memo + // this.creationUserData.moderator = data.moderator data.row.toggleDetails() }, updateUserData(rowItem, newCreation) { diff --git a/admin/src/components/Tables/SearchUserTable.spec.js b/admin/src/components/Tables/SearchUserTable.spec.js index eb87357cc..e9072e54b 100644 --- a/admin/src/components/Tables/SearchUserTable.spec.js +++ b/admin/src/components/Tables/SearchUserTable.spec.js @@ -1,8 +1,6 @@ import { mount } from '@vue/test-utils' import SearchUserTable from './SearchUserTable.vue' -const date = new Date() - const localVue = global.localVue const apolloMutateMock = jest.fn().mockResolvedValue({}) @@ -96,16 +94,29 @@ describe('SearchUserTable', () => { await wrapper.findAll('tbody > tr').at(1).trigger('click') }) + describe('isAdmin', () => { + beforeEach(async () => { + await wrapper.find('div.change-user-role-formular').vm.$emit('updateIsAdmin', { + userId: 1, + isAdmin: new Date(), + }) + }) + + it('emits updateIsAdmin', () => { + expect(wrapper.emitted('updateIsAdmin')).toEqual([[1, expect.any(Date)]]) + }) + }) + describe('deleted at', () => { beforeEach(async () => { await wrapper.find('div.deleted-user-formular').vm.$emit('updateDeletedAt', { userId: 1, - deletedAt: date, + deletedAt: new Date(), }) }) it('emits updateDeletedAt', () => { - expect(wrapper.emitted('updateDeletedAt')).toEqual([[1, date]]) + expect(wrapper.emitted('updateDeletedAt')).toEqual([[1, expect.any(Date)]]) }) }) diff --git a/admin/src/components/Tables/SearchUserTable.vue b/admin/src/components/Tables/SearchUserTable.vue index 0be24a099..772160202 100644 --- a/admin/src/components/Tables/SearchUserTable.vue +++ b/admin/src/components/Tables/SearchUserTable.vue @@ -18,7 +18,7 @@