skillbox/client/cypress/e2e/frontend/read-only/project.spec.js

47 lines
1.3 KiB
JavaScript

import { getMinimalMe } from '../../../support/helpers';
const getOperations = ({ readOnly = false, classReadOnly = false }) => ({
MeQuery: getMinimalMe({ readOnly, classReadOnly }),
ProjectQuery: {
project: {
id: 'projectId',
slug: 'project-name',
final: false,
student: {
id: btoa('PrivateUserNode:1'),
},
entriesCount: 1,
entries: [{}],
},
},
});
const testProject = (readOnly, shouldActionsExist, classReadOnly = false) => {
cy.mockGraphqlOps({ operations: getOperations({ readOnly, classReadOnly }) });
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 when license expired', () => {
testProject(true, false);
});
it('Can not create and edit project entry when class inactive', () => {
testProject(false, false, true);
});
});