diff --git a/client/cypress/integration/frontend/read-only/portfolio.spec.js b/client/cypress/integration/frontend/read-only/portfolio.spec.js new file mode 100644 index 00000000..8eb73b66 --- /dev/null +++ b/client/cypress/integration/frontend/read-only/portfolio.spec.js @@ -0,0 +1,44 @@ +import {getMinimalMe} from '../../../support/helpers'; + +const getOperations = ({readOnly = false}) => ({ + MeQuery: getMinimalMe({readOnly}), + ProjectsQuery: { + projects: { + edges: [ + { + node: { + id: 'projectId', + final: false, + student: { + id: 'meId', + }, + entriesCount: 3, + }, + }, + ], + }, + }, +}); + +describe('Read Only Portfolio', () => { + beforeEach(() => { + cy.setup(); + }); + + it('Can create and edit project', () => { + cy.mockGraphqlOps({operations: getOperations({readOnly: false})}); + + cy.visit('/portfolio'); + cy.getByDataCy('add-project-button').should('exist'); + cy.getByDataCy('project-widget').should('have.length', 1); + cy.getByDataCy('project-widget-actions').should('exist'); + }); + it('Can not create and edit project', () => { + 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'); + }); +}); diff --git a/client/cypress/integration/frontend/read-only/project.spec.js b/client/cypress/integration/frontend/read-only/project.spec.js new file mode 100644 index 00000000..b27e1d64 --- /dev/null +++ b/client/cypress/integration/frontend/read-only/project.spec.js @@ -0,0 +1,48 @@ +import {getMinimalMe} from '../../../support/helpers'; + +const getOperations = ({readOnly = false}) => ({ + MeQuery: getMinimalMe({readOnly}), + ProjectQuery: { + project: { + id: 'projectId', + final: false, + student: { + id: 'meId', + }, + entriesCount: 3, + entries: { + edges: [ + { + node: {}, + }, + ], + }, + }, + }, +}); + +const testProject = (readOnly, shouldActionsExist) => { + cy.mockGraphqlOps({operations: getOperations({readOnly})}); + + const exist = shouldActionsExist ? 'exist' : 'not.exist'; + + cy.visit('/portfolio/project-name'); + cy.getByDataCy('project-title').should('exist'); + cy.getByDataCy('project-entry').should('have.length', 1); + cy.getByDataCy('add-project-entry').should(exist); + cy.getByDataCy('project-actions').should(exist); + cy.getByDataCy('project-entry-more').should(exist); +}; + +describe('Read Only Project', () => { + beforeEach(() => { + cy.setup(); + }); + + it('Can create and edit project entry', () => { + testProject(false, true); + }); + it('Can not create and edit project entry', () => { + testProject(true, false); + }); +}); diff --git a/client/cypress/integration/frontend/snapshots.spec.js b/client/cypress/integration/frontend/snapshots.spec.js index d820584d..3877580d 100644 --- a/client/cypress/integration/frontend/snapshots.spec.js +++ b/client/cypress/integration/frontend/snapshots.spec.js @@ -1,4 +1,3 @@ -import getMe from '../../fixtures/me.minimal'; import module from '../../fixtures/module.minimal'; import mocks from '../../fixtures/mocks'; import {getMinimalMe} from '../../support/helpers'; diff --git a/client/cypress/support/helpers.js b/client/cypress/support/helpers.js index 27532c28..908b7e77 100644 --- a/client/cypress/support/helpers.js +++ b/client/cypress/support/helpers.js @@ -2,6 +2,7 @@ export const getMinimalMe = ({readOnly = false, classReadOnly = false, isTeacher = true}) => ({ me: { + id: 'meId', onboardingVisited: true, readOnly, isTeacher, diff --git a/client/src/components/portfolio/ProjectActions.vue b/client/src/components/portfolio/ProjectActions.vue index 601ebefa..ebe17199 100644 --- a/client/src/components/portfolio/ProjectActions.vue +++ b/client/src/components/portfolio/ProjectActions.vue @@ -1,5 +1,7 @@