Add frontend tests for snapshot menu

This commit is contained in:
Ramon Wenger 2021-05-12 16:50:51 +02:00
parent 38313ecb26
commit 7b42f3c187
3 changed files with 63 additions and 5 deletions

View File

@ -1,8 +1,64 @@
import minimalMe from '../../fixtures/me.minimal';
const me = isTeacher => ({
...minimalMe,
isTeacher,
});
const module = () => ({
title: 'title',
metaTitle: 'metaTitle',
heroImage: 'heroImage',
teaser: 'teaser',
intro: 'intro',
assignments: {},
objectiveGroups: [],
id: '',
chapters: [],
});
const operations = isTeacher => ({
operations: {
MeQuery: {
me: me(isTeacher),
},
ModuleDetailsQuery: {
module: module(),
},
},
});
describe('Snapshot', () => {
it('Menu is visible for teacher', () => {
cy.get('NotImplemented');
beforeEach(() => {
cy.server();
cy.task('getSchema').then(schema => {
cy.mockGraphql({
schema,
mocks: {
UUID: () => '123-456-789',
GenericStreamFieldType: () => 'GenericStreamFieldType',
},
});
});
cy.viewport('macbook-15');
});
it('Menu is visible for teacher', () => {
cy.fakeLogin('nico.zickgraf', 'test');
cy.mockGraphqlOps(operations(true));
cy.visit('module/miteinander-reden/');
cy.getByDataCy('snapshot-menu').should('be.visible');
});
it('Menu is not visible for student', () => {
cy.get('NotImplemented');
cy.fakeLogin('rahel.cueni', 'test');
cy.mockGraphqlOps(operations(false));
cy.visit('module/miteinander-reden/');
cy.getByDataCy('module-title').should('be.visible');
cy.getByDataCy('snapshot-menu').should('not.exist');
});
});

View File

@ -1,5 +1,7 @@
<template>
<div class="snapshot-menu">
<div
class="snapshot-menu"
data-cy="snapshot-menu">
<a
data-cy="module-snapshots-button"
class="snapshot-menu__toggle"

View File

@ -32,7 +32,7 @@ export default {
return this.me.selectedClass;
},
canManageContent() {
return this.me.permissions.includes('users.can_manage_school_class_content');
return this.me.isTeacher;
},
currentClassName() {
let currentClass = this.me.schoolClasses.find(schoolClass => {