import {getMinimalMe} from '../../../support/helpers';

const getOperations = ({readOnly}) => ({
  MeQuery: getMinimalMe({readOnly}),
  NewsTeasers: {
    newsTeasers: {
      edges: [
        {},
        {},
        {},
      ]
    }
  }
});

describe('Read Only News', () => {
  beforeEach(() => {
    cy.setup();
  });

  it('displays the news', () => {
    cy.mockGraphqlOps({
      operations: getOperations({readOnly: false}),
    });

    cy.visit('/');

    cy.getByDataCy('news-navigation-link').should('exist');

    cy.getByDataCy('news-teasers').should('exist');
    cy.getByDataCy('news-teaser').should('have.length', 2);
  });
  it('does not display the news', () => {
    cy.mockGraphqlOps({
      operations: getOperations({readOnly: true}),
    });

    cy.visit('/');

    cy.getByDataCy('news-navigation-link').should('not.exist');
    cy.getByDataCy('news-teasers').should('not.exist');
  });
});
