Update frontend tests

This commit is contained in:
Ramon Wenger 2021-08-30 16:34:35 +02:00
parent c1ef6a2aee
commit 84d9836c41
3 changed files with 35 additions and 18 deletions

View File

@ -15,7 +15,7 @@ describe('The Room Page', () => {
};
const RoomEntriesQuery = {
room
room,
};
const operations = {
@ -29,9 +29,9 @@ describe('The Room Page', () => {
{
type: 'text_block',
value: {
text: entryText
}
}
text: entryText,
},
},
],
author: {
firstName: 'Rachel',
@ -65,9 +65,24 @@ describe('The Room Page', () => {
cy.get('.room-entry__content:first').should('contain', entryText).should('contain', 'Rachel Green');
});
it.only('changes visibility of a room', () => {
it('room actions should not exist for student', () => {
const operations = {
MeQuery: getMinimalMe({isTeacher: false}),
RoomEntriesQuery,
};
cy.mockGraphqlOps({
operations,
});
cy.visit(`/room/${slug}`);
cy.getByDataCy('room-title').should('exist');
cy.getByDataCy('room-actions').should('not.exist');
});
it('changes visibility of a room', () => {
const MeQuery = getMinimalMe({
isTeacher: true
isTeacher: true,
});
const operations = {
MeQuery,
@ -77,10 +92,10 @@ describe('The Room Page', () => {
success: true,
room: {
...room,
restricted: true
}
}
}
restricted: true,
},
},
},
};
cy.mockGraphqlOps({

View File

@ -72,7 +72,7 @@ describe('The Rooms Page', () => {
cy.get('[data-cy=add-room]').should('exist');
});
it('add room should not exist for student', () => {
it('actions should not exist for student', () => {
const operations = getOperations(false);
cy.mockGraphqlOps({
operations,
@ -81,7 +81,7 @@ describe('The Rooms Page', () => {
cy.visit('/rooms');
cy.getByDataCy('room-widget').should('have.length', 1);
cy.get('[data-cy=add-room]').should('not.exist');
cy.getByDataCy('toggle-room-actions-menu').should('not.exist');
});
it('adds a room as teacher', () => {

View File

@ -12,7 +12,9 @@
v-if="canEdit"/>
</div>
<div class="room__header">
<h1 class="room__title">{{ room.title }}</h1>
<h1
class="room__title"
data-cy="room-title">{{ room.title }}</h1>
<p class="room__intro">
{{ room.description }}
</p>
@ -55,8 +57,8 @@
computed: {
canEdit() {
return !this.me.readOnly && !this.me.selectedClass.readOnly;
}
return this.me.isTeacher && !this.me.readOnly && !this.me.selectedClass.readOnly;
},
},
apollo: {
@ -64,7 +66,7 @@
query: ROOM_ENTRIES_QUERY,
variables() {
return {
slug: this.slug
slug: this.slug,
};
},
update({room}) {
@ -72,8 +74,8 @@
return this.$getRidOfEdges(room);
},
pollInterval: 5000,
}
}
},
},
};
</script>