Fix content block deletion bug
This commit is contained in:
parent
e86d67ae35
commit
ab65e07a1d
|
|
@ -1,10 +1,17 @@
|
||||||
export default {
|
const minimalMe = {
|
||||||
username: '',
|
username: '',
|
||||||
firstName: '',
|
firstName: '',
|
||||||
lastName: '',
|
lastName: '',
|
||||||
avatarUrl: '',
|
avatarUrl: '',
|
||||||
email: '',
|
email: '',
|
||||||
onboardingVisited: true,
|
onboardingVisited: true,
|
||||||
schoolClasses: {},
|
schoolClasses: {},
|
||||||
id: '',
|
id: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getMe = isTeacher => ({
|
||||||
|
...minimalMe,
|
||||||
|
isTeacher,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default getMe;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
export default {
|
export default {
|
||||||
title: 'title',
|
title: 'A Module Mock Title',
|
||||||
metaTitle: 'metaTitle',
|
metaTitle: 'A Module Meta Mock Title',
|
||||||
heroImage: 'heroImage',
|
heroImage: 'heroImage',
|
||||||
teaser: 'teaser',
|
teaser: 'A Module Mock Teaser',
|
||||||
intro: 'intro',
|
intro: 'intro',
|
||||||
assignments: {},
|
assignments: {},
|
||||||
objectiveGroups: [],
|
objectiveGroups: [],
|
||||||
id: '',
|
id: '',
|
||||||
chapters: [],
|
chapters: [],
|
||||||
|
topic: {
|
||||||
|
title: 'A Topic Mock Title',
|
||||||
|
description: 'A Topic Mock Description'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
import getMe from '../../fixtures/me.minimal';
|
||||||
|
import module from '../../fixtures/module.minimal';
|
||||||
|
import mocks from '../../fixtures/mocks';
|
||||||
|
|
||||||
|
// title: String
|
||||||
|
// slug: String!
|
||||||
|
// hiddenFor: [SchoolClassNode]
|
||||||
|
// visibleFor: [SchoolClassNode]
|
||||||
|
// userCreated: Boolean!
|
||||||
|
// contents: GenericStreamFieldType
|
||||||
|
// type: String
|
||||||
|
// id: ID!
|
||||||
|
// mine: Boolean
|
||||||
|
// bookmarks: [ContentBlockBookmarkNode]
|
||||||
|
// originalCreator: PublicUserNode
|
||||||
|
const chapters = [{
|
||||||
|
title: 'ABC',
|
||||||
|
description: 'DEF',
|
||||||
|
contentBlocks: [
|
||||||
|
{
|
||||||
|
title: 'A ContentBlock',
|
||||||
|
userCreated: true,
|
||||||
|
mine: true,
|
||||||
|
contents: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}];
|
||||||
|
|
||||||
|
const operations = {
|
||||||
|
MeQuery: {
|
||||||
|
me: getMe(true),
|
||||||
|
},
|
||||||
|
ModuleDetailsQuery: {
|
||||||
|
module: {
|
||||||
|
...module,
|
||||||
|
chapters,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
DeleteContentBlock: {
|
||||||
|
success: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('Custom Content Block', () => {
|
||||||
|
before(() => {
|
||||||
|
cy.task('getSchema').then(schema => {
|
||||||
|
cy.mockGraphql({
|
||||||
|
schema,
|
||||||
|
mocks,
|
||||||
|
operations,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
cy.viewport('macbook-15');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Deletes the custom content block and removes it from the view', () => {
|
||||||
|
cy.fakeLogin('nico.zickgraf', 'test');
|
||||||
|
cy.visit('module/some-module');
|
||||||
|
|
||||||
|
cy.log('Toggling Edit Mode');
|
||||||
|
cy.getByDataCy('toggle-editing').click();
|
||||||
|
|
||||||
|
cy.getByDataCy('module-title').should('exist');
|
||||||
|
cy.get('.content-block').should('have.length', 1);
|
||||||
|
|
||||||
|
cy.log('Opening More Menu');
|
||||||
|
cy.getByDataCy('more-options-link').click();
|
||||||
|
|
||||||
|
// check if content block is still there
|
||||||
|
cy.log('Deleting Content Block');
|
||||||
|
cy.getByDataCy('delete-content-block-link').click();
|
||||||
|
|
||||||
|
cy.get('.content-block').should('have.length', 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -1,16 +1,11 @@
|
||||||
import minimalMe from '../../fixtures/me.minimal';
|
import getMe from '../../fixtures/me.minimal';
|
||||||
import module from '../../fixtures/module.minimal';
|
import module from '../../fixtures/module.minimal';
|
||||||
import mocks from '../../fixtures/mocks';
|
import mocks from '../../fixtures/mocks';
|
||||||
|
|
||||||
const me = isTeacher => ({
|
|
||||||
...minimalMe,
|
|
||||||
isTeacher,
|
|
||||||
});
|
|
||||||
|
|
||||||
const operations = isTeacher => ({
|
const operations = isTeacher => ({
|
||||||
operations: {
|
operations: {
|
||||||
MeQuery: {
|
MeQuery: {
|
||||||
me: me(isTeacher),
|
me: getMe(isTeacher),
|
||||||
},
|
},
|
||||||
ModuleDetailsQuery: {
|
ModuleDetailsQuery: {
|
||||||
module,
|
module,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
// ***********************************************************
|
// ***********************************************************
|
||||||
|
|
||||||
// Import commands.js using ES2015 syntax:
|
// Import commands.js using ES2015 syntax:
|
||||||
import './commands'
|
import './commands';
|
||||||
|
|
||||||
// Alternatively you can use CommonJS syntax:
|
// Alternatively you can use CommonJS syntax:
|
||||||
// require('./commands')
|
// require('./commands')
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,9 @@
|
||||||
v-bind="me"
|
v-bind="me"
|
||||||
class="block-actions__user-widget content-block__user-widget"/>
|
class="block-actions__user-widget content-block__user-widget"/>
|
||||||
<more-options-widget>
|
<more-options-widget>
|
||||||
<li class="popover-links__link"><a @click="deleteContentBlock(contentBlock)">Löschen</a></li>
|
<li class="popover-links__link"><a
|
||||||
|
data-cy="delete-content-block-link"
|
||||||
|
@click="deleteContentBlock(contentBlock)">Löschen</a></li>
|
||||||
<li class="popover-links__link"><a @click="editContentBlock(contentBlock)">Bearbeiten</a></li>
|
<li class="popover-links__link"><a @click="editContentBlock(contentBlock)">Bearbeiten</a></li>
|
||||||
</more-options-widget>
|
</more-options-widget>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -193,7 +195,7 @@
|
||||||
id: parent
|
id: parent
|
||||||
};
|
};
|
||||||
const data = store.readQuery({query, variables});
|
const data = store.readQuery({query, variables});
|
||||||
data.chapter.contentBlocks.edges.splice(data.chapter.contentBlocks.edges.findIndex(edge => edge.node.id === id), 1);
|
data.chapter.contentBlocks.splice(data.chapter.contentBlocks.findIndex(contentBlock => contentBlock.id === id), 1);
|
||||||
store.writeQuery({query, variables, data});
|
store.writeQuery({query, variables, data});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
<div class="more-options">
|
<div class="more-options">
|
||||||
<a
|
<a
|
||||||
class="more-options__more-link"
|
class="more-options__more-link"
|
||||||
|
data-cy="more-options-link"
|
||||||
@click="showMenu = !showMenu">
|
@click="showMenu = !showMenu">
|
||||||
<ellipses class="more-options__ellipses"/>
|
<ellipses class="more-options__ellipses"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<toggle
|
<toggle
|
||||||
:checked="checked"
|
:checked="checked"
|
||||||
|
data-cy="toggle-editing"
|
||||||
label="Modul anpassen"
|
label="Modul anpassen"
|
||||||
@input="toggle"/>
|
@input="toggle"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue