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', () => { describe('Room Team Management - Read only', () => {
beforeEach(() => { beforeEach(() => {
cy.fakeLogin('nino.teacher', 'test'); cy.setup();
cy.server();
cy.viewport('macbook-15');
cy.task('getSchema').then(schema => {
cy.mockGraphql({
schema,
mocks,
});
});
}); });
it('can edit room', () => { it('can edit room', () => {

View File

@ -27,8 +27,7 @@ const getOperations = ({readOnly, classReadOnly}) => ({
description: 'some description', description: 'some description',
schoolClass: { schoolClass: {
id: SELECTED_CLASS_ID, id: SELECTED_CLASS_ID,
name: 'bla', name: 'bla'
readOnly: classReadOnly,
}, },
}, },
}, },
@ -54,15 +53,7 @@ const checkRoomsReadOnly = ({editable, readOnly, classReadOnly = false}) => {
describe('Room Team Management - Read only', () => { describe('Room Team Management - Read only', () => {
beforeEach(() => { beforeEach(() => {
cy.fakeLogin('nino.teacher', 'test'); cy.setup();
cy.server();
cy.viewport('macbook-15');
cy.task('getSchema').then(schema => {
cy.mockGraphql({
schema,
mocks,
});
});
}); });
it('can edit room', () => { 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 // todo: once above issue is fixed, go back to the original repo -> npm install cypress-graphql-mock
// import 'cypress-graphql-mock'; // import 'cypress-graphql-mock';
import '@iam4x/cypress-graphql-mock'; import '@iam4x/cypress-graphql-mock';
import mocks from '../fixtures/mocks';
Cypress.Commands.add('apolloLogin', (username, password) => { Cypress.Commands.add('apolloLogin', (username, password) => {
const payload = { const payload = {
@ -161,3 +162,15 @@ Cypress.Commands.add('isSubmissionReadOnly', (myText) => {
Cypress.Commands.add('openSidebar', () => { Cypress.Commands.add('openSidebar', () => {
cy.getByDataCy('user-widget-avatar').click(); 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 isSubmissionReadOnly(myText: string): void
openSidebar(): void openSidebar(): void
setup(): void
} }
} }

View File

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

View File

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