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';
|
import {getMinimalMe} from '../../../support/helpers';
|
||||||
|
|
||||||
const MeQuery = getMinimalMe({readOnly: false});
|
const getOperations = (readOnly = false, classReadOnly = false) => {
|
||||||
const me = MeQuery.me;
|
const MeQuery = getMinimalMe({readOnly, classReadOnly});
|
||||||
|
const me = MeQuery.me;
|
||||||
|
|
||||||
const getOperations = () => ({
|
return {
|
||||||
MeQuery,
|
MeQuery,
|
||||||
MySchoolClassQuery: {
|
MySchoolClassQuery: {
|
||||||
me: {
|
me: {
|
||||||
|
|
@ -19,6 +20,22 @@ const getOperations = () => ({
|
||||||
isTeacher: true,
|
isTeacher: true,
|
||||||
isMe: true,
|
isMe: true,
|
||||||
active: 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
|
success: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
};
|
||||||
|
|
||||||
describe('Leave School Class', () => {
|
describe('Leave School Class', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.setup();
|
cy.setup();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('leaves class', () => {
|
it('can leave class', () => {
|
||||||
cy.mockGraphqlOps({
|
cy.mockGraphqlOps({
|
||||||
operations: getOperations(),
|
operations: getOperations(),
|
||||||
});
|
});
|
||||||
|
|
||||||
cy.visit('/me/class');
|
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('leave-group').click();
|
||||||
cy.getByDataCy('modal-save-button').click();
|
cy.getByDataCy('modal-save-button').click();
|
||||||
cy.getByDataCy('read-only-banner').should('exist');
|
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
|
<a
|
||||||
class="member-item__action simple-list__action"
|
class="member-item__action simple-list__action"
|
||||||
data-cy="leave-group"
|
data-cy="leave-group"
|
||||||
v-if="member.isMe"
|
v-if="member.isMe && enableDeactivate"
|
||||||
@click="$emit('leave', member)">Verlassen</a>
|
@click="$emit('leave', member)">Verlassen</a>
|
||||||
<a
|
<a
|
||||||
class="member-item__action simple-list__action"
|
class="member-item__action simple-list__action"
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
<a
|
<a
|
||||||
class="member-item__action simple-list__action"
|
class="member-item__action simple-list__action"
|
||||||
data-cy="add-to-class"
|
data-cy="add-to-class"
|
||||||
v-if="canEdit"
|
v-if="canEdit && enableDeactivate"
|
||||||
@click="$emit('add', member)">Aktivieren</a>
|
@click="$emit('add', member)">Aktivieren</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
:show-code-route="showCodeRoute"
|
:show-code-route="showCodeRoute"
|
||||||
:read-only="me.readOnly"
|
:read-only="me.readOnly"
|
||||||
:can-edit="me.isTeacher"
|
:can-edit="me.isTeacher"
|
||||||
:enable-deactivate="true"
|
:enable-deactivate="!me.readOnly && !me.selectedClass.readOnly"
|
||||||
title="Klassenliste"
|
title="Klassenliste"
|
||||||
class="my-class__class"
|
class="my-class__class"
|
||||||
@add="add"
|
@add="add"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue