Make new tests succeed

This commit is contained in:
Ramon Wenger 2021-07-29 10:52:13 +02:00
parent 37e5c7cf64
commit d4182e7e1a
7 changed files with 28 additions and 27 deletions

View File

@ -64,15 +64,7 @@ const checkRoomReadOnly = ({editable, readOnly, classReadOnly = false}) => {
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,
});
});
cy.setup();
});
it('can edit room', () => {

View File

@ -27,8 +27,7 @@ const getOperations = ({readOnly, classReadOnly}) => ({
description: 'some description',
schoolClass: {
id: SELECTED_CLASS_ID,
name: 'bla',
readOnly: classReadOnly,
name: 'bla'
},
},
},
@ -54,15 +53,7 @@ const checkRoomsReadOnly = ({editable, readOnly, classReadOnly = false}) => {
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,
});
});
cy.setup();
});
it('can edit room', () => {

View File

@ -28,6 +28,7 @@
// todo: once above issue is fixed, go back to the original repo -> npm install cypress-graphql-mock
// import 'cypress-graphql-mock';
import '@iam4x/cypress-graphql-mock';
import mocks from '../fixtures/mocks';
Cypress.Commands.add('apolloLogin', (username, password) => {
const payload = {
@ -161,3 +162,15 @@ Cypress.Commands.add('isSubmissionReadOnly', (myText) => {
Cypress.Commands.add('openSidebar', () => {
cy.getByDataCy('user-widget-avatar').click();
});
Cypress.Commands.add('setup', () => {
cy.fakeLogin('nino.teacher', 'test');
cy.server();
cy.viewport('macbook-15');
cy.task('getSchema').then(schema => {
cy.mockGraphql({
schema,
mocks,
});
});
});

View File

@ -29,5 +29,7 @@ declare namespace Cypress {
isSubmissionReadOnly(myText: string): void
openSidebar(): void
setup(): void
}
}

View File

@ -1,5 +1,7 @@
<template>
<div class="room-actions">
<div
class="room-actions"
data-cy="room-actions">
<a
class="room-actions__more-link"
@click="toggleMenu">
@ -68,8 +70,7 @@
</script>
<style scoped lang="scss">
@import "@/styles/_variables.scss";
@import "@/styles/_mixins.scss";
@import "~styles/helpers";
.room-actions {
&__more-link {

View File

@ -51,7 +51,7 @@
return `room-widget--${this.appearance}`;
},
canEditRoom() {
return this.me.permissions.includes('users.can_manage_school_class_content');
return this.me.isTeacher && !this.me.readOnly && !this.me.selectedClass.readOnly;
}
},

View File

@ -6,7 +6,9 @@
{{ room.description }}
</p>
<div class="room__meta">
<room-actions :id="room.id"/>
<room-actions
:id="room.id"
v-if="canEdit"/>
<room-group-widget v-bind="room.schoolClass"/>
<entry-count-widget :entry-count="roomEntryCount"/>
</div>
@ -14,7 +16,7 @@
<div class="room__content">
<add-room-entry-button
:parent="room"
v-if="room.id && canAdd">
v-if="room.id && canEdit">
<!--
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
@ -38,7 +40,7 @@
mixins: [room, me],
computed: {
canAdd() {
canEdit() {
return !this.me.readOnly && !this.me.selectedClass.readOnly;
}
},