Add new test for room entry actions
This commit is contained in:
parent
8c5bc36728
commit
de03792029
|
|
@ -173,4 +173,42 @@ describe('The Room Page', () => {
|
||||||
cy.url().should('include', 'rooms');
|
cy.url().should('include', 'rooms');
|
||||||
cy.getByDataCy('room-widget').should('have.length', 1);
|
cy.getByDataCy('room-widget').should('have.length', 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('edits own room entry', () => {
|
||||||
|
const MeQuery = getMinimalMe({isTeacher: false});
|
||||||
|
const {me} = MeQuery;
|
||||||
|
const id = atob(me.id).split(':')[1];
|
||||||
|
const authorId = btoa(`PublicUserNode:${id}`);
|
||||||
|
const room = {
|
||||||
|
id: 'some-room',
|
||||||
|
roomEntries: {
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
id: '',
|
||||||
|
slug: '',
|
||||||
|
contents: [],
|
||||||
|
author: {
|
||||||
|
...me,
|
||||||
|
id: authorId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const operations = {
|
||||||
|
MeQuery: MeQuery,
|
||||||
|
RoomEntriesQuery: {
|
||||||
|
room
|
||||||
|
},
|
||||||
|
RoomEntryQuery: {}
|
||||||
|
};
|
||||||
|
cy.mockGraphqlOps({
|
||||||
|
operations
|
||||||
|
});
|
||||||
|
cy.visit(`/room/${slug}`);
|
||||||
|
cy.getByDataCy('room-entry-actions').click();
|
||||||
|
cy.getByDataCy('edit-room-entry').click();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// todo: clean up this file
|
// todo: clean up this file
|
||||||
|
|
||||||
export const getMinimalMe = ({readOnly = false, classReadOnly = false, isTeacher = true}) => ({
|
export const getMinimalMe = ({readOnly = false, classReadOnly = false, isTeacher = true} = {}) => ({
|
||||||
me: {
|
me: {
|
||||||
id: btoa('PrivateUserNode:1'),
|
id: btoa('PrivateUserNode:1'),
|
||||||
readOnly,
|
readOnly,
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,12 @@
|
||||||
<div class="room-entry">
|
<div class="room-entry">
|
||||||
<more-options-widget
|
<more-options-widget
|
||||||
class="room-entry__more"
|
class="room-entry__more"
|
||||||
|
data-cy="room-entry-actions"
|
||||||
v-if="myEntry">
|
v-if="myEntry">
|
||||||
<li class="popover-links__link"><a @click="deleteRoomEntry(id)">Eintrag löschen</a></li>
|
<li class="popover-links__link"><a @click="deleteRoomEntry(id)">Eintrag löschen</a></li>
|
||||||
<li class="popover-links__link"><a @click="editRoomEntry(id)">Eintrag bearbeiten</a></li>
|
<li class="popover-links__link"><a
|
||||||
|
data-cy="edit-room-entry"
|
||||||
|
@click="editRoomEntry(id)">Eintrag bearbeiten</a></li>
|
||||||
</more-options-widget>
|
</more-options-widget>
|
||||||
<router-link
|
<router-link
|
||||||
:to="{name: 'article', params: { slug: slug }}"
|
:to="{name: 'article', params: { slug: slug }}"
|
||||||
|
|
@ -61,7 +64,9 @@
|
||||||
return teaser(this.contents);
|
return teaser(this.contents);
|
||||||
},
|
},
|
||||||
myEntry() {
|
myEntry() {
|
||||||
return this.author.id === this.me.id;
|
const authorId = atob(this.author.id).split(':')[1];
|
||||||
|
const userId = atob(this.me.id).split(':')[1];
|
||||||
|
return authorId === userId;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue