import module from '../../fixtures/module.minimal';
import {getMinimalMe} from '../../support/helpers';

const chapters = [{
  title: 'ABC',
  description: 'DEF',
  contentBlocks: [
    {
      title: 'A ContentBlock',
      userCreated: true,
      mine: true,
      contents: [],
    },
  ],
}];

const operations = {
  MeQuery: getMinimalMe({isTeacher: true}),
  ModuleDetailsQuery: {
    module: {
      chapters,
    },
  },
  DeleteContentBlock: {
    success: true,
  },
  UpdateLastModule: {}
};

describe('Custom Content Block', () => {
  beforeEach(() => {
    cy.setup();
  });

  it.skip('Deletes the custom content block and removes it from the view', () => {
    cy.mockGraphqlOps({
      operations,
    });

    cy.visit('module/some-module');

    cy.log('Toggling Edit Mode');
    cy.getByDataCy('toggle-editing').click();

    cy.getByDataCy('module-title').should('exist');
    cy.get('.content-block').should('have.length', 1);

    cy.log('Opening More Menu');
    cy.getByDataCy('more-options-link').click();

    // check if content block is still there
    cy.log('Deleting Content Block');
    cy.getByDataCy('delete-content-block-link').click();

    cy.get('.content-block').should('have.length', 0);
  });
});
