Refactoring & Feature: edit/delete controls of tasks (#11357)
* Refactoring & Feature: edit/delete group and challenge tasks - Remove showOption from tasks props - Pass all needed data to task for understand in mapGetter function which controls we should show - Improve current solution with edit and delete logic * Fix: this in template * Fix & Test: extend tests, fix can Edit/Delete functions
This commit is contained in:
committed by
Matteo Pagliazzi
parent
c6281b6f17
commit
70b6501135
@@ -6,7 +6,7 @@ describe('canDelete getter', () => {
|
||||
|
||||
|
||||
const task = {userId: 1, challenge: {id: 2}};
|
||||
expect(store.getters['tasks:canDelete'](task)).to.equal(false);
|
||||
expect(store.getters['tasks:canDelete'](task, 'challenge', true, null, null)).to.equal(false);
|
||||
});
|
||||
|
||||
it('can delete broken challenge task', () => {
|
||||
@@ -14,6 +14,6 @@ describe('canDelete getter', () => {
|
||||
|
||||
|
||||
const task = {userId: 1, challenge: {id: 2, broken: true}};
|
||||
expect(store.getters['tasks:canDelete'](task)).to.equal(true);
|
||||
expect(store.getters['tasks:canDelete'](task, 'challenge', true, null, null)).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import generateStore from 'client/store';
|
||||
|
||||
describe('canEdit getter', () => {
|
||||
it('cannot Edit active challenge task', () => {
|
||||
const store = generateStore();
|
||||
|
||||
|
||||
const task = {userId: 1, challenge: {id: 2}};
|
||||
expect(store.getters['tasks:canEdit'](task, 'challenge', true, null, null)).to.equal(false);
|
||||
});
|
||||
|
||||
it('can Edit broken challenge task', () => {
|
||||
const store = generateStore();
|
||||
|
||||
|
||||
const task = {userId: 1, challenge: {id: 2, broken: true}};
|
||||
expect(store.getters['tasks:canEdit'](task, 'challenge', true, null, null)).to.equal(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user