import { getMinimalMe } from '../../../support/helpers'; const getOperations = ({ readOnly = false, classReadOnly = false }) => ({ MeQuery: getMinimalMe({ readOnly, classReadOnly }), ProjectsQuery: { projects: [ { id: 'projectId', final: false, student: { id: btoa('PrivateUserNode:1'), }, 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('project-list').should('exist'); cy.getByDataCy('create-project-button').should('exist'); cy.getByDataCy('project').should('have.length', 1); cy.getByDataCy('project-actions').should('exist'); }); it('Can not create and edit project when license invalid', () => { cy.mockGraphqlOps({ operations: getOperations({ readOnly: true }) }); cy.visit('/portfolio'); cy.getByDataCy('project-list').should('exist'); cy.getByDataCy('add-project-button').should('not.exist'); cy.getByDataCy('project').should('have.length', 1); cy.getByDataCy('project-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.getByDataCy('project-list').should('exist'); cy.getByDataCy('add-project-button').should('not.exist'); cy.getByDataCy('project').should('have.length', 1); cy.getByDataCy('project-actions').should('not.exist'); }); });