Disable activating and deactivating users when in read only mode
This commit is contained in:
parent
4977644fa4
commit
e32b49ad5f
|
|
@ -1,9 +1,10 @@
|
|||
import {getMinimalMe} from '../../../support/helpers';
|
||||
|
||||
const MeQuery = getMinimalMe({readOnly: false});
|
||||
const me = MeQuery.me;
|
||||
const getOperations = (readOnly = false, classReadOnly = false) => {
|
||||
const MeQuery = getMinimalMe({readOnly, classReadOnly});
|
||||
const me = MeQuery.me;
|
||||
|
||||
const getOperations = () => ({
|
||||
return {
|
||||
MeQuery,
|
||||
MySchoolClassQuery: {
|
||||
me: {
|
||||
|
|
@ -19,6 +20,22 @@ const getOperations = () => ({
|
|||
isTeacher: true,
|
||||
isMe: true,
|
||||
active: true
|
||||
},
|
||||
{
|
||||
id: 'notMeId',
|
||||
firstName: 'Otto',
|
||||
lastName: 'Waalkes',
|
||||
isTeacher: false,
|
||||
isMe: false,
|
||||
active: true
|
||||
},
|
||||
{
|
||||
id: 'alsoNotMeId',
|
||||
firstName: 'Kaya',
|
||||
lastName: 'Yanar',
|
||||
isTeacher: false,
|
||||
isMe: false,
|
||||
active: false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -29,22 +46,49 @@ const getOperations = () => ({
|
|||
success: true
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
describe('Leave School Class', () => {
|
||||
beforeEach(() => {
|
||||
cy.setup();
|
||||
});
|
||||
|
||||
it('leaves class', () => {
|
||||
it('can leave class', () => {
|
||||
cy.mockGraphqlOps({
|
||||
operations: getOperations(),
|
||||
});
|
||||
|
||||
cy.visit('/me/class');
|
||||
|
||||
cy.getByDataCy('remove-from-class').should('exist');
|
||||
cy.getByDataCy('add-to-class').should('exist');
|
||||
cy.getByDataCy('leave-group').click();
|
||||
cy.getByDataCy('modal-save-button').click();
|
||||
cy.getByDataCy('read-only-banner').should('exist');
|
||||
});
|
||||
|
||||
it('can not leave class when license invalid', () => {
|
||||
cy.mockGraphqlOps({
|
||||
operations: getOperations(true),
|
||||
});
|
||||
|
||||
cy.visit('/me/class');
|
||||
|
||||
cy.getByDataCy('remove-from-class').should('not.exist');
|
||||
cy.getByDataCy('add-to-class').should('not.exist');
|
||||
cy.getByDataCy('leave-group').should('not.exist');
|
||||
});
|
||||
|
||||
it('can not leave class when class inactive', () => {
|
||||
cy.mockGraphqlOps({
|
||||
operations: getOperations(false, true),
|
||||
});
|
||||
|
||||
cy.visit('/me/class');
|
||||
|
||||
cy.getByDataCy('remove-from-class').should('not.exist');
|
||||
cy.getByDataCy('add-to-class').should('not.exist');
|
||||
cy.getByDataCy('leave-group').should('not.exist');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
<a
|
||||
class="member-item__action simple-list__action"
|
||||
data-cy="leave-group"
|
||||
v-if="member.isMe"
|
||||
v-if="member.isMe && enableDeactivate"
|
||||
@click="$emit('leave', member)">Verlassen</a>
|
||||
<a
|
||||
class="member-item__action simple-list__action"
|
||||
|
|
@ -56,7 +56,7 @@
|
|||
<a
|
||||
class="member-item__action simple-list__action"
|
||||
data-cy="add-to-class"
|
||||
v-if="canEdit"
|
||||
v-if="canEdit && enableDeactivate"
|
||||
@click="$emit('add', member)">Aktivieren</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
:show-code-route="showCodeRoute"
|
||||
:read-only="me.readOnly"
|
||||
:can-edit="me.isTeacher"
|
||||
:enable-deactivate="true"
|
||||
:enable-deactivate="!me.readOnly && !me.selectedClass.readOnly"
|
||||
title="Klassenliste"
|
||||
class="my-class__class"
|
||||
@add="add"
|
||||
|
|
|
|||
Loading…
Reference in New Issue