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); }); });