describe('Assignments', () => {
  const studentSubmission = {
    id: 'submission-id',
    text: '',
    document: '',
    assignment: {},
    submissionFeedback: {
      id: 'feedback-id',
      text: '',
      final: false,
    },
  };

  const operations = {
    ModulesQuery: {},
    AssignmentWithSubmissions: {
      assignment: {
        title: 'Ein Auftragstitel',
        solution: '<p>Eine Lösung</p>',
        assignment: 'Ein Auftrag',
        submissions: [studentSubmission],
      },
    },
    MeQuery: {
      me: {},
    },
    ModuleDetailsQuery: {},
    StudentSubmissions: {
      studentSubmission,
    },
    UpdateSubmissionFeedback({input: {submissionFeedback}}) {
      return {
        updateSubmissionFeedback: {
          successful: true,
          updatedSubmissionFeedback: submissionFeedback,
        },
      };
    },
  };

  beforeEach(() => {
    cy.setup();

    cy.mockGraphqlOps({
      operations,
    });
  });

  it('it does not display HTML tags', () => {
    cy.visit('/module/lohn-und-budget/submissions/QXNzaWdubWVudE5vZGU6MQ==');
    cy.getByDataCy('assignment-solution').should('have.text', 'Eine Lösung');
  });

  it('gives feedback as teacher (with Emojis 🧐)', () => {
    const finalText = 'This is a feedback 🖐️';
    cy.visit('/submission/submission-id');
    cy.getByDataCy('submission-textarea').type('This is a feedback ');
    cy.getByDataCy('emoji-button').should('have.length', 9).first().click();
    cy.getByDataCy('submission-textarea').should('have.value', finalText);
    cy.getByDataCy('submission-form-submit').click();
    cy.getByDataCy('submission-form-submit').should('not.exist');
  });
});
