import {getMe} from '../../support/helpers';
import mocks from '../../fixtures/mocks';

const modules = {
  'lohn-und-budget': {
    'objectiveGroups': {
      'edges': [
        {
          'node': {
            'title': 'LANGUAGE_COMMUNICATION',
            'objectives': {
              'edges': [
                {
                  'node': {
                    'text': 'i-am-an-objective',
                    'hiddenFor': {
                      'edges': [],
                    },
                  },
                },
              ],
            },
          },
        },
      ],
    },
  },
};

const operations = {
  MeQuery() {
    return getMe({
      schoolClasses: ['FLID2018a'],
      teacher: false,
    });
  },
  ModulesQuery: modules,
  MySchoolClassQuery: {
    me: {},
  },
  UpdateLastModule: {
    updateLastModule: {
      success: true,
    },
  },
  SyncModuleVisibility: {
    syncModuleVisibility: {
      success: true,
    },
  },
};

// const mocks = {
//   UUID: () => 'Whatever',
//   GenericStreamFieldType: () => [],
//   ObjectiveGroup: () => ({}),
//   Module: () => ({
//     title: 'title',
//     slug: 'slug',
//     metaTitle: 'metaTitle',
//     teaser: 'teaser',
//     intro: 'intro',
//     assignments: {edges: []},
//     objectiveGroups: {edges: []},
//     id: 'ID',
//   }),
// };

describe('Objective Visibility', () => {
  beforeEach(() => {
    cy.server();
    cy.task('getSchema').then(schema => {
      cy.mockGraphql({
        schema,
        // endpoint: '/api/graphql'
        mocks,
        operations,
      });
    });
  });

  it('should display the correct objectives', () => {
    cy.fakeLogin('rachel.green', 'test');

    cy.visit('/module/lohn-und-budget');
  });
});
