Fix cypress test

This commit is contained in:
Ramon Wenger 2021-08-31 18:50:35 +02:00
parent 94a13f4a15
commit 1a3d9afd31
3 changed files with 38 additions and 36 deletions

View File

@ -1,51 +1,54 @@
import mocks from '../../../fixtures/mocks'; import {getMinimalMe} from '../../../support/helpers';
const SELECTED_CLASS_ID = 'selectedClassId'; const SELECTED_CLASS_ID = 'selectedClassId';
const getOperations = ({readOnly, classReadOnly}) => ({ const getOperations = ({readOnly, classReadOnly}) => {
MeQuery: { const {me} = getMinimalMe({readOnly, classReadOnly, isTeacher: true});
me: { return {
readOnly, MeQuery: {
isTeacher: true, me: {
selectedClass: { ...me,
id: SELECTED_CLASS_ID, readOnly,
readOnly: classReadOnly, selectedClass: {
id: SELECTED_CLASS_ID,
readOnly: classReadOnly,
},
}, },
}, },
}, RoomEntriesQuery: {
RoomEntriesQuery: { room: {
room: { id: 'roomId',
id: 'roomId', slug: '',
slug: '', title: 'room title',
title: 'room title', entryCount: 3,
entryCount: 3, appearance: 'blue',
appearance: 'blue', description: 'room description',
description: 'room description', schoolClass: {
schoolClass: { id: SELECTED_CLASS_ID,
id: SELECTED_CLASS_ID, name: 'selected class',
name: 'selected class', },
}, roomEntries: {
roomEntries: { edges: [
edges: [ {
{ node: {
node: { id: 'entryId',
id: 'entryId',
slug: '', slug: '',
title: 'entry title', title: 'entry title',
contents: [], contents: [],
author: { author: {
id: 'authorId', id: btoa('PublicUserNode:authorId'),
firstName: 'first', firstName: 'first',
lastName: 'last', lastName: 'last',
avatarUrl: '' avatarUrl: '',
} },
},
}, },
}, ],
], },
}, },
}, },
}, };
}); };
const checkRoomReadOnly = ({editable, readOnly, classReadOnly = false}) => { const checkRoomReadOnly = ({editable, readOnly, classReadOnly = false}) => {
const operations = getOperations({readOnly, classReadOnly}); const operations = getOperations({readOnly, classReadOnly});

View File

@ -232,7 +232,7 @@ describe('The Room Page', () => {
}); });
cy.visit(`/room/${slug}`); cy.visit(`/room/${slug}`);
cy.getByDataCy('add-room-entry').click(); cy.getByDataCy('add-room-entry-button').click();
cy.getByDataCy('add-room-entry-modal').should('exist'); cy.getByDataCy('add-room-entry-modal').should('exist');
}); });
}); });

View File

@ -30,7 +30,6 @@
<div class="room__content"> <div class="room__content">
<add-room-entry-button <add-room-entry-button
:parent="room" :parent="room"
data-cy="add-room-entry"
v-if="room.id && !isReadOnly"> v-if="room.id && !isReadOnly">
<!-- <!--
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