const moduleId = window.btoa('ModuleNode:1');
const operations = {
  MeQuery: {
    me: {
      isTeacher: true,
      permissions: ['users.can_manage_school_class_content'],
    },
  },
  ModuleDetailsQuery: {
    module: {
      title: 'Module With Solutions',
      solutionsEnabled: false,
      slug: 'some-module',
      id: moduleId,
      chapters: [],
      language: 'de',
      level: null,
      category: null,
    },
  },
  ModuleEditModeQuery: {},
  UpdateLastModule: {},
  UpdateSolutionVisibility: ({ input: { enabled } }) => {
    return {
      updateSolutionVisibility: {
        success: true,
        solutionsEnabled: enabled,
      },
    };
  },
};
describe('Show solutions', () => {
  beforeEach(() => {
    cy.setup();
    cy.mockGraphqlOps({ operations });
  });
  it('goes to the settings and toggles the "Show solutions" option', () => {
    cy.visit('/module/some-module');

    cy.getByDataCy('module-settings-button').click();

    cy.getByDataCy('base-input-container').should('have.data', 'checked', false);
    cy.getByDataCy('base-input-container').click();
    cy.wait('@UpdateSolutionVisibility');
    cy.getByDataCy('tick-icon').should('be.visible');

    cy.getByDataCy('back-link').click();

    cy.getByDataCy('module-settings-button').click();
    cy.getByDataCy('tick-icon').should('be.visible');
  });
});
