Rename test, add new frontend test for single room view
This commit is contained in:
parent
ff9f2bdd81
commit
11aac2ec94
|
|
@ -14,25 +14,36 @@ const getOperations = ({readOnly, classReadOnly}) => ({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
RoomsQuery: {
|
RoomEntriesQuery: {
|
||||||
rooms: {
|
room: {
|
||||||
edges: [
|
id: 'roomId',
|
||||||
{
|
slug: '',
|
||||||
node: {
|
title: 'room title',
|
||||||
id: '',
|
entryCount: 3,
|
||||||
slug: '',
|
appearance: 'blue',
|
||||||
title: 'some room',
|
description: 'room description',
|
||||||
entryCount: 3,
|
schoolClass: {
|
||||||
appearance: 'red',
|
id: SELECTED_CLASS_ID,
|
||||||
description: 'some description',
|
name: 'selected class',
|
||||||
schoolClass: {
|
},
|
||||||
id: SELECTED_CLASS_ID,
|
roomEntries: {
|
||||||
name: 'bla',
|
edges: [
|
||||||
readOnly: classReadOnly,
|
{
|
||||||
|
node: {
|
||||||
|
id: 'entryId',
|
||||||
|
slug: '',
|
||||||
|
title: 'entry title',
|
||||||
|
contents: [],
|
||||||
|
author: {
|
||||||
|
id: 'authorId',
|
||||||
|
firstName: 'first',
|
||||||
|
lastName: 'last',
|
||||||
|
avatarUrl: ''
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -45,10 +56,9 @@ const checkRoomReadOnly = ({editable, readOnly, classReadOnly = false}) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const exist = editable ? 'exist' : 'not.exist';
|
const exist = editable ? 'exist' : 'not.exist';
|
||||||
cy.visit('rooms');
|
cy.visit('room/some-room');
|
||||||
cy.log('visit');
|
cy.get('.room-entry').should('exist');
|
||||||
cy.get('.room-widget').should('exist');
|
cy.getByDataCy('add-room-entry-button').should(exist);
|
||||||
cy.getByDataCy('add-room').should(exist);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Room Team Management - Read only', () => {
|
describe('Room Team Management - Read only', () => {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
import mocks from '../../../fixtures/mocks';
|
||||||
|
|
||||||
|
const SELECTED_CLASS_ID = 'selectedClassId';
|
||||||
|
|
||||||
|
const getOperations = ({readOnly, classReadOnly}) => ({
|
||||||
|
MeQuery: {
|
||||||
|
me: {
|
||||||
|
onboardingVisited: true,
|
||||||
|
readOnly,
|
||||||
|
isTeacher: true,
|
||||||
|
selectedClass: {
|
||||||
|
id: SELECTED_CLASS_ID,
|
||||||
|
readOnly: classReadOnly,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
RoomsQuery: {
|
||||||
|
rooms: {
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
id: '',
|
||||||
|
slug: '',
|
||||||
|
title: 'some room',
|
||||||
|
entryCount: 3,
|
||||||
|
appearance: 'red',
|
||||||
|
description: 'some description',
|
||||||
|
schoolClass: {
|
||||||
|
id: SELECTED_CLASS_ID,
|
||||||
|
name: 'bla',
|
||||||
|
readOnly: classReadOnly,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const checkRoomsReadOnly = ({editable, readOnly, classReadOnly = false}) => {
|
||||||
|
const operations = getOperations({readOnly, classReadOnly});
|
||||||
|
|
||||||
|
cy.mockGraphqlOps({
|
||||||
|
operations,
|
||||||
|
});
|
||||||
|
|
||||||
|
const exist = editable ? 'exist' : 'not.exist';
|
||||||
|
cy.visit('rooms');
|
||||||
|
cy.log('visit');
|
||||||
|
cy.get('.room-widget').should('exist');
|
||||||
|
cy.getByDataCy('add-room').should(exist);
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('Room Team Management - Read only', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.fakeLogin('nino.teacher', 'test');
|
||||||
|
cy.server();
|
||||||
|
cy.viewport('macbook-15');
|
||||||
|
cy.task('getSchema').then(schema => {
|
||||||
|
cy.mockGraphql({
|
||||||
|
schema,
|
||||||
|
mocks,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can edit room', () => {
|
||||||
|
checkRoomsReadOnly({editable: true, readOnly: false});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can not edit room', () => {
|
||||||
|
checkRoomsReadOnly({editable: false, readOnly: true});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can not edit room of inactive class', () => {
|
||||||
|
checkRoomsReadOnly({editable: false, readOnly: false, classReadOnly: true});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
<div class="room__content">
|
<div class="room__content">
|
||||||
<add-room-entry-button
|
<add-room-entry-button
|
||||||
:parent="room"
|
:parent="room"
|
||||||
v-if="room.id">
|
v-if="room.id && canAdd">
|
||||||
<!--
|
<!--
|
||||||
the v-if is there for the case where the room hasn't loaded yet, but there is already an attempt to create
|
the v-if is there for the case where the room hasn't loaded yet, but there is already an attempt to create
|
||||||
a new room entry. mainly happens during cypress testing, but could also happen on a very slow connection
|
a new room entry. mainly happens during cypress testing, but could also happen on a very slow connection
|
||||||
|
|
@ -30,11 +30,18 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ROOM_ENTRIES_QUERY from '@/graphql/gql/queries/roomEntriesQuery.gql';
|
import ROOM_ENTRIES_QUERY from '@/graphql/gql/queries/roomEntriesQuery.gql';
|
||||||
import roomMixin from '@/mixins/room';
|
import room from '@/mixins/room';
|
||||||
|
import me from '@/mixins/me';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['slug'],
|
props: ['slug'],
|
||||||
mixins: [roomMixin],
|
mixins: [room, me],
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
canAdd() {
|
||||||
|
return !this.me.readOnly && !this.me.selectedClass.readOnly;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
apollo: {
|
apollo: {
|
||||||
modules: {
|
modules: {
|
||||||
|
|
@ -59,5 +66,5 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import "@/styles/_room.scss";
|
@import "~styles/room";
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue