Make project and portfolio read only when selected class inactive
This commit is contained in:
parent
f9273f745c
commit
4977644fa4
|
|
@ -1,7 +1,7 @@
|
||||||
import {getMinimalMe} from '../../../support/helpers';
|
import {getMinimalMe} from '../../../support/helpers';
|
||||||
|
|
||||||
const getOperations = ({readOnly = false}) => ({
|
const getOperations = ({readOnly = false, classReadOnly = false}) => ({
|
||||||
MeQuery: getMinimalMe({readOnly}),
|
MeQuery: getMinimalMe({readOnly, classReadOnly}),
|
||||||
ProjectsQuery: {
|
ProjectsQuery: {
|
||||||
projects: {
|
projects: {
|
||||||
edges: [
|
edges: [
|
||||||
|
|
@ -33,9 +33,17 @@ describe('Read Only Portfolio', () => {
|
||||||
cy.getByDataCy('project-widget').should('have.length', 1);
|
cy.getByDataCy('project-widget').should('have.length', 1);
|
||||||
cy.getByDataCy('project-widget-actions').should('exist');
|
cy.getByDataCy('project-widget-actions').should('exist');
|
||||||
});
|
});
|
||||||
it('Can not create and edit project', () => {
|
it('Can not create and edit project when license invalid', () => {
|
||||||
cy.mockGraphqlOps({operations: getOperations({readOnly: true})});
|
cy.mockGraphqlOps({operations: getOperations({readOnly: true})});
|
||||||
|
|
||||||
|
cy.visit('/portfolio');
|
||||||
|
cy.getByDataCy('add-project-button').should('not.exist');
|
||||||
|
cy.getByDataCy('project-widget').should('have.length', 1);
|
||||||
|
cy.getByDataCy('project-widget-actions').should('not.exist');
|
||||||
|
});
|
||||||
|
it('Can not create and edit project when class inactive', () => {
|
||||||
|
cy.mockGraphqlOps({operations: getOperations({readOnly: false, classReadOnly: true})});
|
||||||
|
|
||||||
cy.visit('/portfolio');
|
cy.visit('/portfolio');
|
||||||
cy.getByDataCy('add-project-button').should('not.exist');
|
cy.getByDataCy('add-project-button').should('not.exist');
|
||||||
cy.getByDataCy('project-widget').should('have.length', 1);
|
cy.getByDataCy('project-widget').should('have.length', 1);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {getMinimalMe} from '../../../support/helpers';
|
import {getMinimalMe} from '../../../support/helpers';
|
||||||
|
|
||||||
const getOperations = ({readOnly = false}) => ({
|
const getOperations = ({readOnly = false, classReadOnly = false}) => ({
|
||||||
MeQuery: getMinimalMe({readOnly}),
|
MeQuery: getMinimalMe({readOnly, classReadOnly}),
|
||||||
ProjectQuery: {
|
ProjectQuery: {
|
||||||
project: {
|
project: {
|
||||||
id: 'projectId',
|
id: 'projectId',
|
||||||
|
|
@ -21,8 +21,8 @@ const getOperations = ({readOnly = false}) => ({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const testProject = (readOnly, shouldActionsExist) => {
|
const testProject = (readOnly, shouldActionsExist, classReadOnly = false) => {
|
||||||
cy.mockGraphqlOps({operations: getOperations({readOnly})});
|
cy.mockGraphqlOps({operations: getOperations({readOnly, classReadOnly})});
|
||||||
|
|
||||||
const exist = shouldActionsExist ? 'exist' : 'not.exist';
|
const exist = shouldActionsExist ? 'exist' : 'not.exist';
|
||||||
|
|
||||||
|
|
@ -42,7 +42,10 @@ describe('Read Only Project', () => {
|
||||||
it('Can create and edit project entry', () => {
|
it('Can create and edit project entry', () => {
|
||||||
testProject(false, true);
|
testProject(false, true);
|
||||||
});
|
});
|
||||||
it('Can not create and edit project entry', () => {
|
it('Can not create and edit project entry when license expired', () => {
|
||||||
testProject(true, false);
|
testProject(true, false);
|
||||||
});
|
});
|
||||||
|
it('Can not create and edit project entry when class inactive', () => {
|
||||||
|
testProject(false, false, true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
<div class="portfolio">
|
<div class="portfolio">
|
||||||
<add-project
|
<add-project
|
||||||
class="portfolio__add-project"
|
class="portfolio__add-project"
|
||||||
v-if="!me.readOnly"/>
|
v-if="!me.readOnly && !me.selectedClass.readOnly"/>
|
||||||
|
|
||||||
<project-widget
|
<project-widget
|
||||||
v-bind="project"
|
v-bind="project"
|
||||||
:user-id="userId"
|
:user-id="userId"
|
||||||
:key="project.id"
|
:key="project.id"
|
||||||
:read-only="me.readOnly"
|
:read-only="me.readOnly || me.selectedClass.readOnly"
|
||||||
class="portfolio__project"
|
class="portfolio__project"
|
||||||
v-for="project in projects"
|
v-for="project in projects"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
<div class="project__meta">
|
<div class="project__meta">
|
||||||
<project-actions
|
<project-actions
|
||||||
:id="project.id"
|
:id="project.id"
|
||||||
v-if="!me.readOnly"/>
|
v-if="!me.readOnly && !me.selectedClass.readOnly"/>
|
||||||
<owner-widget :owner="project.student"/>
|
<owner-widget :owner="project.student"/>
|
||||||
<entry-count-widget :entry-count="projectEntryCount"/>
|
<entry-count-widget :entry-count="projectEntryCount"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -33,11 +33,11 @@
|
||||||
:project="project.id"
|
:project="project.id"
|
||||||
class="project__add-entry"
|
class="project__add-entry"
|
||||||
data-cy="add-project-entry"
|
data-cy="add-project-entry"
|
||||||
v-if="isOwner && !me.readOnly"/>
|
v-if="isOwner && !me.readOnly && !me.selectedClass.readOnly"/>
|
||||||
<project-entry
|
<project-entry
|
||||||
v-bind="entry"
|
v-bind="entry"
|
||||||
:key="index"
|
:key="index"
|
||||||
:read-only="me.readOnly"
|
:read-only="me.readOnly || me.selectedClass.readOnly"
|
||||||
v-for="(entry, index) in project.entries"/>
|
v-for="(entry, index) in project.entries"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue